List of usage examples for org.eclipse.jdt.core IClasspathEntry getEntryKind
int getEntryKind();
From source file:me.gladwell.eclipse.m2e.android.configuration.MavenAndroidClasspathConfigurer.java
License:Open Source License
public void markMavenContainerExported(IClasspathDescriptor classpath) { for (IClasspathEntry entry : classpath.getEntries()) { if (entry.getEntryKind() == IClasspathEntry.CPE_CONTAINER) { if (entry.getPath().toOSString().equals(IClasspathManager.CONTAINER_ID)) { IClasspathEntry newEntry = JavaCore.newContainerEntry(entry.getPath(), true); classpath.removeEntry(entry.getPath()); classpath.addEntry(newEntry); }/*from w w w.j a v a 2s. c o m*/ } } }
From source file:me.gladwell.eclipse.m2e.android.configuration.ObjectSerializationClasspathPersister.java
License:Open Source License
public void save(String project, List<IClasspathEntry> classpath) { ObjectOutputStream os = null; try {/*from w w w . ja v a 2s . co m*/ File file = new File(stateLocation, project); os = new ObjectOutputStream(new BufferedOutputStream(new FileOutputStream(file))) { { enableReplaceObject(true); } protected Object replaceObject(Object o) throws IOException { if (o instanceof IClasspathEntry) { IClasspathEntry e = (IClasspathEntry) o; if (e.getEntryKind() == IClasspathEntry.CPE_PROJECT) { return new ProjectEntryReplace(e); } else if (e.getEntryKind() == IClasspathEntry.CPE_LIBRARY) { return new LibraryEntryReplace(e); } } else if (o instanceof IClasspathAttribute) { return new ClasspathAttributeReplace((IClasspathAttribute) o); } else if (o instanceof IAccessRule) { return new AccessRuleReplace((IAccessRule) o); } else if (o instanceof IPath) { return new PathReplace((IPath) o); } return super.replaceObject(o); } }; os.writeObject(classpath); os.flush(); } catch (IOException e) { throw new ProjectConfigurationException(e); } finally { if (os != null) { try { os.close(); } catch (IOException e) { throw new ProjectConfigurationException(e); } } } }
From source file:me.gladwell.eclipse.m2e.android.test.AndroidMavenPluginTestCase.java
License:Open Source License
protected void assertClasspathContains(IJavaProject javaProject, String path) throws JavaModelException { for (IClasspathEntry entry : javaProject.getRawClasspath()) { if (entry.getPath().toOSString().contains(path)) { return; } else if (entry.getEntryKind() == IClasspathEntry.CPE_CONTAINER) { IClasspathContainer container = JavaCore.getClasspathContainer(entry.getPath(), javaProject); for (IClasspathEntry e : container.getClasspathEntries()) { if (e.getPath().toOSString().contains(path)) { return; }/*from ww w . j a va 2s . com*/ } } } fail(path + " should be in classpath"); }
From source file:me.gladwell.eclipse.m2e.android.test.AndroidMavenPluginTestCase.java
License:Open Source License
protected void assertClasspathDoesNotContain(IJavaProject javaProject, String path) throws JavaModelException { for (IClasspathEntry entry : javaProject.getRawClasspath()) { assertFalse(entry.getPath().toOSString().contains(path)); if (entry.getEntryKind() == IClasspathEntry.CPE_CONTAINER) { IClasspathContainer container = JavaCore.getClasspathContainer(entry.getPath(), javaProject); for (IClasspathEntry e : container.getClasspathEntries()) { assertFalse(path + " should not be in classpath", e.getPath().toOSString().contains(path)); }//from w w w . j a v a 2 s. c o m } } }
From source file:me.gladwell.eclipse.m2e.android.test.AndroidMavenPluginTestCase.java
License:Open Source License
protected IClasspathEntry getClasspathContainer(IJavaProject javaProject, String id) throws JavaModelException { for (IClasspathEntry entry : javaProject.getRawClasspath()) { if (entry.getEntryKind() == IClasspathEntry.CPE_CONTAINER) { if (entry.getPath().toOSString().equals(id)) { return entry; }/*from w ww .j a va2 s . c om*/ } } return null; }
From source file:me.gladwell.eclipse.m2e.android.test.Classpaths.java
License:Open Source License
public static IClasspathEntry findSourceEntry(IClasspathEntry[] classpath, final String path) { for (IClasspathEntry entry : classpath) { if (entry.getEntryKind() == CPE_SOURCE && entry.getPath().toOSString().endsWith(path)) { return entry; }//from w w w . ja v a 2 s . c om } return null; }
From source file:monolipse.core.internal.BooNature.java
License:Open Source License
private Map<IClasspathEntry, IClasspathEntry> addExclusionPatternsTo(IClasspathEntry[] classpath) { Map<IClasspathEntry, IClasspathEntry> modified = new HashMap<IClasspathEntry, IClasspathEntry>(); for (int i = 0; i < classpath.length; i++) { IClasspathEntry entry = classpath[i]; if (entry.getEntryKind() != IClasspathEntry.CPE_SOURCE) continue; IPath[] exclusionPatterns = entry.getExclusionPatterns(); IPath[] newExclusionPatterns = addExclusionPatternsTo(exclusionPatterns); if (exclusionPatterns == newExclusionPatterns) continue; IClasspathEntry newSourceEntry = JavaCore.newSourceEntry(entry.getPath(), entry.getInclusionPatterns(), newExclusionPatterns, entry.getOutputLocation(), entry.getExtraAttributes()); modified.put(entry, newSourceEntry); }//from w ww.ja v a2 s . c om return modified; }
From source file:net.kbserve.pyjdt.properties.models.CPEAbstractContainer.java
License:Open Source License
/** * Update the list of children to include the ICPEType contains the giveb IClasspathEntry * //from ww w. j av a 2s.c o m * @param child * the child * @param project * the project * @return the iCPE type */ public synchronized ICPEType updateChild(IClasspathEntry child, IProject project) { String stringPath = makeStringPath(child.getPath()); ICPEType icp = getChild(stringPath); if (icp == null) { switch (child.getEntryKind()) { case (IClasspathEntry.CPE_CONTAINER): icp = new CPEContainer(); break; case (IClasspathEntry.CPE_LIBRARY): icp = new CPELibrary(); break; case (IClasspathEntry.CPE_PROJECT): icp = new CPEProject(); break; case (IClasspathEntry.CPE_SOURCE): icp = new CPESource(); break; case (IClasspathEntry.CPE_VARIABLE): icp = new CPEVariable(); break; default: throw new UnsupportedOperationException( "Unsupported IClasspathEntry.getEntryKind() = '" + child.getEntryKind() + "' on " + child); } children.add(icp); icp.setPath(stringPath); icp.setParent(this.getPath()); } return icp; }
From source file:net.rim.ejde.internal.core.BasicClasspathElementChangedListener.java
License:Open Source License
static public boolean hasProjectDependencyProblem(IJavaProject javaProject) { IProject project = javaProject.getProject(); try {// w w w .j av a 2 s. c om ResourceBuilderUtils.cleanProblemMarkers(project, new String[] { IRIMMarker.PROJECT_DEPENDENCY_PROBLEM_MARKER }, IResource.DEPTH_ONE); } catch (CoreException e) { _log.error(e); } IClasspathEntry[] classpathEntries = null; try { classpathEntries = javaProject.getRawClasspath(); } catch (JavaModelException e) { _log.error(e); return true; } IProject dependentProject = null; String projectName = null; boolean hasDependencyError = false; for (IClasspathEntry entry : classpathEntries) { if (entry.getEntryKind() == IClasspathEntry.CPE_PROJECT) { projectName = entry.getPath().lastSegment(); dependentProject = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName); if (!isValidDependency(javaProject.getProject(), dependentProject) && !hasDependencyError) { hasDependencyError = true; } } } return hasDependencyError; }
From source file:net.rim.ejde.internal.core.BasicClasspathElementChangedListener.java
License:Open Source License
/** * Checks if all source files are existing. If not, create them. * * @param javaProj/*from w w w . jav a2s.c om*/ */ private void checkSourceFolders(final IJavaProject javaProj) { if (javaProj == null) return; if (javaProj.exists()) { try { if (!javaProj.isOpen()) { javaProj.open(new NullProgressMonitor()); } IClasspathEntry[] entries = javaProj.getRawClasspath(); for (IClasspathEntry entry : entries) { if (IClasspathEntry.CPE_SOURCE == entry.getEntryKind()) { IPath path = entry.getPath(); final IPath folderPath = path.removeFirstSegments(1); if (!folderPath.isEmpty()) { Display.getDefault().asyncExec(new Runnable() { public void run() { try { ImportUtils.createFolders(javaProj.getProject(), folderPath, IResource.FORCE); } catch (CoreException e) { _log.error(e.getMessage()); } } }); } } } } catch (JavaModelException e) { _log.error("findProjectSources: Could not retrieve project sources:", e); //$NON-NLS-1$ } } }