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

@@ -10,11 +10,12 @@
# cd src/libs/qmljs/parser
# QTDIR=~/path/to/qtdeclarative-checkout ./gen-parser.sh
if [ -z "$QTDIR" ]; then
echo "Usage: QTDIR=~/path/to/qtdeclarative-checkout $0" 1>&2
if [ -z "$QTDIR" -o -z "$QLALR" ]; then
echo "Usage: QTDIR=~/path/to/qtdeclarative-checkout QLALR=~/path/to/qlalr $0" 1>&2
exit 1
fi
me=$(dirname $0)
for i in $QTDIR/src/qml/parser/*.{g,h,cpp,pri}; do
@@ -23,22 +24,23 @@ for i in $QTDIR/src/qml/parser/*.{g,h,cpp,pri}; do
fi
done
for i in $QTDIR/src/qml/qml/qqml{error.{h,cpp},dirparser{_p.h,.cpp}}; do
sed -f $me/cmd.sed $i > $me/$(echo $(basename $i) | sed s/qqml/qml/)
for i in $QTDIR/src/qml/qmldirparser/*.{h,cpp}; do
if ! echo $i | grep -q qmljsglobal; then
sed -f $me/cmd.sed $i > $me/$(echo $(basename $i) | sed s/qqml/qml/)
fi
done
# export QmlDirParser
perl -p -0777 -i -e 's/QT_BEGIN_NAMESPACE\n\nclass QmlError;\nclass QmlEngine;\nclass Q_AUTOTEST_EXPORT QmlDirParser/#include "qmljsglobal_p.h"\n\nQT_BEGIN_NAMESPACE\n\nclass QmlError;\nclass QmlEngine;\nclass QML_PARSER_EXPORT QmlDirParser/' qmldirparser_p.h
# export QmlJSGrammar
perl -p -0777 -i -e 's/#include <QtCore\/qglobal.h>\n\nQT_BEGIN_NAMESPACE\n\nclass QmlJSGrammar\n/#include "qmljsglobal_p.h"\n#include <QtCore\/qglobal.h>\n\nQT_BEGIN_NAMESPACE\n\nclass QML_PARSER_EXPORT QmlJSGrammar\n/' qmljsgrammar_p.h
for i in $QTDIR/src/qml/common/qqmljs{sourcelocation,memorypool}_p.h; do
sed -f $me/cmd.sed $i > $me/$(echo $(basename $i) | sed s/qqmljs/qmljs/)
done
# remove qmlapiversion_p.h include
#include "qmlapiversion_p.h"
perl -p -0777 -i -e 's/#include \"qmlapiversion_p.h\"//' qmljsdiagnosticmessage_p.h
# remove qmlglobal_p.h include
perl -p -0777 -i -e 's/#include \"qmlglobal_p.h\"//' qmldirparser.cpp
# remove qmlglobal_p.h include
perl -p -0777 -i -e 's/#include \"qmlglobal_p.h\"//' qmlerror.cpp
# remove qmlglobal_p.h include
perl -p -0777 -i -e 's/#include \<QtQml\/qmlfile.h\>//' qmldirparser.cpp
# remove QtQml/qtqmlglobal.h include
perl -p -0777 -i -e 's/#include \<QtQml\/qtqmlglobal.h\>//' qmlerror.h
# replace private/qhashedstring_p.h include and QHashedStringRef
perl -p -0777 -i -e 's/#include \<private\/qhashedstring_p.h\>//' qmldirparser_p.h
perl -p -0777 -i -e 's/QHashedStringRef/QString/g' qmldirparser_p.h qmldirparser.cpp
@@ -51,11 +53,15 @@ sed -i -e 's/chars.length()/chars.size()/' $me/qmljslexer.cpp
sed -i -e 's/DiagnosticMessage::Error/Severity::Error/g' $me/qmljsparser.cpp
sed -i -e 's/DiagnosticMessage::Warning/Severity::Warning/g' $me/qmljsparser.cpp
sed -i -e 's/DiagnosticMessage::Warning/Severity::Warning/g' $me/qmljsparser_p.h
sed -i -e 's|#include <private/qv4errorobject_p.h>||g' $me/qmlerror.cpp
sed -i -e 's|#include <QtCore/qstring.h>|#include <QString>|g' $me/qmljsengine_p.h
sed -i -e 's|#include <QtCore/qset.h>|#include <QSet>|g' $me/qmljsengine_p.h
sed -i -e 's/qt_qnan/qQNaN/' $me/qmljsengine_p.cpp
sed -i -e 's|#include <QtCore/private/qnumeric_p.h>|#include <QtCore/qnumeric.h>|' $me/qmljsengine_p.cpp
perl -p -0777 -i -e 's/QT_QML_BEGIN_NAMESPACE/#include <qmljs\/qmljsconstants.h>\nQT_QML_BEGIN_NAMESPACE/' qmljsengine_p.h
patch -p1 < grammar.patch
$QLALR qmljs.g
./changeLicense.py $me/../qmljs_global.h qml*.{cpp,h}
patch -p1 < parser.patch