|
18 | 18 | import java.io.FileOutputStream;
|
19 | 19 | import java.io.IOException;
|
20 | 20 | import java.util.ArrayList;
|
21 |
| -import java.util.Collections; |
22 | 21 | import java.util.HashSet;
|
23 | 22 | import java.util.List;
|
24 | 23 | import java.util.Objects;
|
|
59 | 58 | import org.eclipse.jdt.ls.core.internal.JavaLanguageServerPlugin;
|
60 | 59 | import org.eclipse.jdt.ls.core.internal.ProjectUtils;
|
61 | 60 | import org.eclipse.jdt.ls.core.internal.ResourceUtils;
|
| 61 | +import org.eclipse.jdt.ls.core.internal.managers.ProjectsManager; |
62 | 62 | import org.eclipse.jdt.ls.core.internal.managers.UpdateClasspathJob;
|
63 | 63 | import org.eclipse.jdt.ls.core.internal.preferences.Preferences.ReferencedLibraries;
|
64 | 64 | import org.eclipse.lsp4j.jsonrpc.json.adapters.CollectionTypeAdapter;
|
@@ -94,24 +94,25 @@ private static class Classpath {
|
94 | 94 | public static List<PackageNode> listProjects(List<Object> arguments, IProgressMonitor monitor) {
|
95 | 95 | String workspaceUri = (String) arguments.get(0);
|
96 | 96 | IPath workspaceFolderPath = ResourceUtils.canonicalFilePathFromURI(workspaceUri);
|
97 |
| - String invisibleProjectName = ProjectUtils.getWorkspaceInvisibleProjectName(workspaceFolderPath); |
98 | 97 |
|
99 |
| - IProject[] projects = getWorkspaceRoot().getProjects(); |
| 98 | + IJavaProject[] javaProjects = ProjectUtils.getJavaProjects(); |
100 | 99 | ArrayList<PackageNode> children = new ArrayList<>();
|
101 |
| - List<IPath> paths = Collections.singletonList(workspaceFolderPath); |
102 |
| - for (IProject project : projects) { |
103 |
| - if (!project.isAccessible() || !ProjectUtils.isJavaProject(project)) { |
| 100 | + for (IJavaProject javaProject : javaProjects) { |
| 101 | + IProject project = javaProject.getProject(); |
| 102 | + if (!project.isAccessible() || project.getLocation() == null) { |
104 | 103 | continue;
|
105 | 104 | }
|
106 |
| - // Ignore all the projects that's not contained in the workspace folder, except |
107 |
| - // for the invisible project. |
108 |
| - // This check is needed in multi-root scenario. |
109 |
| - if ((!ResourceUtils.isContainedIn(project.getLocation(), paths) |
110 |
| - && !Objects.equals(project.getName(), invisibleProjectName))) { |
| 105 | + |
| 106 | + // ignore default projects |
| 107 | + if (Objects.equals(project.getName(), ProjectsManager.DEFAULT_PROJECT_NAME)) { |
111 | 108 | continue;
|
112 | 109 | }
|
| 110 | + |
113 | 111 | PackageNode projectNode = PackageNode.createNodeForProject(JavaCore.create(project));
|
114 |
| - if (Objects.equals(project.getName(), invisibleProjectName)) { |
| 112 | + |
| 113 | + // set the folder name as the project name when the project location |
| 114 | + // is out of the workspace folder. |
| 115 | + if (!workspaceFolderPath.isPrefixOf(project.getLocation())) { |
115 | 116 | projectNode.setDisplayName(workspaceFolderPath.lastSegment());
|
116 | 117 | }
|
117 | 118 | children.add(projectNode);
|
|
0 commit comments