org.eclipse.xtext.ide.editor.syntaxcoloring.IHighlightedPositionAcceptor Java Examples

The following examples show how to use org.eclipse.xtext.ide.editor.syntaxcoloring.IHighlightedPositionAcceptor. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DotSemanticHighlightingCalculator.java    From gef with Eclipse Public License 2.0 6 votes vote down vote up
private void provideHighlightingForHtmlString(INode node,
		IHighlightedPositionAcceptor acceptor) {
	// highlight the leading '<' symbol
	int openingSymbolOffset = node.getOffset();
	acceptor.addPosition(openingSymbolOffset, 1,
			DotHighlightingConfiguration.HTML_TAG);

	// highlight the trailing '>' symbol
	int closingSymbolOffset = node.getOffset() + node.getText().length()
			- 1;
	acceptor.addPosition(closingSymbolOffset, 1,
			DotHighlightingConfiguration.HTML_TAG);

	// trim the leading '<' and trailing '>' symbols
	String htmlString = node.getText().substring(1,
			node.getText().length() - 1);

	// delegate the highlighting of the the html-label substring to the
	// corresponding sub-grammar highlighter
	DotSubgrammarHighlighter htmlLabelHighlighter = new DotSubgrammarHighlighter(
			DotActivator.ORG_ECLIPSE_GEF_DOT_INTERNAL_LANGUAGE_DOTHTMLLABEL);
	htmlLabelHighlighter.provideHightlightingFor(htmlString,
			node.getOffset() + 1, acceptor);
}
 
Example #2
Source File: SemanticHighlightingCalculator.java    From dsl-devkit with Eclipse Public License 1.0 6 votes vote down vote up
/** {@inheritDoc} */
@Override
public void provideHighlightingFor(final XtextResource resource, final IHighlightedPositionAcceptor acceptor, final CancelIndicator cancelIndicator) {
  if (resource == null) {
    return;
  }
  Iterator<EObject> iter = EcoreUtil.getAllContents(resource, true);
  while (iter.hasNext()) {
    EObject current = iter.next();

    if (current instanceof ConfiguredCheck && ((ConfiguredCheck) current).getSeverity().equals(SeverityKind.IGNORE)) {
      INode node = getFirstParseTreeNode(current, CheckcfgPackage.Literals.CONFIGURED_CHECK__CHECK);
      highlightNode(node, SemanticHighlightingConfiguration.DISABLED_VALUE_ID, acceptor);
    }
  }
}
 
Example #3
Source File: CheckHighlightingCalculator.java    From dsl-devkit with Eclipse Public License 1.0 6 votes vote down vote up
@Override
protected void highlightSpecialIdentifiers(final IHighlightedPositionAcceptor acceptor, final ICompositeNode root) {
  TerminalRule idRule = grammarAccess.getIDRule();

  for (ILeafNode leaf : root.getLeafNodes()) {
    if (commentProvider.isJavaDocComment(leaf)) {
      // not really a special identifier, but we don't want to iterate over the leaf nodes twice, do we?
      acceptor.addPosition(leaf.getOffset(), leaf.getLength(), CheckHighlightingConfiguration.JAVADOC_ID);
    } else if (!leaf.isHidden()) {
      if (leaf.getGrammarElement() instanceof Keyword) {
        // Check if it is a keyword used as an identifier.
        ParserRule rule = GrammarUtil.containingParserRule(leaf.getGrammarElement());
        if (FEATURE_CALL_ID_RULE_NAME.equals(rule.getName())) {
          acceptor.addPosition(leaf.getOffset(), leaf.getLength(), DefaultHighlightingConfiguration.DEFAULT_ID);
        }
      } else {
        highlightSpecialIdentifiers(leaf, acceptor, idRule);
      }
    }
  }
}
 
Example #4
Source File: SemanticHighlightingCalculatorImpl.java    From xtext-core with Eclipse Public License 2.0 6 votes vote down vote up
public boolean doHighlightElement(final EObject it, final IHighlightedPositionAcceptor acceptor) {
  if (it instanceof Operation) {
    return _doHighlightElement((Operation)it, acceptor);
  } else if (it instanceof PrimitiveType) {
    return _doHighlightElement((PrimitiveType)it, acceptor);
  } else if (it instanceof Property) {
    return _doHighlightElement((Property)it, acceptor);
  } else if (it instanceof TypeDeclaration) {
    return _doHighlightElement((TypeDeclaration)it, acceptor);
  } else if (it instanceof TypeReference) {
    return _doHighlightElement((TypeReference)it, acceptor);
  } else if (it instanceof Parameter) {
    return _doHighlightElement((Parameter)it, acceptor);
  } else if (it != null) {
    return _doHighlightElement(it, acceptor);
  } else {
    throw new IllegalArgumentException("Unhandled parameter types: " +
      Arrays.<Object>asList(it, acceptor).toString());
  }
}
 
Example #5
Source File: XbaseHighlightingCalculator.java    From xtext-extras with Eclipse Public License 2.0 6 votes vote down vote up
protected void computeReferencedJvmTypeHighlighting(IHighlightedPositionAcceptor acceptor, EObject referencer,
		CancelIndicator cancelIndicator) {
	for (EReference reference : referencer.eClass().getEAllReferences()) {
		EClass referencedType = reference.getEReferenceType();
		if (EcoreUtil2.isAssignableFrom(TypesPackage.Literals.JVM_TYPE, referencedType)) {
			List<EObject> referencedObjects = EcoreUtil2.getAllReferencedObjects(referencer, reference);
			if (referencedObjects.size() > 0)
				operationCanceledManager.checkCanceled(cancelIndicator);
			for (EObject referencedObject : referencedObjects) {
				EObject resolvedReferencedObject = EcoreUtil.resolve(referencedObject, referencer);
				if (resolvedReferencedObject != null && !resolvedReferencedObject.eIsProxy()) {
					highlightReferenceJvmType(acceptor, referencer, reference, resolvedReferencedObject);
				}
			}
		}
	}
}
 
Example #6
Source File: SemanticHighlighter.java    From xtext-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * Highlights the non-hidden parts of {@code node} with the style that is associated with {@code id}.
 */
protected void highlightNode(INode node, String id, IHighlightedPositionAcceptor acceptor) {
	if (node == null)
		return;
	if (node instanceof ILeafNode) {
		ITextRegion textRegion = node.getTextRegion();
		acceptor.addPosition(textRegion.getOffset(), textRegion.getLength(), id);
	} else {
		for (ILeafNode leaf : node.getLeafNodes()) {
			if (!leaf.isHidden()) {
				ITextRegion leafRegion = leaf.getTextRegion();
				acceptor.addPosition(leafRegion.getOffset(), leafRegion.getLength(), id);
			}
		}
	}
}
 
Example #7
Source File: DotSemanticHighlightingCalculator.java    From gef with Eclipse Public License 2.0 6 votes vote down vote up
private void provideHighlightingForArrowTypeString(INode node,
		IHighlightedPositionAcceptor acceptor) {
	String arrowTypeString = node.getText();
	int offset = node.getOffset();
	String suffix = null;

	// quoted attribute value
	if (arrowTypeString.length() > 0 && arrowTypeString.charAt(0) == '"') {
		// trim the leading '"' and trailing '"' symbols
		arrowTypeString = arrowTypeString.substring(1,
				arrowTypeString.length() - 1);
		// increase offset correspondingly
		offset++;
		// adapt highlighting to quoted style
		suffix = DotHighlightingConfiguration.QUOTED_SUFFIX;
	}

	// delegate the highlighting of the the arrowType substring to the
	// corresponding sub-grammar highlighter
	DotSubgrammarHighlighter arrowTypeHighlighter = new DotSubgrammarHighlighter(
			DotActivator.ORG_ECLIPSE_GEF_DOT_INTERNAL_LANGUAGE_DOTARROWTYPE);
	arrowTypeHighlighter.provideHightlightingFor(arrowTypeString, offset,
			acceptor, suffix);
}
 
