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:
Fawzi Mohamed
2020-02-28 17:51:32 +01:00
parent a24dead5f6
commit b09a48599e
88 changed files with 5290 additions and 4350 deletions

View File

@@ -33,6 +33,7 @@
//#include <qmljs/qmljsinterpreter.h>
#include <qmljs/parser/qmljsast_p.h>
#include <QDebug>
#include <QMutexLocker>
using namespace QmlJSTools::Internal;
@@ -224,6 +225,11 @@ protected:
return true;
}
void throwRecursionDepthError() override
{
qWarning("Warning: Hit maximum recursion limit visiting AST in FunctionFinder.");
}
};
} // anonymous namespace

View File

@@ -149,7 +149,7 @@ Document::Ptr QmlJSRefactoringFile::qmljsDocument() const
return m_qmljsDocument;
}
unsigned QmlJSRefactoringFile::startOf(const AST::SourceLocation &loc) const
unsigned QmlJSRefactoringFile::startOf(const SourceLocation &loc) const
{
return position(loc.startLine, loc.startColumn);
}
@@ -176,7 +176,7 @@ bool QmlJSRefactoringFile::isCursorOn(AST::UiQualifiedId *ast) const
return pos <= ast->identifierToken.end();
}
bool QmlJSRefactoringFile::isCursorOn(AST::SourceLocation loc) const
bool QmlJSRefactoringFile::isCursorOn(SourceLocation loc) const
{
const unsigned pos = cursor().position();
return pos >= loc.begin() && pos <= loc.end();

View File

@@ -49,11 +49,11 @@ public:
\returns the offset in the document for the start position of the given
source location.
*/
unsigned startOf(const QmlJS::AST::SourceLocation &loc) const;
unsigned startOf(const QmlJS::SourceLocation &loc) const;
bool isCursorOn(QmlJS::AST::UiObjectMember *ast) const;
bool isCursorOn(QmlJS::AST::UiQualifiedId *ast) const;
bool isCursorOn(QmlJS::AST::SourceLocation loc) const;
bool isCursorOn(QmlJS::SourceLocation loc) const;
protected:
QmlJSRefactoringFile(const QString &fileName, const QSharedPointer<TextEditor::RefactoringChangesData> &data);

View File

@@ -30,6 +30,8 @@
#include <qmljs/qmljsscopechain.h>
#include <qmljs/parser/qmljsengine_p.h>
#include <QDebug>
using namespace QmlJS;
using namespace QmlJS::AST;
@@ -63,13 +65,13 @@ protected:
node->accept(this);
}
bool containsOffset(AST::SourceLocation start, AST::SourceLocation end)
bool containsOffset(SourceLocation start, SourceLocation end)
{
return _offset >= start.begin() && _offset <= end.end();
}
bool handle(AST::Node *ast,
AST::SourceLocation start, AST::SourceLocation end,
SourceLocation start, SourceLocation end,
bool addToPath = true)
{
if (containsOffset(start, end)) {
@@ -99,8 +101,8 @@ protected:
bool visit(AST::UiQualifiedId *ast) override
{
AST::SourceLocation first = ast->identifierToken;
AST::SourceLocation last;
SourceLocation first = ast->identifierToken;
SourceLocation last;
for (AST::UiQualifiedId *it = ast; it; it = it->next)
last = it->identifierToken;
if (containsOffset(first, last))
@@ -125,6 +127,10 @@ protected:
return handleLocationAst(ast);
}
void throwRecursionDepthError() override
{
qWarning("Warning: Hit maximum recursion depth when visiting the AST in AstPath");
}
};
} // anonmymous

View File

@@ -85,7 +85,7 @@ public: // attributes
QmlJS::Snapshot snapshot;
QmlJS::ContextPtr context;
QList<Range> ranges;
QHash<QString, QList<QmlJS::AST::SourceLocation> > idLocations;
QHash<QString, QList<QmlJS::SourceLocation> > idLocations;
// these are in addition to the parser messages in the document
QList<QmlJS::DiagnosticMessage> semanticMessages;