diff options
author | Fabian Kosmale <fabian.kosmale@qt.io> | 2020-04-23 10:10:31 +0200 |
---|---|---|
committer | Fabian Kosmale <fabian.kosmale@qt.io> | 2020-04-24 11:46:35 +0200 |
commit | b5fa1411a0109c332ffc7c3dbe9145f7ecc2c9a7 (patch) | |
tree | 889b3e6b40e3b0ed6b2b538b5b18015eeba5304e /tools | |
parent | af521a8df6caec41f626a4b3319601c20adff711 (diff) |
qmllint: Show filename in addition to line and column
Fixes: QTBUG-83684
Change-Id: If15a9498ae223dccfbafe88b14453a4b180247d9
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/qmllint/checkidentifiers.cpp | 22 | ||||
-rw-r--r-- | tools/qmllint/checkidentifiers.h | 5 | ||||
-rw-r--r-- | tools/qmllint/findunqualified.cpp | 2 |
3 files changed, 18 insertions, 11 deletions
diff --git a/tools/qmllint/checkidentifiers.cpp b/tools/qmllint/checkidentifiers.cpp index 20b2ba6214..fb7aee2a6d 100644 --- a/tools/qmllint/checkidentifiers.cpp +++ b/tools/qmllint/checkidentifiers.cpp @@ -94,10 +94,11 @@ bool CheckIdentifiers::checkMemberAccess(const QVector<ScopeTree::FieldMember> & if (scope.isNull()) { writeWarning(m_colorOut); m_colorOut->write( - QString::fromLatin1("Type \"%1\" of base \"%2\" not found when accessing member \"%3\" at %4:%5.\n") + QString::fromLatin1("Type \"%1\" of base \"%2\" not found when accessing member \"%3\" at %4:%5:%6.\n") .arg(detectedRestrictiveKind) .arg(detectedRestrictiveName) .arg(access.m_name) + .arg(m_fileName) .arg(access.m_location.startLine) .arg(access.m_location.startColumn), Normal); printContext(access.m_location); @@ -114,10 +115,11 @@ bool CheckIdentifiers::checkMemberAccess(const QVector<ScopeTree::FieldMember> & writeWarning(m_colorOut); m_colorOut->write(QString::fromLatin1( - "\"%1\" is a %2. You cannot access \"%3\" on it at %4:%5\n") + "\"%1\" is a %2. You cannot access \"%3\" on it at %4:%5:%6\n") .arg(detectedRestrictiveName) .arg(detectedRestrictiveKind) .arg(access.m_name) + .arg(m_fileName) .arg(access.m_location.startLine) .arg(access.m_location.startColumn), Normal); printContext(access.m_location); @@ -226,9 +228,10 @@ bool CheckIdentifiers::checkMemberAccess(const QVector<ScopeTree::FieldMember> & writeWarning(m_colorOut); m_colorOut->write(QString::fromLatin1( - "Property \"%1\" not found on type \"%2\" at %3:%4\n") + "Property \"%1\" not found on type \"%2\" at %3:%4:%5\n") .arg(access.m_name) .arg(scopeName) + .arg(m_fileName) .arg(access.m_location.startLine) .arg(access.m_location.startColumn), Normal); printContext(access.m_location); @@ -252,8 +255,8 @@ bool CheckIdentifiers::operator()(const QHash<QString, ScopeTree::ConstPtr> &qml for (const auto &handler : unmatchedSignalHandlers) { writeWarning(m_colorOut); m_colorOut->write(QString::fromLatin1( - "no matching signal found for handler \"%1\" at %2:%3\n") - .arg(handler.first).arg(handler.second.startLine) + "no matching signal found for handler \"%1\" at %2:%3:%4\n") + .arg(handler.first).arg(m_fileName).arg(handler.second.startLine) .arg(handler.second.startColumn), Normal); printContext(handler.second); } @@ -305,8 +308,9 @@ bool CheckIdentifiers::operator()(const QHash<QString, ScopeTree::ConstPtr> &qml if (!qmlIt->type()) { writeWarning(m_colorOut); m_colorOut->write(QString::fromLatin1( - "Type of property \"%2\" not found at %3:%4\n") + "Type of property \"%2\" not found at %3:%4:%5\n") .arg(memberAccessBase.m_name) + .arg(m_fileName) .arg(memberAccessBase.m_location.startLine) .arg(memberAccessBase.m_location.startColumn), Normal); printContext(memberAccessBase.m_location); @@ -332,7 +336,8 @@ bool CheckIdentifiers::operator()(const QHash<QString, ScopeTree::ConstPtr> &qml noUnqualifiedIdentifier = false; writeWarning(m_colorOut); const auto location = memberAccessBase.m_location; - m_colorOut->write(QString::fromLatin1("unqualified access at %1:%2\n") + m_colorOut->write(QString::fromLatin1("unqualified access at %1:%2:%3\n") + .arg(m_fileName) .arg(location.startLine).arg(location.startColumn), Normal); @@ -379,7 +384,8 @@ bool CheckIdentifiers::operator()(const QHash<QString, ScopeTree::ConstPtr> &qml m_colorOut->write( memberAccessBase.m_name + QString::fromLatin1( " is accessible in this scope because " - "you are handling a signal at %1:%2\n") + "you are handling a signal at %1:%2:%3\n") + .arg(m_fileName) .arg(methodUsage.loc.startLine).arg(methodUsage.loc.startColumn), Normal); m_colorOut->write(QLatin1String("Consider using a function instead\n"), Normal); diff --git a/tools/qmllint/checkidentifiers.h b/tools/qmllint/checkidentifiers.h index 5d2236b7f9..28f8b24c09 100644 --- a/tools/qmllint/checkidentifiers.h +++ b/tools/qmllint/checkidentifiers.h @@ -37,8 +37,8 @@ class CheckIdentifiers { public: CheckIdentifiers(ColorOutput *colorOut, const QString &code, const QHash<QString, - ScopeTree::ConstPtr> &types) : - m_colorOut(colorOut), m_code(code), m_types(types) + ScopeTree::ConstPtr> &types, const QString &fileName) : + m_colorOut(colorOut), m_code(code), m_types(types), m_fileName(fileName) {} bool operator ()(const QHash<QString, ScopeTree::ConstPtr> &qmlIDs, @@ -52,6 +52,7 @@ private: ColorOutput *m_colorOut = nullptr; QString m_code; QHash<QString, ScopeTree::ConstPtr> m_types; + QString m_fileName; }; #endif // CHECKIDENTIFIERS_H diff --git a/tools/qmllint/findunqualified.cpp b/tools/qmllint/findunqualified.cpp index 77d7d487fc..abd9c07c31 100644 --- a/tools/qmllint/findunqualified.cpp +++ b/tools/qmllint/findunqualified.cpp @@ -725,7 +725,7 @@ bool FindUnqualifiedIDVisitor::check() outstandingConnection.uiod->initializer->accept(this); } - CheckIdentifiers check(&m_colorOut, m_code, m_exportedName2Scope); + CheckIdentifiers check(&m_colorOut, m_code, m_exportedName2Scope, m_filePath); return check(m_qmlid2scope, m_rootScope, m_rootId); } |