Skip to content

Commit

Permalink
Merge pull request #76 from advanced-security/feat/navigation_to_column
Browse files Browse the repository at this point in the history
feat: navigate to column on top of line
  • Loading branch information
adrienpessu authored Apr 10, 2024
2 parents 827eb24 + 1a88052 commit 752fdf9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,8 @@ class SarifService {
val additionalProperties = result.properties?.additionalProperties ?: mapOf()
val element = Leaf(
leafName = result.message.text ?: "",
address = "${result.locations[0].physicalLocation.artifactLocation.uri}:${result.locations[0].physicalLocation.region.startLine}",
steps = result.codeFlows?.get(0)?.threadFlows?.get(0)?.locations?.map { "${it.location.physicalLocation.artifactLocation.uri}:${it.location.physicalLocation.region.startLine}" }
address = "${result.locations[0].physicalLocation.artifactLocation.uri}:${result.locations[0].physicalLocation.region.startLine ?: 0}:${result.locations[0].physicalLocation.region.startColumn ?: 0}",
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}" }
?: listOf(),
location = result.locations[0].physicalLocation.artifactLocation.uri,
ruleId = result.ruleId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -538,16 +538,17 @@ class SarifViewerWindowFactory : ToolWindowFactory {
override fun mouseClicked(e: MouseEvent) {
val row = tableInfos.rowAtPoint(e.point)
val path = currentLeaf!!.steps[row].split(":")
openFile(project, path[0], path[1].toInt())
openFile(project, path[0], path[1].toInt(), path[2].toInt())
}
})

details.isVisible = true
val addr = currentLeaf!!.address.split(":")
openFile(
project,
currentLeaf!!.location,
currentLeaf!!.address.split(":")[1].toInt(),
0,
addr[1].toInt(),
addr[2].toInt(),
currentLeaf!!.level,
currentLeaf!!.ruleId,
currentLeaf!!.ruleDescription
Expand Down Expand Up @@ -595,7 +596,7 @@ class SarifViewerWindowFactory : ToolWindowFactory {
project,
virtualFile,
lineNumber - 1,
columnNumber
columnNumber - 1
),
true // request focus to editor
)
Expand Down

0 comments on commit 752fdf9

Please sign in to comment.