diff options
author | Maximilian Goldstein <max.goldstein@qt.io> | 2020-01-15 11:25:18 +0100 |
---|---|---|
committer | Maximilian Goldstein <max.goldstein@qt.io> | 2020-01-17 10:02:29 +0100 |
commit | 9e674be4fb8c369873a009f58e3152a12d2c4cce (patch) | |
tree | 034090e7ef4723bafb9983f10ba285fb84735273 /tools/qmlformat/main.cpp | |
parent | 47b187231ab1c45f8609bcbbf6f85f8a05bc9be7 (diff) |
qmlformat: Fix some language features being unsupported
qmlformat now supports:
- arrow functions
- generator functions
- this expressions
- object patterns
- regex literals
- type expressions
- plain expressions
Aborts if an error occurs during dumping now.
Also now automatically tests qmlformat against all example / test qml
files.
Change-Id: Idc24004c6f2c1cd65289bcad75985a1ef047c8d2
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'tools/qmlformat/main.cpp')
-rw-r--r-- | tools/qmlformat/main.cpp | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/tools/qmlformat/main.cpp b/tools/qmlformat/main.cpp index bca788d316..036fbe9748 100644 --- a/tools/qmlformat/main.cpp +++ b/tools/qmlformat/main.cpp @@ -43,7 +43,7 @@ #include "dumpastvisitor.h" #include "restructureastvisitor.h" -bool parseFile(const QString& filename, bool inplace, bool verbose, bool sortImports) +bool parseFile(const QString& filename, bool inplace, bool verbose, bool sortImports, bool force) { QFile file(filename); @@ -101,8 +101,14 @@ bool parseFile(const QString& filename, bool inplace, bool verbose, bool sortImp DumpAstVisitor dump(parser.rootNode(), &comment); - if (dump.error()) - qWarning().noquote() << "An error has occurred. The output may not be reliable."; + if (dump.error()) { + if (force) { + qWarning().noquote() << "An error has occurred. The output may not be reliable."; + } else { + qWarning().noquote() << "Am error has occurred. Aborting."; + return false; + } + } if (inplace) { if (verbose) @@ -145,6 +151,9 @@ int main(int argc, char *argv[]) parser.addOption(QCommandLineOption({"i", "inplace"}, QStringLiteral("Edit file in-place instead of outputting to stdout."))); + parser.addOption(QCommandLineOption({"f", "force"}, + QStringLiteral("Continue even if an error has occurred."))); + parser.addPositionalArgument("filenames", "files to be processed by qmlformat"); parser.process(app); @@ -155,7 +164,7 @@ int main(int argc, char *argv[]) parser.showHelp(-1); for (const QString& file: parser.positionalArguments()) { - if (!parseFile(file, parser.isSet("inplace"), parser.isSet("verbose"), !parser.isSet("no-sort"))) + if (!parseFile(file, parser.isSet("inplace"), parser.isSet("verbose"), !parser.isSet("no-sort"), parser.isSet("force"))) success = false; } #endif |