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); }
public PropertiesCorrectionProcessor(PropertiesCorrectionAssistant assistant) { fAssistant= assistant; fSpellingCorrectionProcessor= new SpellingCorrectionProcessor(); }
return fgNoSuggestionsProposal; List proposals= computeProposals(context, model); if (proposals.isEmpty()) return fgNoSuggestionsProposal; if (canFix(annotation)) { Position pos= model.getPosition(annotation); if (isAtPosition(offset, pos)) { collectSpellingProblems(annotation, annotationList); return computeProposals(context, spellingProblems);
@Override public boolean canFix(Annotation annotation) { return fSpellingCorrectionProcessor.canFix(annotation); }
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()]); }
try { List<ICompletionProposal> proposals= new ArrayList<>(); ICompletionProposal[] spellingProposals= fSpellingCorrectionProcessor.computeQuickAssistProposals(quickAssistContext); if (spellingProposals.length > 1) { for (int i= 0; i < spellingProposals.length; i++) {
@Override public boolean canFix(Annotation annotation) { return fSpellingCorrectionProcessor.canFix(annotation); }
@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()]); }
try { List<ICompletionProposal> proposals= new ArrayList<>(); ICompletionProposal[] spellingProposals= fSpellingCorrectionProcessor.computeQuickAssistProposals(quickAssistContext); if (spellingProposals.length > 1) { for (int i= 0; i < spellingProposals.length; i++) {
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 PropertiesCorrectionProcessor(PropertiesCorrectionAssistant assistant) { fAssistant= assistant; fSpellingCorrectionProcessor= new SpellingCorrectionProcessor(); }
@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()]); }
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 IQuickAssistAssistant getQuickAssistAssistant(ISourceViewer sourceViewer) { if (fPreferenceStore == null || !fPreferenceStore.getBoolean(SpellingService.PREFERENCE_SPELLING_ENABLED)) return null; QuickAssistAssistant assistant= new QuickAssistAssistant(); assistant.setQuickAssistProcessor(new SpellingCorrectionProcessor()); assistant.setRestoreCompletionProposalSize(EditorsPlugin.getDefault().getDialogSettingsSection("quick_assist_proposal_size")); //$NON-NLS-1$ assistant.setInformationControlCreator(getQuickAssistAssistantInformationControlCreator()); return assistant; }
public IQuickAssistAssistant getQuickAssistAssistant(ISourceViewer sourceViewer) { if (fPreferenceStore == null || !fPreferenceStore.getBoolean(SpellingService.PREFERENCE_SPELLING_ENABLED)) return null; IQuickAssistAssistant assistant= new QuickAssistAssistant(); assistant.setQuickAssistProcessor(new SpellingCorrectionProcessor()); assistant.setInformationControlCreator(getQuickAssistAssistantInformationControlCreator()); // Waiting for color preferences, see: https://bugs.eclipse.org/bugs/show_bug.cgi?id=133731 assistant.setProposalSelectorBackground(sourceViewer.getTextWidget().getDisplay().getSystemColor(SWT.COLOR_WHITE)); assistant.setProposalSelectorForeground(sourceViewer.getTextWidget().getDisplay().getSystemColor(SWT.COLOR_BLACK)); return assistant; }