private void addProposals(final SubMenuManager quickFixMenu) { IAnnotationModel sourceModel = sourceViewer.getAnnotationModel(); Iterator annotationIterator = sourceModel.getAnnotationIterator(); while (annotationIterator.hasNext()) { Annotation annotation = (Annotation) annotationIterator.next(); boolean isDeleted = annotation.isMarkedDeleted(); boolean isIncluded = includes(sourceModel.getPosition(annotation), getTextWidget().getCaretOffset()); boolean isFixable = sourceViewer.getQuickAssistAssistant().canFix( annotation); if (!isDeleted && isIncluded && isFixable) { IQuickAssistProcessor processor = sourceViewer .getQuickAssistAssistant() .getQuickAssistProcessor(); IQuickAssistInvocationContext context = sourceViewer .getQuickAssistInvocationContext(); ICompletionProposal[] proposals = processor .computeQuickAssistProposals(context); for (ICompletionProposal proposal : proposals) quickFixMenu.add(createQuickFixAction(proposal)); } } }
@Override public IQuickAssistAssistant getQuickAssistAssistant(ISourceViewer sourceViewer) { // create a content assistant: PyCorrectionAssistant assistant = new PyCorrectionAssistant(); // next create a content assistant processor to populate the completions window IQuickAssistProcessor processor = new PythonCorrectionProcessor(this.getEdit()); // Correction assist works on all assistant.setQuickAssistProcessor(processor); assistant.setInformationControlCreator(getInformationControlCreator(sourceViewer)); //delay and auto activate set on PyContentAssistant constructor. return assistant; }
@Override public SourceViewerConfiguration createSourceViewerConfiguration() { PyContentAssistant contentAssist = new PyContentAssistant(); IContentAssistProcessor processor = createConsoleCompletionProcessor(contentAssist); contentAssist.setContentAssistProcessor(processor, PydevScriptConsoleSourceViewerConfiguration.PARTITION_TYPE); contentAssist.enableAutoActivation(true); contentAssist.enableAutoInsert(false); contentAssist.setAutoActivationDelay(PyCodeCompletionPreferencesPage.getAutocompleteDelay()); PyCorrectionAssistant quickAssist = new PyCorrectionAssistant(); // next create a content assistant processor to populate the completions window IQuickAssistProcessor quickAssistProcessor = createConsoleQuickAssistProcessor(quickAssist); // Correction assist works on all quickAssist.setQuickAssistProcessor(quickAssistProcessor); SourceViewerConfiguration cfg = new PydevScriptConsoleSourceViewerConfiguration(createHover(), contentAssist, quickAssist); return cfg; }
/** * @param length the length of the marker underline. Length == 0 results in a * marker in the vertical ruler and no underline */ BannedElement(String message, String markerId, int iMarkerSeverity, int iMessageSeverity, DocumentLocation start, int length, IQuickAssistProcessor processor) { Preconditions.checkNotNull(message, "element name is null"); Preconditions.checkNotNull(markerId, "markerId is null"); Preconditions.checkNotNull(start, "start is null"); Preconditions.checkArgument(length >= 0, "length < 0"); this.message = message; this.start = start; this.length = length; this.markerId = markerId; this.iMarkerSeverity = iMarkerSeverity; this.iMessageSeverity = iMessageSeverity; this.processor = processor; }
/** * Creates a message from a given {@link BannedElement}. */ void createMessage(IReporter reporter, BannedElement element, int elementOffset) { IMessage message = new LocalizedMessage(element.getIMessageSeverity(), element.getMessage()); message.setTargetObject(this); message.setMarkerId(element.getMarkerId()); message.setLineNo(element.getStart().getLineNumber()); message.setOffset(elementOffset); message.setLength(element.getLength()); message.setAttribute(IQuickAssistProcessor.class.getName(), element.getQuickAssistProcessor()); reporter.addMessage(this, message); }
@Override protected void addMessage(IMessage message, WebResourcesFinderType type) { IReporter reporter = getReporter(); IQuickAssistProcessor processor = getQuickAssistProcessor(type); if (reporter instanceof IncrementalReporter && processor != null) { AnnotationInfo info = new AnnotationInfo(message, AnnotationInfo.NO_PROBLEM_ID, processor); ((IncrementalReporter) reporter).addAnnotationInfo(getValidator(), info); } else { super.addMessage(message, type); } }
private IQuickAssistProcessor getQuickAssistProcessor( WebResourcesFinderType type) { switch (type) { case LINK_HREF: case SCRIPT_SRC: return new WebResourceQuickFixProcessor(); default: return null; } }
IQuickAssistProcessor getQuickAssistProcessor() { return processor; }
@Override protected IQuickAssistProcessor createConsoleQuickAssistProcessor(QuickAssistAssistant quickAssist) { return new PydevConsoleQuickAssistProcessor((PyCorrectionAssistant) quickAssist); }
/** * @return the assistant that should handle quick assist requests (quick fixes) */ protected abstract IQuickAssistProcessor createConsoleQuickAssistProcessor(QuickAssistAssistant quickAssist);