Java Code Examples for org.eclipse.jdt.core.JavaCore#newClasspathAttribute()
The following examples show how to use
org.eclipse.jdt.core.JavaCore#newClasspathAttribute() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: EclipseTestBase_No_ResponseDuirngTypeResolve.java From depends with MIT License | 6 votes |
/** * Extract lib/annotations.jar from the test bundle and add it to the specified project */ private static void addAnnotationJar(IJavaProject jproj, boolean addToModulePath) throws Exception { final String resName = "lib/annotations.jar"; // name in bundle final String libName = resName; // name in destination project InputStream is = null; URL resURL = Apt6TestsPlugin.thePlugin().getBundle().getEntry(resName); is = resURL.openStream(); IPath projPath = jproj.getPath(); IProject proj = jproj.getProject(); IFile libFile = proj.getFile(libName); env.addFolder(projPath, "lib"); if (libFile.exists()) { libFile.setContents(is, true, false, null); } else { libFile.create(is, true, null); } if (addToModulePath) { IClasspathAttribute[] attributes = { JavaCore.newClasspathAttribute(IClasspathAttribute.MODULE, "true") }; env.addEntry(projPath, JavaCore.newLibraryEntry(libFile.getFullPath(), null, null, ClasspathEntry.NO_ACCESS_RULES, attributes, false)); } else { env.addLibrary(projPath, libFile.getFullPath(), null, null); } }
Example 2
Source File: XtendClasspathContainer.java From xtext-xtend with Eclipse Public License 2.0 | 6 votes |
private void addEntry(final List<IClasspathEntry> cpEntries, final String bundleId) { Bundle bundle = Platform.getBundle(bundleId); if (bundle != null) { IPath bundlePath = bundlePath(bundle); IPath sourceBundlePath = calculateSourceBundlePath(bundle, bundlePath); IClasspathAttribute[] extraAttributes = null; if (XtendClasspathContainer.XTEXT_XBASE_LIB_BUNDLE_ID.equals(bundleId) || XtendClasspathContainer.XTEND_LIB_BUNDLE_ID.equals(bundleId) || XtendClasspathContainer.XTEND_LIB_MACRO_BUNDLE_ID.equals(bundleId)) { extraAttributes = new IClasspathAttribute[] { JavaCore.newClasspathAttribute( IClasspathAttribute.JAVADOC_LOCATION_ATTRIBUTE_NAME, calculateJavadocURL()) }; } cpEntries.add(JavaCore.newLibraryEntry(bundlePath, sourceBundlePath, null, new IAccessRule[] {}, extraAttributes, false)); } }
Example 3
Source File: JavadocAttributeConfiguration.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
@Override public IClasspathAttribute performEdit(Shell shell, ClasspathAttributeAccess attribute) { String initialLocation= attribute.getClasspathAttribute().getValue(); String elementName= attribute.getParentClasspassEntry().getPath().lastSegment(); try { URL locationURL= initialLocation != null ? new URL(initialLocation) : null; URL[] result= BuildPathDialogAccess.configureJavadocLocation(shell, elementName, locationURL); if (result != null) { URL newURL= result[0]; String string= newURL != null ? newURL.toExternalForm() : null; return JavaCore.newClasspathAttribute(IClasspathAttribute.JAVADOC_LOCATION_ATTRIBUTE_NAME, string); } } catch (MalformedURLException e) { // todo } return null; }
Example 4
Source File: HoverHandlerTest.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 5 votes |
@Test public void testHoverOnPackageWithNewJavadoc() throws Exception { // See org.eclipse.jdt.ls.tests/testresources/java-doc/readme.txt to generate the remote javadoc importProjects("eclipse/remote-javadoc"); project = WorkspaceHelper.getProject("remote-javadoc"); // First we need to attach our custom Javadoc to java-doc-0.0.1-SNAPSHOT.jar IJavaProject javaProject = JavaCore.create(project); IClasspathEntry[] classpath = javaProject.getRawClasspath(); List<IClasspathEntry> newClasspath = new ArrayList<>(classpath.length); for (IClasspathEntry cpe : classpath) { if (cpe.getEntryKind() == IClasspathEntry.CPE_LIBRARY && cpe.getPath().lastSegment().equals("java-doc-0.0.1-SNAPSHOT.jar")) { String javadocPath = new File("testresources/java-doc/apidocs").getAbsoluteFile().toURI().toString(); IClasspathAttribute atts[] = new IClasspathAttribute[] { JavaCore.newClasspathAttribute("javadoc_location", javadocPath) }; IClasspathEntry newCpe = JavaCore.newLibraryEntry(cpe.getPath(), null, null, null, atts, false); newClasspath.add(newCpe); } else { newClasspath.add(cpe); } } javaProject.setRawClasspath(newClasspath.toArray(new IClasspathEntry[classpath.length]), monitor); handler = new HoverHandler(preferenceManager); //given //Hovers on the java.sql import String payload = createHoverRequest("src/main/java/foo/bar/Bar.java", 2, 14); TextDocumentPositionParams position = getParams(payload); //when Hover hover = handler.hover(position, monitor); assertNotNull(hover); String javadoc = hover.getContents().getLeft().get(1).getLeft(); //Javadoc was read from file://.../org.eclipse.jdt.ls.tests/testresources/java-doc/apidocs/bar/foo/package-summary.html assertTrue(javadoc.contains("this doc is powered by **HTML5**")); assertFalse(javadoc.contains("----"));//no table nonsense }
Example 5
Source File: GWTJarsRuntime.java From gwt-eclipse-plugin with Eclipse Public License 1.0 | 5 votes |
@Override public IClasspathEntry[] getClasspathEntries() { // Note that the GWT SDK puts the javadoc in "doc/javadoc" IPath gwtJavadocLocation = getInstallationPath().append(new Path("doc/javadoc")); IClasspathAttribute[] extraAttributes = new IClasspathAttribute[0]; if (gwtJavadocLocation.toFile().exists()) { extraAttributes = new IClasspathAttribute[] {JavaCore.newClasspathAttribute( IClasspathAttribute.JAVADOC_LOCATION_ATTRIBUTE_NAME, gwtJavadocLocation.toFile() .toURI().toString())}; } List<IClasspathEntry> buildClasspathEntries = new ArrayList<IClasspathEntry>(); if (validate().isOK()) { List<IPath> buildClasspaths = getBuildClasspaths(); for (IPath buildClasspath : buildClasspaths) { if (buildClasspath.lastSegment().startsWith("gwt-")) { buildClasspathEntries.add(JavaCore.newLibraryEntry(buildClasspath, null, null, new IAccessRule[0], extraAttributes, false)); } else { buildClasspathEntries.add(JavaCore.newLibraryEntry(buildClasspath, Util.findSourcesJarForClassesJar(buildClasspath), null, new IAccessRule[0], new IClasspathAttribute[0], false)); } } } return buildClasspathEntries.toArray(NO_ICLASSPATH_ENTRIES); }
Example 6
Source File: NativeLibAttributeConfiguration.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
@Override public IClasspathAttribute performEdit(Shell shell, ClasspathAttributeAccess attribute) { NativeLibrariesDialog dialog= new NativeLibrariesDialog(shell, attribute.getClasspathAttribute().getValue(), attribute.getParentClasspassEntry()); if (dialog.open() == Window.OK) { return JavaCore.newClasspathAttribute(JavaRuntime.CLASSPATH_ATTR_LIBRARY_PATH_ENTRY, dialog.getNativeLibraryPath()); } return null; }
Example 7
Source File: SARLProjectConfigurator.java From sarl with Apache License 2.0 | 5 votes |
/** Replies the default source entries for a SARL project. * * @param projectFolder the folder of the project. * @return the classpath entries. */ public static List<IClasspathEntry> getDefaultSourceClassPathEntries(IPath projectFolder) { final IPath srcJava = projectFolder.append( Path.fromPortableString(SARLConfig.FOLDER_SOURCE_JAVA)); final IClasspathEntry srcJavaEntry = JavaCore.newSourceEntry(srcJava.makeAbsolute()); final IPath srcSarl = projectFolder.append( Path.fromPortableString(SARLConfig.FOLDER_SOURCE_SARL)); final IClasspathEntry srcSarlEntry = JavaCore.newSourceEntry(srcSarl.makeAbsolute()); final IPath srcGeneratedSources = projectFolder.append( Path.fromPortableString(SARLConfig.FOLDER_SOURCE_GENERATED)); final IClasspathAttribute attr = JavaCore.newClasspathAttribute( IClasspathAttribute.IGNORE_OPTIONAL_PROBLEMS, Boolean.TRUE.toString()); final IClasspathEntry srcGeneratedSourcesEntry = JavaCore.newSourceEntry( srcGeneratedSources.makeAbsolute(), ClasspathEntry.INCLUDE_ALL, ClasspathEntry.EXCLUDE_NONE, null /*output location*/, new IClasspathAttribute[] {attr}); final IPath srcResources = projectFolder.append( Path.fromPortableString(SARLConfig.FOLDER_RESOURCES)); final IClasspathEntry srcResourcesEntry = JavaCore.newSourceEntry(srcResources.makeAbsolute()); return Arrays.asList( srcSarlEntry, srcJavaEntry, srcResourcesEntry, srcGeneratedSourcesEntry); }
Example 8
Source File: SerializableAttribute.java From google-cloud-eclipse with Apache License 2.0 | 4 votes |
IClasspathAttribute toClasspathAttribute() { return JavaCore.newClasspathAttribute(name, value); }
Example 9
Source File: CPListElementAttribute.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
public IClasspathAttribute getClasspathAttribute() { Assert.isTrue(!fBuiltIn); return JavaCore.newClasspathAttribute(fKey, (String) fValue); }
Example 10
Source File: JavadocAttributeConfiguration.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
@Override public IClasspathAttribute performRemove(ClasspathAttributeAccess attribute) { return JavaCore.newClasspathAttribute(IClasspathAttribute.JAVADOC_LOCATION_ATTRIBUTE_NAME, null); }
Example 11
Source File: NativeLibAttributeConfiguration.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
@Override public IClasspathAttribute performRemove(ClasspathAttributeAccess attribute) { return JavaCore.newClasspathAttribute(JavaRuntime.CLASSPATH_ATTR_LIBRARY_PATH_ENTRY, null); }