public void register(Injector injector) {

    org.eclipse.xtext.resource.IResourceFactory resourceFactory =
        injector.getInstance(org.eclipse.xtext.resource.IResourceFactory.class);
    org.eclipse.xtext.resource.IResourceServiceProvider serviceProvider =
        injector.getInstance(org.eclipse.xtext.resource.IResourceServiceProvider.class);
    Resource.Factory.Registry.INSTANCE
        .getExtensionToFactoryMap()
        .put("eobjectatoffsettestlanguage", resourceFactory);
    org.eclipse.xtext.resource.IResourceServiceProvider.Registry.INSTANCE
        .getExtensionToFactoryMap()
        .put("eobjectatoffsettestlanguage", serviceProvider);

    if (!EPackage.Registry.INSTANCE.containsKey(
        "http://www.xtext.org/EObjectAtOffsetTestLanguage")) {
      EPackage.Registry.INSTANCE.put(
          "http://www.xtext.org/EObjectAtOffsetTestLanguage",
          org.eclipse
              .xtext
              .resource
              .eObjectAtOffsetTestLanguage
              .EObjectAtOffsetTestLanguagePackage
              .eINSTANCE);
    }
  }
  public void register(Injector injector) {
    if (!EPackage.Registry.INSTANCE.containsKey(
        "http://www.bme.hu/mit/inf/gomrp/statemachine/dsl/text/StateMachineDSL")) {
      EPackage.Registry.INSTANCE.put(
          "http://www.bme.hu/mit/inf/gomrp/statemachine/dsl/text/StateMachineDSL",
          hu.bme
              .mit
              .inf
              .gomrp
              .statemachine
              .dsl
              .text
              .stateMachineDSL
              .StateMachineDSLPackage
              .eINSTANCE);
    }

    org.eclipse.xtext.resource.IResourceFactory resourceFactory =
        injector.getInstance(org.eclipse.xtext.resource.IResourceFactory.class);
    org.eclipse.xtext.resource.IResourceServiceProvider serviceProvider =
        injector.getInstance(org.eclipse.xtext.resource.IResourceServiceProvider.class);
    Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put("smbm", resourceFactory);
    org.eclipse.xtext.resource.IResourceServiceProvider.Registry.INSTANCE
        .getExtensionToFactoryMap()
        .put("smbm", serviceProvider);
  }
  public void register(Injector injector) {
    if (!EPackage.Registry.INSTANCE.containsKey(
        "http://www.eclipse.org/2011/xtext/idea/ui/common/types/xtext/ui/Refactoring")) {
      EPackage.Registry.INSTANCE.put(
          "http://www.eclipse.org/2011/xtext/idea/ui/common/types/xtext/ui/Refactoring",
          org.eclipse
              .xtext
              .idea
              .common
              .types
              .refactoringTestLanguage
              .RefactoringTestLanguagePackage
              .eINSTANCE);
    }

    org.eclipse.xtext.resource.IResourceFactory resourceFactory =
        injector.getInstance(org.eclipse.xtext.resource.IResourceFactory.class);
    org.eclipse.xtext.resource.IResourceServiceProvider serviceProvider =
        injector.getInstance(org.eclipse.xtext.resource.IResourceServiceProvider.class);
    Resource.Factory.Registry.INSTANCE
        .getExtensionToFactoryMap()
        .put("ideaTypesRefactoring", resourceFactory);
    org.eclipse.xtext.resource.IResourceServiceProvider.Registry.INSTANCE
        .getExtensionToFactoryMap()
        .put("ideaTypesRefactoring", serviceProvider);
  }
  public void register(Injector injector) {
    IResourceFactory resourceFactory = injector.getInstance(IResourceFactory.class);
    IResourceServiceProvider serviceProvider = injector.getInstance(IResourceServiceProvider.class);

    Resource.Factory.Registry.INSTANCE
        .getExtensionToFactoryMap()
        .put("___xbasewithannotations", resourceFactory);
    IResourceServiceProvider.Registry.INSTANCE
        .getExtensionToFactoryMap()
        .put("___xbasewithannotations", serviceProvider);
  }
  public void register(Injector injector) {

    org.eclipse.xtext.resource.IResourceFactory resourceFactory =
        injector.getInstance(org.eclipse.xtext.resource.IResourceFactory.class);
    org.eclipse.xtext.resource.IResourceServiceProvider serviceProvider =
        injector.getInstance(org.eclipse.xtext.resource.IResourceServiceProvider.class);
    Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put("qvtc", resourceFactory);
    org.eclipse.xtext.resource.IResourceServiceProvider.Registry.INSTANCE
        .getExtensionToFactoryMap()
        .put("qvtc", serviceProvider);
  }
