diff options
author | Ulf Hermann <ulf.hermann@qt.io> | 2019-09-17 17:13:18 +0200 |
---|---|---|
committer | Ulf Hermann <ulf.hermann@qt.io> | 2019-10-01 09:30:16 +0200 |
commit | b6075d7a4b99e484dfe4095ca8e0fdfb26fa6226 (patch) | |
tree | 494ff0f3d4c2b19a9ff37de8c831d0969767ce7c /tools/qmllint | |
parent | 098bf9739839364df93677dae963427fdec5f6c4 (diff) |
qmllint: Parse variable declarations from PatternElements
Change-Id: If8b4f5302cc1ee3a4193b354503b304534d7dfd9
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'tools/qmllint')
-rw-r--r-- | tools/qmllint/findunqualified.cpp | 12 | ||||
-rw-r--r-- | tools/qmllint/findunqualified.h | 2 |
2 files changed, 14 insertions, 0 deletions
diff --git a/tools/qmllint/findunqualified.cpp b/tools/qmllint/findunqualified.cpp index 799602d225..ee2a0c38c1 100644 --- a/tools/qmllint/findunqualified.cpp +++ b/tools/qmllint/findunqualified.cpp @@ -848,6 +848,18 @@ bool FindUnqualifiedIDVisitor::visit(QQmlJS::AST::UiObjectDefinition *uiod) return true; } +bool FindUnqualifiedIDVisitor::visit(QQmlJS::AST::PatternElement *element) +{ + if (element->isVariableDeclaration()) { + QQmlJS::AST::BoundNames names; + element->boundNames(&names); + for (const auto &name : names) + m_currentScope->insertJSIdentifier(name.id, element->scope); + } + + return true; +} + void FindUnqualifiedIDVisitor::endVisit(QQmlJS::AST::UiObjectDefinition *) { leaveEnvironment(); diff --git a/tools/qmllint/findunqualified.h b/tools/qmllint/findunqualified.h index 98e14f8dc7..80413bd402 100644 --- a/tools/qmllint/findunqualified.h +++ b/tools/qmllint/findunqualified.h @@ -126,6 +126,8 @@ private: // expression handling bool visit(QQmlJS::AST::IdentifierExpression *idexp) override; + + bool visit(QQmlJS::AST::PatternElement *) override; }; |