for (int i = 0; i < locations.length; i++) { Element element = doc.createElement("libraryLocation"); //$NON-NLS-1$ element.setAttribute("jreJar", locations[i].getSystemLibraryPath().toString()); //$NON-NLS-1$ element.setAttribute("jreSrc", locations[i].getSystemLibrarySourcePath().toString()); //$NON-NLS-1$ IPath annotationsPath = locations[i].getExternalAnnotationsPath(); if (null != annotationsPath && !annotationsPath.isEmpty()) { element.setAttribute("jreExternalAnns", annotationsPath.toString()); //$NON-NLS-1$ IPath packageRootPath = locations[i].getPackageRootPath(); if (packageRootPath != null) { element.setAttribute("pkgRoot", packageRootPath.toString()); //$NON-NLS-1$ URL javadocURL= locations[i].getJavadocLocation(); if (javadocURL != null) { element.setAttribute("jreJavadoc", javadocURL.toExternalForm()); //$NON-NLS-1$ URL indexURL = locations[i].getIndexLocation(); if(indexURL != null) { element.setAttribute("jreIndex", indexURL.toExternalForm()); //$NON-NLS-1$
@Override public boolean equals(Object obj) { if (obj instanceof LibraryLocation) { LibraryLocation lib = (LibraryLocation)obj; return getSystemLibraryPath().equals(lib.getSystemLibraryPath()) && equals(getSystemLibrarySourcePath(), lib.getSystemLibrarySourcePath()) && equals(getExternalAnnotationsPath(), lib.getExternalAnnotationsPath()) && equals(getPackageRootPath(), lib.getPackageRootPath()) && LaunchingPlugin.sameURL(getJavadocLocation(), lib.getJavadocLocation()); } return false; }
/** * Creates a new library standin on the given library location. */ public LibraryStandin(LibraryLocation libraryLocation) { fSystemLibrary= libraryLocation.getSystemLibraryPath(); setSystemLibrarySourcePath(libraryLocation.getSystemLibrarySourcePath()); setPackageRootPath(libraryLocation.getPackageRootPath()); setJavadocLocation(libraryLocation.getJavadocLocation()); }
private void processLibraryLocation(LibraryLocation[] libLocations, String label) { for (int l= 0; l < libLocations.length; l++) { LibraryLocation location= libLocations[l]; fLib2Name.put(location.getSystemLibraryPath(), label); } }
for (int i = 0; i < locations.length; i++) { LibraryLocation location = locations[i]; String name = location.getSystemLibraryPath().lastSegment(); if (name.equalsIgnoreCase("rt.jar")) { //$NON-NLS-1$ rtjar = location; newPath= systemLib.getSystemLibraryPath(); } else if (variable.equals(JavaRuntime.JRESRC_VARIABLE)) { newPath= systemLib.getSystemLibrarySourcePath(); } else if (variable.equals(JavaRuntime.JRESRCROOT_VARIABLE)){ newPath= systemLib.getPackageRootPath();
final LibraryLocation location = new LibraryLocation(systemLibraryPath, sourcePath, packageRootPath, javadoc); final IClasspathEntry cpEntry = JavaCore.newLibraryEntry( location.getSystemLibraryPath(), location.getSystemLibrarySourcePath(), location.getPackageRootPath()); final IRuntimeClasspathEntry rtcpEntry = new RuntimeClasspathEntry(cpEntry);
File lib = path.toFile(); if (lib.exists() && lib.isFile()) { LibraryLocation libraryLocation = new LibraryLocation(path, getDefaultSystemLibrarySource(lib), getDefaultPackageRootPath(), for(ListIterator<LibraryLocation> liter = allLibs.listIterator(); liter.hasNext();) { lib = liter.next(); IPath systemLibraryPath = lib.getSystemLibraryPath(); String device = systemLibraryPath.getDevice(); if (device != null) {
for (Iterator<LibraryLocation> locationIterator = libraries.iterator(); locationIterator.hasNext();) { LibraryLocation currentLibrary = locationIterator.next(); matcher.reset(currentLibrary.getSystemLibraryPath().toOSString()); if (matcher.find()){ currentLibrary.setSystemLibrarySource(sourcePath);
/** * @see org.eclipse.jdt.launching.IVMInstallType#getDefaultLibraryLocations(java.io.File) */ @Override public LibraryLocation[] getDefaultLibraryLocations(File installLocation) { IPath libPath = getDefaultSystemLibrary(installLocation); File lib = libPath.toFile(); if (lib.exists()) { return new LibraryLocation[] {new LibraryLocation(libPath, getDefaultSystemLibrarySource(lib), getDefaultPackageRootPath())}; } return new LibraryLocation[0]; }
private static IClasspathAttribute[] buildClasspathAttributes(final IVMInstall vm, final LibraryLocation lib, final boolean overrideJavaDoc) { List<IClasspathAttribute> classpathAttributes = new LinkedList<>(); // process the javadoc location URL javadocLocation = lib.getJavadocLocation(); if (overrideJavaDoc && javadocLocation == null) { javadocLocation = vm.getJavadocLocation(); } if(javadocLocation != null) { IClasspathAttribute javadocCPAttribute = JavaCore.newClasspathAttribute(IClasspathAttribute.JAVADOC_LOCATION_ATTRIBUTE_NAME, javadocLocation.toExternalForm()); classpathAttributes.add(javadocCPAttribute); } // process the index location URL indexLocation = lib.getIndexLocation(); if(indexLocation != null) { IClasspathAttribute indexCPLocation = JavaCore.newClasspathAttribute(IClasspathAttribute.INDEX_LOCATION_ATTRIBUTE_NAME, indexLocation.toExternalForm()); classpathAttributes.add(indexCPLocation); } IPath annotationsPath = lib.getExternalAnnotationsPath(); if (null != annotationsPath && !annotationsPath.isEmpty()) { IClasspathAttribute xAnnLocation = JavaCore.newClasspathAttribute(IClasspathAttribute.EXTERNAL_ANNOTATION_PATH, annotationsPath.toPortableString()); classpathAttributes.add(xAnnLocation); } return classpathAttributes.toArray(new IClasspathAttribute[classpathAttributes.size()]); }
/** * Determines if the present setup is the default location s for this JRE * @return true if the current set of locations are the defaults, false otherwise */ protected boolean isDefaultLocations() { LibraryLocation[] libraryLocations = fLibraryContentProvider.getLibraries(); IVMInstall install = getVMInstall(); if (install == null || libraryLocations == null) { return true; } File installLocation = install.getInstallLocation(); if (installLocation != null) { LibraryLocation[] def = getVMInstallType().getDefaultLibraryLocations(installLocation); if (def.length == libraryLocations.length) { for (int i = 0; i < def.length; i++) { if (!def[i].equals(libraryLocations[i])) { return false; } } return true; } } return false; }
@Override public int hashCode() { return getSystemLibraryPath().hashCode(); }
IPath libraryPath = location.getSystemLibraryPath(); URL javadocLocation = location.getJavadocLocation(); if (overrideJavaDoc && javadocLocation == null) { javadocLocation = vm.getJavadocLocation(); attributes = new IClasspathAttribute[]{JavaCore.newClasspathAttribute(IClasspathAttribute.JAVADOC_LOCATION_ATTRIBUTE_NAME, javadocLocation.toExternalForm())}; IClasspathEntry cpe = JavaCore.newLibraryEntry(libraryPath, location.getSystemLibraryPath(), location.getPackageRootPath(), EMPTY_RULES, attributes, false); IRuntimeClasspathEntry resolved = new RuntimeClasspathEntry(cpe); resolved.setClasspathProperty(kind); IPath sourcePath = location.getSystemLibrarySourcePath(); if (sourcePath != null && !sourcePath.isEmpty()) { resolved.setSourceAttachmentPath(sourcePath); resolved.setSourceAttachmentRootPath(location.getPackageRootPath());
for (int i = 0; i < locations.length; i++) { LibraryLocation location = locations[i]; String name = location.getSystemLibraryPath().lastSegment(); if (name.equalsIgnoreCase("rt.jar")) { //$NON-NLS-1$ rtjar = location; newPath= systemLib.getSystemLibraryPath(); } else if (variable.equals(JavaRuntime.JRESRC_VARIABLE)) { newPath= systemLib.getSystemLibrarySourcePath(); } else if (variable.equals(JavaRuntime.JRESRCROOT_VARIABLE)){ newPath= systemLib.getPackageRootPath();
LibraryLocation location = new LibraryLocation(this.jarFile, Path.EMPTY, Path.EMPTY); IClasspathEntry cpEntry = JavaCore.newLibraryEntry(location.getSystemLibraryPath(), location.getSystemLibrarySourcePath(), location.getPackageRootPath()); for (final String cpElement : classPathStr.split(Pattern.quote(":"))) { //$NON-NLS-1$ final IPath path = parsePath(cpElement, Path.EMPTY, rootPath); location = new LibraryLocation(path, Path.EMPTY, Path.EMPTY); cpEntry = JavaCore.newLibraryEntry(location.getSystemLibraryPath(), location.getSystemLibrarySourcePath(), location.getPackageRootPath()); rtcpEntry = new RuntimeClasspathEntry(cpEntry);
File lib = path.toFile(); if (lib.exists() && lib.isFile()) { LibraryLocation libraryLocation = new LibraryLocation(path, src, Path.EMPTY, url, indexurl); boot.add(libraryLocation); for(ListIterator<LibraryLocation> liter = allLibs.listIterator(); liter.hasNext();) { lib = liter.next(); if(!set.add(lib.getSystemLibraryPath().toOSString())) {
/** * Uses the given src map to find source libraries that are associated with the * library locations in the list. The library locations are updated with the * found source path. * * @param srcMap mapping of library location regexs to source location regexs * @param libraries list of {@link LibraryLocation} objects to update with source locations * @see #getSourceMap() */ private void addSourceLocationsToLibraries(Map<String, String> srcMap, List<LibraryLocation> libraries){ for (Iterator<String> patternIterator = srcMap.keySet().iterator(); patternIterator.hasNext();) { // Try each library regex pattern and see what libraries apply. String currentKey = patternIterator.next(); Pattern currentPattern = Pattern.compile(currentKey); Matcher matcher = currentPattern.matcher(""); //$NON-NLS-1$ for (Iterator<LibraryLocation> locationIterator = libraries.iterator(); locationIterator.hasNext();) { LibraryLocation currentLibrary = locationIterator.next(); matcher.reset(currentLibrary.getSystemLibraryPath().toOSString()); if (matcher.find()){ // Found a file that the pattern applies to, use the map to get the source location String sourceLocation = matcher.replaceAll(srcMap.get(currentKey)); IPath sourcePath = new Path(sourceLocation); // Only add the source archive if it exists if (sourcePath.toFile().exists()){ currentLibrary.setSystemLibrarySource(sourcePath); } } } } }
/** * @see org.eclipse.jdt.launching.IVMInstallType#getDefaultLibraryLocations(java.io.File) */ @Override public LibraryLocation[] getDefaultLibraryLocations(File installLocation) { IPath libPath = getDefaultSystemLibrary(installLocation); File lib = libPath.toFile(); if (lib.exists()) { return new LibraryLocation[] {new LibraryLocation(libPath, getDefaultSystemLibrarySource(lib), getDefaultPackageRootPath())}; } return new LibraryLocation[0]; }
private static IClasspathAttribute[] buildClasspathAttributes(final IVMInstall vm, final LibraryLocation lib, final boolean overrideJavaDoc) { List<IClasspathAttribute> classpathAttributes = new LinkedList<IClasspathAttribute>(); // process the javadoc location URL javadocLocation = lib.getJavadocLocation(); if (overrideJavaDoc && javadocLocation == null) { javadocLocation = vm.getJavadocLocation(); } if(javadocLocation != null) { IClasspathAttribute javadocCPAttribute = JavaCore.newClasspathAttribute(IClasspathAttribute.JAVADOC_LOCATION_ATTRIBUTE_NAME, javadocLocation.toExternalForm()); classpathAttributes.add(javadocCPAttribute); } // process the index location URL indexLocation = lib.getIndexLocation(); if(indexLocation != null) { IClasspathAttribute indexCPLocation = JavaCore.newClasspathAttribute(IClasspathAttribute.INDEX_LOCATION_ATTRIBUTE_NAME, indexLocation.toExternalForm()); classpathAttributes.add(indexCPLocation); } IPath annotationsPath = lib.getExternalAnnotationsPath(); if (null != annotationsPath && !annotationsPath.isEmpty()) { IClasspathAttribute xAnnLocation = JavaCore.newClasspathAttribute(IClasspathAttribute.EXTERNAL_ANNOTATION_PATH, annotationsPath.toPortableString()); classpathAttributes.add(xAnnLocation); } return classpathAttributes.toArray(new IClasspathAttribute[classpathAttributes.size()]); }
boolean equal = true; while (i < newLocations.length && equal) { equal = newLocations[i].equals(prevLocations[i]); i++;