Search in sources :

Example 16 with ClasspathContainerInitializer

use of org.eclipse.jdt.core.ClasspathContainerInitializer in project eclipse.jdt.ls by eclipse.

the class SourceAttachmentCommand method updateContainerClasspath.

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);
    }
}
Also used : IClasspathEntry(org.eclipse.jdt.core.IClasspathEntry) IClasspathContainer(org.eclipse.jdt.core.IClasspathContainer) ClasspathContainerInitializer(org.eclipse.jdt.core.ClasspathContainerInitializer)

Aggregations

ClasspathContainerInitializer (org.eclipse.jdt.core.ClasspathContainerInitializer)16 IClasspathContainer (org.eclipse.jdt.core.IClasspathContainer)10 IClasspathEntry (org.eclipse.jdt.core.IClasspathEntry)9 IJavaProject (org.eclipse.jdt.core.IJavaProject)8 IPath (org.eclipse.core.runtime.IPath)6 IProject (org.eclipse.core.resources.IProject)5 CoreException (org.eclipse.core.runtime.CoreException)4 JavaModelException (org.eclipse.jdt.core.JavaModelException)4 PluginClasspathContainerInitializer (com.liferay.ide.project.core.PluginClasspathContainerInitializer)2 IFolder (org.eclipse.core.resources.IFolder)2 IWorkspace (org.eclipse.core.resources.IWorkspace)2 IWorkspaceRunnable (org.eclipse.core.resources.IWorkspaceRunnable)2 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)2 IStatus (org.eclipse.core.runtime.IStatus)2 Path (org.eclipse.core.runtime.Path)2 FlexibleProjectContainer (org.eclipse.jst.common.jdt.internal.classpath.FlexibleProjectContainer)2 IFacetedProject (org.eclipse.wst.common.project.facet.core.IFacetedProject)2 IFacetedProjectWorkingCopy (org.eclipse.wst.common.project.facet.core.IFacetedProjectWorkingCopy)2 FacetedProjectWorkingCopy (org.eclipse.wst.common.project.facet.core.internal.FacetedProjectWorkingCopy)2 SDK (com.liferay.ide.sdk.core.SDK)1