Conversation
| convertSlash (csf.getSourcePath (stratumn)), true | ||
| convertSlash (csf.getSourcePath (csf.getDefaultStratum())), true | ||
| ); | ||
| for (var anyStratum : csf.getAvailableStrata()) { |
There was a problem hiding this comment.
This fallback is only applied if url is still null after all previous attempts. E.g. this fallback shall not have any impact on cases where the URL was found previously.
In Kotlin sources, it seems to work OKeish - the line is selected according to Java strata (that good). However the debugger strata remains Kotlin. As such the current PC line isn't highlighted, just selected. Not ideal, but I am afraid to switch the strata behind the scene - who knows how that would work in JSPs, etc.?
| private static final Pattern PACKAGE = Pattern.compile("package *([\\p{Alnum}+\\.$]+) *"); | ||
| private void createNewBreakpoint(String url, int line, final DebuggerManager m) { | ||
| try { | ||
| var b = LineBreakpoint.create(url, line); |
There was a problem hiding this comment.
This is a tedious piece of code that every JVM language needs to write to allow LineBreakpoint. I am convinced that LineBreakpoint should be a core debugger feature and should be applicable to any line in any file automatically.
That's why I'd like to introduce LineBreakpoint next to ide/api.debugger/src/org/netbeans/api/debugger/Breakpoint.java and automatically handle placing it everywhere (in .txt files, or .md files, etc.). It would then be up to various debuggers (like JPDA debugger) to pick all such generic LineBreakpoints up and use them.
Of course, that would be for a separate PR and review...
| // | ||
|
|
||
| var sourcePath = new SourcePath(dm.getCurrentSession()); | ||
| sourcePath.showSource(stack[0], null); |
|
2d96384 to
c3ba986
Compare
|
I built the PR and tested SourcePath.showSource with a Kotlin class compiled with an inline function, so it has an SMAP: strata [Java, Kotlin, KotlinDebug], default Kotlin. At the breakpoint the Java line is 9 and the Kotlin line is 2. The PR removes stratumn = csf.getDefaultStratum() before the default-stratum lookup. When the requested stratum has no source but the default one does, like with JSP servlet situation, the editor now opens the default stratum's file at the requested stratum's line. In my test, requesting Java when only the Kotlin-stratum file exists opens it at line 9 on the PR, while master opens line 2. So the change also affects cases that worked before, not only those where no URL was found. For Kotlin itself, the lookup fails because the SMAP's source path is HiKt (a class name). The PR finds the file through the Java stratum and keeps the Kotlin line, which works only because both strata point to the same file. Also: BreakpointInKotlinTest uses a class without an SMAP, so only the Java stratum exists and the test passes on master too. And getURL(CallStackFrame, …), which the current-line annotation uses, still returns null for the Kotlin stratum. |
| /** | ||
| * Content of a class file to test. File named {@code Hi.kt} with content {@link #KOTLIN_HI_SRC} | ||
| * Compiles into following bytes. | ||
| */ |
There was a problem hiding this comment.
I've noticed @eppleton using Base64 in his sample test. Switching to it in 6e383fc as well. Thanks Toni!
|
The Kotlin case regressed: with diag.source=Hi.kt, showSource(frame, null) and showSource(frame, "Kotlin") now open Hi.kt:9 (previous PR version: line 2). The loop finds Hi.kt via the Java stratum and now sets stratumn = anyStratum, so the line comes from Java. For inline code, that is a synthetic line past the end of the file. The Kotlin stratum's line (2) is the correct one; the stratum just fails to resolve because its SMAP source path is HiKt (a class name), even though its source name is Hi.kt. KotlinSmapDiagTest only prints its results and has no assertions, so it passes either way. It would be good to turn the SUMMARY into asserts: null/Kotlin → line 2 in Hi.kt; with only HiKt present, Java → line 2. Also getURL(frame, "Kotlin") should be non-null. |

Hi.ktfile:HiKt.classgets generated$ java -agentlib:jdwp=transport=dt_socket,address=5005,server=y HiKt Listening for transport dt_socket at address: 5005AssertionErrorHi.ktfile is shown and highlights the right location