use of org.yakindu.sct.model.sgen.impl.FeatureConfigurationImpl in project statecharts by Yakindu.
the class SGenSemanticHighlightingCalculator method provideHighlightingFor.
public void provideHighlightingFor(XtextResource resource, IHighlightedPositionAcceptor acceptor) {
if (resource == null || resource.getParseResult() == null)
return;
TreeIterator<EObject> allContents = resource.getAllContents();
while (allContents.hasNext()) {
final EObject object = allContents.next();
if (object instanceof GeneratorEntry) {
GeneratorEntry entry = (GeneratorEntry) object;
List<INode> nodes = NodeModelUtils.findNodesForFeature(entry, SGenPackage.Literals.GENERATOR_ENTRY__CONTENT_TYPE);
List<INode> features = NodeModelUtils.findNodesForFeature(entry, SGenPackage.Literals.GENERATOR_ENTRY__FEATURES);
for (INode node : nodes) {
if (node instanceof LeafNode && !((LeafNode) node).isHidden()) {
acceptor.addPosition(node.getTotalOffset(), node.getTotalLength(), DefaultHighlightingConfiguration.KEYWORD_ID);
}
}
for (INode node : features) {
if (node.getSemanticElement() instanceof FeatureConfigurationImpl) {
FeatureConfigurationImpl feature = (FeatureConfigurationImpl) node.getSemanticElement();
DeprecatableElement deprecatableElement = feature.getType();
if (deprecatableElement != null && deprecatableElement.isDeprecated()) {
acceptor.addPosition(node.getTotalOffset(), node.getTotalLength(), SGenHighlightingConfiguration.DEPRECATION);
}
}
}
// allContents.prune();
} else if (object instanceof ElementReferenceExpression && !((ElementReferenceExpression) object).getReference().eIsProxy()) {
List<INode> nodes = NodeModelUtils.findNodesForFeature(object, ExpressionsPackage.Literals.ELEMENT_REFERENCE_EXPRESSION__REFERENCE);
for (INode node : nodes) {
String name = ((Property) ((ElementReferenceExpression) object).getReference()).getName();
switch(name) {
case SCT_VERSION_VAR:
case SHA256:
case SCTFILE:
case TIMESTAMP_VAR:
case USER_VAR:
case HOSTNAME_VAR:
acceptor.addPosition(node.getTotalOffset(), node.getTotalLength(), DefaultHighlightingConfiguration.KEYWORD_ID);
}
}
}
}
}
Aggregations