Java 类org.eclipse.xtext.resource.IResourceDescription.Manager 实例源码

项目:xtext-core    文件:ResourceSetBasedResourceDescriptions.java   
@Override
public IResourceDescription getResourceDescription(URI uri) {
    if (data != null) {
        return data.getResourceDescription(uri);
    }
    Resource resource = resourceSet.getResource(uri, false);
    if (resource == null)
        return null;
    IResourceServiceProvider resourceServiceProvider = registry.getResourceServiceProvider(uri);
    if (resourceServiceProvider == null)
        return null;
    Manager manager = resourceServiceProvider.getResourceDescriptionManager();
    if (manager == null)
        return null;
    return manager.getResourceDescription(resource);
}
项目:xtext-core    文件:LoadOnDemandResourceDescriptions.java   
@Override
public IResourceDescription getResourceDescription(URI uri) {
    IResourceDescription result = delegate.getResourceDescription(uri);
    if (result == null) {
        Resource resource = EcoreUtil2.getResource(context, uri.toString());
        if (resource != null) {
            IResourceServiceProvider serviceProvider = serviceProviderRegistry.getResourceServiceProvider(uri);
            if (serviceProvider==null)
                throw new IllegalStateException("No "+IResourceServiceProvider.class.getSimpleName()+" found in registry for uri "+uri);
            final Manager resourceDescriptionManager = serviceProvider.getResourceDescriptionManager();
            if (resourceDescriptionManager == null)
                throw new IllegalStateException("No "+IResourceDescription.Manager.class.getName()+" provided by service provider for URI "+uri);
            result = resourceDescriptionManager.getResourceDescription(resource);
        }
    }
    return result;
}
项目:statecharts    文件:ImportedResourceCache.java   
public IResourceDescription get(final URI uri) {
    final ResourceSet set = getResourceSet();
    final Resource resource = set.getResource(uri, true);
    if (resource != null) {
        Optional<IResourceDescription> optional = cache.get(ImportedResourceCache.class, resource,
                new Provider<Optional<IResourceDescription>>() {
                    @Override
                    public Optional<IResourceDescription> get() {
                        IResourceServiceProvider serviceProvider = serviceProviderRegistry
                                .getResourceServiceProvider(uri);
                        if (serviceProvider == null)
                            return Optional.empty();
                        final Manager resourceDescriptionManager = serviceProvider.getResourceDescriptionManager();
                        if (resourceDescriptionManager == null)
                            return Optional.empty();
                        IResourceDescription result = resourceDescriptionManager.getResourceDescription(resource);
                        return Optional.of(result);
                    }
                });
        if (optional.isPresent()) {
            return optional.get();
        }
    }
    return null;
}
项目:xtext-core    文件:EagerResourceSetBasedResourceDescriptions.java   
private IResourceDescription computeResourceDescription(URI uri) {
    Resource resource = resourceSet.getResource(uri, false);
    if (resource == null)
        return null;
    IResourceServiceProvider resourceServiceProvider = registry.getResourceServiceProvider(uri);
    if (resourceServiceProvider == null)
        return null;
    Manager manager = resourceServiceProvider.getResourceDescriptionManager();
    if (manager == null)
        return null;
    return manager.getResourceDescription(resource);
}
项目:xtext-core    文件:NamesAreUniqueValidatorTest.java   
@Override
public IResourceServiceProvider getResourceServiceProvider(URI uri, String contentType) {
    return new DefaultResourceServiceProvider() {
        @Override
        public Manager getResourceDescriptionManager() {
            return resourceDescriptionManager;
        }
    }; 
}
项目:xtext-core    文件:XtextResourceDescriptionTest.java   
@Test public void testComputeEObjectDescriptionsForEmptyFile() throws Exception {
    Resource res = getResourceAndExpect(new StringInputStream(""),URI.createURI("foo.xtext"),1);
    Manager manager = get(IResourceDescription.Manager.class);
    IResourceDescription description = manager.getResourceDescription(res);
    Iterable<IEObjectDescription> iterable = description.getExportedObjects();
    assertTrue(Lists.newArrayList(iterable).isEmpty());
}
项目:xtext-core    文件:XtextResourceDescriptionTest.java   
@Test public void testComputeEObjectDescriptionsForUnnamedGrammar() throws Exception {
    Resource res = getResourceAndExpect(new StringInputStream("grammar "),URI.createURI("foo.xtext"),1);
    Manager manager = get(IResourceDescription.Manager.class);
    IResourceDescription description = manager.getResourceDescription(res);
    Iterable<IEObjectDescription> iterable = description.getExportedObjects();
    assertTrue(Lists.newArrayList(iterable).isEmpty());
}
项目:xtext-core    文件:XtextResourceDescriptionTest.java   
@Test public void testGetExportedEObjectsErroneousResource() throws Exception {
    Resource res = getResourceAndExpect(new StringInputStream("grammar foo Start : 'main';"),URI.createURI("foo.xtext"),1);
    Manager manager = get(IResourceDescription.Manager.class);
    IResourceDescription description = manager.getResourceDescription(res);
    Iterable<IEObjectDescription> iterable = description.getExportedObjects();
    assertTrue(Lists.newArrayList(iterable).size()==2);
}
项目:xtext-core    文件:XtextResourceDescriptionTest.java   
@Test public void testGetExportedEObjects() throws Exception {
    Resource res = getResource(new StringInputStream("grammar foo generate x \"someURI\" Start : 'main';"),URI.createURI("foo.xtext"));
    Manager manager = get(IResourceDescription.Manager.class);
    IResourceDescription description = manager.getResourceDescription(res);
    Iterable<IEObjectDescription> iterable = description.getExportedObjects();
    assertTrue(Lists.newArrayList(iterable).size()==3);
}
项目:xtext-core    文件:XtextResourceDescriptionTest.java   
@Test public void testBug350695() throws Exception {
    Resource res = getResource(new StringInputStream("grammar org.foo.Zonk generate x \"someURI\" Start : 'main';"), URI.createURI("foo.xtext"));
    Manager manager = get(IResourceDescription.Manager.class);
    IResourceDescription description = manager.getResourceDescription(res);
    assertTrue(Iterables.isEmpty(description.getExportedObjects(XtextPackage.Literals.GRAMMAR, QualifiedName.create("org.foo.Zonk"), false)));
    IEObjectDescription element = Iterables.getOnlyElement(
            description.getExportedObjects(XtextPackage.Literals.GRAMMAR, QualifiedName.create("org","foo","Zonk"), false));
    assertNotNull(element);
}
项目:xtext-core    文件:ResourceSetBasedResourceDescriptionsTest.java   
@Override
public IResourceServiceProvider getResourceServiceProvider(URI uri, String contentType) {
    return new DefaultResourceServiceProvider() {
        @Override
        public Manager getResourceDescriptionManager() {
            return resourceDescriptionManager;
        }
    };
}
项目:xtext-core    文件:ImportedNamespaceAwareLocalScopeProviderTest.java   
@Override
public void setUp() throws Exception {
    super.setUp();
    with(new IndexTestLanguageStandaloneSetup());

    globalScopeProvider = new ResourceSetGlobalScopeProvider();
    nameProvider = new DefaultDeclarativeQualifiedNameProvider();
    nameConverter = new IQualifiedNameConverter.DefaultImpl();
    final DefaultResourceDescriptionStrategy strategy = new DefaultResourceDescriptionStrategy();
    strategy.setQualifiedNameProvider(nameProvider);
    final DefaultResourceDescriptionManager resourceDescMnr = new DefaultResourceDescriptionManager() {
        @Override
        public IResourceDescription getResourceDescription(Resource resource) {
            DefaultResourceDescription resourceDescription = new DefaultResourceDescription(resource,
                    strategy);
            return resourceDescription;
        }

    };
    final DefaultResourceServiceProvider provider = new DefaultResourceServiceProvider() {
        @Override
        public Manager getResourceDescriptionManager() {
            return resourceDescMnr;
        }
    };
    globalScopeProvider.setGlobalResourceDecriptionProvider(new GlobalResourceDescriptionProvider(new ResourceServiceProviderRegistryImpl() {
        @Override
        public IResourceServiceProvider getResourceServiceProvider(URI uri, String contentType) {
            return provider;
        }
    }));
    CaseInsensitivityHelper caseInsensitivityHelper = new CaseInsensitivityHelper();
    globalScopeProvider.setCaseInsensitivityHelper(caseInsensitivityHelper);
    scopeProvider = new ImportedNamespaceAwareLocalScopeProvider(globalScopeProvider, nameProvider, nameConverter, caseInsensitivityHelper);
}
项目:xtext-core    文件:ProfilingTest.java   
@Test public void testSimple() throws Exception {
        with(new IndexTestLanguageStandaloneSetup(){
            @Override
            public Injector createInjector() {
                return Guice.createInjector(new org.eclipse.xtext.index.IndexTestLanguageRuntimeModule(){
                    @Override
                    public java.lang.Class<? extends org.eclipse.xtext.scoping.IScopeProvider> bindIScopeProvider() {
                        return OptimizedScopeProvider.class;
                    }
                }
                );
            }
        });
        XtextResourceSet rs = get(XtextResourceSet.class);
        Resource outer = rs.createResource(URI.createURI("outer."+getCurrentFileExtension()));
        outer.load(new StringInputStream(outerFile(ELEMENTS)), null);
        Resource inner = rs.createResource(URI.createURI("inner."+getCurrentFileExtension()));
        StopWatch watch = new StopWatch();

        inner.load(new StringInputStream(generateFile(ELEMENTS)), null);
//      resource.load(new StringInputStream(generateFile(1000)), null);
        watch.resetAndLog("loading");
        EcoreUtil.resolveAll(inner);
        watch.resetAndLog("linking");

        assertTrue(inner.getErrors().size()+" errors ", inner.getErrors().isEmpty());
        Manager manager = get(IResourceDescription.Manager.class);
//      Yourkit.startTracing();
        IResourceDescription iResourceDescription = manager.getResourceDescription(inner);
        Sets.newHashSet(iResourceDescription.getReferenceDescriptions());
//      Yourkit.stopCpuProfiling();
        watch.resetAndLog("resourcedescriptions");
//      System.out.println(Sets.newHashSet(inner.getAllContents()).size());
    }
