use of org.eclipse.xtext.IGrammarAccess in project xtext-core by eclipse.
the class LazyLinkerTest method setUp.
@Override
public void setUp() throws Exception {
super.setUp();
with(new AbstractModule() {
@Override
protected void configure() {
bind(EPackage.Registry.class).toInstance(EPackage.Registry.INSTANCE);
bind(IGrammarAccess.class).toInstance(new IGrammarAccess() {
@Override
public List<Pair<Keyword, Keyword>> findKeywordPairs(String leftKw, String rightKw) {
return Collections.emptyList();
}
@Override
public List<Keyword> findKeywords(String... keywords) {
return Collections.emptyList();
}
@Override
public List<RuleCall> findRuleCalls(AbstractRule... rules) {
return Collections.emptyList();
}
@Override
public Grammar getGrammar() {
return XtextFactory.eINSTANCE.createGrammar();
}
});
}
});
linker = get(LazyLinker.class);
resourceSet = get(XtextResourceSet.class);
resourceSet.setClasspathURIContext(getClass());
lazyLinkingPackage = (EPackage) resourceSet.getResource(URI.createURI("classpath:/org/eclipse/xtext/linking/lazy/LazyLinking.ecore"), true).getContents().get(0);
}
use of org.eclipse.xtext.IGrammarAccess in project xtext-core by eclipse.
the class ChangeSerializer method createResourceUpdater.
protected RelatedResourceUpdater createResourceUpdater(RelatedResource relatedResource) {
URI uri = relatedResource.getUri();
IGrammarAccess grammar = getService(uri, IGrammarAccess.class);
RelatedResourceUpdater updater;
if (grammar != null) {
updater = getService(uri, RelatedXtextResourceUpdater.class);
} else {
updater = getService(uri, RelatedEmfResourceUpdater.class);
}
updater.init(this, resourceSet, relatedResource);
return updater;
}
use of org.eclipse.xtext.IGrammarAccess in project xtext-core by eclipse.
the class XtextFormatterTest method _testXtextXtext.
public void _testXtextXtext() {
Serializer serializer = get(Serializer.class);
IGrammarAccess grammar = get(IGrammarAccess.class);
SaveOptions opt = SaveOptions.newBuilder().format().getOptions();
System.out.println(serializer.serialize(grammar.getGrammar(), opt));
}
Aggregations