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()));
      }
    }
  }
  public void setDocument(IDocument doc) {
    if (getDocument() instanceof IStructuredDocument) {
      RegionParser parser = ((IStructuredDocument) getDocument()).getParser();
      if (parser instanceof StructuredDocumentRegionParser) {
        ((StructuredDocumentRegionParser) parser)
            .removeStructuredDocumentRegionHandler(fResetHandler);
      }
    }

    super.setDocument(doc);

    IReconcilingStrategy validatorStrategy = getValidatorStrategy();
    if (validatorStrategy != null) {
      validatorStrategy.setDocument(doc);
    }
    if (fSemanticHighlightingStrategy != null) {
      fSemanticHighlightingStrategy.setDocument(doc);
    }

    fSpellcheckStrategy = null;
    if (fFoldingStrategy != null) {
      fFoldingStrategy.uninstall();
    }
    fFoldingStrategy = null;

    if (getDocument() instanceof IStructuredDocument) {
      RegionParser parser = ((IStructuredDocument) doc).getParser();
      if (parser instanceof StructuredDocumentRegionParser) {
        ((StructuredDocumentRegionParser) parser).addStructuredDocumentRegionHandler(fResetHandler);
      }
    }
  }
  /** @see org.eclipse.wst.sse.ui.internal.reconcile.DirtyRegionProcessor#uninstall() */
  public void uninstall() {
    if (isInstalled()) {

      IReconcilingStrategy validatorStrategy = getValidatorStrategy();

      if (validatorStrategy != null) {
        if (validatorStrategy instanceof IReleasable) ((IReleasable) validatorStrategy).release();
      }

      if (fSpellcheckStrategy != null) {
        fSpellcheckStrategy.setDocument(null);
        fSpellcheckStrategy = null;
      }

      fReconcileListeners = new ISourceReconcilingListener[0];

      if (getDocument() instanceof IStructuredDocument) {
        RegionParser parser = ((IStructuredDocument) getDocument()).getParser();
        if (parser instanceof StructuredDocumentRegionParser) {
          ((StructuredDocumentRegionParser) parser)
              .removeStructuredDocumentRegionHandler(fResetHandler);
        }
      }
    }
    super.uninstall();
  }
Пример #5
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;
  }
  public void setDocument(IDocument doc) {
    super.setDocument(doc);

    IReconcilingStrategy validatorStrategy = getValidatorStrategy();
    if (validatorStrategy != null) {
      validatorStrategy.setDocument(doc);
    }
    if (fSemanticHighlightingStrategy != null) {
      fSemanticHighlightingStrategy.setDocument(doc);
    }

    fSpellcheckStrategy = null;
    if (fFoldingStrategy != null) {
      fFoldingStrategy.uninstall();
    }
    fFoldingStrategy = null;
  }
 protected IReconcilingStrategy getSpellcheckStrategy() {
   if (fSpellcheckStrategy == null && getDocument() != null) {
     String contentTypeId = getContentType(getDocument());
     if (contentTypeId == null) {
       contentTypeId = IContentTypeManager.CT_TEXT;
     }
     if (getTextViewer() instanceof ISourceViewer) {
       ISourceViewer viewer = (ISourceViewer) getTextViewer();
       fSpellcheckStrategy = new SpellcheckStrategy(viewer, contentTypeId);
       fSpellcheckStrategy.setDocument(getDocument());
     }
   }
   return fSpellcheckStrategy;
 }
  /** @see org.eclipse.wst.sse.ui.internal.reconcile.DirtyRegionProcessor#uninstall() */
  public void uninstall() {
    if (isInstalled()) {

      IReconcilingStrategy validatorStrategy = getValidatorStrategy();

      if (validatorStrategy != null) {
        if (validatorStrategy instanceof IReleasable) ((IReleasable) validatorStrategy).release();
      }

      if (fSpellcheckStrategy != null) {
        fSpellcheckStrategy.setDocument(null);
        fSpellcheckStrategy = null;
      }

      fReconcileListeners = new ISourceReconcilingListener[0];
    }
    super.uninstall();
  }
Пример #9
0
 protected void handleInputDocumentChanged(IDocument oldInput, IDocument newInput) {
   if (shouldInstallCompletionListener) {
     ContentAssistantFacade facade =
         ((ISourceViewerExtension4) textViewer).getContentAssistantFacade();
     if (facade != null) {
       facade.addCompletionListener(documentListener);
     }
     shouldInstallCompletionListener = false;
   }
   if (oldInput instanceof IXtextDocument) {
     ((IXtextDocument) oldInput).removeXtextDocumentContentObserver(documentListener);
   }
   if (newInput instanceof IXtextDocument) {
     ((IXtextDocument) newInput).addXtextDocumentContentObserver(documentListener);
     final IXtextDocument document = XtextDocumentUtil.get(textViewer);
     strategy.setDocument(document);
     if (!initalProcessDone && strategy instanceof IReconcilingStrategyExtension) {
       initalProcessDone = true;
       IReconcilingStrategyExtension reconcilingStrategyExtension =
           (IReconcilingStrategyExtension) strategy;
       reconcilingStrategyExtension.initialReconcile();
     }
   }
 }
 public void setSemanticHighlightingStrategy(IReconcilingStrategy semanticHighlightingStrategy) {
   fSemanticHighlightingStrategy = semanticHighlightingStrategy;
   fSemanticHighlightingStrategy.setDocument(getDocument());
 }