mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[syntax] do lexing only if the current node is lazy parseable
GitOrigin-RevId: 0289cd8505bd2da5c86f8558028fd4db97681568
This commit is contained in:
committed by
intellij-monorepo-bot
parent
71218a4fd8
commit
858659c93b
@@ -77,7 +77,8 @@ fun canLazyNodeBeReparsedIncrementally(parsingContext: LazyParsingContext): Bool
|
||||
}
|
||||
|
||||
fun createLexer(lexerContext: LazyLexingContext): Lexer? {
|
||||
return lexerContext.node.type.lazyParser!!.createLexer(lexerContext)
|
||||
val lazyParser = lexerContext.node.type.lazyParser ?: error("Node ${lexerContext.node} is not lazy parseable")
|
||||
return lazyParser.createLexer(lexerContext)
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+13
-13
@@ -437,8 +437,8 @@ class KmpSyntaxNode internal constructor(
|
||||
var currentLexer = rootLexer
|
||||
while (node != null && node.startOffset <= startOffset && node.endOffset > endOffset) {
|
||||
val type = node.type
|
||||
val nodeText = newText.subSequence(node.startOffset, node.endOffset)
|
||||
if (type.isLazyParseable()) {
|
||||
val nodeText = newText.subSequence(node.startOffset, node.endOffset)
|
||||
val startLexemeIndex = currentTokens
|
||||
.tokenIndexAtOffset((node.startOffset - node.context.offset))
|
||||
.onMinusOne(currentTokens.tokenCount - 1)
|
||||
@@ -466,19 +466,19 @@ class KmpSyntaxNode internal constructor(
|
||||
currentLexer != rootLexer
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
val lexingContext = LazyLexingContext(node, cancellationProvider)
|
||||
val lexer = performWithExtensionSupport(context.extensions()) {
|
||||
createLexer(lexingContext)
|
||||
}
|
||||
if (lexer != null && lexer != currentLexer) {
|
||||
currentLexer = lexer
|
||||
currentTokens = context.tokenizationPolicy.tokenize(
|
||||
text = nodeText,
|
||||
lexer = lexer,
|
||||
cancellationProvider = cancellationProvider,
|
||||
)
|
||||
val lexingContext = LazyLexingContext(node, cancellationProvider)
|
||||
val lexer = performWithExtensionSupport(context.extensions()) {
|
||||
createLexer(lexingContext)
|
||||
}
|
||||
if (lexer != null && lexer != currentLexer) {
|
||||
currentLexer = lexer
|
||||
currentTokens = context.tokenizationPolicy.tokenize(
|
||||
text = nodeText,
|
||||
lexer = lexer,
|
||||
cancellationProvider = cancellationProvider,
|
||||
)
|
||||
}
|
||||
}
|
||||
node = node.children()
|
||||
.firstOrNull { it.startOffset <= startOffset && it.endOffset >= endOffset } as KmpSyntaxNode?
|
||||
|
||||
Reference in New Issue
Block a user