@@ -2,7 +2,7 @@ import com.intellij.lang.annotation.HighlightSeverity
22import com.intellij.lang.javascript.linter.JSLinterError
33import com.intellij.openapi.diagnostic.Logger
44import com.intellij.openapi.util.text.StringUtil
5- import org.codehaus.jettison. json.JSONObject
5+ import kotlinx.serialization. json.*
66import java.io.IOException
77import java.util.*
88
@@ -19,13 +19,13 @@ class TemplateLintResultParser {
1919 private const val SEVERITY = " severity"
2020 private const val MESSAGE = " message"
2121
22- private fun parseItem (map : JSONObject ): JSLinterError {
23- val line = map.getInt( LINE )
24- val column = map.getInt( COLUMN )
25- val rule = map.getString( RULE )
26- val text = map.getString( MESSAGE )
22+ private fun parseItem (map : JsonObject ): JSLinterError {
23+ val line = map[ LINE ] !! .jsonPrimitive.int
24+ val column = map[ COLUMN ] !! .jsonPrimitive.int
25+ val rule = map[ RULE ] !! .jsonPrimitive.content
26+ val text = map[ MESSAGE ] !! .jsonPrimitive.content
2727
28- val highlightSeverity = when (map.getInt( SEVERITY ) ) {
28+ val highlightSeverity = when (map[ SEVERITY ] !! .jsonPrimitive.int ) {
2929 WARNING_SEVERITY -> HighlightSeverity .WARNING
3030 ERROR_SEVERITY -> HighlightSeverity .ERROR
3131 else -> null
@@ -43,14 +43,14 @@ class TemplateLintResultParser {
4343
4444 val errorList: ArrayList <JSLinterError > = ArrayList ()
4545 try {
46- val obj = JSONObject (stdout)
46+ val obj = Json .parseToJsonElement (stdout!! ).jsonObject
4747
48- val issues = obj.getJSONArray(obj.keys().next() as String )
49- for (i in 0 until issues.length() ) {
50- val issue = issues.getJSONObject(i)
48+ val issues = obj.jsonArray
49+ for (i in 0 until issues.size ) {
50+ val issue = issues[i].jsonObject
5151
5252 // we skip fatal errors
53- if (issue.has (" fatal" ) && issue.getBoolean( " fatal" ) ) continue
53+ if (issue.containsKey (" fatal" ) && issue[ " fatal" ]?.jsonPrimitive?.boolean == true ) continue
5454
5555 errorList.add(parseItem(issue))
5656 }
0 commit comments