Search in sources :

Example 6 with UnorderedGroup

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

the class GrammarParserTest method testPrecedencies_05.

@Test
public void testPrecedencies_05() throws Exception {
    UnorderedGroup group = (UnorderedGroup) getModel("name=ID & 'keyword'");
    assertNotNull(group);
    assertEquals(2, group.getElements().size());
    assertTrue(group.getElements().get(0) instanceof Assignment);
    assertTrue(group.getElements().get(1) instanceof Keyword);
}
Also used : Assignment(org.eclipse.xtext.Assignment) Keyword(org.eclipse.xtext.Keyword) UnorderedGroup(org.eclipse.xtext.UnorderedGroup) Test(org.junit.Test)

Example 7 with UnorderedGroup

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

the class GrammarParserTest method testUnorderedGroup_02.

@Test
public void testUnorderedGroup_02() throws Exception {
    UnorderedGroup group = (UnorderedGroup) getModel("'keyword' & 'keyword' & 'keyword'");
    assertNotNull(group);
    assertEquals(3, group.getElements().size());
}
Also used : UnorderedGroup(org.eclipse.xtext.UnorderedGroup) Test(org.junit.Test)

Example 8 with UnorderedGroup

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

the class GrammarParserTest method testPrecedencies_04.

@Test
public void testPrecedencies_04() throws Exception {
    Group group = (Group) getModel("'keyword' ('keyword' & 'keyword') 'keyword'");
    assertNotNull(group);
    assertEquals(3, group.getElements().size());
    assertTrue(group.getElements().get(0) instanceof Keyword);
    assertTrue(group.getElements().get(1) instanceof UnorderedGroup);
    assertTrue(group.getElements().get(2) instanceof Keyword);
}
Also used : Group(org.eclipse.xtext.Group) UnorderedGroup(org.eclipse.xtext.UnorderedGroup) Keyword(org.eclipse.xtext.Keyword) UnorderedGroup(org.eclipse.xtext.UnorderedGroup) Test(org.junit.Test)

Example 9 with UnorderedGroup

use of org.eclipse.xtext.UnorderedGroup 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();
}
Also used : EnumRule(org.eclipse.xtext.EnumRule) UnorderedGroup(org.eclipse.xtext.UnorderedGroup) RuleCall(org.eclipse.xtext.RuleCall) Test(org.junit.Test)

Example 10 with UnorderedGroup

use of org.eclipse.xtext.UnorderedGroup 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();
}
Also used : Assignment(org.eclipse.xtext.Assignment) ParserRule(org.eclipse.xtext.ParserRule) UnorderedGroup(org.eclipse.xtext.UnorderedGroup) TypeRef(org.eclipse.xtext.TypeRef) RuleCall(org.eclipse.xtext.RuleCall) Test(org.junit.Test)

Aggregations

UnorderedGroup (org.eclipse.xtext.UnorderedGroup)35 AbstractElement (org.eclipse.xtext.AbstractElement)16 StringConcatenation (org.eclipse.xtend2.lib.StringConcatenation)13 ParserRule (org.eclipse.xtext.ParserRule)13 Test (org.junit.Test)12 RuleCall (org.eclipse.xtext.RuleCall)11 Group (org.eclipse.xtext.Group)9 Function1 (org.eclipse.xtext.xbase.lib.Functions.Function1)9 Assignment (org.eclipse.xtext.Assignment)8 EObject (org.eclipse.emf.ecore.EObject)7 Action (org.eclipse.xtext.Action)5 Alternatives (org.eclipse.xtext.Alternatives)5 Pair (org.eclipse.xtext.xbase.lib.Pair)5 List (java.util.List)4 TerminalRule (org.eclipse.xtext.TerminalRule)4 ArrayList (java.util.ArrayList)3 AbstractRule (org.eclipse.xtext.AbstractRule)3 Keyword (org.eclipse.xtext.Keyword)3 TypeRef (org.eclipse.xtext.TypeRef)3 Token (org.antlr.runtime.Token)2