use of org.eclipse.xtext.RuleCall in project xtext-core by eclipse.
the class XtextValidationTest method testRuleCallAllowed_05.
@Test
public void testRuleCallAllowed_05() throws Exception {
String grammarAsText = "grammar test with org.eclipse.xtext.common.Terminals\n" + "generate test 'http://test'\n" + "Model: name=Fragment;\n" + "terminal fragment Fragment: 'a'..'z'+;";
Grammar grammar = (Grammar) getModel(grammarAsText);
ParserRule rule = (ParserRule) grammar.getRules().get(0);
RuleCall ruleCall = (RuleCall) ((Assignment) rule.getAlternatives()).getTerminal();
XtextValidator validator = get(XtextValidator.class);
ValidatingMessageAcceptor messageAcceptor = new ValidatingMessageAcceptor(ruleCall, true, false);
validator.setMessageAcceptor(messageAcceptor);
validator.checkUnassignedRuleCallAllowed(ruleCall);
validator.checkTerminalFragmentCalledFromTerminalRule(ruleCall);
messageAcceptor.validate();
}
use of org.eclipse.xtext.RuleCall in project xtext-core by eclipse.
the class XtextValidationTest method testCheckRuleCallInUnorderedGroup_03.
@Test
public void testCheckRuleCallInUnorderedGroup_03() throws Exception {
XtextValidator validator = get(XtextValidator.class);
UnorderedGroup unorderedGroup = XtextFactory.eINSTANCE.createUnorderedGroup();
RuleCall ruleCall = XtextFactory.eINSTANCE.createRuleCall();
EnumRule enumRule = XtextFactory.eINSTANCE.createEnumRule();
ruleCall.setRule(enumRule);
unorderedGroup.getElements().add(ruleCall);
ValidatingMessageAcceptor messageAcceptor = new ValidatingMessageAcceptor(null, false, false);
validator.setMessageAcceptor(messageAcceptor);
validator.checkRuleCallInUnorderedGroup(ruleCall);
messageAcceptor.validate();
}
use of org.eclipse.xtext.RuleCall in project xtext-core by eclipse.
the class XtextValidationTest method testCheckRuleCallInUnorderedGroup_05.
@Test
public void testCheckRuleCallInUnorderedGroup_05() throws Exception {
XtextValidator validator = get(XtextValidator.class);
UnorderedGroup unorderedGroup = XtextFactory.eINSTANCE.createUnorderedGroup();
RuleCall ruleCall = XtextFactory.eINSTANCE.createRuleCall();
TypeRef typeRef = XtextFactory.eINSTANCE.createTypeRef();
typeRef.setClassifier(EcorePackage.Literals.EOBJECT);
ParserRule parserRule = XtextFactory.eINSTANCE.createParserRule();
parserRule.setType(typeRef);
ruleCall.setRule(parserRule);
Assignment assignment = XtextFactory.eINSTANCE.createAssignment();
assignment.setTerminal(ruleCall);
unorderedGroup.getElements().add(assignment);
ValidatingMessageAcceptor messageAcceptor = new ValidatingMessageAcceptor(null, false, false);
validator.setMessageAcceptor(messageAcceptor);
validator.checkRuleCallInUnorderedGroup(ruleCall);
messageAcceptor.validate();
}
use of org.eclipse.xtext.RuleCall in project xtext-core by eclipse.
the class XtextValidationTest method testCheckCrossReferenceTerminal_02.
@Test
public void testCheckCrossReferenceTerminal_02() throws Exception {
XtextValidator validator = get(XtextValidator.class);
CrossReference reference = XtextFactory.eINSTANCE.createCrossReference();
RuleCall call = XtextFactory.eINSTANCE.createRuleCall();
reference.setTerminal(call);
ParserRule rule = XtextFactory.eINSTANCE.createParserRule();
call.setRule(rule);
TypeRef typeRef = XtextFactory.eINSTANCE.createTypeRef();
rule.setType(typeRef);
typeRef.setClassifier(EcorePackage.Literals.EINT);
ValidatingMessageAcceptor messageAcceptor = new ValidatingMessageAcceptor(call, true, false);
validator.setMessageAcceptor(messageAcceptor);
validator.checkCrossReferenceTerminal(reference);
messageAcceptor.validate();
}
use of org.eclipse.xtext.RuleCall in project xtext-core by eclipse.
the class XtextValidationTest method testCheckRuleCallInUnorderedGroup_01.
@Test
public void testCheckRuleCallInUnorderedGroup_01() throws Exception {
XtextValidator validator = get(XtextValidator.class);
UnorderedGroup unorderedGroup = XtextFactory.eINSTANCE.createUnorderedGroup();
RuleCall ruleCall = XtextFactory.eINSTANCE.createRuleCall();
TypeRef typeRef = XtextFactory.eINSTANCE.createTypeRef();
typeRef.setClassifier(EcorePackage.Literals.EOBJECT);
ParserRule parserRule = XtextFactory.eINSTANCE.createParserRule();
parserRule.setType(typeRef);
ruleCall.setRule(parserRule);
unorderedGroup.getElements().add(ruleCall);
ValidatingMessageAcceptor messageAcceptor = new ValidatingMessageAcceptor(ruleCall, true, false);
validator.setMessageAcceptor(messageAcceptor);
validator.checkRuleCallInUnorderedGroup(ruleCall);
messageAcceptor.validate();
}
Aggregations