/** * Creates a new spelling annotation. * * @param problem the spelling problem. */ public SpellingAnnotation(SpellingProblem problem) { super(TYPE, false, problem.getMessage()); fSpellingProblem= problem; }
/** * Returns the proposals for the incorrectly spelled region. * * @param context the invocation context or <code>null</code> if none * @return the proposals for the incorrectly spelled region * @since 3.4 */ public ICompletionProposal[] getProposals(IQuickAssistInvocationContext context) { return getProposals(); } }
public void accept(SpellingProblem problem) { IProblemRequestor requestor= fRequestor; if (requestor != null) { try { int line= getDocument().getLineOfOffset(problem.getOffset()) + 1; String word= getDocument().get(problem.getOffset(), problem.getLength()); boolean dictionaryMatch= false; boolean sentenceStart= false; if (problem instanceof JavaSpellingProblem) { dictionaryMatch= ((JavaSpellingProblem)problem).isDictionaryMatch(); sentenceStart= ((JavaSpellingProblem) problem).isSentenceStart(); } // see: https://bugs.eclipse.org/bugs/show_bug.cgi?id=81514 IEditorInput editorInput= fEditor.getEditorInput(); if (editorInput != null) { CoreSpellingProblem iProblem= new CoreSpellingProblem(problem.getOffset(), problem.getOffset() + problem.getLength() - 1, line, problem.getMessage(), word, dictionaryMatch, sentenceStart, getDocument(), editorInput.getName()); requestor.acceptProblem(iProblem); } } catch (BadLocationException x) { // drop this SpellingProblem } } }
@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); } }
public final void apply(final IDocument document) { final ISpellCheckEngine engine= SpellCheckEngine.getInstance(); final ISpellChecker checker= engine.getSpellChecker(); if (checker != null) { checker.ignoreWord(fWord); SpellingProblem.removeAllInActiveEditor(getEditor(), fWord); } }
@Override public void accept(SpellingProblem problem) { IProblemRequestor requestor= fRequestor; if (requestor != null) { try { int line= getDocument().getLineOfOffset(problem.getOffset()) + 1; String word= getDocument().get(problem.getOffset(), problem.getLength()); boolean dictionaryMatch= false; boolean sentenceStart= false; if (problem instanceof JavaSpellingProblem) { dictionaryMatch= ((JavaSpellingProblem)problem).isDictionaryMatch(); sentenceStart= ((JavaSpellingProblem) problem).isSentenceStart(); } // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=81514 IEditorInput editorInput= fEditor.getEditorInput(); if (editorInput != null) { CoreSpellingProblem iProblem= new CoreSpellingProblem(problem.getOffset(), problem.getOffset() + problem.getLength() - 1, line, problem.getMessage(), word, dictionaryMatch, sentenceStart, getDocument(), editorInput.getName()); requestor.acceptProblem(iProblem); } } catch (BadLocationException x) { // drop this SpellingProblem } } }
@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); } }
protected void handlePreferenceStoreChanged(PropertyChangeEvent event) { if (event.getProperty().equals(SpellingService.PREFERENCE_SPELLING_ENABLED)) { ISourceViewer viewer= getSourceViewer(); if (!(viewer instanceof ISourceViewerExtension2)) return; // cannot unconfigure - do nothing // XXX: this is pretty heavy-weight ((ISourceViewerExtension2)viewer).unconfigure(); viewer.configure(getSourceViewerConfiguration()); if (Boolean.FALSE.equals(event.getNewValue())) SpellingProblem.removeAllInActiveEditor(this, null); IAction quickAssistAction= getAction(ITextEditorActionConstants.QUICK_ASSIST); if (quickAssistAction instanceof IUpdate) ((IUpdate)quickAssistAction).update(); return; } super.handlePreferenceStoreChanged(event); }
@Override public void accept(SpellingProblem problem) { IProblemRequestor requestor= fRequestor; if (requestor != null) { try { int line= getDocument().getLineOfOffset(problem.getOffset()) + 1; String word= getDocument().get(problem.getOffset(), problem.getLength()); boolean dictionaryMatch= false; boolean sentenceStart= false; if (problem instanceof JavaSpellingProblem) { dictionaryMatch= ((JavaSpellingProblem)problem).isDictionaryMatch(); sentenceStart= ((JavaSpellingProblem) problem).isSentenceStart(); } // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=81514 IEditorInput editorInput= fEditor.getEditorInput(); if (editorInput != null) { CoreSpellingProblem iProblem= new CoreSpellingProblem(problem.getOffset(), problem.getOffset() + problem.getLength() - 1, line, problem.getMessage(), word, dictionaryMatch, sentenceStart, getDocument(), editorInput.getName()); requestor.acceptProblem(iProblem); } } catch (BadLocationException x) { // drop this SpellingProblem } } }
/** * Returns the proposals for the incorrectly spelled region. * * @param context the invocation context or <code>null</code> if none * @return the proposals for the incorrectly spelled region * @since 3.4 */ public ICompletionProposal[] getProposals(IQuickAssistInvocationContext context) { return getProposals(); } }
/** * Creates a new spelling annotation. * * @param problem the spelling problem. */ public SpellingAnnotation(SpellingProblem problem) { super(TYPE, false, problem.getMessage()); fSpellingProblem= problem; }
@Override protected void handlePreferenceStoreChanged(PropertyChangeEvent event) { if (event.getProperty().equals(SpellingService.PREFERENCE_SPELLING_ENABLED)) { ISourceViewer viewer= getSourceViewer(); if (!(viewer instanceof ISourceViewerExtension2)) return; // cannot unconfigure - do nothing // XXX: this is pretty heavy-weight ((ISourceViewerExtension2)viewer).unconfigure(); viewer.configure(getSourceViewerConfiguration()); if (Boolean.FALSE.equals(event.getNewValue())) SpellingProblem.removeAll(getSourceViewer(), null); IAction quickAssistAction= getAction(ITextEditorActionConstants.QUICK_ASSIST); if (quickAssistAction instanceof IUpdate) ((IUpdate)quickAssistAction).update(); return; } super.handlePreferenceStoreChanged(event); }
public final void apply(final IDocument document) { final ISpellCheckEngine engine= SpellCheckEngine.getInstance(); final ISpellChecker checker= engine.getSpellChecker(); if (checker == null) return; final ITextEditor editor= getEditor(); if (!checker.acceptsWords()) { final Shell shell; if (editor != null) shell= editor.getEditorSite().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); SpellingProblem.removeAllInActiveEditor(editor, fWord); } }
private List computeProposals(IQuickAssistInvocationContext context, SpellingProblem[] spellingProblems) { List proposals= new ArrayList(); for (int i= 0; i < spellingProblems.length; i++) proposals.addAll(Arrays.asList(spellingProblems[i].getProposals())); return proposals; }
/** * Creates a new spelling annotation. * * @param problem the spelling problem. */ public SpellingAnnotation(SpellingProblem problem) { super(TYPE, false, problem.getMessage()); fSpellingProblem= problem; }
@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); } }