Java Code Examples for org.eclipse.xtext.resource.IResourceServiceProvider#getResourceDescriptionManager()
The following examples show how to use
org.eclipse.xtext.resource.IResourceServiceProvider#getResourceDescriptionManager() .
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: CheckCfgUtil.java From dsl-devkit with Eclipse Public License 1.0 | 6 votes |
/** * Gets the all languages available in the workbench. * * @return set of all languages */ public Set<String> getAllLanguages() { Set<String> languages = new HashSet<String>(); for (String extension : Registry.INSTANCE.getExtensionToFactoryMap().keySet()) { final URI dummyUri = URI.createURI("foo:/foo." + extension); IResourceServiceProvider resourceServiceProvider = Registry.INSTANCE.getResourceServiceProvider(dummyUri); // By checking that description manager is AbstractCachingResourceDescriptionManager we exclude technical languages of the framework if (resourceServiceProvider != null && resourceServiceProvider.getResourceDescriptionManager() instanceof AbstractCachingResourceDescriptionManager) { try { IGrammarAccess grammarAccess = resourceServiceProvider.get(IGrammarAccess.class); if (grammarAccess != null && grammarAccess.getGrammar() != null) { languages.add(grammarAccess.getGrammar().getName()); } } catch (ConfigurationException e) { // Will happen if no binding for IGrammarAccess was present. } } } return languages; }
Example 2
Source File: AbstractPolymorphicScopeProvider.java From dsl-devkit with Eclipse Public License 1.0 | 6 votes |
/** * Return the visible containers given a resource. * * @param resource * the resource. Must not be {@code null} * @return The list of visible containers. */ protected List<IContainer> getVisibleContainers(final XtextResource resource) { URI uri = resource.getURI(); List<IContainer> result = null; final ResourceCache<URI, List<IContainer>> cache = CacheManager.getInstance().getOrCreateResourceCache("AbstractPolymorphicScopeProvider#visibleContainers", resource); //$NON-NLS-1$ if (cache != null) { result = cache.get(uri); if (result != null) { return result; } } final IResourceServiceProvider resourceServiceProvider = resource.getResourceServiceProvider(); final IResourceDescription.Manager descriptionManager = resourceServiceProvider.getResourceDescriptionManager(); final IContainer.Manager containerManager = resourceServiceProvider.getContainerManager(); final IResourceDescription description = descriptionManager.getResourceDescription(resource); final IResourceDescriptions resourceDescriptions = getResourceDescriptions(resource); result = containerManager.getVisibleContainers(description, resourceDescriptions); if (cache != null) { cache.set(uri, result); } return result; }
Example 3
Source File: XIndexer.java From n4js with Eclipse Public License 1.0 | 6 votes |
/** * Compute deltas for resources affected by the given <code>newDeltas</code> and register them in the given * <code>newIndex</code>. * * @param index * the current index; will be changed by this method. * @param remainingURIs * set of URIs that were not processed yet. * @param newDeltas * deltas representing the resources processed during the most recent build iteration. * @param allDeltas * deltas representing all resources processed so far, including {@link XBuildRequest#getExternalDeltas() * external deltas}. * @param context * the build context. * @return list of deltas representing the affected resources. */ public List<Delta> computeAndIndexAffected(ResourceDescriptionsData index, Set<URI> remainingURIs, Collection<Delta> newDeltas, Collection<Delta> allDeltas, XBuildContext context) { ResourceDescriptionsData originalIndex = context.getOldState().getResourceDescriptions(); List<URI> affectedURIs = new ArrayList<>(); for (URI uri : remainingURIs) { IResourceServiceProvider resourceServiceProvider = context.getResourceServiceProvider(uri); IResourceDescription.Manager manager = resourceServiceProvider.getResourceDescriptionManager(); IResourceDescription resourceDescription = originalIndex.getResourceDescription(uri); if (isAffected(resourceDescription, manager, newDeltas, allDeltas, index)) { affectedURIs.add(uri); } } List<Delta> affectedDeltas = getDeltasForChangedResources(affectedURIs, originalIndex, context); for (IResourceDescription.Delta delta : affectedDeltas) { index.register(delta); } return affectedDeltas; }
Example 4
Source File: XIndexer.java From n4js with Eclipse Public License 1.0 | 6 votes |
/** * Index the given resource. * * @param isPreIndexing * can be evaluated to produce different index entries depending on the phase */ protected IResourceDescription.Delta addToIndex(Resource resource, boolean isPreIndexing, ResourceDescriptionsData oldIndex, XBuildContext context) { this.operationCanceledManager.checkCanceled(context.getCancelIndicator()); if (context.getResourceSet() != resource.getResourceSet()) { // we are seeing an out-of-sequence resource - don't index it return null; } URI uri = resource.getURI(); IResourceServiceProvider serviceProvider = context.getResourceServiceProvider(uri); IResourceDescription.Manager manager = serviceProvider.getResourceDescriptionManager(); IResourceDescription newDescription = manager.getResourceDescription(resource); IResourceDescription toBeAdded = new XIndexer.XResolvedResourceDescription(newDescription); IResourceDescription.Delta delta = manager .createDelta(oldIndex != null ? oldIndex.getResourceDescription(uri) : null, toBeAdded); return delta; }
Example 5
Source File: LoadOnDemandResourceDescriptions.java From xtext-core with Eclipse Public License 2.0 | 6 votes |
@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; }
Example 6
Source File: ResourceSetBasedResourceDescriptions.java From xtext-core with Eclipse Public License 2.0 | 6 votes |
@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); }
Example 7
Source File: N4ClusteringBuilderState.java From n4js with Eclipse Public License 1.0 | 5 votes |
protected IResourceDescription.Manager getResourceDescriptionManager(URI uri) { IResourceServiceProvider resourceServiceProvider = managerRegistry.getResourceServiceProvider(uri); if (resourceServiceProvider == null) { return null; } return resourceServiceProvider.getResourceDescriptionManager(); }
Example 8
Source File: MonitoredClusteringBuilderState.java From dsl-devkit with Eclipse Public License 1.0 | 5 votes |
/** * Create a resource description's copy that represents the old state of a resource. Will be used to compute invalidations. * (see 'oldDescriptions' in doUpdate(BuildData, ResourceDescriptionsData, IProgressMonitor)) * * @param original * original resource description, must not be {@code null} * @return a copy, never {@code null} */ private IResourceDescription createOldStateResourceDescription(final IResourceDescription original) { IResourceServiceProvider provider = IResourceServiceProvider.Registry.INSTANCE.getResourceServiceProvider(original.getURI()); if (provider != null && provider.getResourceDescriptionManager() instanceof AbstractCachingResourceDescriptionManager) { // FingerprintResourceDescription is a lightweight implementation that contains only the information for computation of invalidated resources // Should be however used only for those DSLs, which use DDK's custom resource descriptions deltas // This is the case if language's IResourceDescription.Manager implementation subclasses AbstractCachingResourceDescriptionManager return new FingerprintResourceDescription(original); } return new FixedCopiedResourceDescription(original); }
Example 9
Source File: Indexer.java From xtext-core with Eclipse Public License 2.0 | 5 votes |
/** * Index the given resource. * * @param isPreIndexing * can be evaluated to produce different index entries depending on the phase */ protected IResourceDescription.Delta addToIndex(Resource resource, boolean isPreIndexing, ResourceDescriptionsData oldIndex, BuildContext context) { operationCanceledManager.checkCanceled(context.getCancelIndicator()); URI uri = resource.getURI(); IResourceServiceProvider serviceProvider = context.getResourceServiceProvider(uri); IResourceDescription.Manager manager = serviceProvider.getResourceDescriptionManager(); IResourceDescription newDescription = manager.getResourceDescription(resource); IResourceDescription toBeAdded = new Indexer.ResolvedResourceDescription(newDescription); IResourceDescription.Delta delta = manager .createDelta(oldIndex != null ? oldIndex.getResourceDescription(uri) : null, toBeAdded); return delta; }
Example 10
Source File: GlobalResourceDescriptionProvider.java From xtext-core with Eclipse Public License 2.0 | 5 votes |
public IResourceDescription getResourceDescription(Resource resource) { IResourceServiceProvider resourceServiceProvider = resourceServiceProviderRegistry.getResourceServiceProvider(resource.getURI()); if (resourceServiceProvider == null) return null; IResourceDescription.Manager manager = resourceServiceProvider.getResourceDescriptionManager(); if (manager == null) return null; IResourceDescription description = manager.getResourceDescription(resource); return description; }
Example 11
Source File: EagerResourceSetBasedResourceDescriptions.java From xtext-core with Eclipse Public License 2.0 | 5 votes |
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); }
Example 12
Source File: DefaultUniqueNameContext.java From xtext-core with Eclipse Public License 2.0 | 5 votes |
protected IResourceDescription.Manager getResourceDescriptionManager(Resource resource) { IResourceServiceProvider resourceServiceProvider = getResourceServiceProvider(resource); if (resourceServiceProvider == null) { return null; } return resourceServiceProvider.getResourceDescriptionManager(); }
Example 13
Source File: ClusteringBuilderState.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
protected IResourceDescription.Manager getResourceDescriptionManager(URI uri) { IResourceServiceProvider resourceServiceProvider = managerRegistry.getResourceServiceProvider(uri); if (resourceServiceProvider == null) { return null; } return resourceServiceProvider.getResourceDescriptionManager(); }
Example 14
Source File: DocumentBasedDirtyResource.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
protected void initiallyProcessResource(XtextResource resource) { IResourceServiceProvider serviceProvider = resource.getResourceServiceProvider(); if (serviceProvider != null) { IResourceDescription.Manager descriptionManager = serviceProvider.getResourceDescriptionManager(); if (descriptionManager != null) { final IResourceDescription description = descriptionManager.getResourceDescription(resource); if (description != null) copyState(description); } } }
Example 15
Source File: DefaultReferenceFinder.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
@Deprecated protected Map<EObject, URI> createExportedElementsMap(final Resource resource) { return new ForwardingMap<EObject, URI>() { private Map<EObject, URI> delegate; @Override protected Map<EObject, URI> delegate() { if (delegate != null) { return delegate; } URI uri = EcoreUtil2.getPlatformResourceOrNormalizedURI(resource); IResourceServiceProvider resourceServiceProvider = getServiceProviderRegistry().getResourceServiceProvider(uri); if (resourceServiceProvider == null) { return delegate = Collections.emptyMap(); } IResourceDescription.Manager resourceDescriptionManager = resourceServiceProvider.getResourceDescriptionManager(); if (resourceDescriptionManager == null) { return delegate = Collections.emptyMap(); } IResourceDescription resourceDescription = resourceDescriptionManager.getResourceDescription(resource); Map<EObject, URI> exportedElementMap = newIdentityHashMap(); if (resourceDescription != null) { for (IEObjectDescription exportedEObjectDescription : resourceDescription.getExportedObjects()) { EObject eObject = resource.getEObject(exportedEObjectDescription.getEObjectURI().fragment()); if (eObject != null) exportedElementMap.put(eObject, exportedEObjectDescription.getEObjectURI()); } } return delegate = exportedElementMap; } }; }
Example 16
Source File: OpenFileContext.java From n4js with Eclipse Public License 1.0 | 5 votes |
protected IResourceDescription.Manager getResourceDescriptionManager(URI uri) { IResourceServiceProvider resourceServiceProvider = resourceServiceProviderRegistry .getResourceServiceProvider(uri); if (resourceServiceProvider == null) { return null; } return resourceServiceProvider.getResourceDescriptionManager(); }
Example 17
Source File: XStatefulIncrementalBuilder.java From n4js with Eclipse Public License 1.0 | 5 votes |
private Delta buildClustured(Resource resource, XSource2GeneratedMapping newSource2GeneratedMapping, XIndexer.XIndexResult result) { CancelIndicator cancelIndicator = request.getCancelIndicator(); operationCanceledManager.checkCanceled(cancelIndicator); // trigger init resource.getContents(); EcoreUtil2.resolveLazyCrossReferences(resource, CancelIndicator.NullImpl); operationCanceledManager.checkCanceled(cancelIndicator); URI source = resource.getURI(); IResourceServiceProvider serviceProvider = getResourceServiceProvider(resource); IResourceDescription.Manager manager = serviceProvider.getResourceDescriptionManager(); IResourceValidator resourceValidator = serviceProvider.getResourceValidator(); IResourceDescription description = manager.getResourceDescription(resource); SerializableResourceDescription copiedDescription = SerializableResourceDescription.createCopy(description); result.getNewIndex().addDescription(source, copiedDescription); operationCanceledManager.checkCanceled(cancelIndicator); if (request.canValidate()) { List<Issue> issues = resourceValidator.validate(resource, CheckMode.ALL, cancelIndicator); List<LSPIssue> lspIssues = lspIssueConverter.convertToLSPIssues(resource, issues, cancelIndicator); operationCanceledManager.checkCanceled(cancelIndicator); request.setResultIssues(request.getProjectName(), source, lspIssues); boolean proceedGenerate = !request.containsValidationErrors(source); if (proceedGenerate) { operationCanceledManager.checkCanceled(cancelIndicator); generate(resource, newSource2GeneratedMapping, serviceProvider); } else { removeGeneratedFiles(resource.getURI(), newSource2GeneratedMapping); } } IResourceDescription old = context.getOldState().getResourceDescriptions().getResourceDescription(source); return manager.createDelta(old, copiedDescription); }
Example 18
Source File: EagerResourceSetBasedResourceDescriptions.java From n4js with Eclipse Public License 1.0 | 5 votes |
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; IResourceDescription.Manager manager = resourceServiceProvider.getResourceDescriptionManager(); if (manager == null) return null; return manager.getResourceDescription(resource); }
Example 19
Source File: XMIDirtyResource.java From statecharts with Eclipse Public License 1.0 | 4 votes |
public XMIDirtyResource(XMIResource resource, IResourceServiceProvider resourceServiceProvider) { this.resource = resource; this.resourceDescriptionManager = resourceServiceProvider .getResourceDescriptionManager(); }
Example 20
Source File: AbstractScopingTest.java From dsl-devkit with Eclipse Public License 1.0 | 2 votes |
/** * Gets the resource description for a given Xtext resource. * * @param resource * the resource * @return the resource description */ protected final IResourceDescription getResourceDescription(final XtextResource resource) { final IResourceServiceProvider resourceServiceProvider = resource.getResourceServiceProvider(); final IResourceDescription.Manager descriptionManager = resourceServiceProvider.getResourceDescriptionManager(); return descriptionManager.getResourceDescription(resource); }