コード例 #1
0
  /**
   * Source elements returned from this method are instances of <code>IFile</code> or <code>
   * LocalFileStorage</code>.
   *
   * @see org.eclipse.debug.core.sourcelookup.ISourceContainer#findSourceElements(String)
   */
  public Object[] findSourceElements(String name) throws CoreException {
    File file = new File(name);
    if (!file.isAbsolute()) {
      file = new File(fDirectory, name);
    }
    List<Object> sources = new ArrayList<Object>();
    if (file.exists() && file.isFile()) {
      sources.addAll(Arrays.asList(SourceUtils.findSourceElements(file, getDirector())));
    } else {
      sources = new ArrayList<Object>();
    }

    // Check sub-folders
    if (fSubfolders && (isFindDuplicates() || sources.isEmpty())) {
      for (ISourceContainer container : getSourceContainers()) {
        Object[] elements = container.findSourceElements(name);
        if (elements == null || elements.length == 0) {
          continue;
        }
        if (isFindDuplicates()) {
          for (Object element : elements) sources.add(element);
        } else {
          sources.add(elements[0]);
          break;
        }
      }
    }

    if (sources.isEmpty()) return EMPTY;
    return sources.toArray();
  }
コード例 #2
0
 @Override
 public boolean canAddSourceContainers(final ISourceLookupDirector director) {
   final ISourceContainer[] containers = director.getSourceContainers();
   for (final ISourceContainer container : containers) {
     if (container.getType().getId().equals(AllRProjectsSourceContainer.TYPE_ID)) {
       return false;
     }
   }
   return true;
 }
コード例 #3
0
 /* (non-Javadoc)
  * @see org.eclipse.debug.core.sourcelookup.containers.CompositeSourceContainer#createSourceContainers()
  */
 protected ISourceContainer[] createSourceContainers() throws CoreException {
   if (fSubfolders) {
     String[] files = fDirectory.list();
     if (files != null) {
       List<ISourceContainer> dirs = new ArrayList<ISourceContainer>();
       for (String name : files) {
         File file = new File(getDirectory(), name);
         if (file.exists() && file.isDirectory()) {
           dirs.add(new CompilationDirectorySourceContainer(file, true));
         }
       }
       ISourceContainer[] containers = dirs.toArray(new ISourceContainer[dirs.size()]);
       for (ISourceContainer container : containers) {
         container.init(getDirector());
       }
       return containers;
     }
   }
   return new ISourceContainer[0];
 }
コード例 #4
0
 /* (non-Javadoc)
  * @see org.eclipse.debug.internal.core.sourcelookup.ISourceContainerType#getMemento(org.eclipse.debug.internal.core.sourcelookup.ISourceContainer)
  */
 public String getMemento(ISourceContainer container) throws CoreException {
   if (this.equals(container.getType())) {
     return getDelegate().getMemento(container);
   }
   IStatus status =
       new Status(
           IStatus.ERROR,
           DebugPlugin.getUniqueIdentifier(),
           DebugPlugin.ERROR,
           SourceLookupMessages.SourceContainerType_0,
           null);
   throw new CoreException(status);
 }
コード例 #5
0
	private IEditorInput findFileInCommonSourceLookup(IPath path)
	{
		try {
			AbstractSourceLookupDirector director = CDebugCorePlugin.getDefault().getCommonSourceLookupDirector();
			ISourceContainer[] c = director.getSourceContainers();
			for (ISourceContainer sourceContainer : c) {
				Object[] o = sourceContainer.findSourceElements(path.toOSString());
				for (Object object : o) {
					if (object instanceof IFile) {
						return new FileEditorInput((IFile)object);
					} else if (object instanceof LocalFileStorage) {
						LocalFileStorage storage = (LocalFileStorage) object;
						IFileStore ifs = EFS.getStore(storage.getFile().toURI());
						return new FileStoreEditorInput(ifs);
					}
				}
			}
		} catch (Exception _) {
			// do nothing
		}
		return null;
	}