forked from qt-creator/qt-creator
Update qmljs parser to Qt 5.15 parser
* parser side support for annotations, inline components, new UiVersion and all the things included in QT 5.15 parser * SourceLocation moved from QmlJS:AST to QmlJS * Visitors now need to handle throwRecursionDepthError * BaseVisitor for visitors that want to override all visit Task-number: QTCREATORBUG-23591 Change-Id: I682a30d0b08b6c929739fd0e339ef6fbde3eb630 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
This commit is contained in:
@@ -43,6 +43,8 @@
|
||||
#include <qmljstools/qmljsmodelmanager.h>
|
||||
#include <qmljstools/qmljsqtstylecodeformatter.h>
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
const char QML_UI_FILE_WARNING[] = "QmlJSEditor.QmlUiFileWarning";
|
||||
|
||||
using namespace QmlJSEditor;
|
||||
@@ -69,7 +71,7 @@ struct Declaration
|
||||
class FindIdDeclarations: protected Visitor
|
||||
{
|
||||
public:
|
||||
using Result = QHash<QString, QList<AST::SourceLocation> >;
|
||||
using Result = QHash<QString, QList<SourceLocation> >;
|
||||
|
||||
Result operator()(Document::Ptr doc)
|
||||
{
|
||||
@@ -110,7 +112,7 @@ protected:
|
||||
if (auto idExpr = AST::cast<const AST::IdentifierExpression *>(stmt->expression)) {
|
||||
if (!idExpr->name.isEmpty()) {
|
||||
const QString &id = idExpr->name.toString();
|
||||
QList<AST::SourceLocation> *locs = &_ids[id];
|
||||
QList<SourceLocation> *locs = &_ids[id];
|
||||
locs->append(idExpr->firstSourceLocation());
|
||||
locs->append(_maybeIds.value(id));
|
||||
_maybeIds.remove(id);
|
||||
@@ -138,6 +140,11 @@ protected:
|
||||
return false;
|
||||
}
|
||||
|
||||
void throwRecursionDepthError() override
|
||||
{
|
||||
qWarning("Warning: Hit maximum recursion depth while visiting AST in FindIdDeclarations");
|
||||
}
|
||||
|
||||
private:
|
||||
Result _ids;
|
||||
Result _maybeIds;
|
||||
@@ -414,6 +421,11 @@ protected:
|
||||
return true;
|
||||
}
|
||||
|
||||
void throwRecursionDepthError() override
|
||||
{
|
||||
qWarning("Warning: Hit maximum recursion depth while visiting AST in CreateRanges");
|
||||
}
|
||||
|
||||
Range createRange(AST::UiObjectMember *member, AST::UiObjectInitializer *ast)
|
||||
{
|
||||
return createRange(member, member->firstSourceLocation(), ast->rbraceToken);
|
||||
@@ -429,7 +441,7 @@ protected:
|
||||
return createRange(ast, block->lbraceToken, block->rbraceToken);
|
||||
}
|
||||
|
||||
Range createRange(AST::Node *ast, AST::SourceLocation start, AST::SourceLocation end)
|
||||
Range createRange(AST::Node *ast, SourceLocation start, SourceLocation end)
|
||||
{
|
||||
Range range;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user