org.eclipse.xtext.service.AbstractElementFinder.AbstractGrammarElementFinder Java Examples

The following examples show how to use org.eclipse.xtext.service.AbstractElementFinder.AbstractGrammarElementFinder. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ElementFinderTest.java    From xtext-core with Eclipse Public License 2.0 5 votes vote down vote up
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);
		}
	};
}
 
Example #2
Source File: ElementFinderTest.java    From xtext-core with Eclipse Public License 2.0 5 votes vote down vote up
@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());
}
 
Example #3
Source File: ElementFinderTest.java    From xtext-core with Eclipse Public License 2.0 4 votes vote down vote up
@Test public void testFindRuleCalls() {
	AbstractGrammarElementFinder f = grammarFinder();
	AbstractRule r = GrammarUtil.findRuleForName(f.getGrammar(), "FinderKeywords");
	assertEquals(2, f.findRuleCalls(r).size());
}