Package org.eclipse.core.runtime

Examples of org.eclipse.core.runtime.IPath


      int rootPathSegmentCounts,
      ArrayList collector) {
    IResource resource = unit.getResource();
    char[][] typeNames = state.getDefinedTypeNamesFor(resource.getProjectRelativePath().toString());
    if (typeNames != null) {
      IPath path = unit.getPath().removeFirstSegments(rootPathSegmentCounts).removeLastSegments(1);
      for (int j = 0, max2 = typeNames.length; j < max2; j++) {
        IPath localPath = path.append(new String(typeNames[j]) + ".class"); //$NON-NLS-1$
        IResource member = container.findMember(localPath);
        if (member != null && member.exists()) {
          collector.add(member);
        }
      }
    } else {
      IPath path = unit.getPath().removeFirstSegments(rootPathSegmentCounts).removeLastSegments(1);
      path = path.append(Util.getNameWithoutJavaLikeExtension(unit.getElementName()) + ".class"); //$NON-NLS-1$
      IResource member = container.findMember(path);
      if (member != null && member.exists()) {
        collector.add(member);
      }
    }
View Full Code Here


    if (entry.getEntryKind() != IClasspathEntry.CPE_VARIABLE)
      return entry;

    IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot();
    IPath resolvedPath = JavaCore.getResolvedVariablePath(entry.getPath());
    if (resolvedPath == null)
      return null;

    Object target = JavaModel.getTarget(workspaceRoot, resolvedPath, false);
    if (target == null)
      return null;

    // inside the workspace
    if (target instanceof IResource) {
      IResource resolvedResource = (IResource) target;
      switch (resolvedResource.getType()) {

        case IResource.PROJECT :
          // internal project
          return JavaCore.newProjectEntry(
              resolvedPath,
              entry.getAccessRules(),
              entry.combineAccessRules(),
              entry.getExtraAttributes(),
              entry.isExported());
        case IResource.FILE :
          if (org.aspectj.org.eclipse.jdt.internal.compiler.util.Util.isArchiveFileName(resolvedResource.getName())) {
            // internal binary archive
            return JavaCore.newLibraryEntry(
                resolvedPath,
                getResolvedVariablePath(entry.getSourceAttachmentPath()),
                getResolvedVariablePath(entry.getSourceAttachmentRootPath()),
                entry.getAccessRules(),
                entry.getExtraAttributes(),
                entry.isExported());
          }
          break;

        case IResource.FOLDER :
          // internal binary folder
          return JavaCore.newLibraryEntry(
              resolvedPath,
              getResolvedVariablePath(entry.getSourceAttachmentPath()),
              getResolvedVariablePath(entry.getSourceAttachmentRootPath()),
              entry.getAccessRules(),
              entry.getExtraAttributes(),
              entry.isExported());
      }
    }
    // outside the workspace
    if (target instanceof File) {
      File externalFile = JavaModel.getFile(target);
      if (externalFile != null) {
        String fileName = externalFile.getName().toLowerCase();
        if (fileName.endsWith(SuffixConstants.SUFFIX_STRING_jar) || fileName.endsWith(SuffixConstants.SUFFIX_STRING_zip)) {
          // external binary archive
          return JavaCore.newLibraryEntry(
              resolvedPath,
              getResolvedVariablePath(entry.getSourceAttachmentPath()),
              getResolvedVariablePath(entry.getSourceAttachmentRootPath()),
              entry.getAccessRules(),
              entry.getExtraAttributes(),
              entry.isExported());
        }
      } else { // external binary folder
        if (resolvedPath.isAbsolute()){
          return JavaCore.newLibraryEntry(
              resolvedPath,
              getResolvedVariablePath(entry.getSourceAttachmentPath()),
              getResolvedVariablePath(entry.getSourceAttachmentRootPath()),
              entry.getAccessRules(),
View Full Code Here

    if (count == 0)
      return null;

    // lookup variable
    String variableName = variablePath.segment(0);
    IPath resolvedPath = JavaCore.getClasspathVariable(variableName);
    if (resolvedPath == null)
      return null;

    // append path suffix
    if (count > 1) {
      resolvedPath = resolvedPath.append(variablePath.removeFirstSegments(1));
    }
    return resolvedPath;
  }
View Full Code Here

//        System.out.println("JAVA MODEL - Canonical path is original path (member of workspace)");
//      }
      return externalPath;
    }

    IPath canonicalPath = null;
    try {
      canonicalPath =
        new Path(new File(externalPath.toOSString()).getCanonicalPath());
    } catch (IOException e) {
      // default to original path
//      if (JavaModelManager.VERBOSE) {
//        System.out.println("JAVA MODEL - Canonical path is original path (IOException)");
//      }
      return externalPath;
    }
   
    IPath result;
    int canonicalLength = canonicalPath.segmentCount();
    if (canonicalLength == 0) {
      // the java.io.File canonicalization failed
//      if (JavaModelManager.VERBOSE) {
//        System.out.println("JAVA MODEL - Canonical path is original path (canonical path is empty)");
//      }
      return externalPath;
    } else if (externalPath.isAbsolute()) {
      result = canonicalPath;
    } else {
      // if path is relative, remove the first segments that were added by the java.io.File canonicalization
      // e.g. 'lib/classes.zip' was converted to 'd:/myfolder/lib/classes.zip'
      int externalLength = externalPath.segmentCount();
      if (canonicalLength >= externalLength) {
        result = canonicalPath.removeFirstSegments(canonicalLength - externalLength);
      } else {
//        if (JavaModelManager.VERBOSE) {
//          System.out.println("JAVA MODEL - Canonical path is original path (canonical path is " + canonicalPath.toString() + ")");
//        }
        return externalPath;
      }
    }
   
    // keep device only if it was specified (this is because File.getCanonicalPath() converts '/lib/classed.zip' to 'd:/lib/classes/zip')
    if (externalPath.getDevice() == null) {
      result = result.setDevice(null);
    }
//    if (JavaModelManager.VERBOSE) {
//      System.out.println("JAVA MODEL - Canonical path is " + result.toString());
//    }
    return result;
View Full Code Here

    Map rootToResolvedEntries) throws JavaModelException {
     
    String rootID = ((ClasspathEntry)resolvedEntry).rootID();
    if (rootIDs.contains(rootID)) return;

    IPath projectPath = this.project.getFullPath();
    IPath entryPath = resolvedEntry.getPath();
    IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot();
    IPackageFragmentRoot root = null;
   
    switch(resolvedEntry.getEntryKind()){
     
      // source folder
      case IClasspathEntry.CPE_SOURCE :

        if (projectPath.isPrefixOf(entryPath)){
          if (checkExistency) {
            Object target = JavaModel.getTarget(workspaceRoot, entryPath, checkExistency);
            if (target == null) return;
 
            if (target instanceof IFolder || target instanceof IProject){
              root = getPackageFragmentRoot((IResource)target);
            }
          } else {
            root = getFolderPackageFragmentRoot(entryPath);
          }
        }
        break;

      // internal/external JAR or folder
      case IClasspathEntry.CPE_LIBRARY :
     
        if (referringEntry != null  && !resolvedEntry.isExported()) return;
       
        if (checkExistency) {
          Object target = JavaModel.getTarget(workspaceRoot, entryPath, checkExistency);
          if (target == null) return;
 
          if (target instanceof IResource){
            // internal target
            root = getPackageFragmentRoot((IResource) target);
          } else {
            // external target - only JARs allowed
            if (JavaModel.isFile(target) && (org.aspectj.org.eclipse.jdt.internal.compiler.util.Util.isArchiveFileName(entryPath.lastSegment()))) {
              root = new JarPackageFragmentRoot(entryPath, this);
            }
          }
        } else {
          root = getPackageFragmentRoot(entryPath);
View Full Code Here

   * Assumes that the resource is a folder or a file.
   */
  public boolean contains(IResource resource) {
     
    IClasspathEntry[] classpath;
    IPath output;
    try {
      classpath = getResolvedClasspath();
      output = getOutputLocation();
    } catch (JavaModelException e) {
      return false;
    }
   
    IPath fullPath = resource.getFullPath();
    IPath innerMostOutput = output.isPrefixOf(fullPath) ? output : null;
    IClasspathEntry innerMostEntry = null;
    for (int j = 0, cpLength = classpath.length; j < cpLength; j++) {
      IClasspathEntry entry = classpath[j];
   
      IPath entryPath = entry.getPath();
      if ((innerMostEntry == null || innerMostEntry.getPath().isPrefixOf(entryPath))
          && entryPath.isPrefixOf(fullPath)) {
        innerMostEntry = entry;
      }
      IPath entryOutput = classpath[j].getOutputLocation();
      if (entryOutput != null && entryOutput.isPrefixOf(fullPath)) {
        innerMostOutput = entryOutput;
      }
    }
    if (innerMostEntry != null) {
      // special case prj==src and nested output location
View Full Code Here

          return; // setting == IGNORE
        }
        break;
       
      default:
        IPath path = status.getPath();
        if (path != null) arguments = new String[] { path.toString() };
        if (JavaCore.ERROR.equals(getOption(JavaCore.CORE_INCOMPLETE_CLASSPATH, true)) &&
          status.getSeverity() != IStatus.WARNING) {
          severity = IMarker.SEVERITY_ERROR;
        } else {
          severity = IMarker.SEVERITY_WARNING;
View Full Code Here

          // default to the first one
          return pkgFragments[0];
        }
      } else if (Util.isJavaLikeFileName(path.lastSegment())
          || extension.equalsIgnoreCase(EXTENSION_class)) {
        IPath packagePath = path.removeLastSegments(1);
        String packageName = packagePath.toString().replace(IPath.SEPARATOR, '.');
        String typeName = path.lastSegment();
        typeName = typeName.substring(0, typeName.length() - extension.length() - 1);
        String qualifiedName = null;
        if (packageName.length() > 0) {
          qualifiedName = packageName + "." + typeName; //$NON-NLS-1$
View Full Code Here

   * @see IJavaProject
   */
  public IPath getOutputLocation() throws JavaModelException {
    // Do not create marker while getting output location
    JavaModelManager.PerProjectInfo perProjectInfo = this.getPerProjectInfo();
    IPath outputLocation = perProjectInfo.outputLocation;
    if (outputLocation != null) return outputLocation;
   
    // force to read classpath - will position output location as well
    getRawClasspath();
   
View Full Code Here

        break;
      default:
        isSource = element.getAncestor(IJavaElement.COMPILATION_UNIT) != null;
        break;
    }
    IPath elementPath = element.getPath();
   
    // first look at unresolved entries
    int length = rawClasspath.length;
    for (int i = 0; i < length; i++) {
      IClasspathEntry entry = rawClasspath[i];
View Full Code Here

TOP

Related Classes of org.eclipse.core.runtime.IPath

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.