Ejemplo n.º 1
0
  /*
   * (non-Javadoc)
   *
   * @see IJavaSearchScope#encloses(IModelElement)
   */
  public boolean encloses(IModelElement element) {
    IDLTKLanguageToolkit elementToolkit = DLTKLanguageManager.getLanguageToolkit(element);
    if (!toolkit.getNatureId().equals(elementToolkit.getNatureId())) {
      return false;
    }

    if (this.elements != null) {
      for (int i = 0, length = this.elements.size(); i < length; i++) {
        IModelElement scopeElement = this.elements.get(i);
        IModelElement searchedElement = element;
        while (searchedElement != null) {
          if (searchedElement.equals(scopeElement)) return true;
          searchedElement = searchedElement.getParent();
        }
      }
      return false;
    }
    IProjectFragment root = (IProjectFragment) element.getAncestor(IModelElement.PROJECT_FRAGMENT);
    if (root != null && root.isArchive()) {
      // external or internal archive
      IPath rootPath = root.getPath();
      String rootPathToString = rootPath.toString();
      IPath relativePath = getPath(element, true /* relative path */);
      return indexOf(rootPathToString, relativePath.toString()) >= 0;
    }
    // resource in workspace
    String fullResourcePathString = getPath(element, false /* full path */).toString();
    return indexOf(fullResourcePathString) >= 0;
  }
Ejemplo n.º 2
0
 private boolean natureFilter(IModelElement element) {
   // For all projects scope
   if (toolkit == null) {
     return true;
   }
   IDLTKLanguageToolkit elementToolkit = DLTKLanguageManager.getLanguageToolkit(element);
   if (elementToolkit != null && elementToolkit.getNatureId().equals(toolkit.getNatureId())) {
     // Filter by nature.
     return true;
   }
   return false;
 }
 private static String getNatureFromProject(IScriptProject project) {
   final IDLTKLanguageToolkit languageToolkit = DLTKLanguageManager.getLanguageToolkit(project);
   if (languageToolkit != null) {
     return languageToolkit.getNatureId();
   }
   return null;
 }