use of org.eclipse.xtext.ParserRule in project xtext-core by eclipse.
the class OverriddenValueInspectorTest method testBug306281_09.
@Test
public void testBug306281_09() throws Exception {
StringConcatenation _builder = new StringConcatenation();
_builder.append("grammar org.foo with org.eclipse.xtext.common.Terminals");
_builder.newLine();
_builder.append("generate metamodel \'foo.sample\'");
_builder.newLine();
_builder.append("Model : name=ID (({Binary.left=current} operator = [Model] | {Binary.left=current} operator = [Model])?\tname=ID);");
String grammarAsString = _builder.toString();
final Grammar grammar = this.getGrammar(grammarAsString);
AbstractRule _findRuleForName = GrammarUtil.findRuleForName(grammar, "Model");
final ParserRule rule = ((ParserRule) _findRuleForName);
this.validateRule(rule);
Assert.assertEquals(this.warnings.toString(), 2, this.warnings.size());
}
use of org.eclipse.xtext.ParserRule in project xtext-core by eclipse.
the class OverriddenValueInspectorTest method testNoMarkerForCalledRules_01.
@Test
public void testNoMarkerForCalledRules_01() throws Exception {
StringConcatenation _builder = new StringConcatenation();
_builder.append("grammar org.foo with org.eclipse.xtext.common.Terminals");
_builder.newLine();
_builder.append("generate metamodel \'foo.sample\'");
_builder.newLine();
_builder.append("First returns Object: Second;");
_builder.newLine();
_builder.append("Second returns Object: name=ID name=ID;");
_builder.newLine();
String grammarAsString = _builder.toString();
final Grammar grammar = this.getGrammar(grammarAsString);
AbstractRule _findRuleForName = GrammarUtil.findRuleForName(grammar, "First");
ParserRule rule = ((ParserRule) _findRuleForName);
this.validateRule(rule);
Assert.assertEquals(this.warnings.toString(), 0, this.warnings.size());
AbstractRule _findRuleForName_1 = GrammarUtil.findRuleForName(grammar, "Second");
rule = ((ParserRule) _findRuleForName_1);
this.validateRule(rule);
Assert.assertEquals(this.warnings.toString(), 2, this.warnings.size());
}
use of org.eclipse.xtext.ParserRule in project xtext-core by eclipse.
the class OverriddenValueInspectorTest method testBug306281_07.
@Test
public void testBug306281_07() throws Exception {
StringConcatenation _builder = new StringConcatenation();
_builder.append("grammar org.foo with org.eclipse.xtext.common.Terminals");
_builder.newLine();
_builder.append("generate metamodel \'foo.sample\'");
_builder.newLine();
_builder.append("Model : name=ID (({Binary.left=current} operator = [Model] | {Binary.left=current} operator = [Model]) right=ID)* name=ID;");
_builder.newLine();
String grammarAsString = _builder.toString();
final Grammar grammar = this.getGrammar(grammarAsString);
AbstractRule _findRuleForName = GrammarUtil.findRuleForName(grammar, "Model");
final ParserRule rule = ((ParserRule) _findRuleForName);
this.validateRule(rule);
Assert.assertEquals(this.warnings.toString(), 2, this.warnings.size());
}
use of org.eclipse.xtext.ParserRule in project xtext-core by eclipse.
the class XtextLinkerTest method testGuardLinking.
@Test
public void testGuardLinking() throws Exception {
StringConcatenation _builder = new StringConcatenation();
_builder.append("grammar test.Lang with org.eclipse.xtext.common.Terminals");
_builder.newLine();
_builder.append("generate test \'http://test\'");
_builder.newLine();
_builder.append("Root<MyArg>: <MyArg> name=ID | <!MyArg> name=STRING;");
_builder.newLine();
final String grammarAsString = _builder.toString();
EObject _model = this.getModel(grammarAsString);
final Grammar grammar = ((Grammar) _model);
AbstractRule _head = IterableExtensions.<AbstractRule>head(grammar.getRules());
final ParserRule rootRule = ((ParserRule) _head);
AbstractElement _alternatives = rootRule.getAlternatives();
final Alternatives alternatives = ((Alternatives) _alternatives);
AbstractElement _head_1 = IterableExtensions.<AbstractElement>head(alternatives.getElements());
Condition _guardCondition = ((Group) _head_1).getGuardCondition();
final ParameterReference firstGuard = ((ParameterReference) _guardCondition);
Assert.assertEquals(IterableExtensions.<Parameter>head(rootRule.getParameters()), firstGuard.getParameter());
AbstractElement _last = IterableExtensions.<AbstractElement>last(alternatives.getElements());
Condition _guardCondition_1 = ((Group) _last).getGuardCondition();
final Negation secondGuard = ((Negation) _guardCondition_1);
Condition _value = secondGuard.getValue();
Assert.assertEquals(IterableExtensions.<Parameter>head(rootRule.getParameters()), ((ParameterReference) _value).getParameter());
}
use of org.eclipse.xtext.ParserRule in project xtext-core by eclipse.
the class XtextLinkerTest method testNamedParameterLinking.
@Test
public void testNamedParameterLinking() throws Exception {
StringConcatenation _builder = new StringConcatenation();
_builder.append("grammar test.Lang with org.eclipse.xtext.common.Terminals");
_builder.newLine();
_builder.append("generate test \'http://test\'");
_builder.newLine();
_builder.append("Root<MyArg>: rule=Rule<MyArg>;");
_builder.newLine();
_builder.append("Rule<MyParam>: name=ID child=Root<MyArg=MyParam>?;");
_builder.newLine();
final String grammarAsString = _builder.toString();
EObject _model = this.getModel(grammarAsString);
final Grammar grammar = ((Grammar) _model);
AbstractRule _head = IterableExtensions.<AbstractRule>head(grammar.getRules());
final ParserRule rootRule = ((ParserRule) _head);
AbstractRule _last = IterableExtensions.<AbstractRule>last(grammar.getRules());
final ParserRule lastRule = ((ParserRule) _last);
AbstractElement _alternatives = lastRule.getAlternatives();
AbstractElement _last_1 = IterableExtensions.<AbstractElement>last(((Group) _alternatives).getElements());
final Assignment lastAssignment = ((Assignment) _last_1);
AbstractElement _terminal = lastAssignment.getTerminal();
final RuleCall ruleCall = ((RuleCall) _terminal);
final NamedArgument argument = IterableExtensions.<NamedArgument>head(ruleCall.getArguments());
Assert.assertEquals(IterableExtensions.<Parameter>head(rootRule.getParameters()), argument.getParameter());
Condition _value = argument.getValue();
Assert.assertEquals(IterableExtensions.<Parameter>head(lastRule.getParameters()), ((ParameterReference) _value).getParameter());
}
Aggregations