org.eclipse.ui.texteditor.spelling.SpellingContext Java Examples

The following examples show how to use org.eclipse.ui.texteditor.spelling.SpellingContext. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TeXSpellingReconcileStrategy.java    From texlipse with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Creates a new comment reconcile strategy.
 *
 * @param viewer the source viewer
 * @param spellingService the spelling service to use
 */
public TeXSpellingReconcileStrategy(ISourceViewer viewer, SpellingService spellingService) {
    Assert.isNotNull(viewer);
    Assert.isNotNull(spellingService);
    fViewer= viewer;
    fSpellingService= spellingService;
    fSpellingContext= new SpellingContext();
    fSpellingContext.setContentType(getContentType());

}
 
Example #2
Source File: DefaultSpellingEngine.java    From xds-ide with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public void check(IDocument document, IRegion[] regions,
		SpellingContext context, ISpellingProblemCollector collector,
		IProgressMonitor monitor) {
	ISpellingEngine engine = getEngine(context.getContentType());
	if (engine == null){
		engine = getEngine(TEXT_CONTENT_TYPE);
	}
	
	if (engine != null){
		engine.check(document, regions, context, collector, monitor);
	}
}
 
Example #3
Source File: SpellingEngine.java    From xds-ide with Eclipse Public License 1.0 5 votes vote down vote up
public void check(IDocument document, IRegion[] regions, SpellingContext context, ISpellingProblemCollector collector, IProgressMonitor monitor) {
	if (collector != null) {
		final ISpellCheckEngine spellingEngine= SpellCheckEngine.getInstance();
		ISpellChecker checker= spellingEngine.getSpellChecker();
		if (checker != null)
			check(document, regions, checker, collector, monitor);
	}
}
 
Example #4
Source File: GWTSpellingEngine.java    From gwt-eclipse-plugin with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public void check(IDocument document, IRegion[] regions,
    SpellingContext context, ISpellingProblemCollector collector,
    IProgressMonitor monitor) {
  if (JavaCore.JAVA_SOURCE_CONTENT_TYPE.equals(context.getContentType().getId())) {
    gwtEngine.check(document, regions, context, collector, monitor);
  } else {
    super.check(document, regions, context, collector, monitor);
  }
}
 
Example #5
Source File: DefaultSpellingEngine.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
public void check(IDocument document, IRegion[] regions, SpellingContext context, ISpellingProblemCollector collector, IProgressMonitor monitor) {
	ISpellingEngine engine= getEngine(context.getContentType());
	if (engine == null)
		engine= getEngine(TEXT_CONTENT_TYPE);
	if (engine != null)
		engine.check(document, regions, context, collector, monitor);
}
 
Example #6
Source File: SpellingEngine.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
public void check(IDocument document, IRegion[] regions, SpellingContext context, ISpellingProblemCollector collector, IProgressMonitor monitor) {
	if (collector != null) {
		final ISpellCheckEngine spellingEngine= SpellCheckEngine.getInstance();
		ISpellChecker checker= spellingEngine.getSpellChecker();
		if (checker != null)
			check(document, regions, checker, collector, monitor);
	}
}
 
Example #7
Source File: PyReconciler.java    From Pydev with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Creates a new comment reconcile strategy.
 * 
 * @param viewer the source viewer
 * @param spellingService the spelling service to use
 */
public PyReconciler(ISourceViewer viewer, SpellingService spellingService) {
    Assert.isNotNull(viewer);
    Assert.isNotNull(spellingService);
    fViewer = viewer;
    fSpellingService = spellingService;
    fSpellingContext = new SpellingContext();
    fSpellingContext.setContentType(getContentType());
}
 
Example #8
Source File: TexSpellingEngine.java    From texlipse with Eclipse Public License 1.0 4 votes vote down vote up
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();
    }
}
 
Example #9
Source File: CommitCommentArea.java    From APICloud-Studio with GNU General Public License v3.0 4 votes vote down vote up
public CommentSpellingReconcileStrategy(AnnotationModel annotationModel) {
  this.fAnnotationModel = annotationModel;
  fSpellingContext = new SpellingContext();
  fSpellingContext.setContentType(Platform.getContentTypeManager().getContentType(IContentTypeManager.CT_TEXT));
}