/*
  * (non-Javadoc)
  * @see
  * org.eclipse.pde.api.tools.internal.search.AbstractProblemDetector#isProblem
  * (org.eclipse.pde.api.tools.internal.provisional.model.IReference)
  */
 @Override
 protected boolean isProblem(IReference reference) {
   // the reference must be in the system library
   try {
     IApiMember member = reference.getMember();
     IApiComponent apiComponent = member.getApiComponent();
     String[] lowestEEs = apiComponent.getLowestEEs();
     if (lowestEEs == null) {
       // this should not be true for Eclipse bundle as they should
       // always have a EE set
       return false;
     }
     loop:
     for (int i = 0, max = lowestEEs.length; i < max; i++) {
       String lowestEE = lowestEEs[i];
       int eeValue = ProfileModifiers.getValue(lowestEE);
       if (eeValue == ProfileModifiers.NO_PROFILE_VALUE) {
         return false;
       }
       if (!((Reference) reference).resolve(eeValue)) {
         /*
          * Make sure that the resolved reference doesn't below to
          * one of the imported package of the current component
          */
         if (apiComponent instanceof BundleComponent) {
           BundleDescription bundle = ((BundleComponent) apiComponent).getBundleDescription();
           ImportPackageSpecification[] importPackages = bundle.getImportPackages();
           String referencedTypeName = reference.getReferencedTypeName();
           int index = referencedTypeName.lastIndexOf('.');
           String packageName = referencedTypeName.substring(0, index);
           for (int j = 0, max2 = importPackages.length; j < max2; j++) {
             ImportPackageSpecification importPackageSpecification = importPackages[j];
             // get the IPackageDescriptor for the element
             // descriptor
             String importPackageName = importPackageSpecification.getName();
             if (importPackageName.equals(packageName)) {
               continue loop;
             }
           }
         }
         if (this.referenceEEs == null) {
           this.referenceEEs = new HashMap<IReference, Integer>(3);
         }
         this.referenceEEs.put(reference, new Integer(eeValue));
         return true;
       }
     }
   } catch (CoreException e) {
     ApiPlugin.log(e);
   }
   return false;
 }
Пример #2
0
 /**
  * This will check the indirect dependencies of <code>model</code> and install the necessary
  * workspace plugins if we need to import some of their packages.
  *
  * @param model The model of which we wish the dependencies checked.
  */
 private void checkImportPackagesDependencies(IPluginModelBase model) {
   final BundleDescription desc = model.getBundleDescription();
   if (desc == null) {
     return;
   }
   for (ImportPackageSpecification importPackage : desc.getImportPackages()) {
     for (IPluginModelBase workspaceModel : PluginRegistry.getWorkspaceModels()) {
       if (workspaceModel != null && workspaceModel.getBundleDescription() != null) {
         for (ExportPackageDescription export :
             workspaceModel.getBundleDescription().getExportPackages()) {
           if (importPackage.isSatisfiedBy(export)) {
             installBundle(workspaceModel);
             break;
           }
         }
       }
     }
   }
 }