Exemplo n.º 6
0
 private void index(Resource resource, URI uri, ResourceDescriptionsData index) {
   IResourceServiceProvider serviceProvider =
       IResourceServiceProvider.Registry.INSTANCE.getResourceServiceProvider(uri);
   if (serviceProvider != null) {
     IResourceDescription resourceDescription =
         serviceProvider.getResourceDescriptionManager().getResourceDescription(resource);
     if (resourceDescription != null) {
       index.addDescription(uri, resourceDescription);
     }
   }
 }
  public void register(Injector injector) {
    if (!EPackage.Registry.INSTANCE.containsKey("http://www.xtext.org/builddsl")) {
      EPackage.Registry.INSTANCE.put("http://www.xtext.org/builddsl", BuildPackage.eINSTANCE);
    }
    IResourceFactory resourceFactory = injector.getInstance(IResourceFactory.class);
    IResourceServiceProvider serviceProvider = injector.getInstance(IResourceServiceProvider.class);

    Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put("build", resourceFactory);
    IResourceServiceProvider.Registry.INSTANCE
        .getExtensionToFactoryMap()
        .put("build", serviceProvider);
  }
 private void createDirtyResource(Resource resource) {
   IResourceServiceProvider resourceServiceProvider =
       IResourceServiceProvider.Registry.INSTANCE.getResourceServiceProvider(resource.getURI());
   if (resourceServiceProvider == null) {
     return;
   }
   final DirtyResourceAdapter dirtyResource =
       new DirtyResourceAdapter(resource, resourceServiceProvider);
   dirtyStateManager.manageDirtyState(dirtyResource);
   uri2dirtyResource.put(resource.getURI(), dirtyResource);
   if (EcoreUtil.getExistingAdapter(resource, DirtyResourceUpdater.class) == null)
     resource.eAdapters().add(new DirtyResourceUpdater(dirtyResource));
 }
 public ISetup getBug287941TestLanguageSetup() {
   IResourceServiceProvider.Registry.INSTANCE
       .getExtensionToFactoryMap()
       .put("ecore", getEmfServiceProvider());
   return new Bug287941TestLanguageStandaloneSetup() {
     @Override
     public Injector createInjector() {
       return Guice.createInjector(
           Modules2.mixin(
               new Bug287941TestLanguageRuntimeModule(),
               new Bug287941TestLanguageUiModule(Activator.getInstance()),
               new SharedStateModule()));
     }
   };
 }
  public void register(Injector injector) {
    if (!EPackage.Registry.INSTANCE.containsKey("http://www.ExprDemo.expr")) {
      EPackage.Registry.INSTANCE.put(
          "http://www.ExprDemo.expr", expr.exprDemo.ExprDemoPackage.eINSTANCE);
    }

    org.eclipse.xtext.resource.IResourceFactory resourceFactory =
        injector.getInstance(org.eclipse.xtext.resource.IResourceFactory.class);
    org.eclipse.xtext.resource.IResourceServiceProvider serviceProvider =
        injector.getInstance(org.eclipse.xtext.resource.IResourceServiceProvider.class);
    Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put("expr", resourceFactory);
    org.eclipse.xtext.resource.IResourceServiceProvider.Registry.INSTANCE
        .getExtensionToFactoryMap()
        .put("expr", serviceProvider);
  }
  public void register(Injector injector) {
    if (!EPackage.Registry.INSTANCE.containsKey("http://www.caltoopia.org/frontend/Cal")) {
      EPackage.Registry.INSTANCE.put(
          "http://www.caltoopia.org/frontend/Cal", org.caltoopia.frontend.cal.CalPackage.eINSTANCE);
    }

    org.eclipse.xtext.resource.IResourceFactory resourceFactory =
        injector.getInstance(org.eclipse.xtext.resource.IResourceFactory.class);
    org.eclipse.xtext.resource.IResourceServiceProvider serviceProvider =
        injector.getInstance(org.eclipse.xtext.resource.IResourceServiceProvider.class);
    Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put("cal", resourceFactory);
    org.eclipse.xtext.resource.IResourceServiceProvider.Registry.INSTANCE
        .getExtensionToFactoryMap()
        .put("cal", serviceProvider);
  }
  public void register(Injector injector) {
    if (!EPackage.Registry.INSTANCE.containsKey("http://www.bundleDsl.com/BundleDsl")) {
      EPackage.Registry.INSTANCE.put(
          "http://www.bundleDsl.com/BundleDsl", com.bundleDsl.bundleDsl.BundleDslPackage.eINSTANCE);
    }

    org.eclipse.xtext.resource.IResourceFactory resourceFactory =
        injector.getInstance(org.eclipse.xtext.resource.IResourceFactory.class);
    org.eclipse.xtext.resource.IResourceServiceProvider serviceProvider =
        injector.getInstance(org.eclipse.xtext.resource.IResourceServiceProvider.class);
    Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put("bdsl", resourceFactory);
    org.eclipse.xtext.resource.IResourceServiceProvider.Registry.INSTANCE
        .getExtensionToFactoryMap()
        .put("bdsl", serviceProvider);
  }
  public void register(Injector injector) {
    if (!EPackage.Registry.INSTANCE.containsKey("http://www.scribble.org/editor/dsl/ScribbleDsl")) {
      EPackage.Registry.INSTANCE.put(
          "http://www.scribble.org/editor/dsl/ScribbleDsl",
          org.scribble.editor.dsl.scribbleDsl.ScribbleDslPackage.eINSTANCE);
    }

    org.eclipse.xtext.resource.IResourceFactory resourceFactory =
        injector.getInstance(org.eclipse.xtext.resource.IResourceFactory.class);
    org.eclipse.xtext.resource.IResourceServiceProvider serviceProvider =
        injector.getInstance(org.eclipse.xtext.resource.IResourceServiceProvider.class);
    Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put("scr", resourceFactory);
    org.eclipse.xtext.resource.IResourceServiceProvider.Registry.INSTANCE
        .getExtensionToFactoryMap()
        .put("scr", serviceProvider);
  }
  public void register(Injector injector) {
    if (!EPackage.Registry.INSTANCE.containsKey("http://lig.imag.fr/dsl/ExSchema")) {
      EPackage.Registry.INSTANCE.put(
          "http://lig.imag.fr/dsl/ExSchema",
          fr.imag.exschema.xtext.exSchema.ExSchemaPackage.eINSTANCE);
    }

    org.eclipse.xtext.resource.IResourceFactory resourceFactory =
        injector.getInstance(org.eclipse.xtext.resource.IResourceFactory.class);
    org.eclipse.xtext.resource.IResourceServiceProvider serviceProvider =
        injector.getInstance(org.eclipse.xtext.resource.IResourceServiceProvider.class);
    Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put("exschema", resourceFactory);
    org.eclipse.xtext.resource.IResourceServiceProvider.Registry.INSTANCE
        .getExtensionToFactoryMap()
        .put("exschema", serviceProvider);
  }
  public void register(Injector injector) {
    if (!EPackage.Registry.INSTANCE.containsKey("http://www.example.org/domainmodel/Domainmodel")) {
      EPackage.Registry.INSTANCE.put(
          "http://www.example.org/domainmodel/Domainmodel",
          org.example.domainmodel.domainmodel.DomainmodelPackage.eINSTANCE);
    }

    org.eclipse.xtext.resource.IResourceFactory resourceFactory =
        injector.getInstance(org.eclipse.xtext.resource.IResourceFactory.class);
    org.eclipse.xtext.resource.IResourceServiceProvider serviceProvider =
        injector.getInstance(org.eclipse.xtext.resource.IResourceServiceProvider.class);
    Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put("dmdl", resourceFactory);
    org.eclipse.xtext.resource.IResourceServiceProvider.Registry.INSTANCE
        .getExtensionToFactoryMap()
        .put("dmdl", serviceProvider);
  }
  public void register(Injector injector) {
    if (!EPackage.Registry.INSTANCE.containsKey("http://www.eclipse.org/papyrus/alf/Alf")) {
      EPackage.Registry.INSTANCE.put(
          "http://www.eclipse.org/papyrus/alf/Alf",
          org.eclipse.papyrus.uml.alf.alf.AlfPackage.eINSTANCE);
    }

    org.eclipse.xtext.resource.IResourceFactory resourceFactory =
        injector.getInstance(org.eclipse.xtext.resource.IResourceFactory.class);
    org.eclipse.xtext.resource.IResourceServiceProvider serviceProvider =
        injector.getInstance(org.eclipse.xtext.resource.IResourceServiceProvider.class);
    Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put("alf", resourceFactory);
    org.eclipse.xtext.resource.IResourceServiceProvider.Registry.INSTANCE
        .getExtensionToFactoryMap()
        .put("alf", serviceProvider);
  }
  public void register(Injector injector) {
    if (!EPackage.Registry.INSTANCE.containsKey(
        "http://www.bestsolution.at/efxclipse/tooling/decora/DecoraDsl")) {
      EPackage.Registry.INSTANCE.put(
          "http://www.bestsolution.at/efxclipse/tooling/decora/DecoraDsl",
          at.bestsolution.efxclipse.tooling.decora.decoraDsl.DecoraDslPackage.eINSTANCE);
    }

    org.eclipse.xtext.resource.IResourceFactory resourceFactory =
        injector.getInstance(org.eclipse.xtext.resource.IResourceFactory.class);
    org.eclipse.xtext.resource.IResourceServiceProvider serviceProvider =
        injector.getInstance(org.eclipse.xtext.resource.IResourceServiceProvider.class);
    Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put("jsl", resourceFactory);
    org.eclipse.xtext.resource.IResourceServiceProvider.Registry.INSTANCE
        .getExtensionToFactoryMap()
        .put("jsl", serviceProvider);
  }
  public void register(Injector injector) {
    if (!EPackage.Registry.INSTANCE.containsKey(
        "http://www.eclipse.org/2010/tmf/xtext/parser/EncodingUiTest")) {
      EPackage.Registry.INSTANCE.put(
          "http://www.eclipse.org/2010/tmf/xtext/parser/EncodingUiTest",
          org.eclipse.xtext.ui.tests.editor.encoding.encodingTest.EncodingTestPackage.eINSTANCE);
    }

    org.eclipse.xtext.resource.IResourceFactory resourceFactory =
        injector.getInstance(org.eclipse.xtext.resource.IResourceFactory.class);
    org.eclipse.xtext.resource.IResourceServiceProvider serviceProvider =
        injector.getInstance(org.eclipse.xtext.resource.IResourceServiceProvider.class);
    Resource.Factory.Registry.INSTANCE
        .getExtensionToFactoryMap()
        .put("encodinguitestlanguage", resourceFactory);
    org.eclipse.xtext.resource.IResourceServiceProvider.Registry.INSTANCE
        .getExtensionToFactoryMap()
        .put("encodinguitestlanguage", serviceProvider);
  }
  public void register(Injector injector) {
    if (!EPackage.Registry.INSTANCE.containsKey(
        "http://www.eclipse.org/papyrus/property/editor/xtext/UmlProperty")) {
      EPackage.Registry.INSTANCE.put(
          "http://www.eclipse.org/papyrus/property/editor/xtext/UmlProperty",
          org.eclipse.papyrus.property.editor.xtext.umlProperty.UmlPropertyPackage.eINSTANCE);
    }

    org.eclipse.xtext.resource.IResourceFactory resourceFactory =
        injector.getInstance(org.eclipse.xtext.resource.IResourceFactory.class);
    org.eclipse.xtext.resource.IResourceServiceProvider serviceProvider =
        injector.getInstance(org.eclipse.xtext.resource.IResourceServiceProvider.class);
    Resource.Factory.Registry.INSTANCE
        .getExtensionToFactoryMap()
        .put("umlproperty", resourceFactory);
    org.eclipse.xtext.resource.IResourceServiceProvider.Registry.INSTANCE
        .getExtensionToFactoryMap()
        .put("umlproperty", serviceProvider);
  }
  public void register(Injector injector) {
    if (!EPackage.Registry.INSTANCE.containsKey(
        "http://www.xtext.org/example/statemachine/Statemachine")) {
      EPackage.Registry.INSTANCE.put(
          "http://www.xtext.org/example/statemachine/Statemachine",
          org.xtext.example.statemachine.statemachine.StatemachinePackage.eINSTANCE);
    }

    org.eclipse.xtext.resource.IResourceFactory resourceFactory =
        injector.getInstance(org.eclipse.xtext.resource.IResourceFactory.class);
    org.eclipse.xtext.resource.IResourceServiceProvider serviceProvider =
        injector.getInstance(org.eclipse.xtext.resource.IResourceServiceProvider.class);
    Resource.Factory.Registry.INSTANCE
        .getExtensionToFactoryMap()
        .put("statemachine", resourceFactory);
    org.eclipse.xtext.resource.IResourceServiceProvider.Registry.INSTANCE
        .getExtensionToFactoryMap()
        .put("statemachine", serviceProvider);
  }
  public void register(Injector injector) {

    org.eclipse.xtext.resource.IResourceFactory resourceFactory =
        injector.getInstance(org.eclipse.xtext.resource.IResourceFactory.class);
    org.eclipse.xtext.resource.IResourceServiceProvider serviceProvider =
        injector.getInstance(org.eclipse.xtext.resource.IResourceServiceProvider.class);
    Resource.Factory.Registry.INSTANCE
        .getExtensionToFactoryMap()
        .put("bug299395testlanguage", resourceFactory);
    org.eclipse.xtext.resource.IResourceServiceProvider.Registry.INSTANCE
        .getExtensionToFactoryMap()
        .put("bug299395testlanguage", serviceProvider);

    if (!EPackage.Registry.INSTANCE.containsKey(
        "http://www.eclipse.org/2010/tmf/xtext/Bug299395")) {
      EPackage.Registry.INSTANCE.put(
          "http://www.eclipse.org/2010/tmf/xtext/Bug299395",
          org.eclipse.xtext.parsetree.reconstr.bug299395.Bug299395Package.eINSTANCE);
    }
  }
  public void register(Injector injector) {

    org.eclipse.xtext.resource.IResourceFactory resourceFactory =
        injector.getInstance(org.eclipse.xtext.resource.IResourceFactory.class);
    org.eclipse.xtext.resource.IResourceServiceProvider serviceProvider =
        injector.getInstance(org.eclipse.xtext.resource.IResourceServiceProvider.class);
    Resource.Factory.Registry.INSTANCE
        .getExtensionToFactoryMap()
        .put("subtestlanguage", resourceFactory);
    org.eclipse.xtext.resource.IResourceServiceProvider.Registry.INSTANCE
        .getExtensionToFactoryMap()
        .put("subtestlanguage", serviceProvider);

    if (!EPackage.Registry.INSTANCE.containsKey(
        "http://www.eclipse.org/2009/tmf/xtext/SubTestLanguage")) {
      EPackage.Registry.INSTANCE.put(
          "http://www.eclipse.org/2009/tmf/xtext/SubTestLanguage",
          org.eclipse.xtext.generator.ecore.subPackage.SubPackagePackage.eINSTANCE);
    }
  }
  public void register(Injector injector) {

    org.eclipse.xtext.resource.IResourceFactory resourceFactory =
        injector.getInstance(org.eclipse.xtext.resource.IResourceFactory.class);
    org.eclipse.xtext.resource.IResourceServiceProvider serviceProvider =
        injector.getInstance(org.eclipse.xtext.resource.IResourceServiceProvider.class);
    Resource.Factory.Registry.INSTANCE
        .getExtensionToFactoryMap()
        .put("ignorecaseimportstestlanguage", resourceFactory);
    org.eclipse.xtext.resource.IResourceServiceProvider.Registry.INSTANCE
        .getExtensionToFactoryMap()
        .put("ignorecaseimportstestlanguage", serviceProvider);

    if (!EPackage.Registry.INSTANCE.containsKey(
        "http://eclipse.org/xtext/ignoreCaseImportsTestLanguage")) {
      EPackage.Registry.INSTANCE.put(
          "http://eclipse.org/xtext/ignoreCaseImportsTestLanguage",
          org.eclipse.xtext.linking.ignoreCaseImportsTest.IgnoreCaseImportsTestPackage.eINSTANCE);
    }
  }