项目:dsl-devkit    文件:MonitoredClusteringBuilderState.java   
/**
 * Gets a map of URIs indexed by their {@link IResourceDescription.Manager}.
 *
 * @param uRIs
 *          the URIs to index
 * @return the map of URIs indexed by their managers
 */
private ImmutableListMultimap<Manager, URI> getUrisByManager(final Set<URI> uRIs) {
  ImmutableListMultimap.Builder<Manager, URI> builder = ImmutableListMultimap.builder();
  for (URI uri : uRIs) {
    Manager mgr = getResourceDescriptionManager(uri);
    if (mgr != null) {
      builder.put(mgr, uri);
    }
  }
  return builder.build();
}
项目:dsl-devkit    文件:MonitoredClusteringBuilderState.java   
/**
 * Add deltas for the removed resources.
 *
 * @param deletedUris
 *          URIs of the removed resources
 * @param deltas
 *          Deltas
 * @param savedDescriptions
 *          previously saved old resource descriptions
 */
protected void addDeletedURIsToDeltas(final Set<URI> deletedUris, final Set<Delta> deltas, final Map<URI, IResourceDescription> savedDescriptions) {
  for (final URI uri : deletedUris) {
    final IResourceDescription oldDescription = getSavedResourceDescription(savedDescriptions, uri);
    if (oldDescription != null) {
      final IResourceDescription.Manager manager = getResourceDescriptionManager(uri);
      if (manager != null) {
        deltas.add(manager.createDelta(oldDescription, null));
      }
    }
  }
}