public ICompletionProposal[] computeQuickAssistProposals(IQuickAssistInvocationContext invocationContext) { List proposals = new ArrayList(); getLocalRenameQuickAssistProposal(proposals, invocationContext.getSourceViewer(), invocationContext.getOffset()); getSurroundWithNewElementQuickAssistProposal(proposals, invocationContext.getSourceViewer(), invocationContext.getOffset()); getInsertRequiredAttrs(proposals, invocationContext.getSourceViewer(), invocationContext.getOffset()); return (ICompletionProposal[]) proposals.toArray(new ICompletionProposal[proposals.size()]); }
public ICompletionProposal[] computeQuickAssistProposals(IQuickAssistInvocationContext quickAssistContext) { ISourceViewer viewer= quickAssistContext.getSourceViewer(); int documentOffset= quickAssistContext.getOffset(); int length= viewer != null ? viewer.getSelectedRange().y : 0; TextInvocationContext context= new TextInvocationContext(viewer, documentOffset, length); IAnnotationModel model= viewer.getAnnotationModel(); if (model == null) return fgNoSuggestionsProposal; List proposals= computeProposals(context, model); if (proposals.isEmpty()) return fgNoSuggestionsProposal; return (ICompletionProposal[]) proposals.toArray(new ICompletionProposal[proposals.size()]); }
@Override public ICompletionProposal[] computeQuickAssistProposals(IQuickAssistInvocationContext invocationContext) { List<IMarker> markers; try { markers = getMarkersFor(invocationContext.getSourceViewer(), invocationContext.getOffset()); } catch (BadLocationException e) { errorMessage = e.getMessage(); return new ICompletionProposal[0]; } List<ICompletionProposal> result = new ArrayList<>(); for (IMarker marker : markers) { for (IMarkerResolution markerResolution : quickFixer.getResolutions(marker)) { result.add(new MarkerResolutionProposal(marker, markerResolution, invocationContext.getSourceViewer())); } } return result.toArray(new ICompletionProposal[0]); }
@Override public ICompletionProposal[] computeQuickAssistProposals(IQuickAssistInvocationContext quickAssistContext) { ISourceViewer viewer= quickAssistContext.getSourceViewer(); int documentOffset= quickAssistContext.getOffset(); int length= viewer != null ? viewer.getSelectedRange().y : -1; TextInvocationContext context= new TextInvocationContext(viewer, documentOffset, length); IAnnotationModel model= viewer.getAnnotationModel(); if (model == null) return fgNoSuggestionsProposal; List<ICompletionProposal> proposals= computeProposals(context, model); if (proposals.isEmpty()) return fgNoSuggestionsProposal; return proposals.toArray(new ICompletionProposal[proposals.size()]); }
@Override public ICompletionProposal[] computeQuickAssistProposals(IQuickAssistInvocationContext quickAssistContext) { ISourceViewer viewer= quickAssistContext.getSourceViewer(); int documentOffset= quickAssistContext.getOffset(); int length= viewer != null ? viewer.getSelectedRange().y : -1; TextInvocationContext context= new TextInvocationContext(viewer, documentOffset, length); IAnnotationModel model= viewer.getAnnotationModel(); if (model == null) return fgNoSuggestionsProposal; List<ICompletionProposal> proposals= computeProposals(context, model); if (proposals.isEmpty()) return fgNoSuggestionsProposal; return proposals.toArray(new ICompletionProposal[proposals.size()]); }
@Override public final void apply(final IDocument document) { final ISpellCheckEngine engine= SpellCheckEngine.getInstance(); final ISpellChecker checker= engine.getSpellChecker(); if (checker != null) { checker.ignoreWord(fWord); ISourceViewer sourceViewer= fContext.getSourceViewer(); if (sourceViewer != null) SpellingProblem.removeAll(sourceViewer, fWord); } }
/** * @since 2.3 */ protected List<ICompletionProposal> createQuickfixes(IQuickAssistInvocationContext invocationContext, Set<Annotation> applicableAnnotations) { List<ICompletionProposal> result = Lists.newArrayList(); ISourceViewer sourceViewer = invocationContext.getSourceViewer(); IAnnotationModel annotationModel = sourceViewer.getAnnotationModel(); IXtextDocument xtextDocument = XtextDocumentUtil.get(sourceViewer); for(Annotation annotation : applicableAnnotations) { if (annotation instanceof SpellingAnnotation) { SpellingProblem spellingProblem = ((SpellingAnnotation) annotation).getSpellingProblem(); result.addAll(asList(spellingProblem.getProposals())); } else { final Issue issue = issueUtil.getIssueFromAnnotation(annotation); if (issue != null) { Iterable<IssueResolution> resolutions = getResolutions(issue, xtextDocument); if (resolutions.iterator().hasNext()) { Position pos = annotationModel.getPosition(annotation); for (IssueResolution resolution : resolutions) { result.add(create(pos, resolution)); } } } } } return result; }
@Override public final void apply(final IDocument document) { final ISpellCheckEngine engine= SpellCheckEngine.getInstance(); final ISpellChecker checker= engine.getSpellChecker(); if (checker != null) { checker.ignoreWord(fWord); ISourceViewer sourceViewer= fContext.getSourceViewer(); if (sourceViewer != null) SpellingProblem.removeAll(sourceViewer, fWord); } }
@Override public final void apply(final IDocument document) { final ISpellCheckEngine engine= SpellCheckEngine.getInstance(); final ISpellChecker checker= engine.getSpellChecker(); if (checker == null) return; if (!checker.acceptsWords()) { final Shell shell; if (fContext != null && fContext.getSourceViewer() != null) shell= fContext.getSourceViewer().getTextWidget().getShell(); else shell= JavaPlugin.getActiveWorkbenchShell(); if (!canAskToConfigure() || !askUserToConfigureUserDictionary(shell)) return; String[] preferencePageIds= new String[] { "org.eclipse.ui.editors.preferencePages.Spelling" }; //$NON-NLS-1$ PreferencesUtil.createPreferenceDialogOn(shell, preferencePageIds[0], preferencePageIds, null).open(); } if (checker.acceptsWords()) { checker.addWord(fWord); if (fContext != null && fContext.getSourceViewer() != null) SpellingProblem.removeAll(fContext.getSourceViewer(), fWord); } }
@Override public final void apply(final IDocument document) { final ISpellCheckEngine engine= SpellCheckEngine.getInstance(); final ISpellChecker checker= engine.getSpellChecker(); if (checker == null) return; if (!checker.acceptsWords()) { final Shell shell; if (fContext != null && fContext.getSourceViewer() != null) shell= fContext.getSourceViewer().getTextWidget().getShell(); else shell= JavaPlugin.getActiveWorkbenchShell(); if (!canAskToConfigure() || !askUserToConfigureUserDictionary(shell)) return; String[] preferencePageIds= new String[] { "org.eclipse.ui.editors.preferencePages.Spelling" }; //$NON-NLS-1$ PreferencesUtil.createPreferenceDialogOn(shell, preferencePageIds[0], preferencePageIds, null).open(); } if (checker.acceptsWords()) { checker.addWord(fWord); if (fContext != null && fContext.getSourceViewer() != null) SpellingProblem.removeAll(fContext.getSourceViewer(), fWord); } }
/** * @since 2.3 */ protected void selectAndRevealQuickfix(IQuickAssistInvocationContext invocationContext, Set<Annotation> applicableAnnotations, List<ICompletionProposal> completionProposals) { if (completionProposals.isEmpty()) { return; } if (invocationContext instanceof QuickAssistInvocationContext && !((QuickAssistInvocationContext) invocationContext).isSuppressSelection()) { ISourceViewer sourceViewer = invocationContext.getSourceViewer(); IAnnotationModel annotationModel = sourceViewer.getAnnotationModel(); Iterator<Annotation> iterator = applicableAnnotations.iterator(); while(iterator.hasNext()){ Position pos = annotationModel.getPosition(iterator.next()); if (pos != null) { sourceViewer.setSelectedRange(pos.getOffset(), pos.getLength()); sourceViewer.revealRange(pos.getOffset(), pos.getLength()); break; } } } }
public ICompletionProposal[] computeQuickAssistProposals(IQuickAssistInvocationContext invocationContext) { ISourceViewer sourceViewer = invocationContext.getSourceViewer(); if (sourceViewer == null) return new ICompletionProposal[0]; final IDocument document = sourceViewer.getDocument(); if (!(document instanceof IXtextDocument)) return new ICompletionProposal[0]; final IXtextDocument xtextDocument = (IXtextDocument) document; final IAnnotationModel annotationModel = sourceViewer.getAnnotationModel(); List<ICompletionProposal> result = Lists.newArrayList(); try { Set<Annotation> applicableAnnotations = getApplicableAnnotations(xtextDocument, annotationModel, invocationContext.getOffset()); result = createQuickfixes(invocationContext, applicableAnnotations); selectAndRevealQuickfix(invocationContext, applicableAnnotations, result); } catch (BadLocationException e) { errorMessage = e.getMessage(); } sortQuickfixes(result); return result.toArray(new ICompletionProposal[result.size()]); }
@Override public ICompletionProposal[] computeQuickAssistProposals(IQuickAssistInvocationContext quickAssistContext) { ISourceViewer viewer= quickAssistContext.getSourceViewer(); int length= viewer != null ? viewer.getSelectedRange().y : 0; TextInvocationContext context= new TextInvocationContext(viewer, quickAssistContext.getOffset(), length);
private PropertiesAssistContext createAssistContext(IQuickAssistInvocationContext invocationContext) { IEditorPart editorPart= fAssistant.getEditor(); IFile file= editorPart.getEditorInput().getAdapter(IFile.class); ISourceViewer sourceViewer= invocationContext.getSourceViewer(); IType accessorType= ((PropertiesFileEditor) editorPart).getAccessorType(); return new PropertiesAssistContext(sourceViewer, invocationContext.getOffset(), invocationContext.getLength(), file, sourceViewer.getDocument(), accessorType); } }
private PropertiesAssistContext createAssistContext(IQuickAssistInvocationContext invocationContext) { IEditorPart editorPart= fAssistant.getEditor(); IFile file= editorPart.getEditorInput().getAdapter(IFile.class); ISourceViewer sourceViewer= invocationContext.getSourceViewer(); IType accessorType= ((PropertiesFileEditor) editorPart).getAccessorType(); return new PropertiesAssistContext(sourceViewer, invocationContext.getOffset(), invocationContext.getLength(), file, sourceViewer.getDocument(), accessorType); } }
return null; ISourceViewer viewer= quickAssistContext.getSourceViewer(); int documentOffset= quickAssistContext.getOffset();
public ICompletionProposal[] computeQuickAssistProposals(IQuickAssistInvocationContext quickAssistContext) { ITextViewer viewer= quickAssistContext.getSourceViewer(); int documentOffset= quickAssistContext.getOffset();
@Override public ICompletionProposal[] computeQuickAssistProposals(IQuickAssistInvocationContext quickAssistContext) { ISourceViewer viewer= quickAssistContext.getSourceViewer(); int documentOffset= quickAssistContext.getOffset();
public ICompletionProposal[] computeQuickAssistProposals(IQuickAssistInvocationContext quickAssistContext) { ITextViewer viewer= quickAssistContext.getSourceViewer(); int documentOffset= quickAssistContext.getOffset();
@Override public ICompletionProposal[] computeQuickAssistProposals(IQuickAssistInvocationContext quickAssistContext) { ISourceViewer viewer= quickAssistContext.getSourceViewer(); int documentOffset= quickAssistContext.getOffset();