Skip to content

Commit abdfead

Browse files
MrMineO5BFergerson
andauthored
Navigate to line on stack frame changes (#857)
* Navigate to line on stack frame changes * Check for non-null line number * fix: show execution point regression * fix: check for non-null line number Co-authored-by: Brandon Fergerson <bfergerson@apache.org>
1 parent 031ad36 commit abdfead

File tree

2 files changed

+12
-16
lines changed

2 files changed

+12
-16
lines changed

plugin/src/main/java/spp/jetbrains/sourcemarker/status/BreakpointStatusBar.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ public void mouseClicked(MouseEvent e) {
277277
BreakpointHitWindowService.Companion.getInstance(inlayMark.getProject())
278278
.clearContent();
279279
BreakpointHitWindowService.Companion.getInstance(inlayMark.getProject())
280-
.showBreakpointHit(shownBreakpointHit.get(), false);
280+
.showBreakpointHit(shownBreakpointHit.get(), true);
281281
});
282282
}
283283
}));

plugin/src/main/kotlin/spp/jetbrains/sourcemarker/service/instrument/breakpoint/ExecutionPointManager.kt

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,11 @@ import com.intellij.openapi.fileEditor.OpenFileDescriptor
2525
import com.intellij.openapi.project.Project
2626
import com.intellij.xdebugger.XDebuggerUtil
2727
import com.intellij.xdebugger.impl.ui.ExecutionPointHighlighter
28-
import spp.jetbrains.marker.SourceMarker
29-
import spp.protocol.artifact.exception.qualifiedClassName
28+
import spp.jetbrains.marker.impl.ArtifactNamingService
3029
import spp.protocol.artifact.exception.sourceAsLineNumber
3130

3231
/**
33-
* todo: probably don't need this as the breakpoint bar serves as the execution point indicator
32+
* Shows the execution point in the editor for the selected stack frame.
3433
*
3534
* @since 0.3.0
3635
* @author [Brandon Fergerson](mailto:bfergerson@apache.org)
@@ -47,18 +46,15 @@ class ExecutionPointManager(
4746

4847
override fun onChanged(stackFrameManager: StackFrameManager) {
4948
if (!showExecutionPoint) return
50-
val currentFrame = stackFrameManager.currentFrame
51-
var fromClass = currentFrame!!.qualifiedClassName()
52-
53-
//check for inner class
54-
val indexOfDollarSign = fromClass.indexOf("$")
55-
if (indexOfDollarSign >= 0) {
56-
fromClass = fromClass.substring(0, indexOfDollarSign)
57-
}
58-
val fileMarker = SourceMarker.getInstance(project).getSourceFileMarker(fromClass) ?: return
59-
val virtualFile = fileMarker.psiFile.containingFile.virtualFile ?: return
49+
val currentFrame = stackFrameManager.currentFrame ?: return
50+
val psiFile = stackFrameManager.stackTrace.language?.let {
51+
ArtifactNamingService.getService(it).findPsiFile(it, project, currentFrame)
52+
} ?: return
53+
val virtualFile = psiFile.containingFile.virtualFile ?: return
6054
val document = FileDocumentManager.getInstance().getDocument(virtualFile) ?: return
61-
val lineStartOffset = document.getLineStartOffset(currentFrame.sourceAsLineNumber()!!) - 1
55+
val lineStartOffset = currentFrame.sourceAsLineNumber()?.let {
56+
document.getLineStartOffset(it) - 1
57+
} ?: return
6258

6359
ApplicationManager.getApplication().invokeLater {
6460
try {
@@ -69,7 +65,7 @@ class ExecutionPointManager(
6965
executionPointHighlighter.show(
7066
XDebuggerUtil.getInstance().createPositionByOffset(
7167
virtualFile, lineStartOffset
72-
)!!, false, null
68+
)!!, true, null
7369
)
7470
} catch (e: Throwable) {
7571
log.error("Failed to set execution point", e)

0 commit comments

Comments
 (0)