use of org.eclipse.xtext.RuleCall in project ow by vtst.
the class EasySemanticHighlightingCalculator method printDebugInformation.
private void printDebugInformation(INode node) {
EObject grammarElement = node.getGrammarElement();
System.out.println("TEXT: " + node.getText());
System.out.println("GRAMMAR: " + grammarElement.getClass().getName());
if (node.getSemanticElement().eContainer() != null)
System.out.println("SEMANTIC CONTAINER: " + node.getSemanticElement().eContainer().getClass().getName());
if (node.getSemanticElement().eContainmentFeature() != null)
System.out.println("SEMANTIC CONTAINMENT: " + node.getSemanticElement().eContainmentFeature().getName());
System.out.println("SEMANTIC RESOURCE: " + node.getSemanticElement().eResource().getClass().getName());
System.out.println("SEMANTIC: " + node.getSemanticElement().getClass().getName());
if (grammarElement != null)
System.out.println("GRAMMAR ELEMENT CLASS:" + grammarElement.getClass().getName());
if (grammarElement instanceof RuleCall) {
System.out.println("RULE: " + ((RuleCall) grammarElement).getRule().getName());
System.out.println("CLASS: " + ((RuleCall) grammarElement).getRule().eClass().getName());
} else if (grammarElement instanceof Action) {
System.out.println("CARDINALITY: " + ((Action) grammarElement).getCardinality());
System.out.println("FEATURE: " + ((Action) grammarElement).getFeature());
System.out.println("OPERATOR: " + ((Action) grammarElement).getOperator());
}
System.out.println("");
}
use of org.eclipse.xtext.RuleCall in project xtext-xtend by eclipse.
the class XtendLocationInFileProvider method getSignificantTextRegion.
@Override
public ITextRegion getSignificantTextRegion(EObject element) {
if (element instanceof RichStringLiteral) {
ICompositeNode elementNode = findNodeFor(element);
if (elementNode == null) {
return ITextRegion.EMPTY_REGION;
}
ITextRegion result = ITextRegion.EMPTY_REGION;
for (INode node : elementNode.getLeafNodes()) {
if (isHidden(node)) {
continue;
}
EObject grammarElement = node.getGrammarElement();
if (!(grammarElement instanceof RuleCall)) {
continue;
}
RuleCall ruleCall = (RuleCall) grammarElement;
ITextRegionWithLineInformation region = node.getTextRegionWithLineInformation();
int offset = region.getOffset();
int length = region.getLength();
if (grammarAccess.getRICH_TEXTRule() == ruleCall.getRule()) {
offset += 3;
length -= 6;
} else if (grammarAccess.getRICH_TEXT_STARTRule() == ruleCall.getRule()) {
offset += 3;
length -= 4;
} else if (grammarAccess.getRICH_TEXT_ENDRule() == ruleCall.getRule()) {
offset += 1;
length -= 4;
} else if (grammarAccess.getRICH_TEXT_INBETWEENRule() == ruleCall.getRule()) {
offset += 1;
length -= 2;
} else if (grammarAccess.getCOMMENT_RICH_TEXT_ENDRule() == ruleCall.getRule()) {
offset += 2;
length -= 5;
} else if (grammarAccess.getCOMMENT_RICH_TEXT_INBETWEENRule() == ruleCall.getRule()) {
offset += 2;
length -= 3;
} else {
continue;
}
result = result.merge(toZeroBasedRegion(new TextRegionWithLineInformation(offset, length, region.getLineNumber(), region.getEndLineNumber())));
}
return result;
}
return super.getSignificantTextRegion(element);
}
use of org.eclipse.xtext.RuleCall in project xtext-core by eclipse.
the class RequiredRuleNameComputer method getRequiredRuleNames.
/**
* @since 2.14
*/
protected String[][] getRequiredRuleNames(Param param, AbstractElement elementToParse) {
if (elementToParse instanceof RuleCall) {
RuleCall call = (RuleCall) elementToParse;
if (call.getRule() instanceof ParserRule) {
String antlrRuleName = ruleNames.getAntlrRuleName(call.getRule());
if (!call.getArguments().isEmpty()) {
Set<Parameter> context = param.getAssignedParametes();
Set<Parameter> arguments = getAssignedArguments(call, context);
int config = getParameterConfig(arguments);
antlrRuleName = ruleNames.getAntlrRuleName(call.getRule(), config);
}
return new String[][] { { antlrRuleName } };
}
}
return EMPTY_ARRAY;
}
use of org.eclipse.xtext.RuleCall in project xtext-core by eclipse.
the class BaseContentAssistParser method getFollowElements.
protected Collection<FE> getFollowElements(InternalParser parser, AbstractElement entryPoint) {
String ruleName = getRuleName(entryPoint);
if (ruleName == null) {
if (entryPoint instanceof RuleCall) {
RuleCall call = (RuleCall) entryPoint;
AbstractRule rule = call.getRule();
if (rule instanceof ParserRule) {
ruleName = getRuleNames().getAntlrRuleName(rule);
}
}
}
if (ruleName == null) {
throw new IllegalStateException("entryPoint: " + entryPoint);
}
return getFollowElements(parser, ruleName);
}
use of org.eclipse.xtext.RuleCall in project xtext-core by eclipse.
the class AssignmentQuantityAllocator method allowTransient.
protected boolean allowTransient(EObject obj, EStructuralFeature feature, Collection<ISyntaxConstraint> constraint) {
if (feature.getEType() instanceof EEnum)
return true;
Object value = obj.eGet(feature);
List<RuleCall> ruleCalls = GrammarUtil.containedRuleCalls(constraint.iterator().next().getGrammarElement());
if (ruleCalls.isEmpty())
return false;
return valueSerializer.isValid(obj, ruleCalls.get(0), value, null);
}
Aggregations