diff --git a/src/qmldom/qqmldomconstants_p.h b/src/qmldom/qqmldomconstants_p.h index 5307fc8076..8e8b17279e 100644 --- a/src/qmldom/qqmldomconstants_p.h +++ b/src/qmldom/qqmldomconstants_p.h @@ -414,6 +414,7 @@ Q_ENUM_NS(FileLocationRegion); enum DomCreationOption : char { Default, // required by qmlformat for example Extended, // required by qmlls for example + Minimal, // required by QmlDocumentParser in Qt Design Studio, for example }; } // end namespace Dom diff --git a/src/qmldom/qqmldomtop.cpp b/src/qmldom/qqmldomtop.cpp index 36dc42fd5b..50e01cff58 100644 --- a/src/qmldom/qqmldomtop.cpp +++ b/src/qmldom/qqmldomtop.cpp @@ -2241,6 +2241,10 @@ void DomEnvironment::populateFromQmlFile(MutableDomItem &&qmlFile) Q_UNUSED(this); // note: integrity requires "this" to be in the capture list, while // other compilers complain about "this" being unused in the lambda AST::Node::accept(qmlFilePtr->ast(), visitor); + + if (m_domCreationOption == DomCreationOption::Minimal) + return; + CommentCollector collector(qmlFile); collector.collectComments(); }; diff --git a/tests/benchmarks/qml/qmldom/tst_qmldomconstruction.cpp b/tests/benchmarks/qml/qmldom/tst_qmldomconstruction.cpp index 2a53a6dcb4..3e6e02b5f0 100644 --- a/tests/benchmarks/qml/qmldom/tst_qmldomconstruction.cpp +++ b/tests/benchmarks/qml/qmldom/tst_qmldomconstruction.cpp @@ -32,6 +32,9 @@ void tst_qmldomconstruction::domConstructionTime_data() QTest::addRow("extended-tiger.qml") << baseDir + u"/longQmlFile.qml"_s << Extended; QTest::addRow("extended-deeplyNested.qml") << baseDir + u"/deeplyNested.qml"_s << Extended; + + QTest::addRow("minimal-tiger.qml") << baseDir + u"/longQmlFile.qml"_s << Minimal; + QTest::addRow("minimal-deeplyNested.qml") << baseDir + u"/deeplyNested.qml"_s << Minimal; } void tst_qmldomconstruction::domConstructionTime()