Example #8
Source File: XtendHighlightingCalculator.java    From xtext-xtend with Eclipse Public License 2.0 6 votes vote down vote up
protected void highlightDeprecatedXtendAnnotationTarget(IHighlightedPositionAcceptor acceptor, XtendAnnotationTarget target, XAnnotation annotation){
	JvmType annotationType = annotation.getAnnotationType();
	if(annotationType instanceof JvmAnnotationType && DeprecationUtil.isDeprecatedAnnotation((JvmAnnotationType) annotationType)){
		if (target instanceof XtendConstructor) {
			ICompositeNode compositeNode = NodeModelUtils.getNode(target);
			for(ILeafNode leaf: compositeNode.getLeafNodes()) {
				if (leaf.getGrammarElement() == xtendGrammarAccess.getMemberAccess().getNewKeyword_2_2_2()) {
					highlightNode(acceptor, leaf, XbaseHighlightingStyles.DEPRECATED_MEMBERS);
					highlightNode(acceptor, leaf, HighlightingStyles.KEYWORD_ID);
					return;
				}
			}
		} else {
			EStructuralFeature nameFeature = target.eClass().getEStructuralFeature("name");
			if (nameFeature!=null) {
				highlightFeature(acceptor, target, nameFeature, XbaseHighlightingStyles.DEPRECATED_MEMBERS);
			}
		}
	}
}
 
Example #9
Source File: DotArrowTypeSemanticHighlightingCalculator.java    From gef with Eclipse Public License 2.0 6 votes vote down vote up
@Override
public void doProvideHighlightingFor(XtextResource resource,
		IHighlightedPositionAcceptor acceptor,
		CancelIndicator cancelIndicator) {

	// It gets a node model.
	INode root = resource.getParseResult().getRootNode();
	for (INode node : root.getAsTreeIterable()) {
		EObject grammarElement = node.getGrammarElement();
		if (grammarElement instanceof RuleCall) {
			RuleCall rc = (RuleCall) grammarElement;
			AbstractRule r = rc.getRule();
			String ruleName = r.getName();
			switch (ruleName) {
			case "DeprecatedShape": //$NON-NLS-1$
				acceptor.addPosition(node.getOffset(), node.getLength(),
						DotHighlightingConfiguration.DEPRECATED_ATTRIBUTE_VALUE);
				break;
			}
		}
	}
}
 
Example #10
Source File: SoliditySemanticHighlighter.java    From solidity-ide with Eclipse Public License 1.0 6 votes vote down vote up
private void provideHighLightForNamedElement(NamedElement namedElement, INode nextNode, String textStyle,
		IHighlightedPositionAcceptor acceptor) {
	acceptor.addPosition(nextNode.getOffset(), nextNode.getLength(), textStyle);
	List<ElementReferenceExpression> references = EcoreUtil2.getAllContentsOfType(namedElement.eContainer(),
			ElementReferenceExpression.class);
	for (ElementReferenceExpression elementReferenceExpression : references) {
		EObject reference = elementReferenceExpression.getReference();
		if (reference.equals(namedElement)) {
			ICompositeNode referencingNode = NodeModelUtils.findActualNodeFor(elementReferenceExpression);
			BidiIterator<INode> bidiIterator = referencingNode.getChildren().iterator();
			while (bidiIterator.hasNext()) {
				INode currentNode = bidiIterator.next();
				if (currentNode.getText().trim().equals(namedElement.getName())) {
					acceptor.addPosition(currentNode.getOffset(), currentNode.getLength(), textStyle);
				}
			}
		}
	}
}
 
Example #11
Source File: SoliditySemanticHighlighter.java    From solidity-ide with Eclipse Public License 1.0 6 votes vote down vote up
private void provideHighligtingFor(ElementReferenceExpression expression, IHighlightedPositionAcceptor acceptor) {
	EObject reference = expression.getReference();
	if (reference instanceof Declaration) {
		Declaration decl = (Declaration) expression.getReference();
		switch (decl.getName()) {
		case "msg":
		case "block":
		case "tx":
		case "now":
		case "this":
		case "super":
			ICompositeNode node = NodeModelUtils.findActualNodeFor(expression);
			acceptor.addPosition(node.getTotalOffset(), node.getLength() + 1,
					DefaultHighlightingConfiguration.KEYWORD_ID);
		}
	}
}
 
