32class LinterVisitor
final :
public QQmlJSImportVisitor
36 const QString &implicitImportDirectory,
37 const QStringList &qmldirFiles = QStringList(), QQmlJS::Engine *engine =
nullptr);
40 using QQmlJSImportVisitor::endVisit;
41 using QQmlJSImportVisitor::visit;
43 bool preVisit(QQmlJS::AST::Node *)
override;
44 void postVisit(QQmlJS::AST::Node *)
override;
49 bool visit(QQmlJS::AST::StringLiteral *)
override;
50 bool visit(AST::CommaExpression *)
override;
51 bool visit(QQmlJS::AST::NewMemberExpression *)
override;
52 bool visit(QQmlJS::AST::VoidExpression *ast)
override;
53 bool visit(QQmlJS::AST::BinaryExpression *)
override;
54 bool visit(QQmlJS::AST::UiImport *import)
override;
55 bool visit(QQmlJS::AST::UiEnumDeclaration *uied)
override;
56 bool visit(QQmlJS::AST::CaseBlock *)
override;
57 bool visit(QQmlJS::AST::ExpressionStatement *ast)
override;
58 bool visit(QQmlJS::AST::FunctionDeclaration *fdecl)
override;
59 bool visit(QQmlJS::AST::FunctionExpression *fexpr)
override;
60 bool visit(QQmlJS::AST::UiPublicMember *publicMember)
override;
62 void endVisit(QQmlJS::AST::UiProgram *ast)
override;
65 const QQmlJSScope::JavaScriptIdentifier &identifier)
override;
72 QTypeRevision version;
74 QQmlJS::AST::UiImport *uiImport;
76 SeenImport(QQmlJS::AST::UiImport *i) : filename(i->fileName), id(i->importId), uiImport(i)
79 uri = i->importUri->toString();
81 version = i->version->version;
83 friend bool comparesEqual(
const SeenImport &lhs,
const SeenImport &rhs)
noexcept
85 return lhs.filename == rhs.filename && lhs.uri == rhs.uri
86 && lhs.version == rhs.version && lhs.id == rhs.id;
88 Q_DECLARE_EQUALITY_COMPARABLE(SeenImport)
90 friend size_t qHash(
const SeenImport &i, size_t seed = 0)
92 return qHashMulti(seed, i.filename, i.uri, i.version, i.id);
95 QQmlJS::Engine *m_engine =
nullptr;
96 QSet<SeenImport> m_seenImports;
97 QSet<std::pair<
const QQmlJSScope *, QString>> misplacedJSIdentifiers;
98 std::vector<QQmlJS::AST::Node *> m_ancestryIncludingCurrentNode;
100 void handleDuplicateEnums(QQmlJS::AST::UiEnumMemberList *members, QStringView key,
101 const QQmlJS::SourceLocation &location);
102 void warnCaseNoFlowControl(QQmlJS::SourceLocation caseToken)
const;
103 void checkCaseFallthrough(QQmlJS::AST::StatementList *statements, SourceLocation errorLoc,
104 SourceLocation nextLoc);
106 const QString &name,
const QQmlJS::AST::Statement *statement,
107 const QQmlJS::AST::UiPublicMember *associatedPropertyDefinition =
nullptr)
override;
109 const AST::UiPublicMember *associatedPropertyDefinition)
override;
111 void checkIdShadows();