use of org.eclipse.xtext.AbstractRule in project xtext-core by eclipse.
the class ElementFinderTest method testFindRuleCalls.
@Test
public void testFindRuleCalls() {
AbstractGrammarElementFinder f = grammarFinder();
AbstractRule r = GrammarUtil.findRuleForName(f.getGrammar(), "FinderKeywords");
assertEquals(2, f.findRuleCalls(r).size());
}
use of org.eclipse.xtext.AbstractRule in project xtext-core by eclipse.
the class ElementFinderTest method testFindCrossReferences.
@Test
public void testFindCrossReferences() {
AbstractGrammarElementFinder f = grammarFinder();
AbstractRule r = GrammarUtil.findRuleForName(f.getGrammar(), "FQN");
assertNotNull(r);
assertEquals(1, f.findCrossReferences(r).size());
EClass type = (EClass) GrammarUtil.findRuleForName(f.getGrammar(), "Type").getType().getClassifier();
assertNotNull(type);
assertEquals(1, f.findCrossReferences(type).size());
}
use of org.eclipse.xtext.AbstractRule in project xtext-core by eclipse.
the class AnotherInheritanceTest method testSimple.
@Test
public void testSimple() throws Exception {
InheritanceTest2LanguageGrammarAccess g = (InheritanceTest2LanguageGrammarAccess) getGrammarAccess();
assertNotNull(g.getFQNAccess());
AbstractRule fromFQN = g.getFQNAccess().getIDTerminalRuleCall_0().getRule();
assertEquals(fromFQN, g.getIDRule());
assertNotNull(g.getModelAccess());
}
use of org.eclipse.xtext.AbstractRule in project xtext-core by eclipse.
the class InheritanceTest method testMetamodel.
@Test
public void testMetamodel() throws Exception {
AbstractRule rule = GrammarUtil.findRuleForName(getGrammarAccess().getGrammar(), "OverridableParserRule2");
assertNotNull("rule", rule);
TypeRef ref = rule.getType();
assertNotNull("ref", ref);
final EClass clazz = (EClass) ref.getClassifier();
assertNotNull("class", clazz);
assertEquals("AType2", clazz.getName());
assertEquals(2, clazz.getESuperTypes().size());
Set<String> expectedNames = new HashSet<String>(Arrays.asList(new String[] { "AType", "RootRule" }));
Iterator<String> iter = Iterables.transform(clazz.getESuperTypes(), new Function<EClass, String>() {
@Override
public String apply(EClass param) {
return param.getName();
}
}).iterator();
while (iter.hasNext()) {
String name = iter.next();
assertTrue("name = '" + name + "'", expectedNames.remove(name));
}
assertTrue(expectedNames.toString(), expectedNames.isEmpty());
}
use of org.eclipse.xtext.AbstractRule in project xtext-core by eclipse.
the class OverriddenValueInspectorTest method testUnorderedGroup_06.
@Test
public void testUnorderedGroup_06() 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 : a = ID b = STRING & a = 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());
}
Aggregations