mirror of
https://github.com/sigmasternchen/xtext-core
synced 2025-03-16 16:58:56 +00:00
[ide] DefaultSemanticHighlightingCalculator: moved responsibility to check cancel indicator to subclasses
Signed-off-by: Miro Spönemann <miro.spoenemann@itemis.de>
This commit is contained in:
parent
84d7d3927c
commit
49ce6adacf
1 changed files with 6 additions and 11 deletions
|
@ -13,13 +13,11 @@ import org.eclipse.emf.common.util.TreeIterator;
|
|||
import org.eclipse.emf.ecore.EObject;
|
||||
import org.eclipse.emf.ecore.EStructuralFeature;
|
||||
import org.eclipse.xtext.EcoreUtil2;
|
||||
import org.eclipse.xtext.ide.editor.syntaxcoloring.HighlightingStyles;
|
||||
import org.eclipse.xtext.nodemodel.ILeafNode;
|
||||
import org.eclipse.xtext.nodemodel.INode;
|
||||
import org.eclipse.xtext.nodemodel.util.NodeModelUtils;
|
||||
import org.eclipse.xtext.parser.IParseResult;
|
||||
import org.eclipse.xtext.resource.XtextResource;
|
||||
import org.eclipse.xtext.service.OperationCanceledManager;
|
||||
import org.eclipse.xtext.tasks.ITaskFinder;
|
||||
import org.eclipse.xtext.tasks.Task;
|
||||
import org.eclipse.xtext.util.CancelIndicator;
|
||||
|
@ -36,9 +34,6 @@ public class DefaultSemanticHighlightingCalculator implements ISemanticHighlight
|
|||
@Inject
|
||||
private ITaskFinder taskFinder;
|
||||
|
||||
@Inject
|
||||
private OperationCanceledManager operationCanceledManager;
|
||||
|
||||
@Override
|
||||
public void provideHighlightingFor(XtextResource resource, IHighlightedPositionAcceptor acceptor,
|
||||
CancelIndicator cancelIndicator) {
|
||||
|
@ -57,8 +52,8 @@ public class DefaultSemanticHighlightingCalculator implements ISemanticHighlight
|
|||
* </p>
|
||||
* <p>
|
||||
* By default this will visit the elements in the resource recursively and call
|
||||
* {@link #highlightElement(EObject, IHighlightedPositionAcceptor)} for each of them. As the last step, tasks will
|
||||
* be highlighted.
|
||||
* {@link #highlightElement(EObject, IHighlightedPositionAcceptor, CancelIndicator)} for each of them. As the
|
||||
* last step, tasks will be highlighted.
|
||||
* </p>
|
||||
* <p>
|
||||
* Clients can override this method if the default recursive approach does not fit their use case
|
||||
|
@ -88,18 +83,18 @@ public class DefaultSemanticHighlightingCalculator implements ISemanticHighlight
|
|||
CancelIndicator cancelIndicator) {
|
||||
TreeIterator<EObject> iterator = EcoreUtil2.eAll(element);
|
||||
while (iterator.hasNext()) {
|
||||
operationCanceledManager.checkCanceled(cancelIndicator);
|
||||
EObject object = iterator.next();
|
||||
if (highlightElement(object, acceptor)) {
|
||||
if (highlightElement(object, acceptor, cancelIndicator)) {
|
||||
iterator.prune();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true to skip the children of this element false otherwise
|
||||
* @return true to skip the children of this element, false otherwise
|
||||
*/
|
||||
protected boolean highlightElement(EObject object, IHighlightedPositionAcceptor acceptor) {
|
||||
protected boolean highlightElement(EObject object, IHighlightedPositionAcceptor acceptor,
|
||||
CancelIndicator cancelIndicator) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue