use of org.eclipse.xtext.TerminalRule in project xtext-core by eclipse.
the class XtextValidationTest method testRuleCallAllowed_01.
@Test
public void testRuleCallAllowed_01() throws Exception {
String grammarAsText = "grammar test with org.eclipse.xtext.common.Terminals\n" + "generate test 'http://test'\n" + "Model: name=ID;\n" + "terminal MyTerminal: Fragment;\n" + "terminal fragment Fragment: '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.TerminalRule 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.TerminalRule 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.TerminalRule 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.TerminalRule 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();
}
Aggregations