protected void endProcessing() {
    super.endProcessing();
    ValidatorStrategy validatorStrategy = getValidatorStrategy();
    if (validatorStrategy != null) {
      validatorStrategy.endProcessing();
    }
    /* single spell-check for everything to ensure that SpellingProblem offsets are correct */
    IReconcilingStrategy spellingStrategy = getSpellcheckStrategy();
    IDocument document = getDocument();
    if (spellingStrategy != null && document != null) {
      spellingStrategy.reconcile(new Region(0, document.getLength()));
    }

    IReconcilingStrategy semanticHighlightingStrategy = getSemanticHighlightingStrategy();
    if (semanticHighlightingStrategy != null && document != null) {
      semanticHighlightingStrategy.reconcile(new Region(0, document.getLength()));
    }

    if ((getTextViewer() instanceof ISourceViewer)) {
      ISourceViewer sourceViewer = (ISourceViewer) getTextViewer();
      IAnnotationModel annotationModel = sourceViewer.getAnnotationModel();
      for (int i = 0; i < fReconcileListeners.length; i++) {
        fReconcileListeners[i].reconciled(
            document, annotationModel, false, new NullProgressMonitor());
      }
    }
  }
  protected void setEntireDocumentDirty(IDocument document) {
    super.setEntireDocumentDirty(document);

    // make the entire document dirty
    // this also happens on a "save as"
    if (document != null && isInstalled() && fLastPartitions != null && document.getLength() == 0) {
      /**
       * https://bugs.eclipse.org/bugs/show_bug.cgi?id=199053
       *
       * <p>Process the strategies for the last known-good partitions.
       */
      for (int i = 0; i < fLastPartitions.length; i++) {
        ValidatorStrategy validatorStrategy = getValidatorStrategy();
        if (validatorStrategy != null) {
          validatorStrategy.reconcile(
              fLastPartitions[i], createDirtyRegion(fLastPartitions[i], DirtyRegion.REMOVE));
        }
      }
      IReconcilingStrategy spellingStrategy = getSpellcheckStrategy();
      if (spellingStrategy != null) {
        spellingStrategy.reconcile(new Region(0, document.getLength()));
      }

      // if there is a folding strategy then reconcile it
      if (getFoldingStrategy() != null) {
        getFoldingStrategy().reconcile(new Region(0, document.getLength()));
      }
    }
  }
Ejemplo n.º 3
0
  @Override
  protected IStatus run(IProgressMonitor monitor) {
    if (monitor.isCanceled() || paused) return Status.CANCEL_STATUS;

    long start = System.currentTimeMillis();
    if (log.isDebugEnabled()) {
      log.debug("Preparing reconciliation."); // $NON-NLS-1$
    }

    final IXtextDocument document = XtextDocumentUtil.get(textViewer);
    if (document != null) {
      final ReplaceRegion replaceRegionToBeProcessed = getAndResetReplaceRegion();
      if (replaceRegionToBeProcessed != null) {
        if (strategy instanceof IReconcilingStrategyExtension) {
          ((IReconcilingStrategyExtension) strategy).setProgressMonitor(monitor);
        }
        strategy.reconcile(replaceRegionToBeProcessed);
      }
    }
    if (log.isDebugEnabled())
      log.debug(
          "Reconciliation finished. Time required: "
              + (System.currentTimeMillis() - start)); // $NON-NLS-1$
    return Status.OK_STATUS;
  }