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>
This commit is contained in:
parent
b46746c038
commit
ddcd24a345
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -50,7 +50,7 @@ class QmlJSTypeReader
|
|||
{
|
||||
public:
|
||||
struct Import {
|
||||
QString path;
|
||||
QString module;
|
||||
QTypeRevision version;
|
||||
QString prefix;
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue