Skip to content

Commit

Permalink
Merge pull request #16 from adrienpessu/fix_issues
Browse files Browse the repository at this point in the history
fix issues
  • Loading branch information
adrienpessu authored Dec 5, 2023
2 parents 0387443 + cb9a8e9 commit f5d0ba5
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,11 @@ package com.github.adrienpessu.sarifviewer.services

import com.contrastsecurity.sarif.SarifSchema210
import com.fasterxml.jackson.databind.ObjectMapper
import com.fasterxml.jackson.jr.ob.JSON
import com.fasterxml.jackson.module.kotlin.readValue
import com.github.adrienpessu.sarifviewer.exception.SarifViewerException
import com.github.adrienpessu.sarifviewer.models.Leaf
import com.github.adrienpessu.sarifviewer.models.Root
import com.intellij.openapi.components.Service
import com.intellij.openapi.project.Project
import net.minidev.json.JSONArray
import java.net.HttpURLConnection
import java.net.URL
Expand All @@ -32,7 +30,7 @@ class SarifService {
}

fun analyseSarif(sarif: SarifSchema210): HashMap<String, MutableList<Leaf>> {
val map = HashMap<String, MutableList<Leaf>>();
val map = HashMap<String, MutableList<Leaf>>()

sarif.runs.forEach { run ->
run.results.forEach { result ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,8 @@ import com.intellij.openapi.vfs.VirtualFileManager
import com.intellij.openapi.wm.ToolWindow
import com.intellij.openapi.wm.ToolWindowFactory
import com.intellij.ui.ScrollPaneFactory
import com.intellij.ui.TreeSpeedSearch
import com.intellij.ui.components.JBPanel
import com.intellij.ui.content.ContentFactory
import com.intellij.ui.treeStructure.Tree
import git4idea.GitLocalBranch
import git4idea.repo.GitRepository
import git4idea.repo.GitRepositoryChangeListener
Expand All @@ -34,6 +32,7 @@ import java.io.FileReader
import java.io.FileWriter
import java.net.URI
import java.nio.charset.Charset
import java.nio.file.Files
import java.nio.file.Path
import javax.swing.*
import javax.swing.event.HyperlinkEvent
Expand All @@ -43,7 +42,6 @@ import javax.swing.event.TreeSelectionListener
import javax.swing.text.html.HTMLEditorKit
import javax.swing.tree.DefaultMutableTreeNode
import javax.swing.tree.DefaultTreeModel
import javax.swing.tree.TreeNode


class SarifViewerWindowFactory : ToolWindowFactory {
Expand Down Expand Up @@ -161,7 +159,7 @@ class SarifViewerWindowFactory : ToolWindowFactory {
NotificationGroupManager.getInstance()
.getNotificationGroup("SARIF viewer")
.createNotification(message, NotificationType.ERROR)
.notify(project);
.notify(project)

thisLogger().info(message)
}
Expand Down Expand Up @@ -270,15 +268,14 @@ class SarifViewerWindowFactory : ToolWindowFactory {
myList = JTree(root)

myList.isRootVisible = false
val treeSpeedSearch = TreeSpeedSearch(myList)
main = ScrollPaneFactory.createScrollPane(myList);
main = ScrollPaneFactory.createScrollPane(myList)

details.isVisible = false

splitPane.leftComponent = main
splitPane.rightComponent = details

treeSpeedSearch.component.addTreeSelectionListener(object : TreeSelectionListener {
myList.addTreeSelectionListener(object : TreeSelectionListener {
override fun valueChanged(e: TreeSelectionEvent?) {
if (e != null && e.isAddedPath) {
val leaves = map[e.path.parentPath.lastPathComponent.toString()]
Expand Down Expand Up @@ -310,11 +307,12 @@ class SarifViewerWindowFactory : ToolWindowFactory {
}
}
}
});
})
}

private fun manageTreeIcons() {
val tmpFile: File = File.createTempFile("warning", ".svg")
val tmpPath: Path? = Files.createTempFile("warning", ".svg")
val tmpFile = File(tmpPath!!.toUri())
val writer = FileWriter(tmpFile)
writer.write(Icons.ICON_WARNING)
writer.close()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ class Icons {

companion object {
const val ICON_WARNING = "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 12 12\" width=\"12\" height=\"12\"><path d=\"M4.855.708c.5-.896 1.79-.896 2.29 0l4.675 8.351a1.312 1.312 0 0 1-1.146 1.954H1.33A1.313 1.313 0 0 1 .183 9.058ZM7 7V3H5v4Zm-1 3a1 1 0 1 0 0-2 1 1 0 0 0 0 2Z\"></path></svg>"
const val ICON_DIRECTORY = "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 16 16\" width=\"16\" height=\"16\"><path d=\"M0 2.75C0 1.784.784 1 1.75 1H5c.55 0 1.07.26 1.4.7l.9 1.2a.25.25 0 0 0 .2.1h6.75c.966 0 1.75.784 1.75 1.75v8.5A1.75 1.75 0 0 1 14.25 15H1.75A1.75 1.75 0 0 1 0 13.25Zm1.75-.25a.25.25 0 0 0-.25.25v10.5c0 .138.112.25.25.25h12.5a.25.25 0 0 0 .25-.25v-8.5a.25.25 0 0 0-.25-.25H7.5c-.55 0-1.07-.26-1.4-.7l-.9-1.2a.25.25 0 0 0-.2-.1Z\"></path></svg>"
// const val ICON_DIRECTORY = "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 16 16\" width=\"16\" height=\"16\"><path d=\"M0 2.75C0 1.784.784 1 1.75 1H5c.55 0 1.07.26 1.4.7l.9 1.2a.25.25 0 0 0 .2.1h6.75c.966 0 1.75.784 1.75 1.75v8.5A1.75 1.75 0 0 1 14.25 15H1.75A1.75 1.75 0 0 1 0 13.25Zm1.75-.25a.25.25 0 0 0-.25.25v10.5c0 .138.112.25.25.25h12.5a.25.25 0 0 0 .25-.25v-8.5a.25.25 0 0 0-.25-.25H7.5c-.55 0-1.07-.26-1.4-.7l-.9-1.2a.25.25 0 0 0-.2-.1Z\"></path></svg>"
const val ERROR = "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 16 16\" width=\"16\" height=\"16\"><path d=\"M0 2.75C0 1.784.784 1 1.75 1H5c.55 0 1.07.26 1.4.7l.9 1.2a.25.25 0 0 0 .2.1h6.75c.966 0 1.75.784 1.75 1.75v8.5A1.75 1.75 0 0 1 14.25 15H1.75A1.75 1.75 0 0 1 0 13.25Zm1.75-.25a.25.25 0 0 0-.25.25v10.5c0 .138.112.25.25.25h12.5a.25.25 0 0 0 .25-.25v-8.5a.25.25 0 0 0-.25-.25H7.5c-.55 0-1.07-.26-1.4-.7l-.9-1.2a.25.25 0 0 0-.2-.1Z\"></path></svg>"
}
}

0 comments on commit f5d0ba5

Please sign in to comment.