List of usage examples for org.eclipse.jdt.core IClasspathEntry CPE_PROJECT
int CPE_PROJECT
To view the source code for org.eclipse.jdt.core IClasspathEntry CPE_PROJECT.
Click Source Link
From source file:org.openquark.cal.eclipse.embedded.EmbeddedClasspathVariableInitializer.java
License:Open Source License
public static void addQuarkBinariesToClasspath(IProject project) { IJavaProject javaProject = JavaCore.create(project); try {//from w ww . j a v a 2 s . com IClasspathEntry[] originalCP = javaProject.getRawClasspath(); // find the quark binaries project IJavaProject quarkBinaries = getQuarkBinaries(); if (quarkBinaries == null) { // could not find quark binaries project return; } // check to see if classpath entry already exists for (final IClasspathEntry classpathEntry : originalCP) { if (classpathEntry.getEntryKind() == IClasspathEntry.CPE_PROJECT) { if (classpathEntry.getPath().toString().equals(quarkBinaries.getPath())) { // found return; } } } // add it IClasspathEntry quarkBinariesEntry = JavaCore.newProjectEntry(quarkBinaries.getPath()); int originalCPLength = originalCP.length; IClasspathEntry[] newCP = new IClasspathEntry[originalCPLength + 1]; System.arraycopy(originalCP, 0, newCP, 0, originalCPLength); newCP[originalCPLength] = quarkBinariesEntry; javaProject.setRawClasspath(newCP, new NullProgressMonitor()); } catch (JavaModelException e) { } }
From source file:org.org.eclipse.dws.ui.internal.wizards.pages.DependenciesFromClasspathPage.java
License:Open Source License
/** * Checks if is possible dependency.//from ww w.j a v a 2s .c o m * * @param packageFragmentRoot * the package fragment root * * @return the boolean * * @throws JavaModelException * the java model exception */ private Boolean isPossibleDependency(IPackageFragmentRoot packageFragmentRoot) throws JavaModelException { boolean isArchive = packageFragmentRoot.isArchive(); int entryKind = packageFragmentRoot.getRawClasspathEntry().getEntryKind(); boolean isFiltered = isFiltered(packageFragmentRoot); return isArchive && (entryKind != IClasspathEntry.CPE_PROJECT) && entryKind != IClasspathEntry.CPE_SOURCE && !isFiltered; }
From source file:org.org.eclipse.dws.ui.internal.wizards.pages.LookupJavadocAndSourcesForLibrariesInClasspathPage.java
License:Open Source License
/** * Checks if is library with missing javadoc or source. * //w ww .j a v a 2s.com * @param packageFragmentRoot * the package fragment root * * @return the boolean * * @throws JavaModelException * the java model exception */ private Boolean isLibraryWithMissingJavadocOrSource(IPackageFragmentRoot packageFragmentRoot) throws JavaModelException { boolean isArchive = packageFragmentRoot.isArchive(); int entryKind = packageFragmentRoot.getRawClasspathEntry().getEntryKind(); boolean isFiltered = isFiltered(packageFragmentRoot); boolean missesSources = missesSources(packageFragmentRoot); boolean missesJavadoc = missesJavadoc(packageFragmentRoot); return isArchive && (entryKind != IClasspathEntry.CPE_PROJECT) && entryKind != IClasspathEntry.CPE_SOURCE && !isFiltered && (missesJavadoc || missesSources); }
From source file:org.rascalmpl.eclipse.nature.ProjectEvaluatorFactory.java
License:Open Source License
private void collectClassPathForProject(IProject project, List<URL> classPath, List<String> compilerClassPath, Evaluator parser) {/*from w w w. j a v a2 s . c o m*/ try { if (!project.hasNature(JavaCore.NATURE_ID)) { for (IProject ref : project.getReferencedProjects()) { collectClassPathForProject(ref, classPath, compilerClassPath, parser); } } else { IJavaProject jProject = JavaCore.create(project); IPath binFolder = jProject.getOutputLocation(); String binLoc = project.getLocation() + "/" + binFolder.removeFirstSegments(1).toString(); compilerClassPath.add(binLoc); URL binURL = new URL("file", "", binLoc + "/"); parser.addClassLoader(new URLClassLoader(new URL[] { binURL }, getClass().getClassLoader())); classPath.add(binURL); if (!jProject.isOpen()) { return; } IClasspathEntry[] entries = jProject.getResolvedClasspath(true); for (int i = 0; i < entries.length; i++) { IClasspathEntry entry = entries[i]; switch (entry.getEntryKind()) { case IClasspathEntry.CPE_LIBRARY: if (entry.getPath().segment(0).equals(project.getName())) { String file = project.getLocation() + "/" + entry.getPath().removeFirstSegments(1).toString(); URL url = new URL("file", "", file); if (!classPath.contains(url)) { classPath.add(url); compilerClassPath.add(file); } } else { URL url = new URL("file", "", entry.getPath().toString()); if (!classPath.contains(url)) { classPath.add(url); compilerClassPath.add(entry.getPath().toString()); } } break; case IClasspathEntry.CPE_PROJECT: collectClassPathForProject( (IProject) project.getWorkspace().getRoot().findMember(entry.getPath()), classPath, compilerClassPath, parser); break; } } } } catch (CoreException e) { Activator.getInstance().logException("failed to configure classpath", e); } catch (MalformedURLException e) { Activator.getInstance().logException("failed to configure classpath", e); } }
From source file:org.robovm.eclipse.internal.ib.IBIntegratorManager.java
License:Open Source License
private LinkedHashSet<File> resolveClasspath(IWorkspaceRoot root, IJavaProject javaProject) throws JavaModelException { LinkedHashSet<File> classpath = new LinkedHashSet<>(); for (IClasspathEntry cpe : javaProject.getResolvedClasspath(true)) { if (cpe.getEntryKind() == IClasspathEntry.CPE_PROJECT) { IJavaProject jproj = JavaCore.create(root.findMember(cpe.getPath()).getProject()); classpath.addAll(resolveClasspath(root, jproj)); } else if (cpe.getEntryKind() != IClasspathEntry.CPE_SOURCE && cpe.getPath() != null) { File file = cpe.getPath().toFile(); if (!file.exists()) { // Probably a workspace absolute path. Resolve it. IResource res = root.findMember(cpe.getPath()); if (res != null) { file = res.getLocation().toFile(); }//from w ww . jav a 2 s . co m } if (file.exists()) { classpath.add(file); } } } classpath.addAll(getOutputLocations(javaProject)); return classpath; }
From source file:org.robovm.eclipse.RoboVMPlugin.java
License:Open Source License
private static void getSourcePaths(Set<String> paths, IJavaProject javaProject) throws CoreException { try {/*from www. j ava 2s. c o m*/ // add the source jars of rt/objc/cocoatouch etc. File libDir = new File(RoboVMPlugin.getRoboVMHome().getBinDir().getParentFile(), "lib"); paths.add(new File(libDir, "robovm-cocoatouch-sources.jar").getAbsolutePath()); paths.add(new File(libDir, "robovm-objc-sources.jar").getAbsolutePath()); paths.add(new File(libDir, "robovm-rt-sources.jar").getAbsolutePath()); } catch (IOException e) { RoboVMPlugin.consoleError("Couldn't retrieve lib/ directory"); } IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); for (IClasspathEntry entry : javaProject.getResolvedClasspath(true)) { IPath path = null; if (entry.getEntryKind() == IClasspathEntry.CPE_SOURCE) { IResource resource = root.findMember(entry.getPath()); if (resource != null) { path = resource.getLocation(); } } else if (entry.getEntryKind() == IClasspathEntry.CPE_LIBRARY) { if (entry.getSourceAttachmentPath() != null) { path = entry.getSourceAttachmentPath(); } } else if (entry.getEntryKind() == IClasspathEntry.CPE_PROJECT) { IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(entry.getPath().toString()); if (project.isNatureEnabled("org.eclipse.jdt.core.javanature")) { getSourcePaths(paths, JavaCore.create(project)); } } if (path != null) { paths.add(path.toOSString()); } } }
From source file:org.seasar.diigu.eclipse.util.JavaProjectClassLoader.java
License:Apache License
protected void addClasspathEntries(IJavaProject project, Set already, boolean atFirst) { already.add(project);/*from ww w . j a v a 2 s .co m*/ try { IContainer workspaceroot = project.getProject().getParent(); IPath path = project.getOutputLocation(); addURL(toURL(workspaceroot.getFolder(path).getLocation())); IClasspathEntry[] entries = project.getResolvedClasspath(true); for (int i = 0; i < entries.length; i++) { IClasspathEntry entry = entries[i]; switch (entry.getEntryKind()) { case IClasspathEntry.CPE_SOURCE: IPath dist = entry.getOutputLocation(); if (dist != null) { addURL(toURL(workspaceroot.getFolder(dist).getLocation())); } break; case IClasspathEntry.CPE_LIBRARY: case IClasspathEntry.CPE_CONTAINER: case IClasspathEntry.CPE_VARIABLE: IPath p = entry.getPath(); if (p.toFile().exists()) { addURL(toURL(p)); } else { addURL(toURL(workspaceroot.getFile(p).getLocation())); } break; case IClasspathEntry.CPE_PROJECT: IJavaProject proj = ProjectUtils.getJavaProject(entry.getPath().segment(0)); if (proj != null && proj.exists() && already.contains(proj) == false && (atFirst || entry.isExported())) { addClasspathEntries(proj, already, false); } break; default: break; } } } catch (Exception e) { DiiguPlugin.log(e); } }
From source file:org.seasar.kijimuna.core.util.JavaProjectClassLoader.java
License:Apache License
protected void addClasspathEntries(IJavaProject project, Set already, boolean atFirst) { already.add(project);/* ww w. j a v a 2 s. c om*/ try { IContainer workspaceroot = project.getProject().getParent(); IPath path = project.getOutputLocation(); addURL(toURL(workspaceroot.getFolder(path).getLocation())); IClasspathEntry[] entries = project.getResolvedClasspath(true); for (int i = 0; i < entries.length; i++) { IClasspathEntry entry = entries[i]; switch (entry.getEntryKind()) { case IClasspathEntry.CPE_SOURCE: IPath dist = entry.getOutputLocation(); if (dist != null) { addURL(toURL(workspaceroot.getFolder(dist).getLocation())); } break; case IClasspathEntry.CPE_LIBRARY: case IClasspathEntry.CPE_CONTAINER: case IClasspathEntry.CPE_VARIABLE: IPath p = entry.getPath(); if (p.toFile().exists()) { addURL(toURL(p)); } else { addURL(toURL(workspaceroot.getFile(p).getLocation())); } break; case IClasspathEntry.CPE_PROJECT: IJavaProject proj = JavaCore.create(ProjectUtils.getProject(entry.getPath().segment(0))); if (proj != null && proj.exists() && already.contains(proj) == false && (atFirst || entry.isExported())) { addClasspathEntries(proj, already, false); } break; default: break; } } } catch (Exception e) { KijimunaCore.reportException(e); } }
From source file:org.sonar.ide.eclipse.jdt.internal.JavaProjectConfigurator.java
License:Open Source License
/** * Adds the classpath of an eclipse project to the sonarProject recursively, i.e * it iterates all dependent projects. Libraries and output folders of dependent projects * are added, but no source folders./* w w w .j a v a2s . c om*/ * @param javaProject the eclipse project to get the classpath from * @param sonarProjectProperties the sonar project properties to add the classpath to * @param context * @param topProject indicate we are working on the project to be analysed and not on a dependent project * @throws JavaModelException see {@link IJavaProject#getResolvedClasspath(boolean)} */ private void addClassPathToSonarProject(IJavaProject javaProject, JavaProjectConfiguration context, boolean topProject) throws JavaModelException { IClasspathEntry[] classPath = javaProject.getResolvedClasspath(true); for (IClasspathEntry entry : classPath) { switch (entry.getEntryKind()) { case IClasspathEntry.CPE_SOURCE: if (!isSourceExcluded(entry)) { processSourceEntry(entry, javaProject, context, topProject); } break; case IClasspathEntry.CPE_LIBRARY: if (topProject || entry.isExported()) { final String libDir = resolveLibrary(javaProject, entry); if (libDir != null) { LOG.debug("Library: {}", libDir); context.libraries().add(libDir); } } break; case IClasspathEntry.CPE_PROJECT: IJavaModel javaModel = javaProject.getJavaModel(); IJavaProject referredProject = javaModel.getJavaProject(entry.getPath().segment(0)); if (!context.dependentProjects().contains(referredProject)) { LOG.debug("Adding project: {}", referredProject.getProject().getName()); addClassPathToSonarProject(referredProject, context, false); context.dependentProjects().add(referredProject); } break; default: LOG.warn("Unhandled ClassPathEntry : {}", entry); break; } } processOutputDir(javaProject.getOutputLocation(), context, topProject); }
From source file:org.sonarlint.eclipse.jdt.internal.JavaProjectConfigurator.java
License:Open Source License
/** * Adds the classpath of an eclipse project to the sonarProject recursively, i.e * it iterates all dependent projects. Libraries and output folders of dependent projects * are added, but no source folders.//w w w .j a v a 2s. co m * @param javaProject the eclipse project to get the classpath from * @param sonarProjectProperties the sonar project properties to add the classpath to * @param context * @param topProject indicate we are working on the project to be analysed and not on a dependent project * @throws JavaModelException see {@link IJavaProject#getResolvedClasspath(boolean)} */ private void addClassPathToSonarProject(IJavaProject javaProject, JavaProjectConfiguration context, boolean topProject) throws JavaModelException { IClasspathEntry[] classPath = javaProject.getResolvedClasspath(true); for (IClasspathEntry entry : classPath) { switch (entry.getEntryKind()) { case IClasspathEntry.CPE_SOURCE: if (!isSourceExcluded(entry)) { processSourceEntry(entry, javaProject, context, topProject); } break; case IClasspathEntry.CPE_LIBRARY: if (topProject || entry.isExported()) { final String libPath = resolveLibrary(javaProject, entry); if (libPath != null) { context.libraries().add(libPath); } } break; case IClasspathEntry.CPE_PROJECT: IJavaModel javaModel = javaProject.getJavaModel(); IJavaProject referredProject = javaModel.getJavaProject(entry.getPath().segment(0)); if (!context.dependentProjects().contains(referredProject)) { context.dependentProjects().add(referredProject); addClassPathToSonarProject(referredProject, context, false); } break; default: SonarLintCorePlugin.getDefault().info("Unhandled ClassPathEntry : " + entry); break; } } processOutputDir(javaProject.getOutputLocation(), context, topProject); }