Examples of IClasspathEntry


Examples of org.aspectj.org.eclipse.jdt.core.IClasspathEntry

   * Resolve the given raw classpath.
   */
  public IClasspathEntry[] resolveClasspath(IClasspathEntry[] rawClasspath) throws JavaModelException {
    ArrayList resolvedEntries = new ArrayList();
    for (int i = 0, length = rawClasspath.length; i < length; i++) {
      IClasspathEntry rawEntry = rawClasspath[i];
      switch (rawEntry.getEntryKind()){
        case IClasspathEntry.CPE_VARIABLE:
          IClasspathEntry resolvedEntry = null;
          try {
            resolvedEntry = JavaCore.getResolvedClasspathEntry(rawEntry);
          } catch (AssertionFailedException e) {
            // Catch the assertion failure
            // see bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=55992
View Full Code Here

Examples of org.aspectj.org.eclipse.jdt.core.IClasspathEntry

     
      ArrayList resolvedEntries = new ArrayList();
      int length = rawClasspath.length;
      for (int i = 0; i < length; i++) {
 
        IClasspathEntry rawEntry = rawClasspath[i];
        IPath resolvedPath;
       
        switch (rawEntry.getEntryKind()){
         
          case IClasspathEntry.CPE_VARIABLE :
            IClasspathEntry resolvedEntry = null;
            try {
              resolvedEntry = JavaCore.getResolvedClasspathEntry(rawEntry);
            } catch (AssertionFailedException e) {
              // Catch the assertion failure and set ststus instead
              // see bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=55992
              unresolvedEntryStatus = new JavaModelStatus(IJavaModelStatusConstants.INVALID_PATH, e.getMessage());
              break;
            }
            if (resolvedEntry == null) {
              unresolvedEntryStatus = new JavaModelStatus(IJavaModelStatusConstants.CP_VARIABLE_PATH_UNBOUND, this, rawEntry.getPath());
            } else {
              if (rawReverseMap.get(resolvedPath = resolvedEntry.getPath()) == null) {
                rawReverseMap.put(resolvedPath , rawEntry);
                rootPathToResolvedEntries.put(resolvedPath, resolvedEntry);
              }
              resolvedEntries.add(resolvedEntry);
            }
View Full Code Here

Examples of org.aspectj.org.eclipse.jdt.core.IClasspathEntry

    try {
      IClasspathEntry[] classpath = null;
      if (preferredClasspaths != null) classpath = (IClasspathEntry[])preferredClasspaths.get(this);
      if (classpath == null) classpath = getResolvedClasspath();
      for (int i = 0, length = classpath.length; i < length; i++) {
        IClasspathEntry entry = classpath[i];
       
        if (entry.getEntryKind() == IClasspathEntry.CPE_PROJECT){
          IPath prereqProjectPath = entry.getPath();
          int index = cycleParticipants.contains(prereqProjectPath) ? 0 : prereqChain.indexOf(prereqProjectPath);
          if (index >= 0) { // refer to cycle, or in cycle itself
            for (int size = prereqChain.size(); index < size; index++) {
              cycleParticipants.add(prereqChain.get(index));
            }
View Full Code Here

Examples of org.aspectj.org.eclipse.jdt.core.IClasspathEntry

        }
      }
    }

    // recreate the CP entry
    IClasspathEntry entry = null;
    switch (kind) {

      case IClasspathEntry.CPE_PROJECT :
        entry = new ClasspathEntry(
        IPackageFragmentRoot.K_SOURCE,
View Full Code Here

Examples of org.aspectj.org.eclipse.jdt.core.IClasspathEntry

    int sourceEntryCount = 0;
    boolean disableExclusionPatterns = JavaCore.DISABLED.equals(javaProject.getOption(JavaCore.CORE_ENABLE_CLASSPATH_EXCLUSION_PATTERNS, true));
    boolean disableCustomOutputLocations = JavaCore.DISABLED.equals(javaProject.getOption(JavaCore.CORE_ENABLE_CLASSPATH_MULTIPLE_OUTPUT_LOCATIONS, true));

    for (int i = 0 ; i < length; i++) {
      IClasspathEntry resolvedEntry = classpath[i];
      if (disableExclusionPatterns &&
              ((resolvedEntry.getInclusionPatterns() != null && resolvedEntry.getInclusionPatterns().length > 0)
              || (resolvedEntry.getExclusionPatterns() != null && resolvedEntry.getExclusionPatterns().length > 0))) {
        return new JavaModelStatus(IJavaModelStatusConstants.DISABLED_CP_EXCLUSION_PATTERNS, javaProject, resolvedEntry.getPath());
      }
      switch(resolvedEntry.getEntryKind()){
        case IClasspathEntry.CPE_SOURCE :
          sourceEntryCount++;

          IPath customOutput;
          if ((customOutput = resolvedEntry.getOutputLocation()) != null) {

            if (disableCustomOutputLocations) {
              return new JavaModelStatus(IJavaModelStatusConstants.DISABLED_CP_MULTIPLE_OUTPUT_LOCATIONS, javaProject, resolvedEntry.getPath());
            }
            // ensure custom output is in project
            if (customOutput.isAbsolute()) {
              if (!javaProject.getPath().isPrefixOf(customOutput)) {
                return new JavaModelStatus(IJavaModelStatusConstants.PATH_OUTSIDE_PROJECT, javaProject, customOutput.toString());
              }
            } else {
              return new JavaModelStatus(IJavaModelStatusConstants.RELATIVE_PATH, customOutput);
            }

            // ensure custom output doesn't conflict with other outputs
            // check exact match
            if (Util.indexOfMatchingPath(customOutput, outputLocations, outputCount) != -1) {
              continue; // already found
            }
            // accumulate all outputs, will check nesting once all available (to handle ordering issues)
            outputLocations[outputCount++] = customOutput;
          }
      }
    }
    // check nesting across output locations
    for (int i = 1 /*no check for default output*/ ; i < outputCount; i++) {
        IPath customOutput = outputLocations[i];
        int index;
      // check nesting
      if ((index = Util.indexOfEnclosingPath(customOutput, outputLocations, outputCount)) != -1 && index != i) {
        if (index == 0) {
          // custom output is nested in project's output: need to check if all source entries have a custom
          // output before complaining
          if (potentialNestedOutput == null) potentialNestedOutput = customOutput;
        } else {
          return new JavaModelStatus(IJavaModelStatusConstants.INVALID_CLASSPATH, Messages.bind(Messages.classpath_cannotNestOutputInOutput, new String[] {customOutput.makeRelative().toString(), outputLocations[index].makeRelative().toString()}));
        }
      }
    }
    // allow custom output nesting in project's output if all source entries have a custom output
    if (sourceEntryCount <= outputCount-1) {
        allowNestingInOutputLocations[0] = true;
    } else if (potentialNestedOutput != null) {
      return new JavaModelStatus(IJavaModelStatusConstants.INVALID_CLASSPATH, Messages.bind(Messages.classpath_cannotNestOutputInOutput, new String[] {potentialNestedOutput.makeRelative().toString(), outputLocations[0].makeRelative().toString()}));
    }

    for (int i = 0 ; i < length; i++) {
      IClasspathEntry resolvedEntry = classpath[i];
      IPath path = resolvedEntry.getPath();
      int index;
      switch(resolvedEntry.getEntryKind()){

        case IClasspathEntry.CPE_SOURCE :
          hasSource = true;
          if ((index = Util.indexOfMatchingPath(path, outputLocations, outputCount)) != -1){
            allowNestingInOutputLocations[index] = true;
          }
          break;

        case IClasspathEntry.CPE_LIBRARY:
          hasLibFolder |= !org.aspectj.org.eclipse.jdt.internal.compiler.util.Util.isArchiveFileName(path.lastSegment());
          if ((index = Util.indexOfMatchingPath(path, outputLocations, outputCount)) != -1){
            allowNestingInOutputLocations[index] = true;
          }
          break;
      }
    }
    if (!hasSource && !hasLibFolder) { // if no source and no lib folder, then allowed
      for (int i = 0; i < outputCount; i++) allowNestingInOutputLocations[i] = true;
    }

    HashSet pathes = new HashSet(length);

    // check all entries
    for (int i = 0 ; i < length; i++) {
      IClasspathEntry entry = classpath[i];
      if (entry == null) continue;
      IPath entryPath = entry.getPath();
      int kind = entry.getEntryKind();

      // Build some common strings for status message
      boolean isProjectRelative = projectName.equals(entryPath.segment(0));
      String entryPathMsg = isProjectRelative ? entryPath.removeFirstSegments(1).toString() : entryPath.makeRelative().toString();

      // complain if duplicate path
      if (!pathes.add(entryPath)){
        return new JavaModelStatus(IJavaModelStatusConstants.NAME_COLLISION, Messages.bind(Messages.classpath_duplicateEntryPath, new String[] {entryPathMsg, projectName}));
      }
      // no further check if entry coincidates with project or output location
      if (entryPath.equals(projectPath)){
        // complain if self-referring project entry
        if (kind == IClasspathEntry.CPE_PROJECT){
          return new JavaModelStatus(IJavaModelStatusConstants.INVALID_PATH, Messages.bind(Messages.classpath_cannotReferToItself, entryPath.makeRelative().toString()));
        }
        // tolerate nesting output in src if src==prj
        continue;
      }

      // allow nesting source entries in each other as long as the outer entry excludes the inner one
      if (kind == IClasspathEntry.CPE_SOURCE
          || (kind == IClasspathEntry.CPE_LIBRARY && !org.aspectj.org.eclipse.jdt.internal.compiler.util.Util.isArchiveFileName(entryPath.lastSegment()))){
        for (int j = 0; j < classpath.length; j++){
          IClasspathEntry otherEntry = classpath[j];
          if (otherEntry == null) continue;
          int otherKind = otherEntry.getEntryKind();
          IPath otherPath = otherEntry.getPath();
          if (entry != otherEntry
            && (otherKind == IClasspathEntry.CPE_SOURCE
                || (otherKind == IClasspathEntry.CPE_LIBRARY
                    && !org.aspectj.org.eclipse.jdt.internal.compiler.util.Util.isArchiveFileName(otherPath.lastSegment())))){
            char[][] inclusionPatterns, exclusionPatterns;
            if (otherPath.isPrefixOf(entryPath)
                && !otherPath.equals(entryPath)
                && !Util.isExcluded(entryPath.append("*"), inclusionPatterns = ((ClasspathEntry)otherEntry).fullInclusionPatternChars(), exclusionPatterns = ((ClasspathEntry)otherEntry).fullExclusionPatternChars(), false)) { //$NON-NLS-1$
              String exclusionPattern = entryPath.removeFirstSegments(otherPath.segmentCount()).segment(0);
              if (Util.isExcluded(entryPath, inclusionPatterns, exclusionPatterns, false)) {
                return new JavaModelStatus(IJavaModelStatusConstants.INVALID_CLASSPATH, Messages.bind(Messages.classpath_mustEndWithSlash, new String[] {exclusionPattern, entryPath.makeRelative().toString()}));
              } else {
                if (otherKind == IClasspathEntry.CPE_SOURCE) {
                  exclusionPattern += '/';
                  if (!disableExclusionPatterns) {
                    return new JavaModelStatus(IJavaModelStatusConstants.INVALID_CLASSPATH, Messages.bind(Messages.classpath_cannotNestEntryInEntry, new String[] {entryPath.makeRelative().toString(), otherEntry.getPath().makeRelative().toString(), exclusionPattern}));
                  } else {
                    return new JavaModelStatus(IJavaModelStatusConstants.INVALID_CLASSPATH, Messages.bind(Messages.classpath_cannotNestEntryInEntryNoExclusion, new String[] {entryPath.makeRelative().toString(), otherEntry.getPath().makeRelative().toString(), exclusionPattern}));
                  }
                } else {
                  return new JavaModelStatus(IJavaModelStatusConstants.INVALID_CLASSPATH, Messages.bind(Messages.classpath_cannotNestEntryInLibrary, new String[] {entryPath.makeRelative().toString(), otherEntry.getPath().makeRelative().toString()}));
                }
              }
            }
          }
        }
      }

      // prevent nesting output location inside entry unless enclosing is a source entry which explicitly exclude the output location
        char[][] inclusionPatterns = ((ClasspathEntry)entry).fullInclusionPatternChars();
        char[][] exclusionPatterns = ((ClasspathEntry)entry).fullExclusionPatternChars();
        for (int j = 0; j < outputCount; j++){
            IPath currentOutput = outputLocations[j];
          if (entryPath.equals(currentOutput)) continue;
        if (entryPath.isPrefixOf(currentOutput)) {
            if (kind != IClasspathEntry.CPE_SOURCE || !Util.isExcluded(currentOutput, inclusionPatterns, exclusionPatterns, true)) {
            return new JavaModelStatus(IJavaModelStatusConstants.INVALID_CLASSPATH, Messages.bind(Messages.classpath_cannotNestOutputInEntry, new String[] {currentOutput.makeRelative().toString(), entryPath.makeRelative().toString()}));
            }
        }
        }

        // prevent nesting entry inside output location - when distinct from project or a source folder
        for (int j = 0; j < outputCount; j++){
            if (allowNestingInOutputLocations[j]) continue;
            IPath currentOutput = outputLocations[j];
        if (currentOutput.isPrefixOf(entryPath)) {
          return new JavaModelStatus(IJavaModelStatusConstants.INVALID_CLASSPATH, Messages.bind(Messages.classpath_cannotNestEntryInOutput, new String[] {entryPath.makeRelative().toString(), currentOutput.makeRelative().toString()}));
        }
        }
    }
    // ensure that no specific output is coincidating with another source folder (only allowed if matching current source folder)
    // 36465 - for 2.0 backward compatibility, only check specific output locations (the default can still coincidate)
    // perform one separate iteration so as to not take precedence over previously checked scenarii (in particular should
    // diagnose nesting source folder issue before this one, for example, [src]"Project/", [src]"Project/source/" and output="Project/" should
    // first complain about missing exclusion pattern
    for (int i = 0 ; i < length; i++) {
      IClasspathEntry entry = classpath[i];
      if (entry == null) continue;
      IPath entryPath = entry.getPath();
      int kind = entry.getEntryKind();

      // Build some common strings for status message
      boolean isProjectRelative = projectName.equals(entryPath.segment(0));
      String entryPathMsg = isProjectRelative ? entryPath.removeFirstSegments(1).toString() : entryPath.makeRelative().toString();

      if (kind == IClasspathEntry.CPE_SOURCE) {
        IPath output = entry.getOutputLocation();
        if (output == null) continue; // 36465 - for 2.0 backward compatibility, only check specific output locations (the default can still coincidate)
        // if (output == null) output = projectOutputLocation; // if no specific output, still need to check using default output (this line would check default output)
        for (int j = 0; j < length; j++) {
          IClasspathEntry otherEntry = classpath[j];
          if (otherEntry == entry) continue;

          // Build some common strings for status message
          boolean opStartsWithProject = projectName.equals(otherEntry.getPath().segment(0));
          String otherPathMsg = opStartsWithProject ? otherEntry.getPath().removeFirstSegments(1).toString() : otherEntry.getPath().makeRelative().toString();

          switch (otherEntry.getEntryKind()) {
            case IClasspathEntry.CPE_SOURCE :
              if (otherEntry.getPath().equals(output)) {
                return new JavaModelStatus(IJavaModelStatusConstants.INVALID_CLASSPATH, Messages.bind(Messages.classpath_cannotUseDistinctSourceFolderAsOutput, new String[] {entryPathMsg, otherPathMsg, projectName}));
              }
              break;
            case IClasspathEntry.CPE_LIBRARY :
              if (otherEntry.getPath().equals(output)) {
                return new JavaModelStatus(IJavaModelStatusConstants.INVALID_CLASSPATH, Messages.bind(Messages.classpath_cannotUseLibraryAsOutput, new String[] {entryPathMsg, otherPathMsg, projectName}));
              }
          }
        }
      }
View Full Code Here

Examples of org.aspectj.org.eclipse.jdt.core.IClasspathEntry

              return JavaModelStatus.VERIFIED_OK;
            }
            IClasspathEntry[] containerEntries = container.getClasspathEntries();
            if (containerEntries != null){
              for (int i = 0, length = containerEntries.length; i < length; i++){
                IClasspathEntry containerEntry = containerEntries[i];
                int kind = containerEntry == null ? 0 : containerEntry.getEntryKind();
                if (containerEntry == null
                  || kind == IClasspathEntry.CPE_SOURCE
                  || kind == IClasspathEntry.CPE_VARIABLE
                  || kind == IClasspathEntry.CPE_CONTAINER){
                    String description = container.getDescription();
View Full Code Here

Examples of org.aspectj.org.eclipse.jdt.core.IClasspathEntry

          boolean[] foundChildren = new boolean[children.getLength()];
          NodeList attributeList = ClasspathEntry.getChildAttributes(ClasspathEntry.TAG_ATTRIBUTES, children, foundChildren);
          IClasspathAttribute[] extraAttributes = ClasspathEntry.decodeExtraAttributes(attributeList);
          attributeList = ClasspathEntry.getChildAttributes(ClasspathEntry.TAG_ACCESS_RULES, children, foundChildren);
          IAccessRule[] accessRules = ClasspathEntry.decodeAccessRules(attributeList);
          IClasspathEntry entry = JavaCore.newLibraryEntry(new Path(path), sourceAttach, sourceAttachRoot, accessRules, extraAttributes, false/*not exported*/);
          res.add(entry);
        }
      }
    }
   
 
View Full Code Here

Examples of org.aspectj.org.eclipse.jdt.core.IClasspathEntry

        ArrayList affectedProjects = new ArrayList();
        for (int i= 0; i < allJavaProjects.length; i++) {
          IJavaProject javaProject = allJavaProjects[i];
          IClasspathEntry[] entries= javaProject.getRawClasspath();
          for (int j= 0; j < entries.length; j++) {
            IClasspathEntry entry = entries[j];
            if (entry.getEntryKind() == IClasspathEntry.CPE_CONTAINER) {
              if (containerPath.equals(entry.getPath())) {
                affectedProjects.add(javaProject);
                break;
              }       
            }
          }
View Full Code Here

Examples of org.aspectj.org.eclipse.jdt.core.IClasspathEntry

      IClasspathEntry[] entries = javaProject.getRawClasspath();
      int length = entries.length;
      IClasspathEntry[] sourceEntries = new IClasspathEntry[length];
      int sourceEntriesNumber = 0;
      for (int i = 0; i < length; i++) {
        IClasspathEntry entry = entries[i];
        if (entry.getEntryKind() == IClasspathEntry.CPE_SOURCE)
          sourceEntries[sourceEntriesNumber++] = entry;
      }
      if (sourceEntriesNumber == 0) {
        IPath projectPath = javaProject.getPath();
        for (int i = 0; i < length; i++) {
          IClasspathEntry entry = entries[i];
          if (entry.getEntryKind() == IClasspathEntry.CPE_LIBRARY && entry.getPath().equals(projectPath)) {
            // the project is also a library folder (see https://bugs.eclipse.org/bugs/show_bug.cgi?id=89815)
            // ensure a job exists to index it as a binary folder
            this.manager.indexLibrary(projectPath, this.project);
            return true;
          }
        }

        // nothing to index but want to save an empty index file so its not 'rebuilt' when part of a search request
        Index index = this.manager.getIndexForUpdate(this.containerPath, true, /*reuse index file*/ true /*create if none*/);
        if (index != null)
          this.manager.saveIndex(index);
        return true;
      }
      if (sourceEntriesNumber != length)
        System.arraycopy(sourceEntries, 0, sourceEntries = new IClasspathEntry[sourceEntriesNumber], 0, sourceEntriesNumber);
 
      Index index = this.manager.getIndexForUpdate(this.containerPath, true, /*reuse index file*/ true /*create if none*/);
      if (index == null) return true;
      monitor = index.monitor;
      if (monitor == null) return true; // index got deleted since acquired
     
      monitor.enterRead(); // ask permission to read

      String[] paths = index.queryDocumentNames(""); // all file names //$NON-NLS-1$
      int max = paths == null ? 0 : paths.length;
      final SimpleLookupTable indexedFileNames = new SimpleLookupTable(max == 0 ? 33 : max + 11);
      final String OK = "OK"; //$NON-NLS-1$
      final String DELETED = "DELETED"; //$NON-NLS-1$
      if (paths != null) {
        for (int i = 0; i < max; i++)
          indexedFileNames.put(paths[i], DELETED);
      }
      final long indexLastModified = max == 0 ? 0L : index.getIndexFile().lastModified();

      IWorkspaceRoot root = this.project.getWorkspace().getRoot();
      for (int i = 0; i < sourceEntriesNumber; i++) {
        if (this.isCancelled) return false;

        IClasspathEntry entry = sourceEntries[i];
        IResource sourceFolder = root.findMember(entry.getPath());
        if (sourceFolder != null) {
         
          // collect output locations if source is project (see http://bugs.eclipse.org/bugs/show_bug.cgi?id=32041)
          final HashSet outputs = new HashSet();
          if (sourceFolder.getType() == IResource.PROJECT) {
View Full Code Here

Examples of org.aspectj.org.eclipse.jdt.core.IClasspathEntry

      //  e.g. org.eclipse.swt.win32/ws/win32/swt.jar
      //        is NOT on the classpath of org.eclipse.swt.win32
      IFile jarFile = (IFile)target;
      JavaProject javaProject = (JavaProject) this.javaModel.getJavaProject(jarFile);
      try {
        IClasspathEntry entry = javaProject.getClasspathEntryFor(jarPath);
        if (entry != null) {
          return javaProject.getPackageFragmentRoot(jarFile);
        }
      } catch (JavaModelException e) {
        // ignore and try to find another project
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.