protected boolean checkImportedNamespaceExists(String importedNamespace, Resource res) {
   if (importedNamespace.endsWith(".*")) {
     importedNamespace = importedNamespace.substring(0, importedNamespace.length() - 2); // remove
     // wildcard
   }
   IResourceDescriptions resourceDescriptions =
       resourceDescriptionsProvider.getResourceDescriptions(res);
   URI uri = res.getURI();
   IResourceDescription resourceDescription = resourceDescriptions.getResourceDescription(uri);
   if (resourceDescription == null) {
     return false; // no resource description could be found, so package
     // cannot be resolved anyway
   }
   for (IContainer container :
       containerManager.getVisibleContainers(resourceDescription, resourceDescriptions)) {
     final Iterable<IResourceDescription> currentDescriptions =
         container.getResourceDescriptions();
     for (IResourceDescription resDesc : currentDescriptions) {
       Iterable<IEObjectDescription> visiblePackages =
           resDesc.getExportedObjectsByType(TypesPackage.Literals.PACKAGE);
       for (IEObjectDescription pkgDesc : visiblePackages) {
         if (pkgDesc.getName().toString().equals(importedNamespace)) {
           return true;
         }
       }
     }
   }
   return false;
 }
 private boolean atLeastOnePackageExistsInIndex(Resource res) {
   IResourceDescriptions resourceDescriptions =
       resourceDescriptionsProvider.getResourceDescriptions(res);
   URI uri = res.getURI();
   IResourceDescription resourceDescription = resourceDescriptions.getResourceDescription(uri);
   for (IContainer container :
       containerManager.getVisibleContainers(resourceDescription, resourceDescriptions)) {
     final Iterable<IResourceDescription> currentDescriptions =
         container.getResourceDescriptions();
     for (IResourceDescription resDesc : currentDescriptions) {
       Iterable<IEObjectDescription> visisblePackages =
           resDesc.getExportedObjectsByType(TypesPackage.Literals.PACKAGE);
       if (!Iterables.isEmpty(visisblePackages)) {
         return true;
       }
     }
   }
   return false;
 }
Beispiel #3
0
  protected void cacheMetaParameters(EObject scopeDetermeningObject) {
    // System.err.println("Computing meta cache");
    metaCache = Maps.newHashMap();
    Resource scopeDetermeningResource = scopeDetermeningObject.eResource();

    IResourceDescriptions descriptionIndex =
        indexProvider.getResourceDescriptions(scopeDetermeningResource);
    IResourceDescription descr =
        descriptionIndex.getResourceDescription(scopeDetermeningResource.getURI());
    if (descr == null) return; // give up - some sort of clean build
    EClass wantedType = PPTPPackage.Literals.TYPE_ARGUMENT;
    for (IContainer visibleContainer : manager.getVisibleContainers(descr, descriptionIndex)) {
      for (IEObjectDescription objDesc : visibleContainer.getExportedObjects()) {
        QualifiedName q = objDesc.getQualifiedName();
        if ("Type".equals(q.getFirstSegment())) {
          if (wantedType == objDesc.getEClass() || wantedType.isSuperTypeOf(objDesc.getEClass()))
            metaCache.put(q.getLastSegment(), objDesc);
        }
      }
    }
  }