コード例 #1
0
 protected Object internalGetParent(Object element) {
   // since we insert logical package containers we have to fix
   // up the parent for package fragment roots so that they refer
   // to the container and containers refere to the project
   //
   if (element instanceof ISourceFolderRoot) {
     ISourceFolderRoot root = (ISourceFolderRoot) element;
     IRubyProject project = root.getRubyProject();
     try {
       ILoadpathEntry[] entries = project.getRawLoadpath();
       for (int i = 0; i < entries.length; i++) {
         ILoadpathEntry entry = entries[i];
         if (entry.getEntryKind() == ILoadpathEntry.CPE_CONTAINER) {
           if (LoadPathContainer.contains(project, entry, root))
             return new LoadPathContainer(project, entry);
         }
       }
     } catch (RubyModelException e) {
       // fall through
     }
   }
   if (element instanceof LoadPathContainer) {
     return ((LoadPathContainer) element).getRubyProject();
   }
   return super.internalGetParent(element);
 }
コード例 #2
0
ファイル: IndexManager.java プロジェクト: aptana/rdt
  /**
   * Trigger addition of the entire content of a project Note: the actual operation is performed in
   * background
   */
  public void indexAll(IProject project) {
    if (RubyCore.getPlugin() == null) return;

    // Also request indexing of binaries on the classpath
    // determine the new children
    try {
      RubyModel model = RubyModelManager.getRubyModelManager().getRubyModel();
      RubyProject javaProject = (RubyProject) model.getRubyProject(project);
      // only consider immediate libraries - each project will do the same
      // NOTE: force to resolve CP variables before calling indexer - 19303, so that initializers
      // will be run in the current thread.
      ILoadpathEntry[] entries =
          javaProject.getResolvedLoadpath(
              true /* ignoreUnresolvedEntry */, false /* don't generateMarkerOnError */, false /*
																													 * don't
																													 * returnResolutionInProgress
																													 */);
      for (int i = 0; i < entries.length; i++) {
        ILoadpathEntry entry = entries[i];
        if (entry.getEntryKind() == ILoadpathEntry.CPE_LIBRARY)
          this.indexLibrary(entry.getPath(), project);
      }
    } catch (RubyModelException e) { // cannot retrieve classpath info
    }

    // check if the same request is not already in the queue
    IndexRequest request = new IndexAllProject(project, this);
    if (!isJobWaiting(request)) this.request(request);
  }
コード例 #3
0
  private Object[] rootsAndContainers(IRubyProject project, Object[] roots)
      throws RubyModelException {
    List result = new ArrayList(roots.length);
    Set containers = new HashSet(roots.length);
    Set containedRoots = new HashSet(roots.length);

    ILoadpathEntry[] entries = project.getRawLoadpath();
    for (int i = 0; i < entries.length; i++) {
      ILoadpathEntry entry = entries[i];
      if (entry != null && entry.getEntryKind() == ILoadpathEntry.CPE_CONTAINER) {
        ISourceFolderRoot[] roots1 = project.findSourceFolderRoots(entry);
        containedRoots.addAll(Arrays.asList(roots1));
        containers.add(entry);
      }
    }
    for (int i = 0; i < roots.length; i++) {
      if (roots[i] instanceof ISourceFolderRoot) {
        if (!containedRoots.contains(roots[i])) {
          result.add(roots[i]);
        }
      } else {
        result.add(roots[i]);
      }
    }
    for (Iterator each = containers.iterator(); each.hasNext(); ) {
      ILoadpathEntry element = (ILoadpathEntry) each.next();
      result.add(new LoadPathContainer(project, element));
    }
    return result.toArray();
  }