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;
63 const QQmlJSScope::JavaScriptIdentifier &identifier)
override;
70 QTypeRevision version;
72 QQmlJS::AST::UiImport *uiImport;
74 SeenImport(QQmlJS::AST::UiImport *i) : filename(i->fileName), id(i->importId), uiImport(i)
77 uri = i->importUri->toString();
79 version = i->version->version;
81 friend bool comparesEqual(
const SeenImport &lhs,
const SeenImport &rhs)
noexcept
83 return lhs.filename == rhs.filename && lhs.uri == rhs.uri
84 && lhs.version == rhs.version && lhs.id == rhs.id;
86 Q_DECLARE_EQUALITY_COMPARABLE(SeenImport)
88 friend size_t qHash(
const SeenImport &i, size_t seed = 0)
90 return qHashMulti(seed, i.filename, i.uri, i.version, i.id);
93 QQmlJS::Engine *m_engine =
nullptr;
94 QSet<SeenImport> m_seenImports;
95 QSet<std::pair<
const QQmlJSScope *, QString>> misplacedJSIdentifiers;
96 std::vector<QQmlJS::AST::Node *> m_ancestryIncludingCurrentNode;
98 void handleDuplicateEnums(QQmlJS::AST::UiEnumMemberList *members, QStringView key,
99 const QQmlJS::SourceLocation &location);
100 void warnCaseNoFlowControl(QQmlJS::SourceLocation caseToken)
const;
101 void checkCaseFallthrough(QQmlJS::AST::StatementList *statements, SourceLocation errorLoc,
102 SourceLocation nextLoc);
104 const QString &name,
const QQmlJS::AST::Statement *statement,
105 const QQmlJS::AST::UiPublicMember *associatedPropertyDefinition =
nullptr)
override;
107 const AST::UiPublicMember *associatedPropertyDefinition)
override;
108 void handleUselessExpressionStatement(
const AST::ExpressionStatement *ast);