Search in sources :

Example 1 with HighlightingPresenter

use of org.eclipse.xtext.ui.editor.syntaxcoloring.HighlightingPresenter in project dsl-devkit by dsldevkit.

the class FixedHighlightingReconciler method modelChanged.

/**
 * {@inheritDoc}
 */
@Override
public void modelChanged(final XtextResource resource, final CancelIndicator cancelIndicator) {
    // ensure at most one thread can be reconciling at any time
    synchronized (fReconcileLock) {
        if (reconciling) {
            return;
        }
        reconciling = true;
    }
    final HighlightingPresenter highlightingPresenter = presenter;
    try {
        if (highlightingPresenter == null) {
            return;
        }
        highlightingPresenter.setCanceled(false);
        if (highlightingPresenter.isCanceled()) {
            return;
        }
        startReconcilingPositions();
        if (!highlightingPresenter.isCanceled()) {
            reconcilePositions(resource);
        }
        final TextPresentation[] textPresentation = new TextPresentation[1];
        if (!highlightingPresenter.isCanceled()) {
            textPresentation[0] = highlightingPresenter.createPresentation(addedPositions, removedPositions);
        }
        if (!highlightingPresenter.isCanceled()) {
            updatePresentation(textPresentation[0], addedPositions, removedPositions);
        }
        stopReconcilingPositions();
    } finally {
        synchronized (fReconcileLock) {
            reconciling = false;
            if (cleanUpAfterReconciliation) {
                editor = null;
                sourceViewer = null;
                presenter = null;
                cleanUpAfterReconciliation = false;
            }
        }
    }
}
Also used : HighlightingPresenter(org.eclipse.xtext.ui.editor.syntaxcoloring.HighlightingPresenter) TextPresentation(org.eclipse.jface.text.TextPresentation)

Example 2 with HighlightingPresenter

use of org.eclipse.xtext.ui.editor.syntaxcoloring.HighlightingPresenter in project statecharts by Yakindu.

the class XtextStyledTextHighlightingReconciler method modelChanged.

public void modelChanged(XtextResource resource) {
    // ensure at most one thread can be reconciling at any time
    synchronized (fReconcileLock) {
        if (reconciling)
            return;
        reconciling = true;
    }
    final HighlightingPresenter highlightingPresenter = presenter;
    try {
        if (highlightingPresenter == null)
            return;
        highlightingPresenter.setCanceled(false);
        if (highlightingPresenter.isCanceled())
            return;
        startReconcilingPositions();
        if (!highlightingPresenter.isCanceled()) {
            reconcilePositions(resource);
        }
        final TextPresentation[] textPresentation = new TextPresentation[1];
        if (!highlightingPresenter.isCanceled()) {
            textPresentation[0] = highlightingPresenter.createPresentation(addedPositions, removedPositions);
        }
        if (!highlightingPresenter.isCanceled())
            updatePresentation(textPresentation[0], addedPositions, removedPositions);
        stopReconcilingPositions();
    } finally {
        synchronized (fReconcileLock) {
            reconciling = false;
        }
    }
}
Also used : HighlightingPresenter(org.eclipse.xtext.ui.editor.syntaxcoloring.HighlightingPresenter) TextPresentation(org.eclipse.jface.text.TextPresentation)

Aggregations

TextPresentation (org.eclipse.jface.text.TextPresentation)2 HighlightingPresenter (org.eclipse.xtext.ui.editor.syntaxcoloring.HighlightingPresenter)2