QmlDesigner: Remove builtins and jsroot

There is now the QML module. So we don't need to parse the builtin
qmltypes files. We ignore java script extensions too. Maybe we can
remove the fake types too.

Change-Id: I7a89237bae945be9a22355c549ebc208ccbfaa33
Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
This commit is contained in:
Marco Bubke
2025-01-15 19:27:15 +01:00
parent 7dd6ab39ca
commit f4a080344f
4 changed files with 36 additions and 17 deletions

View File

@@ -55,10 +55,6 @@ Component {
name: "QDeclarativeListProperty<QGraphicsObject>"
}
Component {
name: "QLocale"
}
Component {
name: "QPen"
}

View File

@@ -431,6 +431,14 @@ EnumerationTypes addEnumerationTypes(Storage::Synchronization::Types &types,
return enumerationTypes;
}
TypeNameString extensionTypeName(const auto &component)
{
if (component.extensionIsJavaScript())
return {};
return component.extensionTypeName();
}
void addType(Storage::Synchronization::Types &types,
SourceId sourceId,
ModuleId cppModuleId,
@@ -455,7 +463,7 @@ void addType(Storage::Synchronization::Types &types,
const auto &type = types.emplace_back(
Utils::SmallStringView{typeName},
Storage::Synchronization::ImportedType{TypeNameString{component.baseTypeName()}},
Storage::Synchronization::ImportedType{TypeNameString{component.extensionTypeName()}},
Storage::Synchronization::ImportedType{extensionTypeName(component)},
createTypeTraits(component.accessSemantics(),
component.hasCustomParser(),
component.isSingleton()),

View File

@@ -47,6 +47,8 @@
#include <QQmlEngine>
#include <QStandardPaths>
#include <source_location>
using namespace std::chrono;
using namespace std::chrono_literals;
@@ -355,7 +357,7 @@ void QmlDesignerProjectManager::editorsClosed(const QList<::Core::IEditor *> &)
namespace {
QString qmlPath(::ProjectExplorer::Target *target)
[[maybe_unused]] QString qmlPath(::ProjectExplorer::Target *target)
{
auto qt = QtSupport::QtKitAspect::qtVersion(target->kit());
if (qt)
@@ -431,11 +433,6 @@ QString qmlPath(::ProjectExplorer::Target *target)
QStringList qmldirPaths;
qmldirPaths.reserve(2);
const QString qmlRootPath = qmlPath(target);
qmldirPaths.append(qmlRootPath + "/builtins.qmltypes");
qmldirPaths.append(qmlRootPath + "/jsroot.qmltypes");
qmldirPaths.append(
Core::ICore::resourcePath("qmldesigner/projectstorage/fake.qmltypes").toString());
@@ -447,11 +444,6 @@ QString qmlPath(::ProjectExplorer::Target *target)
QStringList qmldirPaths;
qmldirPaths.reserve(2);
const auto qmlRootPath = QLibraryInfo::path(QLibraryInfo::QmlImportsPath);
qmldirPaths.append(qmlRootPath + "/builtins.qmltypes");
qmldirPaths.append(qmlRootPath + "/jsroot.qmltypes");
qmldirPaths.append(
Core::ICore::resourcePath("qmldesigner/projectstorage/fake.qmltypes").toString());
@@ -617,7 +609,10 @@ void QmlDesignerProjectManager::update()
propertyEditorResourcesPath(),
{qtCreatorItemLibraryPath()}});
}
} catch (const std::exception &) {
} catch (const std::exception &e) {
auto location = std::source_location::current();
std::cout << location.file_name() << ":" << location.function_name() << ":"
<< location.line() << ": " << e.what() << "\n";
}
}

View File

@@ -291,6 +291,26 @@ TEST_F(QmlTypesParser, extension)
qmltypesFileSourceId)));
}
TEST_F(QmlTypesParser, ignore_java_script_extensions)
{
QString source{R"(import QtQuick.tooling 1.2
Module{
Component { name: "QObject"}
Component { name: "QQmlComponent"
extension: "QObject"
extensionIsJavaScript: true
}})"};
parser.parse(source, imports, types, directoryInfo);
ASSERT_THAT(types,
Contains(IsType("QQmlComponent",
Synchronization::ImportedType{},
Synchronization::ImportedType{},
Storage::TypeTraitsKind::Reference,
qmltypesFileSourceId)));
}
TEST_F(QmlTypesParser, exported_types)
{
QString source{R"(import QtQuick.tooling 1.2