private Set<String> searchUserClass(IRuntimeClasspathEntry[] entries) { Set<String> locations = new LinkedHashSet<String>(); for (int i = 0; i < entries.length; i++) { IRuntimeClasspathEntry entry = entries[i]; if (entry.getClasspathProperty() == IRuntimeClasspathEntry.USER_CLASSES) { String location = entry.getLocation(); if (location != null) { locations.add(location); } } } return locations; }
private IRuntimeClasspathEntry[] resolveOptional(IRuntimeClasspathEntry entry) throws CoreException { if (isOptional(entry.getClasspathEntry())) { return EMPTY_RESULT; } else { throw new CoreException(new Status(IStatus.ERROR, CorePlugin.PLUGIN_ID, String.format("The project: %s which is referenced by the classpath, does not exist", entry.getPath().lastSegment()))); } }
/** * Sometimes for M2E , if you set package type as war , it will load some dependency to WEB App Container. * * Here the method is actaully * @param entryCur * @return */ public static boolean isM2EMavenContainer(IRuntimeClasspathEntry entryCur){ return entryCur.getType()== IRuntimeClasspathEntry.CONTAINER && (( MAVEN_CONTAINER_ID.equals(entryCur.getVariableName()) || NEW_MAVEN_CONTAINER_ID.equals(entryCur.getVariableName())) ); }
private void collectReferencedElements(IJavaProject project, HashSet result) throws CoreException { IRuntimeClasspathEntry[] unresolved = JavaRuntime.computeUnresolvedRuntimeClasspath(project); for (int i= 0; i < unresolved.length; i++) { IRuntimeClasspathEntry curr= unresolved[i]; if (curr.getType() == IRuntimeClasspathEntry.PROJECT) { result.add(new JavadocLinkRef(JavaCore.create((IProject) curr.getResource()))); } else { IRuntimeClasspathEntry[] entries= JavaRuntime.resolveRuntimeClasspathEntry(curr, project); for (int k = 0; k < entries.length; k++) { IRuntimeClasspathEntry entry= entries[k]; if (entry.getType() == IRuntimeClasspathEntry.PROJECT) { result.add(new JavadocLinkRef(JavaCore.create((IProject) entry.getResource()))); } else if (entry.getType() == IRuntimeClasspathEntry.ARCHIVE) { IClasspathEntry classpathEntry= entry.getClasspathEntry(); if (classpathEntry != null) { IPath containerPath= null; if (curr.getType() == IRuntimeClasspathEntry.CONTAINER) { containerPath= curr.getPath(); } result.add(new JavadocLinkRef(containerPath, classpathEntry, project)); } } } } } }
if (obj instanceof IRuntimeClasspathEntry) { IRuntimeClasspathEntry r = (IRuntimeClasspathEntry)obj; if (getType() == r.getType() && getClasspathProperty() == r.getClasspathProperty()) { if (getType() == IRuntimeClasspathEntry.CONTAINER) { String id = getPath().segment(0); ClasspathContainerInitializer initializer = JavaCore.getClasspathContainerInitializer(id); IJavaProject javaProject1 = getJavaProject(); IJavaProject javaProject2 = r.getJavaProject(); if (initializer == null || javaProject1 == null || javaProject2 == null) { return getPath().equals(r.getPath()); Object comparisonID2 = initializer.getComparisonID(r.getPath(), javaProject2); return comparisonID1.equals(comparisonID2); } else if (getPath() != null && getPath().equals(r.getPath())) { IPath sa1 = getSourceAttachmentPath(); IPath root1 = getSourceAttachmentRootPath(); IPath sa2 = r.getSourceAttachmentPath(); IPath root2 = r.getSourceAttachmentRootPath(); return equal(sa1, sa2) && equal(root1, root2);
IPath archPath = JavaCore.getClasspathVariable(entry.getVariableName()); if (archPath != null) { if (entry.getPath().segmentCount() > 1) { archPath = archPath.append(entry.getPath().removeFirstSegments(1)); IPath srcVar = entry.getSourceAttachmentPath(); IPath srcRootPath = null; IPath srcRootVar = entry.getSourceAttachmentRootPath(); if (archPath != null && !archPath.isEmpty()) { if (srcVar != null && !srcVar.isEmpty()) { IClasspathEntry archEntry = JavaCore.newLibraryEntry(archPath, srcPath, srcRootPath, entry.getClasspathEntry().isExported()); IRuntimeClasspathEntry runtimeArchEntry = newRuntimeClasspathEntry(archEntry); runtimeArchEntry.setClasspathProperty(entry.getClasspathProperty()); if (configuration == null) { return resolveRuntimeClasspathEntry(runtimeArchEntry, project);
/** * @see IRuntimeClasspathEntryResolver#resolveRuntimeClasspathEntry(IRuntimeClasspathEntry, ILaunchConfiguration) */ @Override public IRuntimeClasspathEntry[] resolveRuntimeClasspathEntry(IRuntimeClasspathEntry entry, ILaunchConfiguration configuration) throws CoreException { IVMInstall jre = null; if (entry.getType() == IRuntimeClasspathEntry.CONTAINER && entry.getPath().segmentCount() > 1) { // a specific VM jre = JREContainerInitializer.resolveVM(entry.getPath()); } else { // default VM for config jre = JavaRuntime.computeVMInstall(configuration); } if (jre == null) { // cannot resolve JRE return new IRuntimeClasspathEntry[0]; } return resolveLibraryLocations(jre, entry.getClasspathProperty()); }
public String getRealPath() { if(entry == null) return null; if(entry.getType() == IRuntimeClasspathEntry.PROJECT){ return entry.getResource().getLocation().toOSString(); }else{ return entry.getLocation(); } }
private static String[] computeDefaultRuntimeClassPath(IJavaProject jproject, boolean includeTestScope) throws CoreException { IRuntimeClasspathEntry[] unresolved = JavaRuntime.computeUnresolvedRuntimeClasspath(jproject); Set<String> resolved = new LinkedHashSet<String>(); for (int i = 0; i < unresolved.length; i++) { IRuntimeClasspathEntry entry = unresolved[i]; if (entry.getClasspathProperty() == IRuntimeClasspathEntry.USER_CLASSES) { IRuntimeClasspathEntry[] entries = JavaRuntime.resolveRuntimeClasspathEntry(entry, jproject, !includeTestScope); for (int j = 0; j < entries.length; j++) { if (!includeTestScope && JdtUtils.isTest(entries[j].getClasspathEntry())) { continue; } String location = entries[j].getLocation(); if (location != null) { // remove duplicate classpath resolved.add(location); } } } } return resolved.toArray(new String[resolved.size()]); }
public IPath getPath() { return entry.getPath(); }
if (libraries.size() != 1 || !libraries.get(0).getClasspathEntry().getPath().equals(this.jarFile)) { final IPath rootPath = path.removeLastSegments(1); for (final IRuntimeClasspathEntry location : libraries) { final Element libraryNode = document.createElement(SREConstants.XML_LIBRARY_LOCATION); libraryNode.setAttribute(SREConstants.XML_SYSTEM_LIBRARY_PATH, makeRelativePath(location.getPath(), path, rootPath)); libraryNode.setAttribute(SREConstants.XML_PACKAGE_ROOT_PATH, makeRelativePath(location.getSourceAttachmentRootPath(), path, rootPath)); libraryNode.setAttribute(SREConstants.XML_SOURCE_PATH, makeRelativePath(location.getSourceAttachmentPath(), path, rootPath));
/** * Returns a list of resources of currently selected folders */ protected List getSelectedFolders() { List list = getEntriesAsList(); List folders = new ArrayList(); Iterator iter = list.iterator(); while (iter.hasNext()) { IRuntimeClasspathEntry entry = (IRuntimeClasspathEntry)iter.next(); if (entry.getType() == IRuntimeClasspathEntry.ARCHIVE) { IResource res = entry.getResource(); if (res != null && res instanceof IContainer) { folders.add(res); } } } return folders; }
public int getType() { return entry.getType(); }
public static void adjustClasspathProperty(IRuntimeClasspathEntry r, IClasspathEntry entry) { if (r.getClasspathProperty() == IRuntimeClasspathEntry.USER_CLASSES) { if (Arrays.stream(entry.getExtraAttributes()).anyMatch(attribute -> IClasspathAttribute.MODULE.equals(attribute.getName()) && Boolean.TRUE.toString().equals(attribute.getValue()))) { r.setClasspathProperty(IRuntimeClasspathEntry.MODULE_PATH); } else { r.setClasspathProperty(IRuntimeClasspathEntry.CLASS_PATH); } } }
public int getClasspathProperty() { return entry.getClasspathProperty(); }
/** * Prompts source attachment. * * @see org.eclipse.jface.action.IAction#run() */ public void run() { IClasspathEntry classpathEntry = BuildPathDialogAccess.configureSourceAttachment(getShell(), fEntries[0].getClasspathEntry()); if (classpathEntry != null) { for (int i = 0; i < fEntries.length; i++) { IRuntimeClasspathEntry entry = fEntries[i]; entry.setSourceAttachmentPath(classpathEntry.getSourceAttachmentPath()); entry.setSourceAttachmentRootPath(classpathEntry.getSourceAttachmentRootPath()); getViewer().refresh(entry); } getViewer().notifyChanged(); } }
public String getLocation() { return entry.getLocation(); }
public org.eclipse.jdt.core.IClasspathEntry getClasspathEntry() { return entry.getClasspathEntry(); }
resolved.setClasspathProperty(kind); IPath sourcePath = location.getSystemLibrarySourcePath(); if (sourcePath != null && !sourcePath.isEmpty()) { resolved.setSourceAttachmentPath(sourcePath); resolved.setSourceAttachmentRootPath(location.getPackageRootPath());