Skip to content

Commit 991cec8

Browse files
committed
feat(lint): add tool ID to SketchInspectionError
Include the inspection tool ID in SketchInspectionError and update related methods to handle the new field. Adjust the display table to show the tool name.
1 parent db5e4ea commit 991cec8

File tree

3 files changed

+14
-10
lines changed

3 files changed

+14
-10
lines changed

core/src/main/kotlin/cc/unitmesh/devti/sketch/lint/SketchCodeInspection.kt

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@ import javax.swing.table.DefaultTableModel
3333

3434
object SketchCodeInspection {
3535
fun showErrors(errors: List<SketchInspectionError>, panel: JPanel) {
36-
val columnNames = arrayOf("Line", "Description", "Highlight Type")
36+
val columnNames = arrayOf("Line", "Description", "Highlight Type", "Name")
3737
val data = errors.map {
38-
arrayOf(it.lineNumber, it.description, it.highlightType.toString())
38+
arrayOf(it.lineNumber, it.description, it.highlightType.toString(), it.toolId)
3939
}.toTypedArray()
4040

4141
val tableModel = DefaultTableModel(data, columnNames)
@@ -103,12 +103,14 @@ object SketchCodeInspection {
103103
indicator, PairProcessor.alwaysTrue<LocalInspectionToolWrapper?, ProblemDescriptor?>()
104104
)
105105

106-
val problems = result.values.flatten()
107-
return@runReadAction problems
108-
.sortedBy { it.lineNumber }
109-
.distinctBy { it.lineNumber }.map {
110-
SketchInspectionError.from(it)
106+
val errors = mutableListOf<SketchInspectionError>()
107+
for ((wrapper, problems) in result) {
108+
problems.forEach {
109+
errors.add(SketchInspectionError.from(it, wrapper))
111110
}
111+
}
112+
113+
return@runReadAction errors.sortedBy { it.lineNumber }.distinctBy { it.lineNumber }
112114
}
113115
}
114116

core/src/main/kotlin/cc/unitmesh/devti/sketch/lint/SketchInspectionError.kt

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,21 @@ package cc.unitmesh.devti.sketch.lint
22

33
import com.intellij.codeInspection.ProblemDescriptor
44
import com.intellij.codeInspection.ProblemHighlightType
5+
import com.intellij.codeInspection.ex.LocalInspectionToolWrapper
56

67
data class SketchInspectionError(
78
val lineNumber: Int,
89
val description: String,
910
val highlightType: ProblemHighlightType,
11+
val toolId: String?,
1012
) {
1113
companion object {
12-
fun from(problemDescriptor: ProblemDescriptor): SketchInspectionError {
14+
fun from(problemDescriptor: ProblemDescriptor, toolwrapper: LocalInspectionToolWrapper): SketchInspectionError {
1315
return SketchInspectionError(
1416
problemDescriptor.lineNumber,
1517
problemDescriptor.descriptionTemplate,
16-
problemDescriptor.highlightType
18+
problemDescriptor.highlightType,
19+
toolwrapper.id
1720
)
1821
}
1922
}

exts/devins-lang/src/main/kotlin/cc/unitmesh/devti/language/utils/ProjectFileUtil.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package cc.unitmesh.devti.language.utils
22

33
import com.intellij.openapi.application.ApplicationManager
4-
import com.intellij.openapi.application.runReadAction
54
import com.intellij.openapi.project.Project
65
import com.intellij.openapi.project.guessProjectDir
76
import com.intellij.openapi.util.io.FileUtilRt

0 commit comments

Comments
 (0)