Example #12
Source File: XbaseHighlightingCalculator.java    From xtext-extras with Eclipse Public License 2.0 6 votes vote down vote up
@Override
public void provideHighlightingFor(XtextResource resource, IHighlightedPositionAcceptor acceptor,
		CancelIndicator cancelIndicator) {
	if (resource == null)
		return;
	IParseResult parseResult = resource.getParseResult();
	if (parseResult == null || parseResult.getRootASTElement() == null)
		return;
	if (highlightedIdentifiers == null) {
		highlightedIdentifiers = initializeHighlightedIdentifiers();
		idLengthsToHighlight = new BitSet();
		for (String s : highlightedIdentifiers.keySet()) {
			idLengthsToHighlight.set(s.length());
		}
	}
	//TODO remove this check when the typesystem works without a java project
	if (resource.isValidationDisabled()) {
		highlightSpecialIdentifiers(acceptor, parseResult.getRootNode());
		return;
	}
	doProvideHighlightingFor(resource, acceptor, cancelIndicator);
}
 
Example #13
Source File: GamlSemanticHighlightingCalculator.java    From gama with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void provideHighlightingFor(final XtextResource resource, final IHighlightedPositionAcceptor arg1,
		final CancelIndicator arg2) {
	if (resource == null) { return; }
	acceptor = arg1;
	final TreeIterator<EObject> root = resource.getAllContents();
	while (root.hasNext()) {
		process(root.next());
	}
	done.clear();
	highlightTasks(resource, acceptor);
}
 
Example #14
Source File: DotSubgrammarHighlighter.java    From gef with Eclipse Public License 2.0 5 votes vote down vote up
public void provideHightlightingFor(String text, int startOffset,
		IHighlightedPositionAcceptor hostGrammarAcceptor, String suffix) {

	Injector injector = DotActivator.getInstance().getInjector(language);
	ISemanticHighlightingCalculator subgrammarCalculator = injector
			.getInstance(ISemanticHighlightingCalculator.class);

	XtextResource xtextResource = DotEditorUtils.getXtextResource(injector,
			text);

	subgrammarCalculator.provideHighlightingFor(xtextResource,
			new IHighlightedPositionAcceptor() {

				@Override
				public void addPosition(int offset, int length,
						String... id) {
					if (suffix != null) {
						id = Arrays.stream(id).map(e -> e + suffix)
								.toArray(String[]::new);
					}

					hostGrammarAcceptor.addPosition(startOffset + offset,
							length, id);
				}

			}, null);
}
 
Example #15
Source File: SemanticHighlightingCalculator.java    From dsl-devkit with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Highlights a given parse tree node.
 *
 * @param node
 *          the node from the parse tree
 * @param id
 *          the id of the configuration
 * @param acceptor
 *          the acceptor
 */
private void highlightNode(final INode node, final String id, final IHighlightedPositionAcceptor acceptor) {
  if (node == null) {
    return;
  }
  if (node instanceof ILeafNode) {
    acceptor.addPosition(node.getOffset(), node.getLength(), id);
  } else {
    for (ILeafNode leaf : node.getLeafNodes()) {
      if (!leaf.isHidden()) {
        acceptor.addPosition(leaf.getOffset(), leaf.getLength(), id);
      }
    }
  }
}
 
Example #16
Source File: SemanticHighlightingCalculatorImpl.java    From xtext-core with Eclipse Public License 2.0 5 votes vote down vote up
public boolean doHighlightNode(final IHighlightedPositionAcceptor acceptor, final EObject object, final EStructuralFeature feature, final String style) {
  final Consumer<INode> _function = (INode it) -> {
    acceptor.addPosition(it.getOffset(), it.getLength(), style);
  };
  NodeModelUtils.findNodesForFeature(object, feature).forEach(_function);
  return false;
}
 
Example #17
Source File: XtendHighlightingCalculator.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
@Override
protected void highlightSpecialIdentifiers(ILeafNode leafNode, IHighlightedPositionAcceptor acceptor,
		TerminalRule idRule) {
	super.highlightSpecialIdentifiers(leafNode, acceptor, idRule);
	if (contextualKeywords != null && contextualKeywords.contains(leafNode.getGrammarElement())) {
		ITextRegion leafRegion = leafNode.getTextRegion();
		acceptor.addPosition(leafRegion.getOffset(), leafRegion.getLength(),
				HighlightingStyles.DEFAULT_ID);
	}
}
 
