Achal1607 commented on code in PR #8897:
URL: https://github.com/apache/netbeans/pull/8897#discussion_r2425368358
##########
java/java.lsp.server/src/org/netbeans/modules/java/lsp/server/debugging/launch/NbLaunchDelegate.java:
##########
@@ -570,8 +572,18 @@ public void finished(boolean success) {
} else if (launchType == LaunchType.RUN_TEST) {
mainSource = false;
} else {
- FileObject fileRoot = sourceCP != null ?
sourceCP.findOwnerRoot(toRun) : null;
- mainSource = fileRoot == null ||
UnitTestForSourceQuery.findSources(fileRoot).length == 0;
+ mainSource = false;
+ if (sourceCP != null) {
+ FileObject root = sourceCP.findOwnerRoot(toRun);
+ if (root != null) {
+ String relativePath = FileUtil.getRelativePath(root,
toRun);
+ if (relativePath != null &&
relativePath.toLowerCase().endsWith(".java")) {
+ String className = relativePath.substring(0,
relativePath.length() - 5).replace('/', '.');
+ ClasspathInfo cpi = ClasspathInfo.create(toRun);
+ mainSource = SourceUtils.isMainClass(className, cpi,
true);
Review Comment:
No, `cpi` would never be `null`. Because at least javac `BOOT_CLASS_PATH` is
added in the `CPI` and returned by the `create` method.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists