Skip to content

Commit 1af1ed3

Browse files
Support searching main classes from the workspace invisible project (#305)
* Support searching main classes from the workspace invisible project Signed-off-by: Jinbo Wang <[email protected]> * Address review comment Signed-off-by: Jinbo Wang <[email protected]>
1 parent ac7d26b commit 1af1ed3

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

com.microsoft.java.debug.plugin/src/main/java/com/microsoft/java/debug/plugin/internal/ResolveMainClassHandler.java

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
package com.microsoft.java.debug.plugin.internal;
1313

1414
import java.util.ArrayList;
15+
import java.util.Collection;
1516
import java.util.Collections;
1617
import java.util.Comparator;
1718
import java.util.List;
@@ -23,6 +24,7 @@
2324

2425
import org.apache.commons.lang3.StringUtils;
2526
import org.eclipse.core.resources.IFile;
27+
import org.eclipse.core.resources.IFolder;
2628
import org.eclipse.core.resources.IProject;
2729
import org.eclipse.core.resources.IResource;
2830
import org.eclipse.core.runtime.CoreException;
@@ -37,6 +39,7 @@
3739
import org.eclipse.jdt.core.search.SearchParticipant;
3840
import org.eclipse.jdt.core.search.SearchPattern;
3941
import org.eclipse.jdt.core.search.SearchRequestor;
42+
import org.eclipse.jdt.ls.core.internal.ProjectUtils;
4043
import org.eclipse.jdt.ls.core.internal.ResourceUtils;
4144
import org.eclipse.jdt.ls.core.internal.managers.ProjectsManager;
4245

@@ -107,7 +110,8 @@ public void acceptSearchMatch(SearchMatch match) {
107110
String projectName = ProjectsManager.DEFAULT_PROJECT_NAME.equals(project.getName()) ? null : project.getName();
108111
if (projectName == null
109112
|| targetProjectPath.isEmpty()
110-
|| ResourceUtils.isContainedIn(project.getLocation(), targetProjectPath)) {
113+
|| ResourceUtils.isContainedIn(project.getLocation(), targetProjectPath)
114+
|| isContainedInInvisibleProject(project, targetProjectPath)) {
111115
String filePath = null;
112116

113117
if (match.getResource() instanceof IFile) {
@@ -141,6 +145,15 @@ public void acceptSearchMatch(SearchMatch match) {
141145
return resolutions;
142146
}
143147

148+
private boolean isContainedInInvisibleProject(IProject project, Collection<IPath> rootPaths) {
149+
if (project == null) {
150+
return false;
151+
}
152+
153+
IFolder workspaceLinkFolder = project.getFolder(ProjectUtils.WORKSPACE_LINK);
154+
return workspaceLinkFolder.exists() && ResourceUtils.isContainedIn(workspaceLinkFolder.getLocation(), rootPaths);
155+
}
156+
144157
private ValidationResponse validateLaunchConfigCore(List<Object> arguments) throws CoreException {
145158
ValidationResponse response = new ValidationResponse();
146159

0 commit comments

Comments
 (0)