Package org.eclipse.jdt.core

Examples of org.eclipse.jdt.core.IClasspathEntry


    List rawLibrariesPath = new ArrayList();
    LinkedHashSet resolvedEntries = new LinkedHashSet();
   
    if(resolveChainedLibraries) {
      for (int index = 0; index < rawClasspath.length; index++) {
        IClasspathEntry currentEntry = rawClasspath[index];
        if (currentEntry.getEntryKind() == IClasspathEntry.CPE_LIBRARY) {
          rawLibrariesPath.add(ClasspathEntry.resolveDotDot(getProject().getLocation(), currentEntry.getPath()));
        }
      }
      if (referencedEntries != null) {
        // The Set is required to keep the order intact while the referencedEntriesMap (Map)
        // is used to map the referenced entries with path
        LinkedHashSet referencedEntriesSet = new LinkedHashSet();
        for (int index = 0; index < referencedEntries.length; index++) {
          IPath path = referencedEntries[index].getPath();
          if (!rawLibrariesPath.contains(path) && referencedEntriesMap.get(path) == null) {
            referencedEntriesMap.put(path, referencedEntries[index]);
            referencedEntriesSet.add(referencedEntries[index]);
          }
        }
        if (referencedEntriesSet.size() > 0) {
          result.referencedEntries = new IClasspathEntry[referencedEntriesSet.size()];
          referencedEntriesSet.toArray(result.referencedEntries);
        }
      }
    }
   
    int length = rawClasspath.length;
    for (int i = 0; i < length; i++) {

      IClasspathEntry rawEntry = rawClasspath[i];
      IClasspathEntry resolvedEntry = rawEntry;

      switch (rawEntry.getEntryKind()){

        case IClasspathEntry.CPE_VARIABLE :
          try {
            resolvedEntry = manager.resolveVariableEntry(rawEntry, usePreviousSession);
          } catch (ClasspathEntry.AssertionFailedException e) {
            // Catch the assertion failure and set status instead
            // see bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=55992
            result.unresolvedEntryStatus = new JavaModelStatus(IJavaModelStatusConstants.INVALID_PATH, e.getMessage());
            break;
          }
          if (resolvedEntry == null) {
            result.unresolvedEntryStatus = new JavaModelStatus(IJavaModelStatusConstants.CP_VARIABLE_PATH_UNBOUND, this, rawEntry.getPath());
          } else {
            // If the entry is already present in the rawReversetMap, it means the entry and the chained libraries
            // have already been processed. So, skip it.
            if (resolveChainedLibraries && resolvedEntry.getEntryKind() == IClasspathEntry.CPE_LIBRARY
                          && result.rawReverseMap.get(resolvedEntry.getPath()) == null) {
              // resolve Class-Path: in manifest
              ClasspathEntry[] extraEntries = ((ClasspathEntry) resolvedEntry).resolvedChainedLibraries();
              for (int j = 0, length2 = extraEntries.length; j < length2; j++) {
                if (!rawLibrariesPath.contains(extraEntries[j].getPath())) {
                  // https://bugs.eclipse.org/bugs/show_bug.cgi?id=305037
                  // referenced entries for variable entries could also be persisted with extra attributes, so addAsChainedEntry = true
                  addToResult(rawEntry, extraEntries[j], result, resolvedEntries, externalFoldersManager, referencedEntriesMap, true, knownDrives);
                }
              }
            }
            addToResult(rawEntry, resolvedEntry, result, resolvedEntries, externalFoldersManager, referencedEntriesMap, false, knownDrives);
          }
          break;

        case IClasspathEntry.CPE_CONTAINER :
          IClasspathContainer container = usePreviousSession ? manager.getPreviousSessionContainer(rawEntry.getPath(), this) : JavaCore.getClasspathContainer(rawEntry.getPath(), this);
          if (container == null){
            result.unresolvedEntryStatus = new JavaModelStatus(IJavaModelStatusConstants.CP_CONTAINER_PATH_UNBOUND, this, rawEntry.getPath());
            break;
          }

          IClasspathEntry[] containerEntries = container.getClasspathEntries();
          if (containerEntries == null) {
            if (JavaModelManager.CP_RESOLVE_VERBOSE || JavaModelManager.CP_RESOLVE_VERBOSE_FAILURE) {
              JavaModelManager.getJavaModelManager().verbose_missbehaving_container_null_entries(this, rawEntry.getPath());
            }
            break;
          }

          // container was bound
          for (int j = 0, containerLength = containerEntries.length; j < containerLength; j++){
            ClasspathEntry cEntry = (ClasspathEntry) containerEntries[j];
            if (cEntry == null) {
              if (JavaModelManager.CP_RESOLVE_VERBOSE || JavaModelManager.CP_RESOLVE_VERBOSE_FAILURE) {
                JavaModelManager.getJavaModelManager().verbose_missbehaving_container(this, rawEntry.getPath(), containerEntries);
              }
              break;
            }
            // if container is exported or restricted, then its nested entries must in turn be exported  (21749) and/or propagate restrictions
            cEntry = cEntry.combineWith((ClasspathEntry) rawEntry);
           
            if (cEntry.getEntryKind() == IClasspathEntry.CPE_LIBRARY) {
              // resolve ".." in library path
              cEntry = cEntry.resolvedDotDot(getProject().getLocation());
              // https://bugs.eclipse.org/bugs/show_bug.cgi?id=313965
              // Do not resolve if the system attribute is set to false 
              if (resolveChainedLibraries
                  && JavaModelManager.getJavaModelManager().resolveReferencedLibrariesForContainers
                  && result.rawReverseMap.get(cEntry.getPath()) == null) {
                // resolve Class-Path: in manifest
                ClasspathEntry[] extraEntries = cEntry.resolvedChainedLibraries();
                for (int k = 0, length2 = extraEntries.length; k < length2; k++) {
                  if (!rawLibrariesPath.contains(extraEntries[k].getPath())) {
                    addToResult(rawEntry, extraEntries[k], result, resolvedEntries, externalFoldersManager, referencedEntriesMap, false, knownDrives);
                  }
                }
              }
            }
            addToResult(rawEntry, cEntry, result, resolvedEntries, externalFoldersManager, referencedEntriesMap, false, knownDrives);
          }
          break;

        case IClasspathEntry.CPE_LIBRARY:
          // resolve ".." in library path
          resolvedEntry = ((ClasspathEntry) rawEntry).resolvedDotDot(getProject().getLocation());
         
          if (resolveChainedLibraries && result.rawReverseMap.get(resolvedEntry.getPath()) == null) {
            // resolve Class-Path: in manifest
            ClasspathEntry[] extraEntries = ((ClasspathEntry) resolvedEntry).resolvedChainedLibraries();
            for (int k = 0, length2 = extraEntries.length; k < length2; k++) {
              if (!rawLibrariesPath.contains(extraEntries[k].getPath())) {
                addToResult(rawEntry, extraEntries[k], result, resolvedEntries, externalFoldersManager, referencedEntriesMap, true, knownDrives);
View Full Code Here


    if (result.rawReverseMap.get(resolvedPath = resolvedEntry.getPath()) == null) {
      result.rawReverseMap.put(resolvedPath, rawEntry);
      result.rootPathToResolvedEntries.put(resolvedPath, resolvedEntry);
      resolvedEntries.add(resolvedEntry);
      if (addAsChainedEntry) {
        IClasspathEntry chainedEntry = null;
        chainedEntry = (ClasspathEntry) oldChainedEntriesMap.get(resolvedPath);
        if (chainedEntry != null) {
          // This is required to keep the attributes if any added by the user in
          // the previous session such as source attachment path etc.
          copyFromOldChainedEntry((ClasspathEntry) resolvedEntry, (ClasspathEntry) chainedEntry);
View Full Code Here

    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

      }
    }
  } 

  public IClasspathEntry[] getClasspathEntries() {
    IClasspathEntry layoutextlib = JavaCore.newLibraryEntry(jar_path, src_path, new Path("src"), true); //$NON-NLS-1$
    return new IClasspathEntry[] { layoutextlib };
  }
View Full Code Here

        for (IClasspathEntry entry : entries) {
          if (entry.getPath().equals(VS_LAYOUTEXT))
            layout_exists = true;
        }
        if (!layout_exists) {
          IClasspathEntry varEntry = JavaCore.newContainerEntry(VS_LAYOUTEXT, false);
          IClasspathEntry[] newClasspath = new IClasspathEntry[entries.length + 1];
          System.arraycopy(entries, 0, newClasspath, 0, entries.length);
          newClasspath[entries.length] = varEntry;
          javaProject.setRawClasspath(newClasspath, monitor);
        }
View Full Code Here

        try {
            IClasspathEntry[] paths = project.getResolvedClasspath(true);
            Set<IPath> outputPaths = new HashSet<IPath>();
            if (paths != null) {
                for ( int i = 0; i < paths.length; i++ ) {
                    IClasspathEntry path = paths[i];
                    if (path.getEntryKind() == IClasspathEntry.CPE_LIBRARY) {
                        URL url = getRawLocationURL(path.getPath());
                        pathElements.add(url);
                    } else if (path.getEntryKind() == IClasspathEntry.CPE_SOURCE) {
                      IPath output = path.getOutputLocation();
                      if (path.getOutputLocation() != null) {
                        outputPaths.add(output);
                      }
                    }
                }
            }
            IPath location = getProjectLocation(project.getProject());
            IPath outputPath = location.append(project.getOutputLocation().removeFirstSegments(1));
            pathElements.add(0, outputPath.toFile().toURI().toURL());
            for (IPath path: outputPaths) {
              outputPath = location.append(path.removeFirstSegments(1));
                pathElements.add(0, outputPath.toFile().toURI().toURL());
            }
           
            // also add classpath of required projects
            for (String projectName: project.getRequiredProjectNames()) {
View Full Code Here

    {
        try {
            File buildFile = new File(root, "build.xml");
            List<String> paths = _connector.getRequiredLibs(buildFile);

            IClasspathEntry jreEntry = JavaCore.newContainerEntry(new Path(
                "org.eclipse.jdt.launching.JRE_CONTAINER"));
            IClasspathEntry srcEntry = JavaCore.newSourceEntry(new Path("/"
                + projectName));
            ArrayList<IClasspathEntry> entries = new ArrayList<IClasspathEntry>();
            entries.add(srcEntry);
            entries.add(jreEntry);
View Full Code Here

     * @param confs
     *            the configurations to use in the classpath container.
     */
    public static void addCPContainer(IJavaProject project, IPath projectRelativePath, String confs) {
        try {
            IClasspathEntry newEntry = JavaCore.newContainerEntry(new Path(
                    IvyClasspathContainer.CONTAINER_ID).append(projectRelativePath).append(confs));

            IClasspathEntry[] entries = project.getRawClasspath();

            List newEntries = new ArrayList(Arrays.asList(entries));
View Full Code Here

     * @param cpc
     *            the container to transform into an IvyClasspathContainer
     * @return the IvyClasspathContainer is such, null, if not
     */
    public static IvyClasspathContainer jdt2IvyCPC(ClassPathContainer cpc) {
        IClasspathEntry entry = cpc.getClasspathEntry();
        try {
            IClasspathContainer icp = JavaCore.getClasspathContainer(entry.getPath(), cpc
                    .getJavaProject());
            if (icp instanceof IvyClasspathContainer) {
                return (IvyClasspathContainer) icp;
            }
        } catch (JavaModelException e) {
View Full Code Here

     */
    public static IvyClasspathContainer getIvyClasspathContainer(IJavaProject javaProject) {
        try {
            IClasspathEntry[] entries = javaProject.getRawClasspath();
            for (int i = 0; i < entries.length; i++) {
                IClasspathEntry entry = entries[i];
                if (entry != null && entry.getEntryKind() == IClasspathEntry.CPE_CONTAINER) {
                    IPath path = entry.getPath();
                    if (isIvyClasspathContainer(path)) {
                        IClasspathContainer cp = JavaCore.getClasspathContainer(path, javaProject);
                        if (cp instanceof IvyClasspathContainer) {
                            return (IvyClasspathContainer) cp;
                        }
View Full Code Here

TOP

Related Classes of org.eclipse.jdt.core.IClasspathEntry

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.