diff options
-rw-r--r-- | tests/auto/qml/qmlformat/data/verbatimString.formatted.qml | 3 | ||||
-rw-r--r-- | tests/auto/qml/qmlformat/data/verbatimString.qml | 3 | ||||
-rw-r--r-- | tests/auto/qml/qmlmin/tst_qmlmin.cpp | 3 | ||||
-rw-r--r-- | tools/qmlformat/dumpastvisitor.cpp | 6 |
4 files changed, 15 insertions, 0 deletions
diff --git a/tests/auto/qml/qmlformat/data/verbatimString.formatted.qml b/tests/auto/qml/qmlformat/data/verbatimString.formatted.qml index fa7fbbe32b..84abe38f88 100644 --- a/tests/auto/qml/qmlformat/data/verbatimString.formatted.qml +++ b/tests/auto/qml/qmlformat/data/verbatimString.formatted.qml @@ -1,4 +1,7 @@ Item { property string verbatim1: 'A "verbatim" string!' property string verbatim2: "A 'verbatim' string\u2757" + property string verbatim3: `400 + 300 is ${400 + 300}. + +mutliline` } diff --git a/tests/auto/qml/qmlformat/data/verbatimString.qml b/tests/auto/qml/qmlformat/data/verbatimString.qml index 15b080a87b..fa16b97dca 100644 --- a/tests/auto/qml/qmlformat/data/verbatimString.qml +++ b/tests/auto/qml/qmlformat/data/verbatimString.qml @@ -1,4 +1,7 @@ Item { property string verbatim1: 'A "verbatim" string!' property string verbatim2: "A 'verbatim' string\u2757" +property string verbatim3: `400 + 300 is ${400 + 300}. + +mutliline` }
\ No newline at end of file diff --git a/tests/auto/qml/qmlmin/tst_qmlmin.cpp b/tests/auto/qml/qmlmin/tst_qmlmin.cpp index 24e926ffb3..cc028d979f 100644 --- a/tests/auto/qml/qmlmin/tst_qmlmin.cpp +++ b/tests/auto/qml/qmlmin/tst_qmlmin.cpp @@ -137,6 +137,9 @@ void tst_qmlmin::initTestCase() invalidFiles << "tests/auto/qml/qqmllanguage/data/requiredProperties.2.qml"; // generatorFunction.qml is not invalid per se, but the minifier cannot handle yield statements invalidFiles << "tests/auto/qml/qqmlecmascript/data/generatorFunction.qml"; + // minifer can't handle template strings properly + invalidFiles << "tests/auto/qml/qmlformat/data/verbatimString.qml"; + invalidFiles << "tests/auto/qml/qmlformat/data/verbatimString.formatted.qml"; #endif } diff --git a/tools/qmlformat/dumpastvisitor.cpp b/tools/qmlformat/dumpastvisitor.cpp index c92d25787f..19bf3d6717 100644 --- a/tools/qmlformat/dumpastvisitor.cpp +++ b/tools/qmlformat/dumpastvisitor.cpp @@ -418,6 +418,12 @@ QString DumpAstVisitor::parseExpression(ExpressionNode *expression) return "--"+parseExpression(cast<PreDecrementExpression *>(expression)->expression); case Node::Kind_NumericLiteral: return QString::number(cast<NumericLiteral *>(expression)->value); + case Node::Kind_TemplateLiteral: { + auto firstSrcLoc = cast<TemplateLiteral *>(expression)->firstSourceLocation(); + auto lastSrcLoc = cast<TemplateLiteral *>(expression)->lastSourceLocation(); + return m_engine->code().mid(static_cast<int>(firstSrcLoc.begin()), + static_cast<int>(lastSrcLoc.end() - firstSrcLoc.begin())); + } case Node::Kind_StringLiteral: { auto srcLoc = cast<StringLiteral *>(expression)->firstSourceLocation(); return m_engine->code().mid(static_cast<int>(srcLoc.begin()), |