Java 类org.eclipse.xtext.service.AbstractElementFinder.AbstractGrammarElementFinder 实例源码

项目:xtext-core    文件:ElementFinderTest.java   
private AbstractGrammarElementFinder grammarFinder() {
    final String file = "classpath:/org/eclipse/xtext/generator/grammarAccess/ElementFinderTestLanguage.xtext";
    XtextResourceSet rs = get(XtextResourceSet.class);
    rs.setClasspathURIContext(getClass());
    final Resource r = rs.getResource(URI.createURI(file), true);
    return new AbstractGrammarElementFinder() {
        @Override
        public Grammar getGrammar() {
            return (Grammar) r.getContents().get(0);
        }
    };
}
项目:xtext-core    文件:ElementFinderTest.java   
@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());
}
项目:xtext-core    文件:ElementFinderTest.java   
@Test public void testFindRuleCalls() {
    AbstractGrammarElementFinder f = grammarFinder();
    AbstractRule r = GrammarUtil.findRuleForName(f.getGrammar(), "FinderKeywords");
    assertEquals(2, f.findRuleCalls(r).size());
}