aboutsummaryrefslogtreecommitdiffstats
path: root/tools/qmllint/main.cpp
diff options
context:
space:
mode:
authorMaximilian Goldstein <max.goldstein@qt.io>2021-07-05 12:48:49 +0200
committerMaximilian Goldstein <max.goldstein@qt.io>2021-07-07 14:03:21 +0200
commit67894892da4c4f9985307e8cfc76aad766de88ac (patch)
tree0a18866189ab8f3cadb8a182d538f871de6cd21b /tools/qmllint/main.cpp
parenteb8925682462c78fe5879d61662eb739b972e981 (diff)
qmllint: Integrate type inference warnings
This change helps bring in type inference and compiler warnings previously only generated by qmlcachegen+. These warnings are disabled by default and have to be enabled manually via the --compiler option. Also makes the logger handle zero length SourceLocations properly by just highlighting the entire line instead of hitting an assert. Change-Id: Iebad6e9236214d9367f97487e7b5787592edab7d Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
Diffstat (limited to 'tools/qmllint/main.cpp')
-rw-r--r--tools/qmllint/main.cpp14
1 files changed, 14 insertions, 0 deletions
diff --git a/tools/qmllint/main.cpp b/tools/qmllint/main.cpp
index d86fc55de0..0e2a479596 100644
--- a/tools/qmllint/main.cpp
+++ b/tools/qmllint/main.cpp
@@ -27,9 +27,11 @@
****************************************************************************/
#include "findwarnings.h"
+#include "codegen.h"
#include "../shared/qqmltoolingsettings.h"
#include <QtQmlCompiler/private/qqmljsresourcefilemapper_p.h>
+#include <QtQmlCompiler/private/qqmljscompiler_p.h>
#include <QtQml/private/qqmljslexer_p.h>
#include <QtQml/private/qqmljsparser_p.h>
@@ -179,6 +181,18 @@ static bool lint_file(const QString &filename, const bool silent, QJsonArray *js
parser.rootNode()->accept(&v);
success = v.check();
+ Codegen codegen { &importer, resourceFile, qmltypesFiles, &v.logger(), code };
+
+ QQmlJSSaveFunction saveFunction = [](const QV4::CompiledData::SaveableUnitPointer &,
+ const QQmlJSAotFunctionMap &,
+ QString *) { return true; };
+
+ QQmlJSCompileError error;
+
+ QLoggingCategory::setFilterRules(u"qt.qml.compiler=false"_qs);
+
+ qCompileQmlFile(filename, saveFunction, &codegen, &error);
+
if (json) {
for (const auto &error : v.logger().errors())
addJsonWarning(error);