use of org.eclipse.xtext.RuleCall in project xtext-core by eclipse.
the class XtextValidationTest method testRuleCallAllowed_07.
@Test
public void testRuleCallAllowed_07() throws Exception {
String grammarAsText = "grammar test with org.eclipse.xtext.common.Terminals\n" + "generate test 'http://test'\n" + "Model: name=ID;\n" + "terminal Terminal: Model;";
Grammar grammar = (Grammar) getModel(grammarAsText);
TerminalRule rule = (TerminalRule) grammar.getRules().get(1);
RuleCall ruleCall = (RuleCall) rule.getAlternatives();
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 testRuleCallAllowed_02.
@Test
public void testRuleCallAllowed_02() throws Exception {
String grammarAsText = "grammar test with org.eclipse.xtext.common.Terminals\n" + "generate test 'http://test'\n" + "Model: name=ID;\n" + "terminal fragment FirstFragment: SecondFragment;\n" + "terminal fragment SecondFragment: 'a'..'z'+;";
Grammar grammar = (Grammar) getModel(grammarAsText);
TerminalRule rule = (TerminalRule) grammar.getRules().get(1);
RuleCall ruleCall = (RuleCall) rule.getAlternatives();
XtextValidator validator = get(XtextValidator.class);
ValidatingMessageAcceptor messageAcceptor = new ValidatingMessageAcceptor(null, false, 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 testRuleCallAllowed_06.
@Test
public void testRuleCallAllowed_06() throws Exception {
String grammarAsText = "grammar test with org.eclipse.xtext.common.Terminals\n" + "generate test 'http://test'\n" + "Model: name=Terminal;\n" + "terminal Terminal: Enum;\n" + "enum Enum: A | B;";
Grammar grammar = (Grammar) getModel(grammarAsText);
TerminalRule rule = (TerminalRule) grammar.getRules().get(1);
RuleCall ruleCall = (RuleCall) rule.getAlternatives();
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 testRuleCallAllowed_03.
@Test
public void testRuleCallAllowed_03() throws Exception {
String grammarAsText = "grammar test with org.eclipse.xtext.common.Terminals\n" + "generate test 'http://test'\n" + "Model: name=ID;\n" + "terminal fragment Fragment: Terminal;\n" + "terminal Terminal: 'a'..'z'+;";
Grammar grammar = (Grammar) getModel(grammarAsText);
TerminalRule rule = (TerminalRule) grammar.getRules().get(1);
RuleCall ruleCall = (RuleCall) rule.getAlternatives();
XtextValidator validator = get(XtextValidator.class);
ValidatingMessageAcceptor messageAcceptor = new ValidatingMessageAcceptor(null, false, 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 XtextSerializerTest method testFQNInSuper_02.
@Ignore("Serialization does not have the correct context information")
@Test
public void testFQNInSuper_02() {
Grammar grammar = load(URI.createURI("classpath:/org/eclipse/xtext/grammarinheritance/InheritanceTestLanguage.xtext"));
AbstractRule rule = GrammarUtil.findRuleForName(grammar, "FQN");
Assert.assertNotNull(rule);
Group group = (Group) rule.getAlternatives();
RuleCall ruleCall = (RuleCall) group.getElements().get(0);
TerminalRule id = (TerminalRule) ruleCall.getRule();
Assert.assertSame(grammar, GrammarUtil.getGrammar(id));
String string = get(ISerializer.class).serialize(rule.getAlternatives());
Assert.assertEquals("ID (\".\" ID)*", string);
// currently wrong result is
Assert.assertEquals("super::ID (\".\" super::ID)*", string);
}
Aggregations