aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2020-08-13 15:59:52 +0200
committerUlf Hermann <ulf.hermann@qt.io>2020-08-20 11:55:48 +0200
commitddcd24a345149915f7320a8fef9b7625b7d7e9ca (patch)
tree376805f2730a7b19854bbaf58c61e15370f2e5a2 /tools
parentb46746c0386c0b3c528e74e130cdc15b2019f384 (diff)
Improve the QML/JS type reader
Don't alternate between paths and URIs if we only need the URIs, and don't rely on casting from ASCII to QString or QChar. Change-Id: I4c206d5ff488939d5d2d78a3694d8eaf54ec5ec1 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'tools')
-rw-r--r--tools/qmllint/findwarnings.cpp7
-rw-r--r--tools/shared/importedmembersvisitor.cpp6
-rw-r--r--tools/shared/qmljstypereader.cpp2
-rw-r--r--tools/shared/qmljstypereader.h2
4 files changed, 8 insertions, 9 deletions
diff --git a/tools/qmllint/findwarnings.cpp b/tools/qmllint/findwarnings.cpp
index 83e0c63653..c574c166a9 100644
--- a/tools/qmllint/findwarnings.cpp
+++ b/tools/qmllint/findwarnings.cpp
@@ -201,13 +201,12 @@ void FindWarningVisitor::importBareQmlTypes()
void FindWarningVisitor::importHelper(const QString &module, const QString &prefix,
QTypeRevision version)
{
- const QString id = QString(module).replace(QLatin1Char('/'), QLatin1Char('.'));
- QPair<QString, QString> importId { id, prefix };
+ const QPair<QString, QString> importId { module, prefix };
if (m_alreadySeenImports.contains(importId))
return;
m_alreadySeenImports.insert(importId);
- const auto qmltypesPaths = qQmlResolveImportPaths(id, m_qmltypesDirs, version);
+ const auto qmltypesPaths = qQmlResolveImportPaths(module, m_qmltypesDirs, version);
for (auto const &qmltypesPath : qmltypesPaths) {
if (QFile::exists(qmltypesPath + SlashQmldir)) {
processImport(prefix, readQmldir(qmltypesPath), version);
@@ -227,7 +226,7 @@ ScopeTree::Ptr FindWarningVisitor::localFile2ScopeTree(const QString &filePath)
const auto imports = typeReader.imports();
for (const auto &import : imports)
- importHelper(import.path, import.prefix, import.version);
+ importHelper(import.module, import.prefix, import.version);
return result;
}
diff --git a/tools/shared/importedmembersvisitor.cpp b/tools/shared/importedmembersvisitor.cpp
index 2162044f99..36282ea55c 100644
--- a/tools/shared/importedmembersvisitor.cpp
+++ b/tools/shared/importedmembersvisitor.cpp
@@ -63,7 +63,7 @@ bool ImportedMembersVisitor::visit(UiObjectDefinition *definition)
QString superType;
for (auto segment = definition->qualifiedTypeNameId; segment; segment = segment->next) {
if (!superType.isEmpty())
- superType.append('.');
+ superType.append(u'.');
superType.append(segment->name.toString());
}
scope->setSuperclassName(superType);
@@ -125,12 +125,12 @@ bool ImportedMembersVisitor::visit(UiSourceElement *sourceElement)
method.setMethodType(MetaMethod::Method);
FormalParameterList *parameters = fexpr->formals;
while (parameters) {
- method.addParameter(parameters->element->bindingIdentifier.toString(), "");
+ method.addParameter(parameters->element->bindingIdentifier.toString(), QString());
parameters = parameters->next;
}
currentObject()->addMethod(method);
} else if (ClassExpression *clexpr = sourceElement->sourceElement->asClassDefinition()) {
- MetaProperty prop { clexpr->name.toString(), "", false, false, false, false, 1 };
+ MetaProperty prop { clexpr->name.toString(), QString(), false, false, false, false, 1 };
currentObject()->addProperty(prop);
} else if (cast<VariableStatement *>(sourceElement->sourceElement)) {
// nothing to do
diff --git a/tools/shared/qmljstypereader.cpp b/tools/shared/qmljstypereader.cpp
index 3825535d44..527dba4535 100644
--- a/tools/shared/qmljstypereader.cpp
+++ b/tools/shared/qmljstypereader.cpp
@@ -52,7 +52,7 @@ static QList<QmlJSTypeReader::Import> parseHeaders(QQmlJS::AST::UiHeaderItemList
auto uri = import->importUri;
while (uri) {
path.append(uri->name);
- path.append(QLatin1Char('/'));
+ path.append(u'.');
uri = uri->next;
}
path.chop(1);
diff --git a/tools/shared/qmljstypereader.h b/tools/shared/qmljstypereader.h
index 8485f6be6b..9afa5d46e6 100644
--- a/tools/shared/qmljstypereader.h
+++ b/tools/shared/qmljstypereader.h
@@ -50,7 +50,7 @@ class QmlJSTypeReader
{
public:
struct Import {
- QString path;
+ QString module;
QTypeRevision version;
QString prefix;
};