public IClasspathContainer getClasspathContainer(IPath path, IJavaProject project) throws CoreException { return JavaCore.getClasspathContainer(path, project); } }
/** * Returns the label of a classpath container * @param containerPath The path of the container. * @param project The project the container is resolved in. * @return Returns the label of the classpath container * @throws JavaModelException Thrown when the resolving of the container failed. */ public static String getContainerEntryLabel(IPath containerPath, IJavaProject project) throws JavaModelException { IClasspathContainer container= JavaCore.getClasspathContainer(containerPath, project); if (container != null) { return container.getDescription(); } ClasspathContainerInitializer initializer= JavaCore.getClasspathContainerInitializer(containerPath.segment(0)); if (initializer != null) { return initializer.getDescription(containerPath, project); } return containerPath.toString(); }
private void collectContainerRuntimeClasspathIfPresent(IJavaProject project, List<IRuntimeClasspathEntry> result, boolean includeExportedEntriesOnly, LaunchConfigurationScope configurationScopes) throws CoreException { IClasspathContainer container = JavaCore.getClasspathContainer(GradleClasspathContainer.CONTAINER_PATH, project); if (container != null) { collectContainerRuntimeClasspath(container, result, includeExportedEntriesOnly, configurationScopes); } }
/** * Returns the label of a classpath container. * The returned label is BiDi-processed with {@link TextProcessor#process(String, String)}. * * @param containerPath the path of the container * @param project the project the container is resolved in * @return the label of the classpath container * @throws JavaModelException when resolving of the container failed */ public static String getContainerEntryLabel(IPath containerPath, IJavaProject project) throws JavaModelException { IClasspathContainer container= JavaCore.getClasspathContainer(containerPath, project); if (container != null) { return org.eclipse.jdt.internal.core.manipulation.util.Strings.markLTR(container.getDescription()); } ClasspathContainerInitializer initializer= JavaCore.getClasspathContainerInitializer(containerPath.segment(0)); if (initializer != null) { return org.eclipse.jdt.internal.core.manipulation.util.Strings.markLTR(initializer.getDescription(containerPath, project)); } return BasicElementLabels.getPathLabel(containerPath, false); } }
public ClassPathContainer(IJavaProject parent, IClasspathEntry entry) { super(parent); fClassPathEntry= entry; try { fContainer= JavaCore.getClasspathContainer(entry.getPath(), parent); } catch (JavaModelException e) { fContainer= null; } }
/** * Returns the label of a classpath container. * The returned label is BiDi-processed with {@link TextProcessor#process(String, String)}. * * @param containerPath the path of the container * @param project the project the container is resolved in * @return the label of the classpath container * @throws JavaModelException when resolving of the container failed */ public static String getContainerEntryLabel(IPath containerPath, IJavaProject project) throws JavaModelException { IClasspathContainer container= JavaCore.getClasspathContainer(containerPath, project); if (container != null) { return org.eclipse.jdt.internal.core.manipulation.util.Strings.markLTR(container.getDescription()); } ClasspathContainerInitializer initializer= JavaCore.getClasspathContainerInitializer(containerPath.segment(0)); if (initializer != null) { return org.eclipse.jdt.internal.core.manipulation.util.Strings.markLTR(initializer.getDescription(containerPath, project)); } return BasicElementLabels.getPathLabel(containerPath, false); }
public ClassPathContainer(IJavaProject parent, IClasspathEntry entry) { super(parent); fClassPathEntry= entry; try { fContainer= JavaCore.getClasspathContainer(entry.getPath(), parent); } catch (JavaModelException e) { fContainer= null; } }
private static void updateContainerClasspath(IJavaProject javaProject, IPath containerPath, IClasspathEntry newEntry) throws CoreException { IClasspathContainer container = JavaCore.getClasspathContainer(containerPath, javaProject); List<IClasspathEntry> newEntries = updateElements(container.getClasspathEntries(), newEntry, (entry) -> { return entry.getEntryKind() == newEntry.getEntryKind() && entry.getPath().equals(newEntry.getPath()); }); IClasspathContainer updatedContainer = new UpdatedClasspathContainer(container, newEntries.toArray(new IClasspathEntry[0])); ClasspathContainerInitializer initializer = JavaCore.getClasspathContainerInitializer(containerPath.segment(0)); if (initializer != null) { initializer.requestClasspathContainerUpdate(containerPath, javaProject, updatedContainer); } }
/** * @param loader * @param project * @param entry * @throws JavaModelException */ private void addContainerEntry(TaglibClassLoader loader, IJavaProject project, IClasspathEntry entry) throws JavaModelException { IClasspathContainer container = JavaCore.getClasspathContainer(entry.getPath(), project); if (container != null) { // avoid infinite recursion if (!fContainerEntries.contains(container.getPath().toString())) { fContainerEntries.add(container.getPath().toString()); IClasspathEntry[] cpes = container.getClasspathEntries(); // recursive call here addClasspathEntries(loader, project, cpes); } } }
public ClassPathContainer(IJavaProject parent, IClasspathEntry entry) { super(parent); fClassPathEntry= entry; try { fContainer= JavaCore.getClasspathContainer(entry.getPath(), parent); } catch (JavaModelException e) { fContainer= null; } fDecorateTestCodeContainerIcons= PreferenceConstants.getPreferenceStore().getBoolean(PreferenceConstants.DECORATE_TEST_CODE_CONTAINER_ICONS); }
private ClasspathElement createClasspathElementForEntry(final IProject project, final IClasspathEntry entry) { final IPath entryPath = entry.getPath(); final URI archiveURI = URI.createURI(entryPath.toString()); final int kind = entry.getEntryKind(); String elementName = entryPath.toString(); if (kind == IClasspathEntry.CPE_CONTAINER) { try { final IClasspathContainer container = JavaCore.getClasspathContainer(entryPath, JavaCore.create(project)); if (container != null) { elementName = container.getDescription(); } } catch (CoreException ce) { } } ClasspathElement element = createClasspathEntryElement(project, archiveURI, elementName, entry); return element; }
private static void updateContainerClasspath(IJavaProject jproject, IPath containerPath, IClasspathEntry newEntry, String[] changedAttributes, IProgressMonitor monitor) throws CoreException { IClasspathContainer container= JavaCore.getClasspathContainer(containerPath, jproject); if (container == null) { throw new CoreException(new Status(IStatus.ERROR, JavaUI.ID_PLUGIN, IStatus.ERROR, "Container " + containerPath + " cannot be resolved", null)); //$NON-NLS-1$//$NON-NLS-2$ } IClasspathEntry[] entries= container.getClasspathEntries(); IClasspathEntry[] newEntries= new IClasspathEntry[entries.length]; for (int i= 0; i < entries.length; i++) { IClasspathEntry curr= entries[i]; if (curr.getEntryKind() == newEntry.getEntryKind() && curr.getPath().equals(newEntry.getPath())) { newEntries[i]= getUpdatedEntry(curr, newEntry, changedAttributes, jproject); } else { newEntries[i]= curr; } } requestContainerUpdate(jproject, container, newEntries); monitor.worked(1); }
private static void updateContainerClasspath(IJavaProject jproject, IPath containerPath, IClasspathEntry newEntry, String[] changedAttributes, IProgressMonitor monitor) throws CoreException { IClasspathContainer container= JavaCore.getClasspathContainer(containerPath, jproject); if (container == null) { throw new CoreException(new Status(IStatus.ERROR, JavaUI.ID_PLUGIN, IStatus.ERROR, "Container " + containerPath + " cannot be resolved", null)); //$NON-NLS-1$//$NON-NLS-2$ } IClasspathEntry[] entries= container.getClasspathEntries(); IClasspathEntry[] newEntries= new IClasspathEntry[entries.length]; for (int i= 0; i < entries.length; i++) { IClasspathEntry curr= entries[i]; if (curr.getEntryKind() == newEntry.getEntryKind() && curr.getPath().equals(newEntry.getPath())) { newEntries[i]= getUpdatedEntry(curr, newEntry, changedAttributes, jproject); } else { newEntries[i]= curr; } } requestContainerUpdate(jproject, container, newEntries); monitor.worked(1); }
private static IClasspathEntry getRealClasspathEntry(IJavaProject jproject, IPath containerPath, IPath libPath) throws JavaModelException { IClasspathContainer container= JavaCore.getClasspathContainer(containerPath, jproject); if (container != null) { IClasspathEntry[] entries= container.getClasspathEntries(); for (int i= 0; i < entries.length; i++) { IClasspathEntry curr= entries[i]; IClasspathEntry resolved= JavaCore.getResolvedClasspathEntry(curr); if (resolved != null && libPath.equals(resolved.getPath())) { return curr; // return the real entry } } } return null; // not found }
public IClasspathContainer getWebAppLibrariesContainer(IProject webProject, boolean create) { IJavaProject jproj = JavaCore.create(webProject); IClasspathContainer container = null; IClasspathEntry entry = create ? null : getExistingContainer(jproj, WEB_APP_LIBS_PATH); if (entry != null || create) { try { container = JavaCore.getClasspathContainer(WEB_APP_LIBS_PATH, jproj); } catch (JavaModelException e) { J2EEPlugin.getDefault().getLogger().logError(e); } } return container; }
/** * Returns the associated container or <code>null</code> if unavailable. * * @return classpath container or <code>null</code> * @throws CoreException if unable to retrieve container */ public IClasspathContainer getClasspathContainer() throws CoreException { ISourceLookupDirector director = getDirector(); if (director != null) { ILaunchConfiguration configuration = director.getLaunchConfiguration(); if (configuration != null) { IJavaProject project = JavaRuntime.getJavaProject(configuration); if (project != null) { return JavaCore.getClasspathContainer(getPath(), project); } } } return null; }
public static IClasspathContainer getInstalledContainer(IProject project, IPath containerPath) { IJavaProject jproj = JavaCore.create(project); IClasspathEntry entry = getInstalledContainerEntry(jproj, containerPath); IClasspathContainer container = null; if (entry != null) { try { container = JavaCore.getClasspathContainer(containerPath, jproj); } catch (JavaModelException e) { J2EEPlugin.getDefault().getLogger().logError(e); } } return container; }
public boolean isInsideJRE(IJavaElement element) { IPackageFragmentRoot root= (IPackageFragmentRoot) element.getAncestor(IJavaElement.PACKAGE_FRAGMENT_ROOT); if (root != null) { try { IClasspathEntry entry= root.getRawClasspathEntry(); if (entry.getEntryKind() == IClasspathEntry.CPE_CONTAINER) { IClasspathContainer container= JavaCore.getClasspathContainer(entry.getPath(), root.getJavaProject()); return container != null && container.getKind() == IClasspathContainer.K_DEFAULT_SYSTEM; } return false; } catch (JavaModelException e) { JavaPlugin.log(e); } } return true; // include JRE in doubt } }
public boolean isInsideJRE(IJavaElement element) { IPackageFragmentRoot root= (IPackageFragmentRoot) element.getAncestor(IJavaElement.PACKAGE_FRAGMENT_ROOT); if (root != null) { try { IClasspathEntry entry= root.getRawClasspathEntry(); if (entry.getEntryKind() == IClasspathEntry.CPE_CONTAINER) { IClasspathContainer container= JavaCore.getClasspathContainer(entry.getPath(), root.getJavaProject()); return container != null && container.getKind() == IClasspathContainer.K_DEFAULT_SYSTEM; } return false; } catch (JavaModelException e) { JavaPlugin.log(e); } } return true; // include JRE in doubt } }
public boolean isInsideJRE(IJavaElement element) { IPackageFragmentRoot root= (IPackageFragmentRoot) element.getAncestor(IJavaElement.PACKAGE_FRAGMENT_ROOT); if (root != null) { try { IClasspathEntry entry= root.getRawClasspathEntry(); if (entry.getEntryKind() == IClasspathEntry.CPE_CONTAINER) { IClasspathContainer container= JavaCore.getClasspathContainer(entry.getPath(), root.getJavaProject()); return container != null && container.getKind() == IClasspathContainer.K_DEFAULT_SYSTEM; } return false; } catch (JavaModelException e) { JavaPlugin.log(e); } } return true; // include JRE in doubt } }