Ignore @SpringBootApplication classes in test source folders - #421
Open
Martin Lippert (martinlippert) wants to merge 1 commit into
Open
Ignore @SpringBootApplication classes in test source folders#421Martin Lippert (martinlippert) wants to merge 1 commit into
Martin Lippert (martinlippert) wants to merge 1 commit into
Conversation
`vscode.java.resolveMainClass` searches every source folder of a project, so a `@SpringBootApplication` class copied into `src/test/java` — a common pattern for integration tests — was offered as an additional launch candidate. Running an app then popped up a quick pick asking the user to choose between the real main class and one that is irrelevant to launch. Filter those out by matching each resolved main class against the test source folders of the project's classpath. The Spring Tools classpath listener already reports `isTest` for each source entry (set from `IClasspathEntry.isTest()`), so no extra language server round trip is needed; the flag was just missing from the `CPE` type declaration. The unfiltered list stays available via `getMainClasses()` so that live processes launched from a test main class are still associated with their app. When every main class sits in a test source folder, the filter falls back to the full list to keep such a project launchable. Closes microsoft#420
Collaborator
Author
|
@microsoft-github-policy-service agree company="Broadcom" |
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.
vscode.java.resolveMainClasssearches every source folder of a project, so a@SpringBootApplicationclass copied intosrc/test/java— a common pattern for integration tests — was offered as an additional launch candidate. Running an app then popped up a quick pick asking the user to choose between the real main class and one that is irrelevant to launch.Filter those out by matching each resolved main class against the test source folders of the project's classpath. The Spring Tools classpath listener already reports
isTestfor each source entry (set fromIClasspathEntry.isTest()), so no extra language server round trip is needed; the flag was just missing from theCPEtype declaration.The unfiltered list stays available via
getMainClasses()so that live processes launched from a test main class are still associated with their app. When every main class sits in a test source folder, the filter falls back to the full list to keep such a project launchable.Closes #420