-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
353 additions
and
125 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
src/main/kotlin/org/move/ide/annotator/externalLinter/JsonAptosCompilerError.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
@file:Suppress("PropertyName") | ||
|
||
package org.move.ide.annotator.externalLinter | ||
|
||
import com.fasterxml.jackson.core.JsonProcessingException | ||
import com.intellij.openapi.util.TextRange | ||
import org.move.cli.runConfigurations.aptos.JSON_MAPPER | ||
|
||
fun parseJsonCompilerErrors(outputLines: List<String>): List<AptosJsonCompilerError> { | ||
return outputLines | ||
.mapNotNull { AptosJsonCompilerError.fromLine(it) } | ||
} | ||
|
||
data class AptosJsonCompilerError( | ||
val severity: String, | ||
val code: String?, | ||
val message: String, | ||
val labels: List<CodeLabel>, | ||
val notes: List<String>, | ||
) { | ||
fun toTestString(): String = | ||
"$severity: '$message' " + | ||
"at ${labels.find { it.style == "Primary" }?.range?.toTextRange()}" | ||
|
||
companion object { | ||
fun fromLine(line: String): AptosJsonCompilerError? { | ||
if (!line.startsWith("{\"")) return null | ||
try { | ||
val compilerMessage = | ||
JSON_MAPPER.readValue(line, AptosJsonCompilerError::class.java) | ||
return compilerMessage | ||
} catch (_: JsonProcessingException) { | ||
return null | ||
} | ||
} | ||
} | ||
} | ||
|
||
data class CodeLabel( | ||
val style: String, | ||
val file_id: String, | ||
val range: CodeRange, | ||
val message: String, | ||
) | ||
|
||
data class CodeRange( | ||
val start: Int, | ||
val end: Int, | ||
) { | ||
fun toTextRange(): TextRange = TextRange(start, end) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.