Skip to content

Commit 752fdf9

Browse files
authored
Merge pull request #76 from advanced-security/feat/navigation_to_column
feat: navigate to column on top of line
2 parents 827eb24 + 1a88052 commit 752fdf9

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

src/main/kotlin/com/github/adrienpessu/sarifviewer/services/SarifService.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,8 @@ class SarifService {
100100
val additionalProperties = result.properties?.additionalProperties ?: mapOf()
101101
val element = Leaf(
102102
leafName = result.message.text ?: "",
103-
address = "${result.locations[0].physicalLocation.artifactLocation.uri}:${result.locations[0].physicalLocation.region.startLine}",
104-
steps = result.codeFlows?.get(0)?.threadFlows?.get(0)?.locations?.map { "${it.location.physicalLocation.artifactLocation.uri}:${it.location.physicalLocation.region.startLine}" }
103+
address = "${result.locations[0].physicalLocation.artifactLocation.uri}:${result.locations[0].physicalLocation.region.startLine ?: 0}:${result.locations[0].physicalLocation.region.startColumn ?: 0}",
104+
steps = result.codeFlows?.get(0)?.threadFlows?.get(0)?.locations?.map { "${it.location.physicalLocation.artifactLocation.uri}:${it.location.physicalLocation.region.startLine}:${it.location.physicalLocation.region.startColumn}" }
105105
?: listOf(),
106106
location = result.locations[0].physicalLocation.artifactLocation.uri,
107107
ruleId = result.ruleId,

src/main/kotlin/com/github/adrienpessu/sarifviewer/toolWindow/SarifViewerWindowFactory.kt

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -538,16 +538,17 @@ class SarifViewerWindowFactory : ToolWindowFactory {
538538
override fun mouseClicked(e: MouseEvent) {
539539
val row = tableInfos.rowAtPoint(e.point)
540540
val path = currentLeaf!!.steps[row].split(":")
541-
openFile(project, path[0], path[1].toInt())
541+
openFile(project, path[0], path[1].toInt(), path[2].toInt())
542542
}
543543
})
544544

545545
details.isVisible = true
546+
val addr = currentLeaf!!.address.split(":")
546547
openFile(
547548
project,
548549
currentLeaf!!.location,
549-
currentLeaf!!.address.split(":")[1].toInt(),
550-
0,
550+
addr[1].toInt(),
551+
addr[2].toInt(),
551552
currentLeaf!!.level,
552553
currentLeaf!!.ruleId,
553554
currentLeaf!!.ruleDescription
@@ -595,7 +596,7 @@ class SarifViewerWindowFactory : ToolWindowFactory {
595596
project,
596597
virtualFile,
597598
lineNumber - 1,
598-
columnNumber
599+
columnNumber - 1
599600
),
600601
true // request focus to editor
601602
)

0 commit comments

Comments
 (0)