use of org.eclipse.xtext.ParserRule in project xtext-core by eclipse.
the class NoJdtTestLanguageSemanticSequencer method sequence.
@Override
public void sequence(ISerializationContext context, EObject semanticObject) {
EPackage epackage = semanticObject.eClass().getEPackage();
ParserRule rule = context.getParserRule();
Action action = context.getAssignedAction();
Set<Parameter> parameters = context.getEnabledBooleanParameters();
if (epackage == NoJdtPackage.eINSTANCE)
switch(semanticObject.eClass().getClassifierID()) {
case NoJdtPackage.GREETING:
sequence_Greeting(context, (Greeting) semanticObject);
return;
case NoJdtPackage.MODEL:
sequence_Model(context, (Model) semanticObject);
return;
}
if (errorAcceptor != null)
errorAcceptor.accept(diagnosticProvider.createInvalidContextOrTypeDiagnostic(semanticObject, context));
}
use of org.eclipse.xtext.ParserRule in project xtext-core by eclipse.
the class FollowElementComputer method computeFollowElements.
public void computeFollowElements(Collection<FollowElement> followElements, final IFollowElementAcceptor followElementAcceptor) {
FollowElementCalculator calculator = feCalculatorProvider.get();
calculator.acceptor = element -> {
ParserRule rule = GrammarUtil.containingParserRule(element);
if (rule == null || !GrammarUtil.isDatatypeRule(rule))
followElementAcceptor.accept(element);
};
for (FollowElement element : followElements) {
computeFollowElements(calculator, element);
}
}
use of org.eclipse.xtext.ParserRule in project xtext-core by eclipse.
the class RequiredRuleNameComputer method adjustRuleName.
protected String adjustRuleName(String ruleName, Param param) {
AbstractElement elementToParse = param.elementToParse;
Set<Parameter> context = getAssignedParameters(elementToParse, param.paramStack);
if (!context.isEmpty()) {
ParserRule containingRule = GrammarUtil.containingParserRule(elementToParse);
String antlrRuleName = ruleNames.getAntlrRuleName(containingRule);
int len = antlrRuleName.length();
if (antlrRuleName.startsWith("rule")) {
// rule__XYZ instead of ruleXYZ
len += 2;
}
int config = getParameterConfig(context);
String result = ruleNames.getAntlrRuleName(containingRule, config) + ruleName.substring(len);
return result;
}
return ruleName;
}
use of org.eclipse.xtext.ParserRule 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.ParserRule in project xtext-core by eclipse.
the class PartialContentAssistTestLanguageSemanticSequencer method sequence.
@Override
public void sequence(ISerializationContext context, EObject semanticObject) {
EPackage epackage = semanticObject.eClass().getEPackage();
ParserRule rule = context.getParserRule();
Action action = context.getAssignedAction();
Set<Parameter> parameters = context.getEnabledBooleanParameters();
if (epackage == PartialContentAssistTestLanguagePackage.eINSTANCE)
switch(semanticObject.eClass().getClassifierID()) {
case PartialContentAssistTestLanguagePackage.PROPERTY:
sequence_Property(context, (Property) semanticObject);
return;
case PartialContentAssistTestLanguagePackage.TYPE_DECLARATION:
sequence_TypeDeclaration(context, (TypeDeclaration) semanticObject);
return;
}
if (errorAcceptor != null)
errorAcceptor.accept(diagnosticProvider.createInvalidContextOrTypeDiagnostic(semanticObject, context));
}
Aggregations