コード例 #1
0
  @Override
  public IReconciler getReconciler(ISourceViewer sourceViewer) {
    if (fPreferenceStore == null
        || !fPreferenceStore.getBoolean(SpellingService.PREFERENCE_SPELLING_ENABLED)) return null;

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

    // Overridden (just) to return a PyReconciler!
    IReconcilingStrategy strategy = new PyReconciler(sourceViewer, spellingService);

    MonoReconciler reconciler = new MonoReconciler(strategy, false);
    reconciler.setIsIncrementalReconciler(false);
    reconciler.setProgressMonitor(new NullProgressMonitor());
    reconciler.setDelay(500);
    return reconciler;
  }
コード例 #2
0
  @Override
  public ITextHover getTextHover(final ISourceViewer aSourceViewer, final String aContentType) {

    boolean engineEnabled =
        pPreferenceStore.getBoolean(SpellingService.PREFERENCE_SPELLING_ENABLED);

    if (pSpellCheckHover == null && engineEnabled) {
      SpellingService selectedService = new SpellingService(pPreferenceStore);

      try {
        SpellingEngineDescriptor engineDescriptor =
            selectedService.getActiveSpellingEngineDescriptor(pPreferenceStore);

        if (engineDescriptor != null) {
          // A spell engine may be available
          ISpellingEngine engine = engineDescriptor.createEngine();
          if (engine != null) {
            pSpellCheckHover = new RestTextHover(engine);
          }

        } else {
          // No spell engine available
          RestPlugin.logWarning("No spell engin found");
        }

      } catch (CoreException e) {
        DebugPlugin.logMessage("Error preparing the spell engine", e);
      }
    }

    // Update spell checking state
    if (pSpellCheckHover != null) {
      pSpellCheckHover.enableSpellChecking(engineEnabled);
    }
    return pSpellCheckHover;
  }
コード例 #3
0
  public org.eclipse.jface.text.reconciler.IReconciler getReconciler(
      final org.eclipse.jface.text.source.ISourceViewer sourceViewer) {
    if (fPreferenceStore == null
        || !fPreferenceStore.getBoolean(
            org.eclipse.ui.texteditor.spelling.SpellingService.PREFERENCE_SPELLING_ENABLED)) {
      return null;
    }

    org.eclipse.ui.texteditor.spelling.SpellingService spellingService =
        org.eclipse.ui.editors.text.EditorsUI.getSpellingService();
    if (spellingService.getActiveSpellingEngineDescriptor(fPreferenceStore) == null) {
      return null;
    }

    org.eclipse.jface.text.reconciler.IReconcilingStrategy strategy =
        new org.eclipse.ui.texteditor.spelling.SpellingReconcileStrategy(
            sourceViewer, spellingService) {
          @Override
          protected org.eclipse.ui.texteditor.spelling.ISpellingProblemCollector
              createSpellingProblemCollector() {
            final org.eclipse.ui.texteditor.spelling.ISpellingProblemCollector collector =
                super.createSpellingProblemCollector();

            return new org.eclipse.ui.texteditor.spelling.ISpellingProblemCollector() {

              public void accept(org.eclipse.ui.texteditor.spelling.SpellingProblem problem) {
                int offset = problem.getOffset();
                int length = problem.getLength();
                if (sourceViewer == null) {
                  return;
                }
                org.eclipse.jface.text.IDocument document = sourceViewer.getDocument();
                if (document == null) {
                  return;
                }
                String text;
                try {
                  text = document.get(offset, length);
                } catch (org.eclipse.jface.text.BadLocationException e) {
                  return;
                }
                if (new edu.ustb.sei.mde.testing.testdefinition.resource.testmodel.ui
                        .TestmodelIgnoredWordsFilter()
                    .ignoreWord(text)) {
                  return;
                }
                collector.accept(problem);
              }

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

              public void endCollecting() {
                collector.endCollecting();
              }
            };
          }
        };
    org.eclipse.jface.text.reconciler.MonoReconciler reconciler =
        new org.eclipse.jface.text.reconciler.MonoReconciler(strategy, false);
    reconciler.setDelay(500);
    return reconciler;
  }