Find main classes in projects whose sources are linked in - #633
Open
Artem (sorteam) wants to merge 1 commit into
Open
Find main classes in projects whose sources are linked in#633Artem (sorteam) wants to merge 1 commit into
Artem (sorteam) wants to merge 1 commit into
Conversation
resolveMainClassUnderPaths keeps a project only when its own location is inside the requested folder. A project can instead keep its description outside the folder and reach the sources through linked folders, and then it is dropped before the search runs: the folder appears to contain no main class, so the Run and Debug view generates no configuration and the Spring Boot Dashboard cannot resolve an application's main class. The accept-match branch already makes an exception for the invisible project, which is one instance of this shape (a single link named after ProjectUtils.WORKSPACE_LINK); the scope filter it depends on does not, so that exception can never fire. Check the locations of the project's source folders in both places instead.
Artem (sorteam)
requested review from
Changyong Gong (chagong),
Sheng Chen (jdneo),
Jinbo Wang (testforstephen) and
wenyt (wenytang-ms)
as code owners
September 4, 2026 16:21
Author
|
@microsoft-github-policy-service agree |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
ResolveMainClassHandler.resolveMainClassUnderPathsbuilds the search scope by keeping only theprojects whose own location is inside the requested folder:
A project can instead keep its description outside that folder and reach the sources through linked
folders. Such a project is dropped before the search runs, so the folder looks as if it contained no
main class:
Run and Debuggenerates no Java configuration for it (the launch configurationprovider calls
vscode.java.resolveMainClass(folder.uri)), and anything else that resolves a mainclass by folder gets an empty answer.
The code already knows about this shape.
acceptSearchMatchmakes an exception for the invisibleproject:
but the scope filter it depends on has no such exception, so the invisible-project branch can never
fire - the project is not in the scope to begin with.
Fix
Check the locations of the project's source folders as well, in both places: for each source entry of
the raw classpath, resolve the workspace path through
IWorkspaceRoot.findMemberand compare thatlocation against the requested folders. A project belongs to the folder its sources are in rather
than to the folder its description happens to live in.
Reproduction
Create a java project whose source folders are linked resources pointing into a workspace folder,
with the project's own location elsewhere (any importer that provisions projects outside the
repository does this; the invisible project is a one-link special case of it). Open the workspace
folder and note that
Run and Debugoffers no Java configuration, while the same sources in aregular project do.
Verification
I compiled the modified class against the plugin jar shipped in
vscjava.vscode-java-debug0.59.0and the jdt.ls plugins from
redhat.java. I have not run the project's Maven build or testsuite.