diff options
author | Semih Yavuz <semih.yavuz@qt.io> | 2024-04-30 14:33:24 +0200 |
---|---|---|
committer | Semih Yavuz <semih.yavuz@qt.io> | 2024-05-07 13:36:09 +0200 |
commit | 5230151276041b16521122d6a55f5bc45780cdf2 (patch) | |
tree | c42698833f5b21c47ad3d88026ffe1c8f628961f /src/qml/parser/qqmljs.g | |
parent | 04751e1cf86647554d69c014c2c423f3c6c89ead (diff) |
semantichighlighting: highlight for-declarations
Add declarationKindToken location in the pattern element node. This is
required for semantic highlighting to highlight the type correctly
within iteration statements.
Add type identifier region for the declaration kind token in the
for-declaration construct.
Fixes: QTBUG-124677
Task-number: QTBUG-120000
Change-Id: I02520bdc6f1b9dfc5d47078cd7e5e8d2f40bf382
Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
Diffstat (limited to 'src/qml/parser/qqmljs.g')
-rw-r--r-- | src/qml/parser/qqmljs.g | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/qml/parser/qqmljs.g b/src/qml/parser/qqmljs.g index 964b653ebc..32b609f5ff 100644 --- a/src/qml/parser/qqmljs.g +++ b/src/qml/parser/qqmljs.g @@ -3568,6 +3568,11 @@ IterationStatement: T_FOR T_LPAREN LexicalDeclaration T_SEMICOLON ExpressionOpt_ AST::ForStatement *node = new (pool) AST::ForStatement( static_cast<AST::VariableStatement *>(sym(3).Node)->declarations, sym(5).Expression, sym(7).Expression, sym(9).Statement); + if (node->declarations) { + AST::PatternElement *pe = node->declarations->declaration; + pe->isForDeclaration = true; + pe->declarationKindToken = loc(3); + } node->forToken = loc(1); node->lparenToken = loc(2); node->firstSemicolonToken = loc(4); @@ -3639,6 +3644,7 @@ ForDeclaration: Var BindingIdentifier TypeAnnotationOpt; node->identifierToken = loc(2); node->scope = sym(1).scope; node->isForDeclaration = true; + node->declarationKindToken = loc(1); sym(1).Node = node; } break; ./ @@ -3651,6 +3657,7 @@ ForDeclaration: Var BindingPattern; auto *node = new (pool) AST::PatternElement(sym(2).Pattern, nullptr); node->scope = sym(1).scope; node->isForDeclaration = true; + node->declarationKindToken = loc(1); sym(1).Node = node; } break; ./ |