Skip to content

Commit

Permalink
Remove error listeners from highlighting lexer
Browse files Browse the repository at this point in the history
fixes #111
  • Loading branch information
ligee committed Jul 2, 2022
1 parent 7a96077 commit 03ddf99
Showing 1 changed file with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ class KotlinHighlighter(private val styles: SyntaxPlugin.HighlightStyles): BaseH
try {
with(KotlinParserForHighlighting(code)) {
addParseListener(listener)
removeErrorListeners()
script()
}
} catch (e: Throwable) {
Expand Down Expand Up @@ -68,10 +67,17 @@ class KotlinHighlighter(private val styles: SyntaxPlugin.HighlightStyles): BaseH
override fun setErrorIndex(p0: Int) {}

private class KotlinParserForHighlighting(code: String) :
KotlinParser(CommonTokenStream(KotlinLexer(CharStreams.fromString(code))))
KotlinParser(
CommonTokenStream(
KotlinLexer(CharStreams.fromString(code)).also {
it.removeErrorListeners()
}
)
)
{
init {
_buildParseTrees = false
removeErrorListeners()
}
}
}

0 comments on commit 03ddf99

Please sign in to comment.