Search in sources :

Example 61 with AbstractRule

use of org.eclipse.xtext.AbstractRule in project xtext-core by eclipse.

the class TreeConstTest method testRuleCall4.

@Test
public void testRuleCall4() throws Exception {
    AbstractRule rule = parseRule("Model: Foo | Bar; Foo: name=ID; Bar: val=INT;");
    assertTypes(nfa.getNFA(rule.getAlternatives()).getTypes(), "Foo", "Bar");
}
Also used : AbstractRule(org.eclipse.xtext.AbstractRule) Test(org.junit.Test)

Example 62 with AbstractRule

use of org.eclipse.xtext.AbstractRule in project xtext-core by eclipse.

the class TreeConstTest method testMultiAction3.

@Test
public void testMultiAction3() throws Exception {
    AbstractRule rule = parseRule("Model: 'a' {Type1} | 'b' {Type2} | 'c' name=ID;");
    assertTypes(nfa.getNFA(rule.getAlternatives()).getTypes(), "Type1", "Type2", "Model");
}
Also used : AbstractRule(org.eclipse.xtext.AbstractRule) Test(org.junit.Test)

Example 63 with AbstractRule

use of org.eclipse.xtext.AbstractRule in project xtext-core by eclipse.

the class TreeConstTest method testRuleCall5.

@Test
public void testRuleCall5() throws Exception {
    AbstractRule rule = parseRule("Model: (Foo | Bar) v2=ID v1=ID; Foo: name=ID; Bar: val=INT;");
    assertTypes(nfa.getNFA(rule.getAlternatives()).getTypes(), "Foo", "Bar");
}
Also used : AbstractRule(org.eclipse.xtext.AbstractRule) Test(org.junit.Test)

Example 64 with AbstractRule

use of org.eclipse.xtext.AbstractRule in project xtext-core by eclipse.

the class XtextValidationTest method testBug_282852_06.

@Test
public void testBug_282852_06() throws Exception {
    Grammar base = XtextFactory.eINSTANCE.createGrammar();
    AbstractRule ruleFoo = XtextFactory.eINSTANCE.createParserRule();
    ruleFoo.setName("Foo");
    base.getRules().add(ruleFoo);
    AbstractRule subRuleFoo = XtextFactory.eINSTANCE.createParserRule();
    subRuleFoo.setName("Foo");
    base.getRules().add(subRuleFoo);
    XtextValidator validator = get(XtextValidator.class);
    configureValidator(validator, this, subRuleFoo);
    validator.checkRuleName(subRuleFoo);
    assertEquals("A rule's name has to be unique.", lastMessage);
}
Also used : Grammar(org.eclipse.xtext.Grammar) AbstractRule(org.eclipse.xtext.AbstractRule) Test(org.junit.Test)

Example 65 with AbstractRule

use of org.eclipse.xtext.AbstractRule in project xtext-core by eclipse.

the class XtextValidationTest method testBug_282852_05.

@Test
public void testBug_282852_05() throws Exception {
    Grammar base = XtextFactory.eINSTANCE.createGrammar();
    AbstractRule ruleFoo = XtextFactory.eINSTANCE.createParserRule();
    ruleFoo.setName("Foo");
    base.getRules().add(ruleFoo);
    AbstractRule subRuleFoo = XtextFactory.eINSTANCE.createParserRule();
    subRuleFoo.setName("foo");
    base.getRules().add(subRuleFoo);
    XtextValidator validator = get(XtextValidator.class);
    configureValidator(validator, this, subRuleFoo);
    validator.checkRuleName(subRuleFoo);
    assertEquals("A rule's name has to be unique even case insensitive. This grammar contains another rule 'Foo'.", lastMessage);
}
Also used : Grammar(org.eclipse.xtext.Grammar) AbstractRule(org.eclipse.xtext.AbstractRule) Test(org.junit.Test)

Aggregations

AbstractRule (org.eclipse.xtext.AbstractRule)222 Test (org.junit.Test)128 Grammar (org.eclipse.xtext.Grammar)106 StringConcatenation (org.eclipse.xtend2.lib.StringConcatenation)96 ParserRule (org.eclipse.xtext.ParserRule)94 EObject (org.eclipse.emf.ecore.EObject)59 AbstractXtextRuleInspectorTest (org.eclipse.xtext.xtext.AbstractXtextRuleInspectorTest)49 RuleCall (org.eclipse.xtext.RuleCall)36 AbstractElement (org.eclipse.xtext.AbstractElement)34 TerminalRule (org.eclipse.xtext.TerminalRule)20 XtextResource (org.eclipse.xtext.resource.XtextResource)17 EClassifier (org.eclipse.emf.ecore.EClassifier)14 EnumRule (org.eclipse.xtext.EnumRule)14 ArrayList (java.util.ArrayList)12 Assignment (org.eclipse.xtext.Assignment)12 Group (org.eclipse.xtext.Group)12 InternalEObject (org.eclipse.emf.ecore.InternalEObject)11 IEObjectDescription (org.eclipse.xtext.resource.IEObjectDescription)11 EClass (org.eclipse.emf.ecore.EClass)10 StringConcatenationClient (org.eclipse.xtend2.lib.StringConcatenationClient)10