Search in sources :

Example 1 with AbstractGrammarElementFinder

use of org.eclipse.xtext.service.AbstractElementFinder.AbstractGrammarElementFinder 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());
}
Also used : AbstractGrammarElementFinder(org.eclipse.xtext.service.AbstractElementFinder.AbstractGrammarElementFinder) AbstractRule(org.eclipse.xtext.AbstractRule) Test(org.junit.Test)

Example 2 with AbstractGrammarElementFinder

use of org.eclipse.xtext.service.AbstractElementFinder.AbstractGrammarElementFinder 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());
}
Also used : EClass(org.eclipse.emf.ecore.EClass) AbstractGrammarElementFinder(org.eclipse.xtext.service.AbstractElementFinder.AbstractGrammarElementFinder) AbstractRule(org.eclipse.xtext.AbstractRule) Test(org.junit.Test)

Example 3 with AbstractGrammarElementFinder

use of org.eclipse.xtext.service.AbstractElementFinder.AbstractGrammarElementFinder in project xtext-core by eclipse.

the class ElementFinderTest method grammarFinder.

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);
        }
    };
}
Also used : XtextResourceSet(org.eclipse.xtext.resource.XtextResourceSet) Resource(org.eclipse.emf.ecore.resource.Resource) AbstractGrammarElementFinder(org.eclipse.xtext.service.AbstractElementFinder.AbstractGrammarElementFinder) Grammar(org.eclipse.xtext.Grammar)

Aggregations

AbstractGrammarElementFinder (org.eclipse.xtext.service.AbstractElementFinder.AbstractGrammarElementFinder)3 AbstractRule (org.eclipse.xtext.AbstractRule)2 Test (org.junit.Test)2 EClass (org.eclipse.emf.ecore.EClass)1 Resource (org.eclipse.emf.ecore.resource.Resource)1 Grammar (org.eclipse.xtext.Grammar)1 XtextResourceSet (org.eclipse.xtext.resource.XtextResourceSet)1