Search in sources :

Example 1 with AbstractRule

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

the class RuleCallImpl method setRule.

/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
public void setRule(AbstractRule newRule) {
    AbstractRule oldRule = rule;
    rule = newRule;
    if (eNotificationRequired())
        eNotify(new ENotificationImpl(this, Notification.SET, XtextTestPackage.RULE_CALL__RULE, oldRule, rule));
}
Also used : ENotificationImpl(org.eclipse.emf.ecore.impl.ENotificationImpl) AbstractRule(org.eclipse.xtext.xtextTest.AbstractRule)

Example 2 with AbstractRule

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

the class ParseErrorHandlingTest method testParseError2.

@Test
public void testParseError2() throws Exception {
    Grammar grammar = (Grammar) getModelAndExpect("grammar a import 'holla' foo returns y::Z : name=foo #;", 4);
    AbstractRule rule = grammar.getRules().get(0);
    Assignment assignment = (Assignment) rule.getAlternatives();
    RuleCall call = (RuleCall) assignment.getTerminal();
    assertSame(rule, call.getRule());
// assertWithXtend("'foo'", "rules.first().eAllContents().typeSelect(RuleCall).first().rule.name", grammar);
}
Also used : Assignment(org.eclipse.xtext.xtextTest.Assignment) Grammar(org.eclipse.xtext.xtextTest.Grammar) AbstractRule(org.eclipse.xtext.xtextTest.AbstractRule) RuleCall(org.eclipse.xtext.xtextTest.RuleCall) Test(org.junit.Test)

Example 3 with AbstractRule

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

the class ParseErrorHandlingTest method testParseError3.

@Test
public void testParseError3() throws Exception {
    Grammar grammar = (Grammar) getModelAndExpect("grammar a import 'holla' foo returns y::Z : name=foo #############", 4);
    AbstractRule rule = grammar.getRules().get(0);
    Assignment assignment = (Assignment) rule.getAlternatives();
    RuleCall call = (RuleCall) assignment.getTerminal();
    assertSame(rule, call.getRule());
// assertWithXtend("'foo'", "rules.first().eAllContents().typeSelect(RuleCall).first().rule.name", grammar);
}
Also used : Assignment(org.eclipse.xtext.xtextTest.Assignment) Grammar(org.eclipse.xtext.xtextTest.Grammar) AbstractRule(org.eclipse.xtext.xtextTest.AbstractRule) RuleCall(org.eclipse.xtext.xtextTest.RuleCall) Test(org.junit.Test)

Example 4 with AbstractRule

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

the class ParseErrorHandlingTest method testParseError4.

@Test
public void testParseError4() throws Exception {
    Grammar grammar = (Grammar) getModelAndExpect("grammar a import 'holla' foo returns y::Z : name=foo # 'foo'; bar : 'stuff'", 5);
    AbstractRule rule = grammar.getRules().get(0);
    Assignment assignment = (Assignment) rule.getAlternatives();
    RuleCall call = (RuleCall) assignment.getTerminal();
    assertSame(rule, call.getRule());
    // assertWithXtend("'foo'", "rules.first().eAllContents().typeSelect(RuleCall).first().rule.name", grammar);
    AbstractRule secondRule = grammar.getRules().get(1);
    Keyword stuff = (Keyword) secondRule.getAlternatives();
    assertEquals("stuff", stuff.getValue());
// assertWithXtend("'stuff'", "rules.get(1).eAllContents().typeSelect(Keyword).first().value", grammar);
}
Also used : Assignment(org.eclipse.xtext.xtextTest.Assignment) Keyword(org.eclipse.xtext.xtextTest.Keyword) Grammar(org.eclipse.xtext.xtextTest.Grammar) AbstractRule(org.eclipse.xtext.xtextTest.AbstractRule) RuleCall(org.eclipse.xtext.xtextTest.RuleCall) Test(org.junit.Test)

Aggregations

AbstractRule (org.eclipse.xtext.xtextTest.AbstractRule)4 Assignment (org.eclipse.xtext.xtextTest.Assignment)3 Grammar (org.eclipse.xtext.xtextTest.Grammar)3 RuleCall (org.eclipse.xtext.xtextTest.RuleCall)3 Test (org.junit.Test)3 ENotificationImpl (org.eclipse.emf.ecore.impl.ENotificationImpl)1 Keyword (org.eclipse.xtext.xtextTest.Keyword)1