/** * @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; }
@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); }
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 } } }
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) 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); } }
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); } }
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; }
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; }
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; }
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; }
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; }
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; }
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; }
public void accept(SpellingProblem problem) { fAddAnnotations.put(new Annotation(SPELLING_ERROR, false, problem.getMessage()), new Position(problem.getOffset(), problem.getLength())); }
public void apply(IDocument document) { TexSpellDictionary dict = TexSpellingEngine.getDict(fLang); dict.addWord(ferror.getInvalidWord()); SpellingProblem.removeAll(fviewer, ferror.getInvalidWord()); }
public void apply(IDocument document) { fIgnore.add(fWord); SpellingProblem.removeAll(fViewer, fWord); }
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(); } }
public void accept(SpellingProblem problem) { fAddAnnotations.put(new SpellingAnnotation(problem), new Position(problem.getOffset(), problem.getLength())); }
@Override public void accept(SpellingProblem problem) { fAddAnnotations .put(new SpellingAnnotation(problem), new Position(problem.getOffset(), problem.getLength())); }