Example #18
Source File: SARLHighlightingCalculator.java    From sarl with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("checkstyle:all")
@Override
protected void computeFeatureCallHighlighting(XAbstractFeatureCall featureCall, IHighlightedPositionAcceptor acceptor) {
	super.computeFeatureCallHighlighting(featureCall, acceptor);

	JvmIdentifiableElement feature = featureCall.getFeature();
	if (feature != null && !feature.eIsProxy() && feature instanceof JvmOperation && !featureCall.isOperation()) {
		if (isCapacityMethodCall((JvmOperation) feature)) {
			highlightFeatureCall(featureCall, acceptor, SARLHighlightingStyles.CAPACITY_METHOD_INVOCATION);
		}
	}
}
 
Example #19
Source File: XtendHighlightingCalculator.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
protected void highlightElement(XtendField field, IHighlightedPositionAcceptor acceptor, CancelIndicator cancelIndicator) {		
	highlightFeature(acceptor, field, XtendPackage.Literals.XTEND_FIELD__NAME, FIELD);
	
	if(field.isStatic()) {
		highlightFeature(acceptor, field, XtendPackage.Literals.XTEND_FIELD__NAME, STATIC_FIELD);
		
		if (field.isFinal()) {
			highlightFeature(acceptor, field, XtendPackage.Literals.XTEND_FIELD__NAME, STATIC_FINAL_FIELD);
		}
	}
	
	XExpression initializer = field.getInitialValue();
	highlightRichStrings(initializer, acceptor);
}
 
Example #20
Source File: XtendHighlightingCalculator.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
protected void highlightElement(XtendFunction function, IHighlightedPositionAcceptor acceptor, CancelIndicator cancelIndicator) {
	highlightFeature(acceptor, function, XtendPackage.Literals.XTEND_FUNCTION__NAME, METHOD);
	XExpression rootExpression = function.getExpression();
	highlightRichStrings(rootExpression, acceptor);
	CreateExtensionInfo createExtensionInfo = function.getCreateExtensionInfo();
	if (createExtensionInfo != null) {
		highlightRichStrings(createExtensionInfo.getCreateExpression(), acceptor);
	}
}
 
Example #21
Source File: XtendHighlightingCalculator.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
protected void highlightElement(XtendAnnotationType xtendType, IHighlightedPositionAcceptor acceptor, CancelIndicator cancelIndicator) {		
	for(XAnnotation annotation: xtendType.getAnnotations()) {
		JvmType annotationType = annotation.getAnnotationType();
		if (annotationType != null && !annotationType.eIsProxy() && Active.class.getName().equals(annotationType.getIdentifier())) {
			highlightFeature(acceptor, annotation, XtendPackage.Literals.XTEND_TYPE_DECLARATION__NAME, ACTIVE_ANNOTATION);
			break;
		}
	}
}
 
Example #22
Source File: SleighHighlightingCalculator.java    From ghidra with Apache License 2.0 5 votes vote down vote up
private void setStyle(IHighlightedPositionAcceptor acceptor, INode n, EObject vnode) {
	if (vnode instanceof LOCALSYM) {
		setNodeStyle(acceptor, n, LOCAL);
	} else if (vnode instanceof VARSYM) {
		setNodeStyle(acceptor, n, VARIABLE);
	} else if (vnode instanceof SUBTABLESYM) {
		setNodeStyle(acceptor, n, SUBTABLE);
	} else if (vnode instanceof fielddef) {
		setNodeStyle(acceptor, n, TOKENFIELD);
	} else {
		// System.out.println("  symtype = " + vnode);
	}
}
 
Example #23
Source File: XtendHighlightingCalculator.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
protected void highlightRichStrings(XExpression expression, IHighlightedPositionAcceptor acceptor) {
	if (expression != null) {
		TreeIterator<EObject> iterator = EcoreUtil2.eAll(expression);
		while (iterator.hasNext()) {
			EObject object = iterator.next();
			if (object instanceof RichString) {
				RichStringHighlighter highlighter = createRichStringHighlighter(acceptor);
				processor.process((RichString) object, highlighter, indentationHandlerProvider.get());
				iterator.prune();
			}
		}
	}
}
 
