Search in sources :

Example 1 with IGrammarAccess

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);
}
Also used : IGrammarAccess(org.eclipse.xtext.IGrammarAccess) Keyword(org.eclipse.xtext.Keyword) XtextResourceSet(org.eclipse.xtext.resource.XtextResourceSet) AbstractRule(org.eclipse.xtext.AbstractRule) RuleCall(org.eclipse.xtext.RuleCall) AbstractModule(com.google.inject.AbstractModule) EPackage(org.eclipse.emf.ecore.EPackage) Pair(org.eclipse.xtext.util.Pair)

Example 2 with IGrammarAccess

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;
}
Also used : IGrammarAccess(org.eclipse.xtext.IGrammarAccess) URI(org.eclipse.emf.common.util.URI)

Example 3 with IGrammarAccess

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));
}
Also used : IGrammarAccess(org.eclipse.xtext.IGrammarAccess) SaveOptions(org.eclipse.xtext.resource.SaveOptions) Serializer(org.eclipse.xtext.parsetree.reconstr.Serializer)

Aggregations

IGrammarAccess (org.eclipse.xtext.IGrammarAccess)3 AbstractModule (com.google.inject.AbstractModule)1 URI (org.eclipse.emf.common.util.URI)1 EPackage (org.eclipse.emf.ecore.EPackage)1 AbstractRule (org.eclipse.xtext.AbstractRule)1 Keyword (org.eclipse.xtext.Keyword)1 RuleCall (org.eclipse.xtext.RuleCall)1 Serializer (org.eclipse.xtext.parsetree.reconstr.Serializer)1 SaveOptions (org.eclipse.xtext.resource.SaveOptions)1 XtextResourceSet (org.eclipse.xtext.resource.XtextResourceSet)1 Pair (org.eclipse.xtext.util.Pair)1