org.eclipse.xtext.resource.impl.DefaultResourceDescription Java Examples
The following examples show how to use
org.eclipse.xtext.resource.impl.DefaultResourceDescription.
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: DefaultResourceDescriptionManagerTest.java From xtext-core with Eclipse Public License 2.0 | 6 votes |
@Before public void setUp() throws Exception { EObject copy = EcoreUtil.copy(EcorePackage.eINSTANCE); resource = new ResourceImpl(); resource.getContents().add(copy); IQualifiedNameProvider nameProvider = new IQualifiedNameProvider.AbstractImpl() { @Override public QualifiedName getFullyQualifiedName(EObject obj) { if (obj instanceof ENamedElement) return QualifiedName.create(((ENamedElement) obj).getName()); return null; } }; DefaultResourceDescriptionStrategy descriptionStrategy = new DefaultResourceDescriptionStrategy(); descriptionStrategy.setQualifiedNameProvider(nameProvider); resourceDescription = new DefaultResourceDescription(resource, descriptionStrategy) { @Override public Iterable<QualifiedName> getImportedNames() { return importedNames; } }; manager = new DefaultResourceDescriptionManager(); importedNames = Collections.emptySet(); }
Example #2
Source File: JavaResourceDescriptionManager.java From xtext-extras with Eclipse Public License 2.0 | 5 votes |
@Override public IResourceDescription getResourceDescription(Resource resource) { if (resource instanceof JavaResource) { JavaResource javaResource = (JavaResource) resource; boolean initialized = javaResource.isInitialized() || javaResource.isInitializing(); try { if (!initialized) { javaResource.eSetDeliver(false); javaResource.installStubs(); } DefaultResourceDescription result = new DefaultResourceDescription(resource, descriptionStrategy, cache); if (!initialized) { for (IEObjectDescription d : result.getExportedObjects()) { d.getEObjectURI(); } } return result; } finally { if (!initialized) { javaResource.discardDerivedState(); javaResource.eSetDeliver(true); } } } throw new IllegalArgumentException("Can only handle JavaResources"); }
Example #3
Source File: DirtyStateEditorSupportTest.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
@Override public IResourceDescription getResourceDescription(Resource resource) { return new DefaultResourceDescription(resource, null) { @Override protected List<IEObjectDescription> computeExportedObjects() { return exportedObjects; } }; }
Example #4
Source File: ImportedNamespaceAwareLocalScopeProviderTest.java From xtext-core with Eclipse Public License 2.0 | 5 votes |
@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); }
Example #5
Source File: CachingStateBasedContainerManager.java From dsl-devkit with Eclipse Public License 1.0 | 5 votes |
/** * Returns the containers for the given handles, where one of the containers will also include {@code desc} when appropriate. * * @param handles * handles to get containers for, must not be {@code null} * @param desc * description to add, must not be {@code null} * @param resourceDescriptions * resource descriptions, must not be {@code null} * @return list of containers, never {@code null} */ protected List<IContainer> getContainersForHandlesAndResource(final List<String> handles, final IResourceDescription desc, final IResourceDescriptions resourceDescriptions) { List<IContainer> result = getVisibleContainers(handles, resourceDescriptions); if (!result.isEmpty()) { URI descURI = desc.getURI(); for (int i = 0; i < result.size(); i++) { if (result.get(i).getResourceDescription(descURI) != null) { return result; } } // Do *not* add the context resource description itself if we're in the first phase of a build: 'desc' itself // may not be in any consistent state, and adding it to the containers may result in recursive invocations of // getEObjectDescriptions(), leading to a stack overflow since it may in turn invoke getVisibleContainers() again. if (desc instanceof DefaultResourceDescription) { DefaultResourceDescription d = (DefaultResourceDescription) desc; if (BuildPhases.isIndexing(d.getResource())) { return result; } } // the IResourceDescription was found nowhere, add it to the first one that matches the description's domain. IDomain descDomain = mapper.map(descURI); IContainer wrappedContainer = null; int index = 0; for (int i = 0; i < result.size(); i++) { IContainer container = result.get(i); IDomain containerDomain = mapper.map(container); if (containerDomain != null && containerDomain.equals(descDomain)) { wrappedContainer = new DescriptionAddingContainer(desc, container); result.set(index, wrappedContainer); return result; } index++; } // If we get here, we found no container with a matching domain. Add to the first, but use a DescriptionAddingContainer that // will add the description at the end. wrappedContainer = new DescriptionAtEndAddingContainer(desc, result.get(0)); result.set(0, wrappedContainer); } return result; }
Example #6
Source File: ImportedResourceCache.java From statecharts with Eclipse Public License 1.0 | 5 votes |
public IResourceDescription get(final URI uri) { refreshFile(uri); try { return (IResourceDescription) getEditingDomain() .runExclusive(new RunnableWithResult.Impl<IResourceDescription>() { @Override public void run() { final ResourceSet set = getResourceSet(); final Resource resource = set.getResource(uri, true); if (resource != null) { IResourceServiceProvider serviceProvider = serviceProviderRegistry .getResourceServiceProvider(uri); if (serviceProvider == null) { setResult(new DefaultResourceDescription(resource, delegateStrategy)); return; } final Manager resourceDescriptionManager = serviceProvider .getResourceDescriptionManager(); if (resourceDescriptionManager == null) return; IResourceDescription result = resourceDescriptionManager .getResourceDescription(resource); setResult(result); } } }); } catch (InterruptedException e) { e.printStackTrace(); return null; } }
Example #7
Source File: GenericResourceDescriptionManager.java From xtext-core with Eclipse Public License 2.0 | 4 votes |
@Override public IResourceDescription getResourceDescription(Resource resource) { return new DefaultResourceDescription(resource, resourceDescriptionStrategy, cache); }