List of usage examples for org.eclipse.jdt.core IClasspathAttribute JAVADOC_LOCATION_ATTRIBUTE_NAME
String JAVADOC_LOCATION_ATTRIBUTE_NAME
To view the source code for org.eclipse.jdt.core IClasspathAttribute JAVADOC_LOCATION_ATTRIBUTE_NAME.
Click Source Link
From source file:at.bestsolution.efxclipse.tooling.jdt.core.internal.BuildPathSupport.java
License:Open Source License
public static IClasspathEntry getJavaFXLibraryEntry(IJavaProject project) { IPath[] paths = getFxJarPath(project); if (paths != null) { IPath jarLocationPath = paths[0]; IPath javadocLocation = paths[1]; IPath fxSource = paths[3];/* www . j a v a 2 s.c o m*/ IClasspathAttribute[] attributes; IAccessRule[] accessRules = {}; if (javadocLocation == null || !javadocLocation.toFile().exists()) { attributes = new IClasspathAttribute[] { JavaCore.newClasspathAttribute( IClasspathAttribute.JAVADOC_LOCATION_ATTRIBUTE_NAME, WEB_JAVADOC_LOCATION) }; } else { attributes = new IClasspathAttribute[] { JavaCore.newClasspathAttribute(IClasspathAttribute.JAVADOC_LOCATION_ATTRIBUTE_NAME, javadocLocation.toFile().toURI().toString()) }; } if (jarLocationPath.toFile().exists()) { return JavaCore.newLibraryEntry(jarLocationPath, fxSource, null, accessRules, attributes, false); } } return null; }
From source file:at.bestsolution.efxclipse.tooling.pde.java7.JavaFXClassPathExtender.java
License:Open Source License
private IClasspathEntry getEntry(IVMInstall vm, BundleDescription project) { IPath[] paths = BuildPathSupport.getFxJarPath(vm); if (paths == null) { return null; } else {/* ww w .j ava 2s . c o m*/ List<IAccessRule> l = new ArrayList<IAccessRule>(); for (ImportPackageSpecification i : project.getImportPackages()) { if (i.getName().startsWith("javafx")) { l.add(JavaCore.newAccessRule(new Path(i.getName().replace('.', '/') + "/*"), IAccessRule.K_ACCESSIBLE)); } else if (i.getName().startsWith("com.sun.browser")) { l.add(JavaCore.newAccessRule(new Path(i.getName().replace('.', '/') + "/*"), IAccessRule.K_DISCOURAGED)); } else if (i.getName().startsWith("com.sun.deploy")) { l.add(JavaCore.newAccessRule(new Path(i.getName().replace('.', '/') + "/*"), IAccessRule.K_DISCOURAGED)); } else if (i.getName().startsWith("com.sun.glass")) { l.add(JavaCore.newAccessRule(new Path(i.getName().replace('.', '/') + "/*"), IAccessRule.K_DISCOURAGED)); } else if (i.getName().startsWith("com.sun.javafx")) { l.add(JavaCore.newAccessRule(new Path(i.getName().replace('.', '/') + "/*"), IAccessRule.K_DISCOURAGED)); } else if (i.getName().startsWith("com.sun.media")) { l.add(JavaCore.newAccessRule(new Path(i.getName().replace('.', '/') + "/*"), IAccessRule.K_DISCOURAGED)); } else if (i.getName().startsWith("com.sun.openpisces")) { l.add(JavaCore.newAccessRule(new Path(i.getName().replace('.', '/') + "/*"), IAccessRule.K_DISCOURAGED)); } else if (i.getName().startsWith("com.sun.prism")) { l.add(JavaCore.newAccessRule(new Path(i.getName().replace('.', '/') + "/*"), IAccessRule.K_DISCOURAGED)); } else if (i.getName().startsWith("com.sun.scenario")) { l.add(JavaCore.newAccessRule(new Path(i.getName().replace('.', '/') + "/*"), IAccessRule.K_DISCOURAGED)); } else if (i.getName().startsWith("com.sun.t2k")) { l.add(JavaCore.newAccessRule(new Path(i.getName().replace('.', '/') + "/*"), IAccessRule.K_DISCOURAGED)); } else if (i.getName().startsWith("com.sun.webpane")) { l.add(JavaCore.newAccessRule(new Path(i.getName().replace('.', '/') + "/*"), IAccessRule.K_DISCOURAGED)); } else if (i.getName().startsWith("netscape.javascript")) { l.add(JavaCore.newAccessRule(new Path(i.getName().replace('.', '/') + "/*"), IAccessRule.K_DISCOURAGED)); } } IClasspathAttribute[] extraAttributes = { JavaCore.newClasspathAttribute(IClasspathAttribute.JAVADOC_LOCATION_ATTRIBUTE_NAME, paths[1] == null || !paths[1].toFile().exists() ? BuildPathSupport.WEB_JAVADOC_LOCATION : paths[1].toFile().toURI().toString()) }; return JavaCore.newLibraryEntry(paths[0], null, null, l.toArray(new IAccessRule[0]), extraAttributes, false); } }
From source file:at.bestsolution.efxclipse.tooling.pde.ui.classpath.JavaFXClassPathExtender.java
License:Open Source License
@Override public List<IClasspathEntry> getInitialEntries(BundleDescription project) { for (String e : project.getExecutionEnvironments()) { IExecutionEnvironment env = EnvironmentsManager.getDefault().getEnvironment(e); if (env == null) { continue; }// www. j a v a 2 s . c o m IVMInstall vm = env.getDefaultVM(); if (vm == null) { for (IVMInstall i : env.getCompatibleVMs()) { vm = i; break; } } if (vm != null) { IPath[] paths = BuildPathSupport.getFxJarPath(vm); if (paths == null) { return Collections.emptyList(); } else { List<IAccessRule> l = new ArrayList<IAccessRule>(); for (ImportPackageSpecification i : project.getImportPackages()) { if (i.getName().startsWith("javafx")) { l.add(JavaCore.newAccessRule(new Path(i.getName().replace('.', '/') + "/*"), IAccessRule.K_ACCESSIBLE)); } else if (i.getName().startsWith("com.sun.browser")) { l.add(JavaCore.newAccessRule(new Path(i.getName().replace('.', '/') + "/*"), IAccessRule.K_DISCOURAGED)); } else if (i.getName().startsWith("com.sun.deploy")) { l.add(JavaCore.newAccessRule(new Path(i.getName().replace('.', '/') + "/*"), IAccessRule.K_DISCOURAGED)); } else if (i.getName().startsWith("com.sun.glass")) { l.add(JavaCore.newAccessRule(new Path(i.getName().replace('.', '/') + "/*"), IAccessRule.K_DISCOURAGED)); } else if (i.getName().startsWith("com.sun.javafx")) { l.add(JavaCore.newAccessRule(new Path(i.getName().replace('.', '/') + "/*"), IAccessRule.K_DISCOURAGED)); } else if (i.getName().startsWith("com.sun.media")) { l.add(JavaCore.newAccessRule(new Path(i.getName().replace('.', '/') + "/*"), IAccessRule.K_DISCOURAGED)); } else if (i.getName().startsWith("com.sun.openpisces")) { l.add(JavaCore.newAccessRule(new Path(i.getName().replace('.', '/') + "/*"), IAccessRule.K_DISCOURAGED)); } else if (i.getName().startsWith("com.sun.prism")) { l.add(JavaCore.newAccessRule(new Path(i.getName().replace('.', '/') + "/*"), IAccessRule.K_DISCOURAGED)); } else if (i.getName().startsWith("com.sun.scenario")) { l.add(JavaCore.newAccessRule(new Path(i.getName().replace('.', '/') + "/*"), IAccessRule.K_DISCOURAGED)); } else if (i.getName().startsWith("com.sun.t2k")) { l.add(JavaCore.newAccessRule(new Path(i.getName().replace('.', '/') + "/*"), IAccessRule.K_DISCOURAGED)); } else if (i.getName().startsWith("com.sun.webpane")) { l.add(JavaCore.newAccessRule(new Path(i.getName().replace('.', '/') + "/*"), IAccessRule.K_DISCOURAGED)); } else if (i.getName().startsWith("netscape.javascript")) { l.add(JavaCore.newAccessRule(new Path(i.getName().replace('.', '/') + "/*"), IAccessRule.K_DISCOURAGED)); } } IClasspathAttribute[] extraAttributes = { JavaCore.newClasspathAttribute(IClasspathAttribute.JAVADOC_LOCATION_ATTRIBUTE_NAME, paths[1] == null || !paths[1].toFile().exists() ? BuildPathSupport.WEB_JAVADOC_LOCATION : paths[1].toFile().toURI().toString()) }; return Collections.singletonList(JavaCore.newContainerEntry(paths[0], l.toArray(new IAccessRule[0]), extraAttributes, false)); } } } return Collections.emptyList(); }
From source file:at.bestsolution.fxide.jdt.corext.javadoc.JavaDocLocations.java
License:Open Source License
public static URL getLibraryJavadocLocation(IClasspathEntry entry) { if (entry == null) { throw new IllegalArgumentException("Entry must not be null"); //$NON-NLS-1$ }//from w w w .ja v a 2 s . co m int kind = entry.getEntryKind(); if (kind != IClasspathEntry.CPE_LIBRARY && kind != IClasspathEntry.CPE_VARIABLE) { throw new IllegalArgumentException("Entry must be of kind CPE_LIBRARY or CPE_VARIABLE"); //$NON-NLS-1$ } IClasspathAttribute[] extraAttributes = entry.getExtraAttributes(); for (int i = 0; i < extraAttributes.length; i++) { IClasspathAttribute attrib = extraAttributes[i]; if (IClasspathAttribute.JAVADOC_LOCATION_ATTRIBUTE_NAME.equals(attrib.getName())) { return parseURL(attrib.getValue()); } } return null; }
From source file:com.amazonaws.eclipse.android.sdk.classpath.AndroidSdkClasspathContainer.java
License:Open Source License
/** * Loads the JDT classpath entries for the AWS SDK for Android from the * specified SDK install and returns them as a list. * * @param sdkInstall//from www . jav a2 s . c om * The SDK install from which to load the classpath entries. * * @return A list of the JDT classpath entries for the AWS SDK for Android * at the specified install base. */ private List<IClasspathEntry> loadSdkClasspathEntries(AbstractSdkInstall sdkInstall) { List<IClasspathEntry> classpathEntries = new ArrayList<IClasspathEntry>(); IPath sdkJarPath = null, sdkSourceJarPath = null; try { File sdkJar = sdkInstall.getSdkJar(); sdkJarPath = project.getLocation().append("libs").append(sdkJar.getName()); } catch (FileNotFoundException e) { // The SDK has been deleted, there's no classpath entries anymore. return new ArrayList<IClasspathEntry>(); } IClasspathAttribute externalJavadocPath = JavaCore.newClasspathAttribute( IClasspathAttribute.JAVADOC_LOCATION_ATTRIBUTE_NAME, sdkInstall.getJavadocURL()); if (externalJavadocPath.getValue() != null) { classpathEntries.add(JavaCore.newLibraryEntry(sdkJarPath, sdkSourceJarPath, null, new IAccessRule[0], new IClasspathAttribute[] { externalJavadocPath }, true)); } else { classpathEntries.add(JavaCore.newLibraryEntry(sdkJarPath, sdkSourceJarPath, null, new IAccessRule[0], new IClasspathAttribute[0], true)); } for (File jarFile : sdkInstall.getThirdPartyJars()) { IPath thirdPartyJarPath = new Path(jarFile.getAbsolutePath()); classpathEntries.add(JavaCore.newLibraryEntry(thirdPartyJarPath, thirdPartyJarPath, null, true)); } return classpathEntries; }
From source file:com.amazonaws.eclipse.lambda.project.classpath.LambdaRuntimeClasspathContainer.java
License:Open Source License
private IClasspathEntry loadRuntimeClasspathEntry(LambdaRuntimeLibraryComponent component) { IPath classJarPath = new Path(component.getClassJarFile().getAbsolutePath()); IClasspathAttribute attrs[] = new IClasspathAttribute[0]; if (component.getJavadocJarFile() != null) { attrs = new IClasspathAttribute[] { JavaCore.newClasspathAttribute(IClasspathAttribute.JAVADOC_LOCATION_ATTRIBUTE_NAME, constructJavadocLocationAttributeValue(component.getJavadocJarFile())) }; }// ww w . j a v a2 s .c o m return JavaCore.newLibraryEntry(classJarPath, null, null, new IAccessRule[0], attrs, true); }
From source file:com.amazonaws.eclipse.sdk.ui.classpath.AwsClasspathContainer.java
License:Open Source License
/** * Loads the JDT classpath entries for the AWS SDK for Java from the specified * SDK install and returns them as a list. * * @param sdkInstall/*from w ww.ja v a 2 s . c om*/ * The SDK install from which to load the classpath entries. * * @return A list of the JDT classpath entries for the AWS SDK for Java at the * specified install base. */ private List<IClasspathEntry> loadSdkClasspathEntries(SdkInstall sdkInstall) { List<IClasspathEntry> classpathEntries = new ArrayList<IClasspathEntry>(); IPath sdkJarPath, sdkSourceJarPath; try { sdkJarPath = new Path(sdkInstall.getSdkJar().getAbsolutePath()); sdkSourceJarPath = new Path(sdkInstall.getSdkSourceJar().getAbsolutePath()); } catch (FileNotFoundException e) { // The SDK has been deleted, there's no classpath entries anymore. return new ArrayList<IClasspathEntry>(); } IClasspathAttribute externalJavadocPath = JavaCore.newClasspathAttribute( IClasspathAttribute.JAVADOC_LOCATION_ATTRIBUTE_NAME, sdkInstall.getJavadocURL()); if (externalJavadocPath.getValue() != null) { classpathEntries.add(JavaCore.newLibraryEntry(sdkJarPath, sdkSourceJarPath, null, new IAccessRule[0], new IClasspathAttribute[] { externalJavadocPath }, true)); } else { classpathEntries.add(JavaCore.newLibraryEntry(sdkJarPath, sdkSourceJarPath, null, new IAccessRule[0], new IClasspathAttribute[0], true)); } for (File jarFile : sdkInstall.getThirdPartyJars()) { IPath thirdPartyJarPath = new Path(jarFile.getAbsolutePath()); classpathEntries.add(JavaCore.newLibraryEntry(thirdPartyJarPath, thirdPartyJarPath, null, true)); } return classpathEntries; }
From source file:com.android.ide.eclipse.adt.internal.project.AndroidClasspathContainerInitializer.java
License:Open Source License
/** * Generates an array of {@link IClasspathEntry} from a set of paths. * @see #getTargetPaths(IAndroidTarget)/* w w w. ja v a 2 s .c o m*/ */ private static IClasspathEntry[] createClasspathEntriesFromPaths(String[] paths, IAndroidTarget target) { ArrayList<IClasspathEntry> list = new ArrayList<IClasspathEntry>(); // First, we create the IClasspathEntry for the framework. // now add the android framework to the class path. // create the path object. IPath androidLib = new Path(paths[CACHE_INDEX_JAR]); IPath androidSrc = null; String androidSrcOsPath = null; IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); if (target != null) { androidSrcOsPath = ProjectHelper.loadStringProperty(root, getAndroidSourceProperty(target)); } if (androidSrcOsPath != null && androidSrcOsPath.trim().length() > 0) { androidSrc = new Path(androidSrcOsPath); } if (androidSrc == null) { androidSrc = new Path(paths[CACHE_INDEX_SRC]); File androidSrcFile = new File(paths[CACHE_INDEX_SRC]); if (!androidSrcFile.isDirectory()) { androidSrc = null; } } if (androidSrc == null && target != null) { Bundle bundle = getSourceBundle(); if (bundle != null) { AndroidVersion version = target.getVersion(); String apiString = version.getApiString(); String sourcePath = apiString + SOURCES_ZIP; URL sourceURL = bundle.getEntry(sourcePath); if (sourceURL != null) { URL url = null; try { url = FileLocator.resolve(sourceURL); } catch (IOException ignore) { } if (url != null) { androidSrcOsPath = url.getFile(); if (new File(androidSrcOsPath).isFile()) { androidSrc = new Path(androidSrcOsPath); } } } } } // create the java doc link. String androidApiURL = ProjectHelper.loadStringProperty(root, PROPERTY_ANDROID_API); String apiURL = null; if (androidApiURL != null && testURL(androidApiURL)) { apiURL = androidApiURL; } else { if (testURL(paths[CACHE_INDEX_DOCS_URI])) { apiURL = paths[CACHE_INDEX_DOCS_URI]; } else if (testURL(ANDROID_API_REFERENCE)) { apiURL = ANDROID_API_REFERENCE; } } IClasspathAttribute[] attributes = null; if (apiURL != null && !NULL_API_URL.equals(apiURL)) { IClasspathAttribute cpAttribute = JavaCore .newClasspathAttribute(IClasspathAttribute.JAVADOC_LOCATION_ATTRIBUTE_NAME, apiURL); attributes = new IClasspathAttribute[] { cpAttribute }; } // create the access rule to restrict access to classes in // com.android.internal IAccessRule accessRule = JavaCore.newAccessRule(new Path("com/android/internal/**"), //$NON-NLS-1$ IAccessRule.K_NON_ACCESSIBLE); IClasspathEntry frameworkClasspathEntry = JavaCore.newLibraryEntry(androidLib, androidSrc, // source attachment path null, // default source attachment root path. new IAccessRule[] { accessRule }, attributes, false // not exported. ); list.add(frameworkClasspathEntry); // now deal with optional libraries if (paths.length >= 5) { String docPath = paths[CACHE_INDEX_OPT_DOCS_URI]; int i = 4; while (i < paths.length) { Path jarPath = new Path(paths[i++]); attributes = null; if (docPath.length() > 0) { attributes = new IClasspathAttribute[] { JavaCore .newClasspathAttribute(IClasspathAttribute.JAVADOC_LOCATION_ATTRIBUTE_NAME, docPath) }; } IClasspathEntry entry = JavaCore.newLibraryEntry(jarPath, null, // source attachment path null, // default source attachment root path. null, attributes, false // not exported. ); list.add(entry); } } if (apiURL != null) { ProjectHelper.saveStringProperty(root, PROPERTY_ANDROID_API, apiURL); } if (androidSrc != null && target != null) { ProjectHelper.saveStringProperty(root, getAndroidSourceProperty(target), androidSrc.toOSString()); } return list.toArray(new IClasspathEntry[list.size()]); }
From source file:com.android.ide.eclipse.adt.internal.project.AndroidClasspathContainerInitializer.java
License:Open Source License
@Override public void requestClasspathContainerUpdate(IPath containerPath, IJavaProject project, IClasspathContainer containerSuggestion) throws CoreException { AdtPlugin plugin = AdtPlugin.getDefault(); synchronized (Sdk.getLock()) { boolean sdkIsLoaded = plugin.getSdkLoadStatus() == LoadStatus.LOADED; // check if the project has a valid target. IAndroidTarget target = null;//from w w w . j a v a2s .c om if (sdkIsLoaded) { target = Sdk.getCurrent().getTarget(project.getProject()); } if (sdkIsLoaded && target != null) { String[] paths = getTargetPaths(target); IPath android_lib = new Path(paths[CACHE_INDEX_JAR]); IClasspathEntry[] entries = containerSuggestion.getClasspathEntries(); for (int i = 0; i < entries.length; i++) { IClasspathEntry entry = entries[i]; if (entry.getEntryKind() == IClasspathEntry.CPE_LIBRARY) { IPath entryPath = entry.getPath(); if (entryPath != null) { if (entryPath.equals(android_lib)) { IPath entrySrcPath = entry.getSourceAttachmentPath(); IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); if (entrySrcPath != null) { ProjectHelper.saveStringProperty(root, getAndroidSourceProperty(target), entrySrcPath.toString()); } else { ProjectHelper.saveStringProperty(root, getAndroidSourceProperty(target), null); } IClasspathAttribute[] extraAttributtes = entry.getExtraAttributes(); if (extraAttributtes.length == 0) { ProjectHelper.saveStringProperty(root, PROPERTY_ANDROID_API, NULL_API_URL); } for (int j = 0; j < extraAttributtes.length; j++) { IClasspathAttribute extraAttribute = extraAttributtes[j]; String value = extraAttribute.getValue(); if ((value == null || value.trim().length() == 0) && IClasspathAttribute.JAVADOC_LOCATION_ATTRIBUTE_NAME .equals(extraAttribute.getName())) { value = NULL_API_URL; } if (IClasspathAttribute.JAVADOC_LOCATION_ATTRIBUTE_NAME .equals(extraAttribute.getName())) { ProjectHelper.saveStringProperty(root, PROPERTY_ANDROID_API, value); } } } } } } rebindClasspathEntries(project.getJavaModel(), containerPath); } } }
From source file:com.android.ide.eclipse.adt.internal.project.LibraryClasspathContainerInitializer.java
License:Open Source License
private static List<IClasspathEntry> convertJarsToClasspathEntries(final IProject iProject, Set<File> jarFiles) { List<IClasspathEntry> entries = new ArrayList<IClasspathEntry>(jarFiles.size()); // and process the jar files list, but first sanitize it to remove dups. JarListSanitizer sanitizer = new JarListSanitizer( iProject.getFolder(SdkConstants.FD_OUTPUT).getLocation().toFile(), new AndroidPrintStream(iProject, null /*prefix*/, AdtPlugin.getOutStream())); String errorMessage = null;/*from w w w .ja v a 2 s. c o m*/ try { List<File> sanitizedList = sanitizer.sanitize(jarFiles); for (File jarFile : sanitizedList) { if (jarFile instanceof CPEFile) { CPEFile cpeFile = (CPEFile) jarFile; IClasspathEntry e = cpeFile.getClasspathEntry(); entries.add(JavaCore.newLibraryEntry(e.getPath(), e.getSourceAttachmentPath(), e.getSourceAttachmentRootPath(), e.getAccessRules(), e.getExtraAttributes(), true /*isExported*/)); } else { String jarPath = jarFile.getAbsolutePath(); IPath sourceAttachmentPath = null; IClasspathAttribute javaDocAttribute = null; File jarProperties = new File(jarPath + DOT_PROPERTIES); if (jarProperties.isFile()) { Properties p = new Properties(); InputStream is = null; try { p.load(is = new FileInputStream(jarProperties)); String value = p.getProperty(ATTR_SRC); if (value != null) { File srcPath = getFile(jarFile, value); if (srcPath.exists()) { sourceAttachmentPath = new Path(srcPath.getAbsolutePath()); } } value = p.getProperty(ATTR_DOC); if (value != null) { File docPath = getFile(jarFile, value); if (docPath.exists()) { try { javaDocAttribute = JavaCore.newClasspathAttribute( IClasspathAttribute.JAVADOC_LOCATION_ATTRIBUTE_NAME, docPath.toURI().toURL().toString()); } catch (MalformedURLException e) { AdtPlugin.log(e, "Failed to process 'doc' attribute for %s", jarProperties.getAbsolutePath()); } } } } catch (FileNotFoundException e) { // shouldn't happen since we check upfront } catch (IOException e) { AdtPlugin.log(e, "Failed to read %s", jarProperties.getAbsolutePath()); } finally { if (is != null) { try { is.close(); } catch (IOException e) { // ignore } } } } if (javaDocAttribute != null) { entries.add(JavaCore.newLibraryEntry(new Path(jarPath), sourceAttachmentPath, null /*sourceAttachmentRootPath*/, new IAccessRule[0], new IClasspathAttribute[] { javaDocAttribute }, true /*isExported*/)); } else { entries.add(JavaCore.newLibraryEntry(new Path(jarPath), sourceAttachmentPath, null /*sourceAttachmentRootPath*/, true /*isExported*/)); } } } } catch (DifferentLibException e) { errorMessage = e.getMessage(); AdtPlugin.printErrorToConsole(iProject, (Object[]) e.getDetails()); } catch (Sha1Exception e) { errorMessage = e.getMessage(); } processError(iProject, errorMessage, AdtConstants.MARKER_DEPENDENCY, true /*outputToConsole*/); return entries; }