Exemplo n.º 24
0
 private ResourceSet createResourceSet(URI genModelUri) {
   ResourceSetImpl resourceSet;
   if (genModelUri.fileExtension().equals("xcore")) {
     IResourceServiceProvider resourceServiceProvider =
         IResourceServiceProvider.Registry.INSTANCE.getResourceServiceProvider(genModelUri);
     IStorage2UriMapper storage2UriMapper = resourceServiceProvider.get(IStorage2UriMapper.class);
     IProject project = storage2UriMapper.getStorages(genModelUri).iterator().next().getSecond();
     resourceSet =
         (ResourceSetImpl) resourceServiceProvider.get(IResourceSetProvider.class).get(project);
   } else {
     resourceSet = new ResourceSetImpl();
   }
   Resource ecorePackageResource = EcorePackage.eINSTANCE.eResource();
   Map<URI, Resource> uriResourceMap = Maps.newHashMap();
   uriResourceMap.put(
       URI.createPlatformResourceURI(PATH_TO_ECORE_ECORE, true), ecorePackageResource);
   uriResourceMap.put(
       URI.createPlatformPluginURI(PATH_TO_ECORE_ECORE, true), ecorePackageResource);
   resourceSet.setURIResourceMap(uriResourceMap);
   return resourceSet;
 }
