List of usage examples for org.eclipse.jdt.core IClasspathEntry getEntryKind
int getEntryKind();
From source file:in.software.analytics.parichayana.core.internal.builder.ParichayanaBuilder.java
License:Open Source License
private List<ICompilationUnit> getCompilationUnits() throws JavaModelException { List<ICompilationUnit> compilationUnits = new ArrayList<ICompilationUnit>(); IJavaProject javaProject = JavaCore.create(project); IClasspathEntry[] entries = javaProject.getRawClasspath(); for (IClasspathEntry entry : entries) { if (entry.getEntryKind() == IClasspathEntry.CPE_SOURCE) { IPackageFragmentRoot[] roots = javaProject.findPackageFragmentRoots(entry); for (IPackageFragmentRoot root : roots) { if (root.isArchive()) { continue; }/* w ww. j a va 2 s. c om*/ IJavaElement[] children = root.getChildren(); for (IJavaElement child : children) { if (child instanceof IPackageFragment) { IPackageFragment packageFragment = (IPackageFragment) child; ICompilationUnit[] cus = packageFragment.getCompilationUnits(); for (ICompilationUnit cu : cus) { cleanupMarkers(cu.getUnderlyingResource()); compilationUnits.add(cu); } } } } } } return compilationUnits; }
From source file:io.sarl.eclipse.wizards.newproject.NewSarlProjectWizard.java
License:Apache License
private static boolean hasSourcePath(IJavaProject javaProject, IPath path) { if (path != null) { final IPath pathInProject = javaProject.getProject().getFullPath().append(path); try {/* w w w. j a v a 2 s . co m*/ for (final IClasspathEntry entry : javaProject.getRawClasspath()) { if (entry.getEntryKind() == IClasspathEntry.CPE_SOURCE && pathInProject.equals(entry.getPath())) { return true; } } } catch (Throwable exception) { // } } return false; }
From source file:io.sarl.eclipse.wizards.newproject.NewSarlProjectWizard.java
License:Apache License
private static String buildInvalidOutputPathMessageFragment(IJavaProject javaProject) { final StringBuilder sourceFolders = new StringBuilder(); try {//from w w w .j a va 2 s. c o m for (final IClasspathEntry entry : javaProject.getRawClasspath()) { if (entry.getEntryKind() == IClasspathEntry.CPE_SOURCE) { sourceFolders.append("\t"); //$NON-NLS-1$ sourceFolders.append(entry.getPath().toOSString()); sourceFolders.append("\n"); //$NON-NLS-1$ } } } catch (Throwable exception) { // } return sourceFolders.toString(); }
From source file:it.wallgren.android.platform.project.AndroidPlatformProject.java
License:Apache License
private IClasspathEntry[] mangleClasspath(IClasspathEntry[] rawClasspath, IProject project, IFolder repoLink) { LinkedList<IClasspathEntry> entries = new LinkedList<IClasspathEntry>(); // Filter out anything that is not framworks, packages, libcore or R IFile frameworks = project.getFile("frameworks"); IFile packages = project.getFile("packages"); IFile libcore = project.getFile("libcore"); for (IClasspathEntry entry : rawClasspath) { if (entry.getEntryKind() == IClasspathEntry.CPE_SOURCE) { // is frameworks source folder or R source folder if (frameworks.getFullPath().isPrefixOf(entry.getPath()) || libcore.getFullPath().isPrefixOf(entry.getPath()) || packages.getFullPath().isPrefixOf(entry.getPath()) || entry.getPath().lastSegment().equals("R")) { IPath path = entry.getPath().removeFirstSegments(1); IFolder entryFolder = repoLink.getFolder(path); if (!isBroken(entryFolder)) { entries.add(JavaCore.newSourceEntry(entryFolder.getFullPath())); }// w w w .j a v a 2 s . c o m } } } // Add the special platform libs container entries.add(getAndroidDependenceis(repoPath)); return entries.toArray(new IClasspathEntry[0]); }
From source file:jasima_gui.EclipseProjectClassLoader.java
License:Open Source License
protected Resource findResource(final String name, IJavaProject proj, boolean onlyExported) throws CoreException { IClasspathEntry[] classpath = proj.getResolvedClasspath(true); byte[] content; content = readResource(proj.getOutputLocation().makeRelative(), name); if (content != null) { return new Resource(proj.getOutputLocation().makeRelative(), content); }//ww w .ja v a 2s .c o m for (IClasspathEntry entry : classpath) { if (onlyExported && !entry.isExported()) continue; if (entry.getEntryKind() == IClasspathEntry.CPE_LIBRARY) { content = readResource(entry.getPath(), name); if (content != null) { return new Resource(entry.getPath(), content); } } else if (entry.getEntryKind() == IClasspathEntry.CPE_PROJECT) { IProject projEntry = (IProject) ResourcesPlugin.getWorkspace().getRoot() .findMember(entry.getPath()); Resource result = findResource(name, JavaCore.create(projEntry), true); if (result != null) { return result; } } } return null; }
From source file:me.gladwell.eclipse.m2e.android.configuration.classpath.ModifySourceFolderOutputClasspathConfigurer.java
License:Open Source License
public void configure(Project project) { for (IClasspathEntry entry : project.getClasspath().getEntries()) { if (entry.getOutputLocation() != null && entry.getEntryKind() == IClasspathEntry.CPE_SOURCE && !entry.getOutputLocation() .equals(project.getJavaProject().getPath().append(ANDROID_CLASSES_FOLDER))) { project.getClasspath().removeEntry(entry.getPath()); project.getClasspath().addSourceEntry(entry.getPath(), project.getJavaProject().getPath().append(ANDROID_CLASSES_FOLDER), true); }/* www . ja v a 2 s .c o m*/ } }
From source file:me.gladwell.eclipse.m2e.android.configuration.ClasspathAttacher.java
License:Open Source License
public Iterable<IClasspathEntry> attach(IJavaProject project, Iterable<IClasspathEntry> classpath) { List<IClasspathEntry> processed = new ArrayList<IClasspathEntry>(); try {// w w w . j a va2 s. c o m IMavenProjectFacade mavenProjectFacade = registry.getProject(project.getProject()); if (mavenProjectFacade == null) { warn("maven project not yet registered for " + project); return processed; } MavenProject mavenProject = mavenProjectFacade.getMavenProject(new NullProgressMonitor()); MavenAndroidProject androidProject = factory.createAndroidProject(mavenProject); List<ArtifactRepository> repositories = mavenProject.getRemoteArtifactRepositories(); for (IClasspathEntry entry : classpath) { try { if (CPE_LIBRARY == entry.getEntryKind() && !attacher.isAttached(entry)) { Dependency dependency = findDependency(entry, androidProject.getNonRuntimeDependencies()); if (!maven.isUnavailable(dependency.getGroup(), dependency.getName(), dependency.getVersion(), "jar", classifier, repositories)) { Artifact docs = maven.resolve(dependency.getGroup(), dependency.getName(), dependency.getVersion(), "jar", classifier, repositories, new NullProgressMonitor()); processed.add(attacher.attach(entry, docs)); } else { debug(classifier + " unavailable for classpath entry=[" + entry + "]"); processed.add(entry); } } else { processed.add(entry); } } catch (Exception e) { debug("could not resolve " + classifier + " for classpath entry=[" + entry + "]", e); processed.add(entry); } } } catch (CoreException e) { throw new ProjectConfigurationException(e); } return processed; }
From source file:me.gladwell.eclipse.m2e.android.configuration.Classpaths.java
License:Open Source License
private static Predicate<IClasspathEntry> entryOfType(final int type) { return new Predicate<IClasspathEntry>() { public boolean apply(IClasspathEntry entry) { return entry.getEntryKind() == type; }//from w w w . jav a 2s .c om }; }
From source file:me.gladwell.eclipse.m2e.android.configuration.MavenAndroidClasspathConfigurer.java
License:Open Source License
public void removeJreClasspathContainer(IClasspathDescriptor classpath) { for (IClasspathEntry entry : classpath.getEntries()) { if (entry.getEntryKind() == IClasspathEntry.CPE_CONTAINER) { if (entry.getPath().toOSString().contains(JavaRuntime.JRE_CONTAINER)) { classpath.removeEntry(entry.getPath()); }/*from w w w .j a v a 2 s .co m*/ } } }
From source file:me.gladwell.eclipse.m2e.android.configuration.MavenAndroidClasspathConfigurer.java
License:Open Source License
public void modifySourceFolderOutput(IJavaProject javaProject, AndroidProject project, IClasspathDescriptor classpath) { for (IClasspathEntry entry : classpath.getEntries()) { if (entry.getOutputLocation() != null && entry.getEntryKind() == IClasspathEntry.CPE_SOURCE && !entry.getOutputLocation().equals(javaProject.getPath().append(ANDROID_CLASSES_FOLDER))) { classpath.removeEntry(entry.getPath()); classpath.addSourceEntry(entry.getPath(), javaProject.getPath().append(ANDROID_CLASSES_FOLDER), false);/*from w w w.j a v a2 s. com*/ } } }