diff options
Diffstat (limited to 'src/plugins/qmldesigner/designercore')
15 files changed, 57 insertions, 26 deletions
diff --git a/src/plugins/qmldesigner/designercore/filemanager/addpropertyvisitor.cpp b/src/plugins/qmldesigner/designercore/filemanager/addpropertyvisitor.cpp index 7c0688ba9a..3c04d341bb 100644 --- a/src/plugins/qmldesigner/designercore/filemanager/addpropertyvisitor.cpp +++ b/src/plugins/qmldesigner/designercore/filemanager/addpropertyvisitor.cpp @@ -79,8 +79,8 @@ bool AddPropertyVisitor::visit(QmlJS::AST::UiObjectBinding *ast) void AddPropertyVisitor::addInMembers(QmlJS::AST::UiObjectInitializer *initializer) { QmlJS::AST::UiObjectMemberList *insertAfter = searchMemberToInsertAfter(initializer->members, m_name, m_propertyOrder); - QmlJS::AST::SourceLocation endOfPreviousMember; - QmlJS::AST::SourceLocation startOfNextMember; + QmlJS::SourceLocation endOfPreviousMember; + QmlJS::SourceLocation startOfNextMember; bool previousMemberSemicolon = false; unsigned depth; diff --git a/src/plugins/qmldesigner/designercore/filemanager/astobjecttextextractor.cpp b/src/plugins/qmldesigner/designercore/filemanager/astobjecttextextractor.cpp index d29ac90cde..8633e270e4 100644 --- a/src/plugins/qmldesigner/designercore/filemanager/astobjecttextextractor.cpp +++ b/src/plugins/qmldesigner/designercore/filemanager/astobjecttextextractor.cpp @@ -27,6 +27,8 @@ #include <qmljs/parser/qmljsast_p.h> +#include <QDebug> + using namespace QmlDesigner; ASTObjectTextExtractor::ASTObjectTextExtractor(const QString &text): @@ -69,3 +71,8 @@ bool ASTObjectTextExtractor::visit(QmlJS::AST::UiObjectDefinition *ast) return m_text.isEmpty(); } + +void ASTObjectTextExtractor::throwRecursionDepthError() +{ + qWarning("Warning: Hit maximum recursion depth while visiting the AST in ASTObjectTextExtractor"); +} diff --git a/src/plugins/qmldesigner/designercore/filemanager/astobjecttextextractor.h b/src/plugins/qmldesigner/designercore/filemanager/astobjecttextextractor.h index 385d8c1c97..ecc00bde18 100644 --- a/src/plugins/qmldesigner/designercore/filemanager/astobjecttextextractor.h +++ b/src/plugins/qmldesigner/designercore/filemanager/astobjecttextextractor.h @@ -43,6 +43,8 @@ protected: bool visit(QmlJS::AST::UiObjectBinding *ast) override; bool visit(QmlJS::AST::UiObjectDefinition *ast) override; + void throwRecursionDepthError() override; + private: QmlJS::Document::MutablePtr m_document; quint32 m_location = 0; diff --git a/src/plugins/qmldesigner/designercore/filemanager/firstdefinitionfinder.cpp b/src/plugins/qmldesigner/designercore/filemanager/firstdefinitionfinder.cpp index 76ecb59f30..7fe59053da 100644 --- a/src/plugins/qmldesigner/designercore/filemanager/firstdefinitionfinder.cpp +++ b/src/plugins/qmldesigner/designercore/filemanager/firstdefinitionfinder.cpp @@ -98,3 +98,8 @@ bool FirstDefinitionFinder::visit(QmlJS::AST::UiObjectDefinition *ast) } return true; } + +void FirstDefinitionFinder::throwRecursionDepthError() +{ + qWarning("Warning: Hit maximum recursion depth while visiting the AST in FirstDefinitionFinder"); +} diff --git a/src/plugins/qmldesigner/designercore/filemanager/firstdefinitionfinder.h b/src/plugins/qmldesigner/designercore/filemanager/firstdefinitionfinder.h index b4e9826f52..2a963ae2fb 100644 --- a/src/plugins/qmldesigner/designercore/filemanager/firstdefinitionfinder.h +++ b/src/plugins/qmldesigner/designercore/filemanager/firstdefinitionfinder.h @@ -43,6 +43,8 @@ protected: bool visit(QmlJS::AST::UiObjectBinding *ast) override; bool visit(QmlJS::AST::UiObjectDefinition *ast) override; + void throwRecursionDepthError() override; + void extractFirstObjectDefinition(QmlJS::AST::UiObjectInitializer* ast); private: diff --git a/src/plugins/qmldesigner/designercore/filemanager/moveobjectbeforeobjectvisitor.cpp b/src/plugins/qmldesigner/designercore/filemanager/moveobjectbeforeobjectvisitor.cpp index 3be5de5bc9..a4931be538 100644 --- a/src/plugins/qmldesigner/designercore/filemanager/moveobjectbeforeobjectvisitor.cpp +++ b/src/plugins/qmldesigner/designercore/filemanager/moveobjectbeforeobjectvisitor.cpp @@ -147,7 +147,7 @@ void MoveObjectBeforeObjectVisitor::doMove() moveInfo.prefixToInsert = QString(moveInfo.leadingCharsToRemove, QLatin1Char(' ')); moveInfo.suffixToInsert = separator + QStringLiteral("\n\n"); } else { - const QmlJS::AST::SourceLocation insertionPoint = lastParentLocation(); + const QmlJS::SourceLocation insertionPoint = lastParentLocation(); Q_ASSERT(insertionPoint.isValid()); moveInfo.destination = insertionPoint.offset; int dummy = -1; @@ -169,7 +169,7 @@ QmlJS::AST::Node *MoveObjectBeforeObjectVisitor::movingObjectParent() const return nullptr; } -QmlJS::AST::SourceLocation MoveObjectBeforeObjectVisitor::lastParentLocation() const +QmlJS::SourceLocation MoveObjectBeforeObjectVisitor::lastParentLocation() const { dump(movingObjectParents); @@ -179,5 +179,5 @@ QmlJS::AST::SourceLocation MoveObjectBeforeObjectVisitor::lastParentLocation() c else if (auto initializer = QmlJS::AST::cast<QmlJS::AST::UiArrayBinding*>(parent)) return initializer->rbracketToken; else - return QmlJS::AST::SourceLocation(); + return QmlJS::SourceLocation(); } diff --git a/src/plugins/qmldesigner/designercore/filemanager/moveobjectbeforeobjectvisitor.h b/src/plugins/qmldesigner/designercore/filemanager/moveobjectbeforeobjectvisitor.h index 922d9fe40a..c47caf56e2 100644 --- a/src/plugins/qmldesigner/designercore/filemanager/moveobjectbeforeobjectvisitor.h +++ b/src/plugins/qmldesigner/designercore/filemanager/moveobjectbeforeobjectvisitor.h @@ -58,7 +58,7 @@ private: void doMove(); QmlJS::AST::Node *movingObjectParent() const; - QmlJS::AST::SourceLocation lastParentLocation() const; + QmlJS::SourceLocation lastParentLocation() const; private: QStack<QmlJS::AST::Node *> parents; diff --git a/src/plugins/qmldesigner/designercore/filemanager/objectlengthcalculator.cpp b/src/plugins/qmldesigner/designercore/filemanager/objectlengthcalculator.cpp index e0908f2f27..f54167c2d8 100644 --- a/src/plugins/qmldesigner/designercore/filemanager/objectlengthcalculator.cpp +++ b/src/plugins/qmldesigner/designercore/filemanager/objectlengthcalculator.cpp @@ -88,3 +88,8 @@ bool ObjectLengthCalculator::visit(QmlJS::AST::UiObjectDefinition *ast) return m_offset < end; } + +void ObjectLengthCalculator::throwRecursionDepthError() +{ + qWarning("Warning: Hit maximum recursion depth while visiting the AST in ObjectLengthCalculator"); +} diff --git a/src/plugins/qmldesigner/designercore/filemanager/objectlengthcalculator.h b/src/plugins/qmldesigner/designercore/filemanager/objectlengthcalculator.h index af745d2acd..f9bce822e3 100644 --- a/src/plugins/qmldesigner/designercore/filemanager/objectlengthcalculator.h +++ b/src/plugins/qmldesigner/designercore/filemanager/objectlengthcalculator.h @@ -43,6 +43,8 @@ protected: bool visit(QmlJS::AST::UiObjectBinding *ast) override; bool visit(QmlJS::AST::UiObjectDefinition *ast) override; + void throwRecursionDepthError() override; + private: QmlJS::Document::MutablePtr m_doc; quint32 m_offset = 0; diff --git a/src/plugins/qmldesigner/designercore/filemanager/qmlrewriter.cpp b/src/plugins/qmldesigner/designercore/filemanager/qmlrewriter.cpp index 94b89efcd9..25a72134b2 100644 --- a/src/plugins/qmldesigner/designercore/filemanager/qmlrewriter.cpp +++ b/src/plugins/qmldesigner/designercore/filemanager/qmlrewriter.cpp @@ -68,12 +68,12 @@ QString QMLRewriter::textBetween(int startPosition, int endPosition) const return m_textModifier->text().mid(startPosition, endPosition - startPosition); } -QString QMLRewriter::textAt(const QmlJS::AST::SourceLocation &location) const +QString QMLRewriter::textAt(const QmlJS::SourceLocation &location) const { return m_textModifier->text().mid(location.offset, location.length); } -unsigned QMLRewriter::calculateIndentDepth(const QmlJS::AST::SourceLocation &position) const +unsigned QMLRewriter::calculateIndentDepth(const QmlJS::SourceLocation &position) const { QTextDocument *doc = m_textModifier->textDocument(); QTextCursor tc(doc); @@ -151,20 +151,20 @@ QString QMLRewriter::removeIndentation(const QString &text, unsigned depth) return result; } -QmlJS::AST::SourceLocation QMLRewriter::calculateLocation(QmlJS::AST::UiQualifiedId *id) +QmlJS::SourceLocation QMLRewriter::calculateLocation(QmlJS::AST::UiQualifiedId *id) { Q_ASSERT(id != nullptr); - const QmlJS::AST::SourceLocation startLocation = id->identifierToken; + const QmlJS::SourceLocation startLocation = id->identifierToken; QmlJS::AST::UiQualifiedId *nextId = id; while (nextId->next) { nextId = nextId->next; } - const QmlJS::AST::SourceLocation endLocation = nextId->identifierToken; + const QmlJS::SourceLocation endLocation = nextId->identifierToken; - return QmlJS::AST::SourceLocation(startLocation.offset, endLocation.end() - startLocation.offset); + return QmlJS::SourceLocation(startLocation.offset, endLocation.end() - startLocation.offset); } bool QMLRewriter::isMissingSemicolon(QmlJS::AST::UiObjectMember *member) @@ -340,3 +340,8 @@ void QMLRewriter::dump(const ASTPath &path) qCDebug(qmlRewriter).noquote() << QString(i + 1, QLatin1Char('-')) << typeid(*node).name(); } } + +void QMLRewriter::throwRecursionDepthError() +{ + qCWarning(qmlRewriter) << "Warning: Hit maximum recursion level while visiting AST in QMLRewriter"; +} diff --git a/src/plugins/qmldesigner/designercore/filemanager/qmlrewriter.h b/src/plugins/qmldesigner/designercore/filemanager/qmlrewriter.h index 062710ef4c..c773de35be 100644 --- a/src/plugins/qmldesigner/designercore/filemanager/qmlrewriter.h +++ b/src/plugins/qmldesigner/designercore/filemanager/qmlrewriter.h @@ -51,20 +51,22 @@ public: protected: using QmlJS::AST::Visitor::visit; + void throwRecursionDepthError() override; + virtual void replace(int offset, int length, const QString &text); virtual void move(const QmlDesigner::TextModifier::MoveInfo &moveInfo); QString textBetween(int startPosition, int endPosition) const; - QString textAt(const QmlJS::AST::SourceLocation &location) const; + QString textAt(const QmlJS::SourceLocation &location) const; int indentDepth() const { return textModifier()->indentDepth(); } - unsigned calculateIndentDepth(const QmlJS::AST::SourceLocation &position) const; + unsigned calculateIndentDepth(const QmlJS::SourceLocation &position) const; static QString addIndentation(const QString &text, unsigned depth); static QString removeIndentation(const QString &text, unsigned depth); static QString removeIndentationFromLine(const QString &text, int depth); - static QmlJS::AST::SourceLocation calculateLocation(QmlJS::AST::UiQualifiedId *id); + static QmlJS::SourceLocation calculateLocation(QmlJS::AST::UiQualifiedId *id); static bool isMissingSemicolon(QmlJS::AST::UiObjectMember *member); static bool isMissingSemicolon(QmlJS::AST::Statement *stmt); diff --git a/src/plugins/qmldesigner/designercore/model/basetexteditmodifier.cpp b/src/plugins/qmldesigner/designercore/model/basetexteditmodifier.cpp index a5fddccba9..c1298aa92e 100644 --- a/src/plugins/qmldesigner/designercore/model/basetexteditmodifier.cpp +++ b/src/plugins/qmldesigner/designercore/model/basetexteditmodifier.cpp @@ -93,7 +93,7 @@ bool BaseTextEditModifier::renameId(const QString &oldId, const QString &newId) if (auto bte = qobject_cast<TextEditor::TextEditorWidget*>(plainTextEdit())) { if (auto document = qobject_cast<QmlJSEditor::QmlJSEditorDocument *>(bte->textDocument())) { Utils::ChangeSet changeSet; - foreach (const QmlJS::AST::SourceLocation &loc, + foreach (const QmlJS::SourceLocation &loc, document->semanticInfo().idLocations.value(oldId)) { changeSet.replace(loc.begin(), loc.end(), newId); } diff --git a/src/plugins/qmldesigner/designercore/model/documentmessage.cpp b/src/plugins/qmldesigner/designercore/model/documentmessage.cpp index cbf5843dac..1d0c124b52 100644 --- a/src/plugins/qmldesigner/designercore/model/documentmessage.cpp +++ b/src/plugins/qmldesigner/designercore/model/documentmessage.cpp @@ -26,6 +26,7 @@ #include <documentmessage.h> #include <qmljs/parser/qmljsengine_p.h> +#include <qmljs/parser/qmljsdiagnosticmessage_p.h> namespace QmlDesigner { diff --git a/src/plugins/qmldesigner/designercore/model/texttomodelmerger.cpp b/src/plugins/qmldesigner/designercore/model/texttomodelmerger.cpp index de07ef230f..a82792b1e8 100644 --- a/src/plugins/qmldesigner/designercore/model/texttomodelmerger.cpp +++ b/src/plugins/qmldesigner/designercore/model/texttomodelmerger.cpp @@ -772,8 +772,8 @@ void TextToModelMerger::setupImports(const Document::Ptr &doc, continue; QString version; - if (import->versionToken.isValid()) - version = textAt(doc, import->versionToken); + if (import->version != nullptr) + version = QLatin1String("%1.%2").arg(import->version->majorVersion).arg(import->version->minorVersion); const QString &as = import->importId.toString(); if (!import->fileName.isEmpty()) { @@ -2036,7 +2036,7 @@ void TextToModelMerger::collectLinkErrors(QList<DocumentMessage> *errors, const void TextToModelMerger::collectImportErrors(QList<DocumentMessage> *errors) { if (m_rewriterView->model()->imports().isEmpty()) { - const QmlJS::DiagnosticMessage diagnosticMessage(QmlJS::Severity::Error, AST::SourceLocation(0, 0, 0, 0), QCoreApplication::translate("QmlDesigner::TextToModelMerger", "No import statements found")); + const QmlJS::DiagnosticMessage diagnosticMessage(QmlJS::Severity::Error, SourceLocation(0, 0, 0, 0), QCoreApplication::translate("QmlDesigner::TextToModelMerger", "No import statements found")); errors->append(DocumentMessage(diagnosticMessage, QUrl::fromLocalFile(m_document->fileName()))); } @@ -2047,7 +2047,7 @@ void TextToModelMerger::collectImportErrors(QList<DocumentMessage> *errors) if (supportedQtQuickVersion(import.version())) { hasQtQuick = true; } else { - const QmlJS::DiagnosticMessage diagnosticMessage(QmlJS::Severity::Error, AST::SourceLocation(0, 0, 0, 0), + const QmlJS::DiagnosticMessage diagnosticMessage(QmlJS::Severity::Error, SourceLocation(0, 0, 0, 0), QCoreApplication::translate("QmlDesigner::TextToModelMerger", "Unsupported QtQuick version")); errors->append(DocumentMessage(diagnosticMessage, QUrl::fromLocalFile(m_document->fileName()))); } @@ -2172,14 +2172,14 @@ QSet<QPair<QString, QString> > TextToModelMerger::qrcMapping() const } QString TextToModelMerger::textAt(const Document::Ptr &doc, - const AST::SourceLocation &location) + const SourceLocation &location) { return doc->source().mid(location.offset, location.length); } QString TextToModelMerger::textAt(const Document::Ptr &doc, - const AST::SourceLocation &from, - const AST::SourceLocation &to) + const SourceLocation &from, + const SourceLocation &to) { return doc->source().mid(from.offset, to.end() - from.begin()); } diff --git a/src/plugins/qmldesigner/designercore/model/texttomodelmerger.h b/src/plugins/qmldesigner/designercore/model/texttomodelmerger.h index 82def3927f..2884453f8c 100644 --- a/src/plugins/qmldesigner/designercore/model/texttomodelmerger.h +++ b/src/plugins/qmldesigner/designercore/model/texttomodelmerger.h @@ -144,10 +144,10 @@ private: void addIsoIconQrcMapping(const QUrl &fileUrl); static QString textAt(const QmlJS::Document::Ptr &doc, - const QmlJS::AST::SourceLocation &location); + const QmlJS::SourceLocation &location); static QString textAt(const QmlJS::Document::Ptr &doc, - const QmlJS::AST::SourceLocation &from, - const QmlJS::AST::SourceLocation &to); + const QmlJS::SourceLocation &from, + const QmlJS::SourceLocation &to); private: RewriterView *m_rewriterView; |