public void search(
      ISearchRequestor requestor, QuerySpecification querySpecification, IProgressMonitor monitor)
      throws CoreException {

    if (querySpecification.getLimitTo() != S_LIMIT_REF
        && querySpecification.getLimitTo() != S_LIMIT_ALL) return;

    String search;
    if (querySpecification instanceof ElementQuerySpecification) {
      IJavaElement element = ((ElementQuerySpecification) querySpecification).getElement();
      if (element instanceof IType) search = ((IType) element).getFullyQualifiedName('.');
      else search = element.getElementName();
      int type = element.getElementType();
      if (type == IJavaElement.TYPE) fSearchFor = S_FOR_TYPES;
      else if (type == IJavaElement.PACKAGE_FRAGMENT || type == IJavaElement.PACKAGE_FRAGMENT_ROOT)
        fSearchFor = S_FOR_PACKAGES;
    } else {
      fSearchFor = ((PatternQuerySpecification) querySpecification).getSearchFor();
      search = ((PatternQuerySpecification) querySpecification).getPattern();
    }
    if (fSearchFor != S_FOR_TYPES && fSearchFor != S_FOR_PACKAGES) return;
    fSearchPattern = PatternConstructor.createPattern(search, true);
    fSearchRequestor = requestor;

    IPath[] enclosingPaths = querySpecification.getScope().enclosingProjectsAndJars();
    IPluginModelBase[] pluginModels = PluginRegistry.getWorkspaceModels();
    monitor.beginTask(PDEUIMessages.ClassSearchParticipant_taskMessage, pluginModels.length);
    for (int i = 0; i < pluginModels.length; i++) {
      IProject project = pluginModels[i].getUnderlyingResource().getProject();
      if (!monitor.isCanceled() && encloses(enclosingPaths, project.getFullPath()))
        searchProject(project, monitor);
    }
  }
Example #2
0
 /**
  * This will search through the workspace for a plugin defined with the given symbolic name and
  * return it if any.
  *
  * @param bundleName Symbolic name of the plugin we're searching a workspace project for.
  * @return The workspace project of the given symbolic name, <code>null</code> if none could be
  *     found.
  */
 public static IProject getProject(String bundleName) {
   for (IPluginModelBase model : PluginRegistry.getWorkspaceModels()) {
     if (model.getBundleDescription().getSymbolicName().equals(bundleName)) {
       return model.getUnderlyingResource().getProject();
     }
   }
   return null;
 }
 private void computeUnmigrated() {
   IPluginModelBase[] models = PluginRegistry.getWorkspaceModels();
   ArrayList<IPluginModelBase> modelArray = new ArrayList<IPluginModelBase>();
   try {
     for (int i = 0; i < models.length; i++) {
       if (models[i].getUnderlyingResource().getProject().hasNature(JavaCore.NATURE_ID))
         modelArray.add(models[i]);
     }
   } catch (CoreException e) {
     PDEPlugin.logException(e);
   }
   fUnmigrated = modelArray.toArray(new IPluginModelBase[modelArray.size()]);
 }
Example #4
0
 /**
  * This will check through the dependencies of <code>model</code> and install the necessary
  * workspace plugins if they are required.
  *
  * @param model The model of which we wish the dependencies checked.
  */
 private void checkRequireBundleDependencies(IPluginModelBase model) {
   final BundleDescription desc = model.getBundleDescription();
   if (desc == null) {
     return;
   }
   for (BundleSpecification requiredBundle : desc.getRequiredBundles()) {
     for (IPluginModelBase workspaceModel : PluginRegistry.getWorkspaceModels()) {
       if (requiredBundle.isSatisfiedBy(workspaceModel.getBundleDescription())) {
         installBundle(workspaceModel);
         break;
       }
     }
   }
 }
Example #5
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;
           }
         }
       }
     }
   }
 }