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

@@ -51,6 +51,7 @@
#include <QTimer>
#include <QtConcurrentRun>
#include <QtConcurrentMap>
#include <QDebug>
#include <QDir>
#include <QApplication>
#include <QLabel>
@@ -70,7 +71,7 @@ namespace {
class FindUsages: protected Visitor
{
public:
using Result = QList<AST::SourceLocation>;
using Result = QList<SourceLocation>;
FindUsages(Document::Ptr doc, const ContextPtr &context)
: _doc(doc)
@@ -236,6 +237,11 @@ protected:
return true;
}
void throwRecursionDepthError() override
{
qWarning("Warning: Hit maximum recursion depth while visitin AST in FindUsages");
}
private:
bool contains(const QmlComponentChain *chain)
{
@@ -294,7 +300,7 @@ private:
class FindTypeUsages: protected Visitor
{
public:
using Result = QList<AST::SourceLocation>;
using Result = QList<SourceLocation>;
FindTypeUsages(Document::Ptr doc, const ContextPtr &context)
: _doc(doc)
@@ -427,6 +433,10 @@ protected:
return false;
}
void throwRecursionDepthError() override
{
qWarning("Warning: Hit maximum recursion depth while visitin AST in FindTypeUsages");
}
private:
bool checkTypeName(UiQualifiedId *id)
@@ -624,6 +634,11 @@ protected:
return true;
}
void throwRecursionDepthError() override
{
qWarning("Warning: Hit maximum recursion depth visiting AST in FindUsages");
}
private:
bool containsOffset(SourceLocation start, SourceLocation end)
{
@@ -720,7 +735,7 @@ public:
// find all idenfifier expressions, try to resolve them and check if the result is in scope
FindUsages findUsages(doc, context);
FindUsages::Result results = findUsages(name, scope);
foreach (const AST::SourceLocation &loc, results)
foreach (const SourceLocation &loc, results)
usages.append(Usage(fileName, matchingLine(loc.offset, doc->source()), loc.startLine, loc.startColumn - 1, loc.length));
if (future->isPaused())
future->waitForResume();
@@ -762,7 +777,7 @@ public:
// find all idenfifier expressions, try to resolve them and check if the result is in scope
FindTypeUsages findUsages(doc, context);
FindTypeUsages::Result results = findUsages(name, scope);
foreach (const AST::SourceLocation &loc, results)
foreach (const SourceLocation &loc, results)
usages.append(Usage(fileName, matchingLine(loc.offset, doc->source()), loc.startLine, loc.startColumn - 1, loc.length));
if (future->isPaused())
future->waitForResume();
@@ -944,7 +959,7 @@ QList<FindReferences::Usage> FindReferences::findUsageOfType(const QString &file
foreach (const QmlJS::Document::Ptr &doc, snapshot) {
FindTypeUsages findUsages(doc, context);
FindTypeUsages::Result results = findUsages(typeName, targetValue);
foreach (const AST::SourceLocation &loc, results) {
foreach (const SourceLocation &loc, results) {
usages.append(Usage(doc->fileName(), matchingLine(loc.offset, doc->source()), loc.startLine, loc.startColumn - 1, loc.length));
}
}