Example #24
Source File: FlexerBasedTemplateBodyHighlighter.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public void doProvideHighlightingFor(final String body, final IHighlightedPositionAcceptor acceptor) {
  StringReader _stringReader = new StringReader(body);
  final FlexTokenSource tokenSource = this._flexerFactory.createTokenSource(_stringReader);
  Token token = tokenSource.nextToken();
  while ((!Objects.equal(token, Token.EOF_TOKEN))) {
    {
      final String id = this._abstractAntlrTokenToAttributeIdMapper.getId(token.getType());
      final int offset = TokenTool.getOffset(token);
      final int length = TokenTool.getLength(token);
      acceptor.addPosition(offset, length, id);
      token = tokenSource.nextToken();
    }
  }
}
 
Example #25
Source File: XtendHighlightingCalculator.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
protected void highlightAnnotations(IHighlightedPositionAcceptor acceptor, XtendAnnotationTarget target) {
	if(target != null){
		for(XAnnotation annotation: target.getAnnotations()) {
			highlightRichStrings(annotation, acceptor);
			highlightDeprecatedXtendAnnotationTarget(acceptor, target, annotation);
		}
	}
}
 
Example #26
Source File: SemanticHighlightingTest.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
@Test public void testNullPointerOnInvalidReturnKeyword() throws Exception {
	XtextResource resource = getResourceFromStringAndExpect(
			"grammar test with org.eclipse.xtext.common.Terminals\n" +
			"import 'http://www.eclipse.org/emf/2002/Ecore'\n" +
			"terminal fragment FOO returns EString: 'a';", 1);
	calculator.provideHighlightingFor(resource, new IHighlightedPositionAcceptor() {
		@Override
		public void addPosition(int offset, int length, String... id) {
			// ignore
		}
	}, CancelIndicator.NullImpl);
}
 
Example #27
Source File: StatemachineSemanticHighlightingCalculator.java    From xtext-web with Eclipse Public License 2.0 5 votes vote down vote up
protected void highlightSignal(EObject owner, Signal signal, EStructuralFeature feature,
		IHighlightedPositionAcceptor acceptor, CancelIndicator cancelIndicator) {
	operationCanceledManager.checkCanceled(cancelIndicator);
	for (INode n : NodeModelUtils.findNodesForFeature(owner, feature)) {
		acceptor.addPosition(n.getOffset(), n.getLength(), signal.eClass().getName());
	}
}
 
Example #28
Source File: StatemachineSemanticHighlightingCalculator.java    From xtext-web with Eclipse Public License 2.0 5 votes vote down vote up
@Override
protected boolean highlightElement(EObject o, IHighlightedPositionAcceptor acceptor,
		CancelIndicator cancelIndicator) {
	if (o instanceof Signal) {
		highlightSignal(o, (Signal) o, StatemachinePackage.Literals.SIGNAL__NAME, acceptor, cancelIndicator);
	} else if (o instanceof Command) {
		highlightSignal(o, ((Command) o).getSignal(), StatemachinePackage.Literals.COMMAND__SIGNAL, acceptor,
				cancelIndicator);
	} else if (o instanceof Event) {
		highlightSignal(o, ((Event) o).getSignal(), StatemachinePackage.Literals.EVENT__SIGNAL, acceptor,
				cancelIndicator);
	}
	return false;
}
 
Example #29
Source File: HighlightingService.java    From xtext-web with Eclipse Public License 2.0 5 votes vote down vote up
protected IHighlightedPositionAcceptor createHighlightedPositionAcceptor(
		List<HighlightingResult.Region> positions) {
	return (int offset, int length, String... ids) -> {
		HighlightingResult.Region region = new HighlightingResult.Region(offset, length, ids);
		positions.add(region);
	};
}
 
Example #30
Source File: HighlightingService.java    From xtext-web with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Compute the highlighting result for the given document. This method should
 * not be called directly from the service dispatcher; use
 * {@link #getResult(XtextWebDocumentAccess)} instead in order to avoid
 * duplicate computations.
 */
@Override
public HighlightingResult compute(IXtextWebDocument doc, CancelIndicator cancelIndicator) {
	HighlightingResult result = new HighlightingResult();
	IHighlightedPositionAcceptor acceptor = createHighlightedPositionAcceptor(result.getRegions());
	highlightingCalculator.provideHighlightingFor(doc.getResource(), acceptor, cancelIndicator);
	return result;
}