aboutsummaryrefslogtreecommitdiffstats
path: root/tools/qmllint/main.cpp
diff options
context:
space:
mode:
authorMaximilian Goldstein <max.goldstein@qt.io>2021-11-15 10:36:53 +0100
committerMaximilian Goldstein <max.goldstein@qt.io>2021-11-17 20:59:23 +0100
commit2248ee16e0f143221803e644d2c4c5ac47a72d63 (patch)
treed95f2c59d8f16d3d6cfaa5d6c2c70f3fcf3bed22 /tools/qmllint/main.cpp
parent6afbf43f83f259f81d23eae34e449bd638149bc3 (diff)
qmllint: Add option for logging absolute paths
Some IDEs might want to parse qmllints logging messages directly instead of using the structured JSON output. For these a hidden --absolute-path option has been introduced so the messages can more easily be mapped to the actual files. Task-number: QTCREATORBUG-17224 Change-Id: I23c4272a45adcb2bf7aeb6ae7b130839b9f05b72 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'tools/qmllint/main.cpp')
-rw-r--r--tools/qmllint/main.cpp21
1 files changed, 15 insertions, 6 deletions
diff --git a/tools/qmllint/main.cpp b/tools/qmllint/main.cpp
index aa3ed86770..7a66d5815c 100644
--- a/tools/qmllint/main.cpp
+++ b/tools/qmllint/main.cpp
@@ -61,9 +61,9 @@
constexpr int JSON_LOGGING_FORMAT_REVISION = 1;
-static bool lint_file(const QString &filename, const bool silent, QJsonArray *json,
- const QStringList &qmlImportPaths, const QStringList &qmltypesFiles,
- const QStringList &resourceFiles,
+static bool lint_file(const QString &filename, const bool silent, const bool useAbsolutePath,
+ QJsonArray *json, const QStringList &qmlImportPaths,
+ const QStringList &qmltypesFiles, const QStringList &resourceFiles,
const QMap<QString, QQmlJSLogger::Option> &options, QQmlJSImporter &importer)
{
QJsonArray warnings;
@@ -170,7 +170,8 @@ static bool lint_file(const QString &filename, const bool silent, QJsonArray *js
importer.setResourceFileMapper(mapper);
- QQmlJSLogger logger(filename, code, silent || json);
+ QQmlJSLogger logger(useAbsolutePath ? info.absoluteFilePath() : filename, code,
+ silent || json);
FindWarningVisitor v {
&importer,
&logger,
@@ -314,6 +315,12 @@ All warnings can be set to three levels:
const QString qmltypesFilesSetting = QLatin1String("OverwriteImportTypes");
settings.addOption(qmltypesFilesSetting);
+ QCommandLineOption absolutePath(
+ QStringList() << "absolute-path",
+ QLatin1String("Use absolute paths for logging instead of relative ones."));
+ absolutePath.setFlags(QCommandLineOption::HiddenFromHelp);
+ parser.addOption(absolutePath);
+
parser.addPositionalArgument(QLatin1String("files"),
QLatin1String("list of qml or js files to verify"));
@@ -348,6 +355,7 @@ All warnings can be set to three levels:
}
bool silent = parser.isSet(silentOption);
+ bool useAbsolutePath = parser.isSet(absolutePath);
bool useJson = parser.isSet(jsonOption);
// use host qml import path as a sane default if not explicitly disabled
@@ -376,6 +384,7 @@ All warnings can be set to three levels:
#else
bool silent = false;
+ bool useAbsolutePaths = false;
bool useJson = false;
bool warnUnqualified = true;
bool warnWithStatement = true;
@@ -430,8 +439,8 @@ All warnings can be set to three levels:
const auto arguments = app.arguments();
for (const QString &filename : arguments) {
#endif
- success &= lint_file(filename, silent, useJson ? &jsonFiles : nullptr, qmlImportPaths,
- qmltypesFiles, resourceFiles, options, importer);
+ success &= lint_file(filename, silent, useAbsolutePath, useJson ? &jsonFiles : nullptr,
+ qmlImportPaths, qmltypesFiles, resourceFiles, options, importer);
}
if (useJson) {