Java Code Examples for org.eclipse.xtext.resource.IResourceDescription#getExportedObjectsByType()
The following examples show how to use
org.eclipse.xtext.resource.IResourceDescription#getExportedObjectsByType() .
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: ExternalIndexSynchronizer.java From n4js with Eclipse Public License 1.0 | 6 votes |
private String getVersion(IResourceDescription resourceDescription, SafeURI<?> nestedLocation, N4JSProjectName name, SafeURI<?> packageLocation) { if (!isProjectDescriptionFile(nestedLocation, packageLocation)) { return null; } Iterable<IEObjectDescription> pds = resourceDescription .getExportedObjectsByType(JSONPackage.eINSTANCE.getJSONDocument()); Iterator<IEObjectDescription> pdsIter = pds.iterator(); if (pdsIter.hasNext()) { IEObjectDescription pDescription = pdsIter.next(); String nameFromPackageJSON = PackageJsonResourceDescriptionExtension.getProjectName(pDescription); if (nameFromPackageJSON == null || name.equals(new N4JSProjectName(nameFromPackageJSON))) { // consistency check String version = pDescription.getUserData(PackageJsonResourceDescriptionExtension.PROJECT_VERSION_KEY); return version; } } return null; }
Example 2
Source File: RuleOverrideUtil.java From xtext-eclipse with Eclipse Public License 2.0 | 6 votes |
public List<IEObjectDescription> getOverridingRules(final AbstractRule originalRule) { Grammar grammar = GrammarUtil.getGrammar(originalRule); final List<IEObjectDescription> overridingRules = newArrayList(); IAcceptor<IReferenceDescription> acceptor = new IAcceptor<IReferenceDescription>() { @Override public void accept(IReferenceDescription referenceToGrammar) { if (referenceToGrammar.getEReference() == XtextPackage.Literals.GRAMMAR__USED_GRAMMARS) { IResourceDescription resourceDescription = resourceDescriptions .getResourceDescription(referenceToGrammar.getSourceEObjectUri().trimFragment()); for (IEObjectDescription rule : resourceDescription.getExportedObjectsByType(originalRule.eClass())) { if (Strings.equal(originalRule.getName(), rule.getQualifiedName().getLastSegment())) { overridingRules.add(rule); break; } } } } }; referenceFinder.findAllReferences(singleton(EcoreUtil2.getPlatformResourceOrNormalizedURI(grammar)), localContextProvider, acceptor, new NullProgressMonitor()); return overridingRules; }
Example 3
Source File: JdtTypesProposalProvider.java From xtext-eclipse with Eclipse Public License 2.0 | 6 votes |
/** * @since 2.8 */ protected Set<String> getDirtyTypeNames(){ Iterable<IEObjectDescription> dirtyTypes = dirtyStateManager.getExportedObjectsByType(TypesPackage.Literals.JVM_TYPE); final Set<String> dirtyNames = new HashSet<String>(); for(IEObjectDescription description: dirtyTypes) { dirtyNames.add(description.getQualifiedName().toString()); } for(URI dirtyURI : ((IDirtyStateManagerExtension) dirtyStateManager).getDirtyResourceURIs()){ IResourceDescriptions index = resourceDescriptionsProvider.createPersistedResourceDescriptions(); IResourceDescription indexedResourceDescription = index.getResourceDescription(dirtyURI); if(indexedResourceDescription != null) for(IEObjectDescription desc : indexedResourceDescription.getExportedObjectsByType(TypesPackage.Literals.JVM_TYPE)){ dirtyNames.add(desc.getQualifiedName().toString()); } } return dirtyNames; }
Example 4
Source File: TestDiscoveryHelper.java From n4js with Eclipse Public License 1.0 | 5 votes |
private boolean isTestModule(final ResourceSet resourceSet, final IResourceDescription module) { if (null == module) { return false; } final Iterable<IEObjectDescription> classes = module.getExportedObjectsByType(T_CLASS); return stream(classes).anyMatch(desc -> hasTestMethods(resourceSet, desc)); }
Example 5
Source File: UserDataMapper.java From n4js with Eclipse Public License 1.0 | 5 votes |
private static Optional<List<String>> readDependenciesFromDescription(IResourceDescription description, String userDataKey) { final Iterable<IEObjectDescription> modules = description .getExportedObjectsByType(TypesPackage.Literals.TMODULE); for (IEObjectDescription module : modules) { final String dependenciesStr = module.getUserData(userDataKey); if (dependenciesStr != null) { return Optional.of(splitter.splitToList(dependenciesStr)); } } return Optional.empty(); }
Example 6
Source File: N4JSResource.java From n4js with Eclipse Public License 1.0 | 5 votes |
/** * Populate the contents list from the serialized type data of an {@link IEObjectDescription}. See * {@link #isLoadedFromDescription()} for details on resources that are being loaded from a description. * * @param description * the description that carries the type data in its user data */ public synchronized boolean loadFromDescription(IResourceDescription description) { if (isLoaded) throw new IllegalStateException("Resource was already loaded"); TModule deserializedModule = null; Iterable<IEObjectDescription> modules = description.getExportedObjectsByType(TypesPackage.Literals.TMODULE); for (IEObjectDescription module : modules) { deserializedModule = UserDataMapper.getDeserializedModuleFromDescription(module, getURI()); if (deserializedModule != null) { break; } } if (deserializedModule != null) { boolean wasDeliver = eDeliver(); try { eSetDeliver(false); ModuleAwareContentsList theContents = (ModuleAwareContentsList) getContents(); if (!theContents.isEmpty()) throw new IllegalStateException("There is already something in the contents list: " + theContents); InternalEObject astProxy = (InternalEObject) N4JSFactory.eINSTANCE.createScript(); astProxy.eSetProxyURI(URI.createURI("#" + AST_PROXY_FRAGMENT)); theContents.sneakyAdd(astProxy); theContents.sneakyAdd(deserializedModule); fullyInitialized = true; // TModule loaded from index had been fully post-processed prior to serialization fullyPostProcessed = true; } finally { eSetDeliver(wasDeliver); } return true; } return false; }
Example 7
Source File: EcoreRefactoringParticipant.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
private URI findPlatformResourceURI(QualifiedName name, EClass type) { for (IResourceDescription resourceDescription : resourceDescriptions.getAllResourceDescriptions()) { if (Strings.equal("ecore", resourceDescription.getURI().fileExtension())) { for (IEObjectDescription eObjectDescription : resourceDescription.getExportedObjectsByType(type)) { if (name.equals(eObjectDescription.getQualifiedName())) { return eObjectDescription.getEObjectURI(); } } } } return null; }