Java 类org.eclipse.ui.texteditor.spelling.SpellingProblem 实例源码

项目:bts    文件:XtextQuickAssistProcessor.java   
/**
 * @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;
   }
项目:gwt-eclipse-plugin    文件:UiBinderStructuredRegionProcessor.java   
@Override
protected boolean isInterestingProblem(SpellingProblem problem) {
  IStructuredDocument doc = (IStructuredDocument) getDocument();
  try {
    ITypedRegion[] partitions = doc.computePartitioning(
        problem.getOffset(), problem.getLength());
    for (ITypedRegion partition : partitions) {
      if (partition.getType().equals(ICSSPartitions.STYLE)) {
        return false;
      }
    }
  } catch (BadLocationException e) {
    // Ignore
  }

  return super.isInterestingProblem(problem);
}
项目:Eclipse-Postfix-Code-Completion    文件:JavaSpellingReconcileStrategy.java   
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
        }
    }
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:JavaSpellingReconcileStrategy.java   
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
        }
    }
}
项目:Eclipse-Postfix-Code-Completion    文件:WordIgnoreProposal.java   
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);
        }
    }
项目:Eclipse-Postfix-Code-Completion    文件:AddWordProposal.java   
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);
        }
    }
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:WordIgnoreProposal.java   
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);
        }
    }
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:AddWordProposal.java   
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);
        }
    }
项目:eclipse.spellchecker    文件:WordIgnoreProposal.java   
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);
        }
    }
项目:eclipse.spellchecker    文件:AddWordProposal.java   
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= Activator.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);
        }
    }
项目:DarwinSPL    文件:DwprofileSourceViewerConfiguration.java   
public IReconciler getReconciler(final ISourceViewer sourceViewer) {
    if (fPreferenceStore == null || !fPreferenceStore.getBoolean(SpellingService.PREFERENCE_SPELLING_ENABLED)) {
        return null;
    }

    SpellingService spellingService = EditorsUI.getSpellingService();
    if (spellingService.getActiveSpellingEngineDescriptor(fPreferenceStore) == null) {
        return null;
    }

    IReconcilingStrategy strategy = new SpellingReconcileStrategy(sourceViewer, spellingService) {

        @Override
        protected ISpellingProblemCollector createSpellingProblemCollector() {
            final ISpellingProblemCollector collector = super.createSpellingProblemCollector();

            return new ISpellingProblemCollector() {

                public void accept(SpellingProblem problem) {
                    int offset = problem.getOffset();
                    int length = problem.getLength();
                    if (sourceViewer == null) {
                        return;
                    }
                    IDocument document = sourceViewer.getDocument();
                    if (document == null) {
                        return;
                    }
                    String text;
                    try {
                        text = document.get(offset, length);
                    } catch (BadLocationException e) {
                        return;
                    }
                    if (new de.darwinspl.preferences.resource.dwprofile.ui.DwprofileIgnoredWordsFilter().ignoreWord(text)) {
                        return;
                    }
                    collector.accept(problem);
                }

                public void beginCollecting() {
                    collector.beginCollecting();
                }

                public void endCollecting() {
                    collector.endCollecting();
                }
            };
        }
    };

    MonoReconciler reconciler = new MonoReconciler(strategy, false);
    reconciler.setDelay(500);
    return reconciler;
}
项目:DarwinSPL    文件:HyexpressionSourceViewerConfiguration.java   
public IReconciler getReconciler(final ISourceViewer sourceViewer) {
    if (fPreferenceStore == null || !fPreferenceStore.getBoolean(SpellingService.PREFERENCE_SPELLING_ENABLED)) {
        return null;
    }

    SpellingService spellingService = EditorsUI.getSpellingService();
    if (spellingService.getActiveSpellingEngineDescriptor(fPreferenceStore) == null) {
        return null;
    }

    IReconcilingStrategy strategy = new SpellingReconcileStrategy(sourceViewer, spellingService) {

        @Override
        protected ISpellingProblemCollector createSpellingProblemCollector() {
            final ISpellingProblemCollector collector = super.createSpellingProblemCollector();

            return new ISpellingProblemCollector() {

                public void accept(SpellingProblem problem) {
                    int offset = problem.getOffset();
                    int length = problem.getLength();
                    if (sourceViewer == null) {
                        return;
                    }
                    IDocument document = sourceViewer.getDocument();
                    if (document == null) {
                        return;
                    }
                    String text;
                    try {
                        text = document.get(offset, length);
                    } catch (BadLocationException e) {
                        return;
                    }
                    if (new eu.hyvar.feature.expression.resource.hyexpression.ui.HyexpressionIgnoredWordsFilter().ignoreWord(text)) {
                        return;
                    }
                    collector.accept(problem);
                }

                public void beginCollecting() {
                    collector.beginCollecting();
                }

                public void endCollecting() {
                    collector.endCollecting();
                }
            };
        }
    };

    MonoReconciler reconciler = new MonoReconciler(strategy, false);
    reconciler.setDelay(500);
    return reconciler;
}
项目:DarwinSPL    文件:HyvalidityformulaSourceViewerConfiguration.java   
public IReconciler getReconciler(final ISourceViewer sourceViewer) {
    if (fPreferenceStore == null || !fPreferenceStore.getBoolean(SpellingService.PREFERENCE_SPELLING_ENABLED)) {
        return null;
    }

    SpellingService spellingService = EditorsUI.getSpellingService();
    if (spellingService.getActiveSpellingEngineDescriptor(fPreferenceStore) == null) {
        return null;
    }

    IReconcilingStrategy strategy = new SpellingReconcileStrategy(sourceViewer, spellingService) {

        @Override
        protected ISpellingProblemCollector createSpellingProblemCollector() {
            final ISpellingProblemCollector collector = super.createSpellingProblemCollector();

            return new ISpellingProblemCollector() {

                public void accept(SpellingProblem problem) {
                    int offset = problem.getOffset();
                    int length = problem.getLength();
                    if (sourceViewer == null) {
                        return;
                    }
                    IDocument document = sourceViewer.getDocument();
                    if (document == null) {
                        return;
                    }
                    String text;
                    try {
                        text = document.get(offset, length);
                    } catch (BadLocationException e) {
                        return;
                    }
                    if (new eu.hyvar.context.contextValidity.resource.hyvalidityformula.ui.HyvalidityformulaIgnoredWordsFilter().ignoreWord(text)) {
                        return;
                    }
                    collector.accept(problem);
                }

                public void beginCollecting() {
                    collector.beginCollecting();
                }

                public void endCollecting() {
                    collector.endCollecting();
                }
            };
        }
    };

    MonoReconciler reconciler = new MonoReconciler(strategy, false);
    reconciler.setDelay(500);
    return reconciler;
}
项目:DarwinSPL    文件:HydatavalueSourceViewerConfiguration.java   
public IReconciler getReconciler(final ISourceViewer sourceViewer) {
    if (fPreferenceStore == null || !fPreferenceStore.getBoolean(SpellingService.PREFERENCE_SPELLING_ENABLED)) {
        return null;
    }

    SpellingService spellingService = EditorsUI.getSpellingService();
    if (spellingService.getActiveSpellingEngineDescriptor(fPreferenceStore) == null) {
        return null;
    }

    IReconcilingStrategy strategy = new SpellingReconcileStrategy(sourceViewer, spellingService) {

        @Override
        protected ISpellingProblemCollector createSpellingProblemCollector() {
            final ISpellingProblemCollector collector = super.createSpellingProblemCollector();

            return new ISpellingProblemCollector() {

                public void accept(SpellingProblem problem) {
                    int offset = problem.getOffset();
                    int length = problem.getLength();
                    if (sourceViewer == null) {
                        return;
                    }
                    IDocument document = sourceViewer.getDocument();
                    if (document == null) {
                        return;
                    }
                    String text;
                    try {
                        text = document.get(offset, length);
                    } catch (BadLocationException e) {
                        return;
                    }
                    if (new eu.hyvar.dataValues.resource.hydatavalue.ui.HydatavalueIgnoredWordsFilter().ignoreWord(text)) {
                        return;
                    }
                    collector.accept(problem);
                }

                public void beginCollecting() {
                    collector.beginCollecting();
                }

                public void endCollecting() {
                    collector.endCollecting();
                }
            };
        }
    };

    MonoReconciler reconciler = new MonoReconciler(strategy, false);
    reconciler.setDelay(500);
    return reconciler;
}
项目:DarwinSPL    文件:HymappingSourceViewerConfiguration.java   
public IReconciler getReconciler(final ISourceViewer sourceViewer) {
    if (fPreferenceStore == null || !fPreferenceStore.getBoolean(SpellingService.PREFERENCE_SPELLING_ENABLED)) {
        return null;
    }

    SpellingService spellingService = EditorsUI.getSpellingService();
    if (spellingService.getActiveSpellingEngineDescriptor(fPreferenceStore) == null) {
        return null;
    }

    IReconcilingStrategy strategy = new SpellingReconcileStrategy(sourceViewer, spellingService) {

        @Override
        protected ISpellingProblemCollector createSpellingProblemCollector() {
            final ISpellingProblemCollector collector = super.createSpellingProblemCollector();

            return new ISpellingProblemCollector() {

                public void accept(SpellingProblem problem) {
                    int offset = problem.getOffset();
                    int length = problem.getLength();
                    if (sourceViewer == null) {
                        return;
                    }
                    IDocument document = sourceViewer.getDocument();
                    if (document == null) {
                        return;
                    }
                    String text;
                    try {
                        text = document.get(offset, length);
                    } catch (BadLocationException e) {
                        return;
                    }
                    if (new eu.hyvar.feature.mapping.resource.hymapping.ui.HymappingIgnoredWordsFilter().ignoreWord(text)) {
                        return;
                    }
                    collector.accept(problem);
                }

                public void beginCollecting() {
                    collector.beginCollecting();
                }

                public void endCollecting() {
                    collector.endCollecting();
                }
            };
        }
    };

    MonoReconciler reconciler = new MonoReconciler(strategy, false);
    reconciler.setDelay(500);
    return reconciler;
}
项目:DarwinSPL    文件:HyconstraintsSourceViewerConfiguration.java   
public IReconciler getReconciler(final ISourceViewer sourceViewer) {
    if (fPreferenceStore == null || !fPreferenceStore.getBoolean(SpellingService.PREFERENCE_SPELLING_ENABLED)) {
        return null;
    }

    SpellingService spellingService = EditorsUI.getSpellingService();
    if (spellingService.getActiveSpellingEngineDescriptor(fPreferenceStore) == null) {
        return null;
    }

    IReconcilingStrategy strategy = new SpellingReconcileStrategy(sourceViewer, spellingService) {

        @Override
        protected ISpellingProblemCollector createSpellingProblemCollector() {
            final ISpellingProblemCollector collector = super.createSpellingProblemCollector();

            return new ISpellingProblemCollector() {

                public void accept(SpellingProblem problem) {
                    int offset = problem.getOffset();
                    int length = problem.getLength();
                    if (sourceViewer == null) {
                        return;
                    }
                    IDocument document = sourceViewer.getDocument();
                    if (document == null) {
                        return;
                    }
                    String text;
                    try {
                        text = document.get(offset, length);
                    } catch (BadLocationException e) {
                        return;
                    }
                    if (new eu.hyvar.feature.constraint.resource.hyconstraints.ui.HyconstraintsIgnoredWordsFilter().ignoreWord(text)) {
                        return;
                    }
                    collector.accept(problem);
                }

                public void beginCollecting() {
                    collector.beginCollecting();
                }

                public void endCollecting() {
                    collector.endCollecting();
                }
            };
        }
    };

    MonoReconciler reconciler = new MonoReconciler(strategy, false);
    reconciler.setDelay(500);
    return reconciler;
}
项目:DarwinSPL    文件:HymanifestSourceViewerConfiguration.java   
public IReconciler getReconciler(final ISourceViewer sourceViewer) {
    if (fPreferenceStore == null || !fPreferenceStore.getBoolean(SpellingService.PREFERENCE_SPELLING_ENABLED)) {
        return null;
    }

    SpellingService spellingService = EditorsUI.getSpellingService();
    if (spellingService.getActiveSpellingEngineDescriptor(fPreferenceStore) == null) {
        return null;
    }

    IReconcilingStrategy strategy = new SpellingReconcileStrategy(sourceViewer, spellingService) {

        @Override
        protected ISpellingProblemCollector createSpellingProblemCollector() {
            final ISpellingProblemCollector collector = super.createSpellingProblemCollector();

            return new ISpellingProblemCollector() {

                public void accept(SpellingProblem problem) {
                    int offset = problem.getOffset();
                    int length = problem.getLength();
                    if (sourceViewer == null) {
                        return;
                    }
                    IDocument document = sourceViewer.getDocument();
                    if (document == null) {
                        return;
                    }
                    String text;
                    try {
                        text = document.get(offset, length);
                    } catch (BadLocationException e) {
                        return;
                    }
                    if (new eu.hyvar.mspl.manifest.resource.hymanifest.ui.HymanifestIgnoredWordsFilter().ignoreWord(text)) {
                        return;
                    }
                    collector.accept(problem);
                }

                public void beginCollecting() {
                    collector.beginCollecting();
                }

                public void endCollecting() {
                    collector.endCollecting();
                }
            };
        }
    };

    MonoReconciler reconciler = new MonoReconciler(strategy, false);
    reconciler.setDelay(500);
    return reconciler;
}
项目:subclipse    文件:CommitCommentArea.java   
public void accept(SpellingProblem problem) {
  fAddAnnotations.put(new Annotation(SPELLING_ERROR, false, problem.getMessage()), 
      new Position(problem.getOffset(), problem.getLength()));
}
项目:texlipse    文件:AddToDictProposal.java   
public void apply(IDocument document) {
    TexSpellDictionary dict = TexSpellingEngine.getDict(fLang);
    dict.addWord(ferror.getInvalidWord());
    SpellingProblem.removeAll(fviewer, ferror.getInvalidWord());
}
项目:texlipse    文件:IgnoreProposal.java   
public void apply(IDocument document) {
    fIgnore.add(fWord);
    SpellingProblem.removeAll(fViewer, fWord);
}
项目:texlipse    文件:TexSpellingEngine.java   
public void check(IDocument document, IRegion[] regions, SpellingContext context, 
        ISpellingProblemCollector collector, IProgressMonitor monitor) {

    if (ignore == null) {
        ignore = new HashSet<String>();
    }

    IProject project = getProject(document);

    String lang = DEFAULT_LANG;
    if (project != null) {
        lang = TexlipseProperties.getProjectProperty(project, TexlipseProperties.LANGUAGE_PROPERTY);
    }
    //Get spellchecker for the correct language
    SpellChecker spellCheck = getSpellChecker(lang);
    if (spellCheck == null) return;

    if (collector instanceof TeXSpellingProblemCollector) {
        ((TeXSpellingProblemCollector) collector).setRegions(regions);
    }

    try {
        spellCheck.addSpellCheckListener(this);
        for (final IRegion r : regions) {
            errors = new LinkedList<SpellCheckEvent>();
            int roffset = r.getOffset();

            //Create a new wordfinder and initialize it
            TexlipseWordFinder wf = new TexlipseWordFinder();
            wf.setIgnoreComments(TexlipsePlugin.getDefault().getPreferenceStore().getBoolean(TexlipseProperties.SPELLCHECKER_IGNORE_COMMENTS));
            wf.setIgnoreMath(TexlipsePlugin.getDefault().getPreferenceStore().getBoolean(TexlipseProperties.SPELLCHECKER_IGNORE_MATH));

            spellCheck.checkSpelling(new StringWordTokenizer(
                    document.get(roffset, r.getLength()), wf));

            for (SpellCheckEvent error : errors) {
                SpellingProblem p = new TexSpellingProblem(error, roffset, lang);
                collector.accept(p);
            }
        }
        spellCheck.removeSpellCheckListener(this);                
    } catch (BadLocationException e) {
        e.printStackTrace();
    }
}
项目:texlipse    文件:TeXSpellingReconcileStrategy.java   
public void accept(SpellingProblem problem) {
    fAddAnnotations.put(new SpellingAnnotation(problem), new Position(problem.getOffset(), problem.getLength()));
}
项目:APICloud-Studio    文件:CommitCommentArea.java   
public void accept(SpellingProblem problem) {
  fAddAnnotations.put(new Annotation(SPELLING_ERROR, false, problem.getMessage()), 
      new Position(problem.getOffset(), problem.getLength()));
}
项目:APICloud-Studio    文件:MultiRegionSpellingReconcileStrategy.java   
public void accept(SpellingProblem problem) {
    fAddAnnotations.put(new SpellingAnnotation(problem), new Position(problem.getOffset(), problem.getLength()));
}
项目:Pydev    文件:PyReconciler.java   
@Override
public void accept(SpellingProblem problem) {
    fAddAnnotations
            .put(new SpellingAnnotation(problem), new Position(problem.getOffset(), problem.getLength()));
}