File tree Expand file tree Collapse file tree 1 file changed +15
-1
lines changed
src/main/kotlin/com/github/xepozz/mago/qualityTool Expand file tree Collapse file tree 1 file changed +15
-1
lines changed Original file line number Diff line number Diff line change @@ -48,9 +48,16 @@ class MagoMessageProcessor(private val info: QualityToolAnnotatorInfo<*>) : Qual
4848// it.file.endsWith(currentFilePath)
4949// }
5050 .map { problem ->
51+ /* *
52+ * temporary convert to bytes-offset to chars offset
53+ */
54+ val range = byteRangeToCharRange(file.text, problem.startChar, problem.endChar)
55+ val textRange = TextRange (range.first, range.last + 1 )
56+ // val textRange = TextRange(problem.startChar, problem.endChar)
57+
5158 QualityToolMessage (
5259 this ,
53- TextRange (problem.startChar, problem.endChar) ,
60+ textRange ,
5461 problem.severity,
5562 problem.message,
5663 MagoReformatFileAction (info.project),
@@ -64,4 +71,11 @@ class MagoMessageProcessor(private val info: QualityToolAnnotatorInfo<*>) : Qual
6471 }
6572 .forEach { addMessage(it) }
6673 }
74+
75+ private fun byteRangeToCharRange (text : String , byteStart : Int , byteEnd : Int ): IntRange {
76+ val bytes = text.toByteArray(Charsets .UTF_8 )
77+ val charStart = String (bytes.copyOf(byteStart), Charsets .UTF_8 ).length
78+ val charEnd = String (bytes.copyOf(byteEnd), Charsets .UTF_8 ).length
79+ return charStart until charEnd
80+ }
6781}
You can’t perform that action at this time.
0 commit comments