Exemplo n.º 25
0
  public void setUri(String uri) {
    ResourceSet rs = forcedResourceSet != null ? forcedResourceSet : new XtextResourceSet();
    for (String loadedResource : loadedResources) {
      URI loadedResourceUri = URI.createURI(loadedResource);
      if (equal(loadedResourceUri.fileExtension(), "genmodel")) {
        IResourceServiceProvider resourceServiceProvider =
            IResourceServiceProvider.Registry.INSTANCE.getResourceServiceProvider(
                loadedResourceUri);
        if (resourceServiceProvider == null) {
          try {
            Class<?> genModelSupport =
                Class.forName("org.eclipse.emf.codegen.ecore.xtext.GenModelSupport");
            Object instance = genModelSupport.newInstance();
            genModelSupport
                .getDeclaredMethod("createInjectorAndDoEMFRegistration")
                .invoke(instance);
          } catch (ClassNotFoundException e) {
            LOG.error("Couldn't initialize GenModel support. Is it on the classpath?");
            LOG.debug(e.getMessage(), e);
          } catch (Exception e) {
            LOG.error("Couldn't initialize GenModel support.", e);
          }
        }
      } else if (equal(loadedResourceUri.fileExtension(), "ecore")) {
        IResourceServiceProvider resourceServiceProvider =
            IResourceServiceProvider.Registry.INSTANCE.getResourceServiceProvider(
                loadedResourceUri);
        if (resourceServiceProvider == null) {
          EcoreSupportStandaloneSetup.setup();
        }
      } else if (equal(loadedResourceUri.fileExtension(), "xcore")) {
        IResourceServiceProvider resourceServiceProvider =
            IResourceServiceProvider.Registry.INSTANCE.getResourceServiceProvider(
                loadedResourceUri);
        if (resourceServiceProvider == null) {
          try {
            Class<?> xcore = Class.forName("org.eclipse.emf.ecore.xcore.XcoreStandaloneSetup");
            xcore.getDeclaredMethod("doSetup", new Class[0]).invoke(null);
          } catch (ClassNotFoundException e) {
            LOG.error("Couldn't initialize Xcore support. Is it on the classpath?");
            LOG.debug(e.getMessage(), e);
          } catch (Exception e) {
            LOG.error("Couldn't initialize Xcore support.", e);
          }
        }
        URI xcoreLangURI =
            URI.createPlatformResourceURI(
                "/org.eclipse.emf.ecore.xcore.lib/model/XcoreLang.xcore", true);
        try {
          rs.getResource(xcoreLangURI, true);
        } catch (WrappedException e) {
          LOG.error("Could not load XcoreLang.xcore.", e);
          Resource brokenResource = rs.getResource(xcoreLangURI, false);
          rs.getResources().remove(brokenResource);
        }
      }
      rs.getResource(loadedResourceUri, true);
    }
    if (!rs.getResources().isEmpty()) {
      installIndex(rs);
      for (int i = 0, size = rs.getResources().size(); i < size; i++) {
        Resource res = rs.getResources().get(i);
        if (res.getContents().isEmpty()) LOG.error("Error loading '" + res.getURI() + "'");
        else if (!res.getErrors().isEmpty())
          LOG.error(
              "Error loading '" + res.getURI() + "':\n" + Joiner.on('\n').join(res.getErrors()));
      }
      EcoreUtil.resolveAll(rs);
    }
    XtextResource resource = (XtextResource) rs.getResource(URI.createURI(uri), true);
    if (resource.getContents().isEmpty()) {
      throw new IllegalArgumentException("Couldn't load grammar for '" + uri + "'.");
    }
    if (!resource.getErrors().isEmpty()) {
      LOG.error(resource.getErrors());
      throw new IllegalStateException(
          "Problem parsing '" + uri + "':\n" + Joiner.on('\n').join(resource.getErrors()));
    }

    final Grammar grammar = (Grammar) resource.getContents().get(0);
    validateGrammar(grammar);
    this.grammar = grammar;
  }