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()]); }
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); } }
@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); } }
private List<ICompletionProposal> computeProposals(IQuickAssistInvocationContext context, IAnnotationModel model) { int offset= context.getOffset(); ArrayList<SpellingProblem> annotationList= new ArrayList<>(); Iterator<Annotation> iter= model.getAnnotationIterator(); while (iter.hasNext()) { Annotation annotation= iter.next(); if (canFix(annotation)) { Position pos= model.getPosition(annotation); if (isAtPosition(offset, pos)) { collectSpellingProblems(annotation, annotationList); } } } SpellingProblem[] spellingProblems= annotationList.toArray(new SpellingProblem[annotationList.size()]); return computeProposals(context, spellingProblems); }
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); } }
@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); } }
private List computeProposals(IQuickAssistInvocationContext context, IAnnotationModel model) { int offset= context.getOffset(); ArrayList annotationList= new ArrayList(); Iterator iter= model.getAnnotationIterator(); while (iter.hasNext()) { Annotation annotation= (Annotation)iter.next(); if (canFix(annotation)) { Position pos= model.getPosition(annotation); if (isAtPosition(offset, pos)) { collectSpellingProblems(annotation, pos, annotationList); } } } SpellingProblem[] spellingProblems= (SpellingProblem[]) annotationList.toArray(new SpellingProblem[annotationList.size()]); return computeProposals(context, spellingProblems); }
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()]); }
/** * @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; }
private List<ICompletionProposal> computeProposals(IQuickAssistInvocationContext context, IAnnotationModel model) { int offset= context.getOffset(); ArrayList<SpellingProblem> annotationList= new ArrayList<>(); Iterator<Annotation> iter= model.getAnnotationIterator(); while (iter.hasNext()) { Annotation annotation= iter.next(); if (canFix(annotation)) { Position pos= model.getPosition(annotation); if (isAtPosition(offset, pos)) { collectSpellingProblems(annotation, annotationList); } } } SpellingProblem[] spellingProblems= annotationList.toArray(new SpellingProblem[annotationList.size()]); return computeProposals(context, spellingProblems); }
@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 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 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) 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 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()]); }