private IClasspathEntry getMatchingEntryIgnoreAttributes(final Map entries, final IClasspathEntry entry) { final Iterator i = entries.keySet().iterator(); while (i.hasNext()) { final IClasspathEntry e = (IClasspathEntry) i.next(); if (e.getEntryKind() == entry.getEntryKind() && e.getPath().equals(entry.getPath()) && e.isExported() == entry.isExported()) { return e; } } return null; }
private IClasspathEntry copyCPEntryWithoutModuleAttribute(IClasspathEntry entry) { IClasspathAttribute[] oldAttributes= entry.getExtraAttributes(); IClasspathAttribute[] newAttributes= new IClasspathAttribute[oldAttributes.length]; int count= 0; for (int i= 0; i < oldAttributes.length; i++) { if (!oldAttributes[i].getName().equals(IClasspathAttribute.MODULE)) newAttributes[count++]= oldAttributes[i]; } if (count == oldAttributes.length) return null; newAttributes= count == 0 ? new IClasspathAttribute[0] : Arrays.copyOf(newAttributes, count); return JavaCore.newContainerEntry(entry.getPath(), entry.getAccessRules(), newAttributes, entry.isExported()); }
private static void addReferencingProjects(IJavaProject focus, Set<IJavaProject> projects) throws JavaModelException { IProject[] referencingProjects= focus.getProject().getReferencingProjects(); for (int i= 0; i < referencingProjects.length; i++) { IJavaProject candidate= JavaCore.create(referencingProjects[i]); if (candidate == null || projects.contains(candidate) || !candidate.exists()) continue; // break cycle IClasspathEntry entry= getReferencingClassPathEntry(candidate, focus); if (entry != null) { projects.add(candidate); if (entry.isExported()) addReferencingProjects(candidate, projects); } } }
private static void addReferencingProjects(IJavaProject focus, Set projects) throws JavaModelException { IProject[] referencingProjects= focus.getProject().getReferencingProjects(); for (int i= 0; i < referencingProjects.length; i++) { IJavaProject candidate= JavaCore.create(referencingProjects[i]); if (candidate == null || projects.contains(candidate) || !candidate.exists()) continue; // break cycle IClasspathEntry entry= getReferencingClassPathEntry(candidate, focus); if (entry != null) { projects.add(candidate); if (entry.isExported()) addReferencingProjects(candidate, projects); } } }
private static void addReferencingProjects(IJavaProject focus, Set<IJavaProject> projects) throws JavaModelException { IProject[] referencingProjects= focus.getProject().getReferencingProjects(); for (int i= 0; i < referencingProjects.length; i++) { IJavaProject candidate= JavaCore.create(referencingProjects[i]); if (candidate == null || projects.contains(candidate) || !candidate.exists()) continue; // break cycle IClasspathEntry entry= getReferencingClassPathEntry(candidate, focus); if (entry != null) { projects.add(candidate); if (entry.isExported()) addReferencingProjects(candidate, projects); } } }
private static void addReferencingProjects(IJavaProject focus, Set<IJavaProject> projects) throws JavaModelException { IProject[] referencingProjects = focus.getProject().getReferencingProjects(); for (int i = 0; i < referencingProjects.length; i++) { IJavaProject candidate = JavaCore.create(referencingProjects[i]); if (candidate == null || projects.contains(candidate) || !candidate.exists()) { continue; // break cycle } IClasspathEntry entry = getReferencingClassPathEntry(candidate, focus); if (entry != null) { projects.add(candidate); if (entry.isExported()) { addReferencingProjects(candidate, projects); } } } }
private static void addRelatedReferencing(IJavaProject focus, Set<IJavaProject> projects) throws CoreException { IProject[] referencingProjects= focus.getProject().getReferencingProjects(); for (int i= 0; i < referencingProjects.length; i++) { IJavaProject candidate= JavaCore.create(referencingProjects[i]); if (candidate == null || projects.contains(candidate) || !candidate.exists()) continue; // break cycle IClasspathEntry entry= getReferencingClassPathEntry(candidate, focus); if (entry != null) { projects.add(candidate); if (entry.isExported()) { addRelatedReferencing(candidate, projects); addRelatedReferenced(candidate, projects); } } } }
private static void addRelatedReferenced(IJavaProject focus, Set<IJavaProject> projects) throws CoreException { IProject[] referencedProjects= focus.getProject().getReferencedProjects(); for (int i= 0; i < referencedProjects.length; i++) { IJavaProject candidate= JavaCore.create(referencedProjects[i]); if (candidate == null || projects.contains(candidate) || !candidate.exists()) continue; // break cycle IClasspathEntry entry= getReferencingClassPathEntry(focus, candidate); if (entry != null) { projects.add(candidate); if (entry.isExported()) { addRelatedReferenced(candidate, projects); addRelatedReferencing(candidate, projects); } } } }
private IClasspathEntry addAttributes(IClasspathEntry entry, IClasspathAttribute[] extraAttributes) { switch (entry.getEntryKind()) { case IClasspathEntry.CPE_CONTAINER: return JavaCore.newContainerEntry(entry.getPath(), entry.getAccessRules(), extraAttributes, entry.isExported()); case IClasspathEntry.CPE_LIBRARY: return JavaCore.newLibraryEntry(entry.getPath(), entry.getSourceAttachmentPath(), entry.getSourceAttachmentRootPath(), entry.getAccessRules(), extraAttributes, entry.isExported()); case IClasspathEntry.CPE_PROJECT: return JavaCore.newProjectEntry(entry.getPath(), entry.getAccessRules(), entry.combineAccessRules(), extraAttributes, entry.isExported()); default: return entry; // other kinds are not handled } }
public static class ClasspathResolutionBreakpointListener { public void breakpoint(int bp) { // override in listener implementation } }
public static class ClasspathResolutionBreakpointListener { public void breakpoint(int bp) { // override in listener implementation } }
private IClasspathEntry createModifiedEntry(IClasspathEntry oldEntry) { return JavaCore.newProjectEntry(createNewPath(), oldEntry.getAccessRules(), oldEntry.combineAccessRules(), oldEntry.getExtraAttributes(), oldEntry.isExported()); }
private IClasspathEntry createModifiedEntry(IClasspathEntry oldEntry) { return JavaCore.newProjectEntry(createNewPath(), oldEntry.getAccessRules(), oldEntry.combineAccessRules(), oldEntry.getExtraAttributes(), oldEntry.isExported()); }
private IClasspathEntry createModifiedEntry(IClasspathEntry oldEntry) { return JavaCore.newProjectEntry(createNewPath(), oldEntry.getAccessRules(), oldEntry.combineAccessRules(), oldEntry.getExtraAttributes(), oldEntry.isExported()); }
private void updateClasspath(IPath newPath, IProgressMonitor monitor) throws JavaModelException { IClasspathEntry[] classpath= fProject.getRawClasspath(); IPath jreContainerPath= new Path(JavaRuntime.JRE_CONTAINER); for (int i= 0; i < classpath.length; i++) { IClasspathEntry curr= classpath[i]; if (curr.getEntryKind() == IClasspathEntry.CPE_CONTAINER && curr.getPath().matchingFirstSegments(jreContainerPath) > 0) { classpath[i]= JavaCore.newContainerEntry(newPath, curr.getAccessRules(), curr.getExtraAttributes(), curr.isExported()); } } fProject.setRawClasspath(classpath, monitor); }
private static IClasspathEntry getReferencingClassPathEntry(IJavaProject referencingProject, IJavaProject referencedProject) throws JavaModelException { IClasspathEntry result = null; IPath path = referencedProject.getProject().getFullPath(); IClasspathEntry[] classpath = referencingProject.getResolvedClasspath(true); for (int i = 0; i < classpath.length; i++) { IClasspathEntry entry = classpath[i]; if (entry.getEntryKind() == IClasspathEntry.CPE_PROJECT && path.equals(entry.getPath())) { if (entry.isExported()) { return entry; } // Consider it as a candidate. May be there is another entry that is // exported. result = entry; } } return result; }
private static IClasspathEntry getReferencingClassPathEntry(IJavaProject referencingProject, IJavaProject referencedProject) throws JavaModelException { IClasspathEntry result= null; IPath path= referencedProject.getProject().getFullPath(); IClasspathEntry[] classpath= referencingProject.getResolvedClasspath(true); for (int i= 0; i < classpath.length; i++) { IClasspathEntry entry= classpath[i]; if (entry.getEntryKind() == IClasspathEntry.CPE_PROJECT && path.equals(entry.getPath())) { if (entry.isExported()) return entry; // Consider it as a candidate. May be there is another entry that is // exported. result= entry; } } return result; }
@Override public IClasspathEntry getSelection() { if (fEditResult != null) { if (fOldClasspathEntry != null && fOldClasspathEntry.getPath().equals(fEditResult.getPath())) { return JavaCore.newContainerEntry(fEditResult.getPath(), fOldClasspathEntry.getAccessRules(), fOldClasspathEntry.getExtraAttributes(), fOldClasspathEntry.isExported()); } else { return JavaCore.newContainerEntry(fEditResult.getPath(), false); } } return null; }
private static void replaceGradleClasspathContainerAttribute(IJavaProject project, String plusKey, String plusValue, String minusKey, IProgressMonitor monitor) throws JavaModelException { IClasspathEntry[] oldClasspath = project.getRawClasspath(); IClasspathEntry[] newClasspath = new IClasspathEntry[oldClasspath.length]; for (int i = 0; i < oldClasspath.length; i++) { IClasspathEntry entry = oldClasspath[i]; if (isGradleClasspathContainer(entry)) { IClasspathAttribute[] attributes = replaceClasspathAttribute(entry.getExtraAttributes(), plusKey, plusValue, minusKey); newClasspath[i] = JavaCore.newContainerEntry(entry.getPath(), entry.getAccessRules(), attributes, entry.isExported()); } else { newClasspath[i] = entry; } } project.setRawClasspath(newClasspath, monitor); }
@Override public IClasspathEntry getSelection() { if (fEditResult != null) { if (fOldClasspathEntry != null && fOldClasspathEntry.getPath().equals(fEditResult.getPath())) { return JavaCore.newContainerEntry(fEditResult.getPath(), fOldClasspathEntry.getAccessRules(), fOldClasspathEntry.getExtraAttributes(), fOldClasspathEntry.isExported()); } else { return JavaCore.newContainerEntry(fEditResult.getPath(), false); } } return null; }