forked from qt-creator/qt-creator
QmlJS: More Qt6
Mostly QRegExp, one QHash::unite. Change-Id: Ia2816fee65b9459c0f89419161f44c38cd572c36 Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
@@ -34,7 +34,7 @@
|
||||
|
||||
#include <QColor>
|
||||
#include <QDir>
|
||||
#include <QRegExp>
|
||||
#include <QRegularExpression>
|
||||
|
||||
using namespace QmlJS;
|
||||
using namespace QmlJS::AST;
|
||||
@@ -907,7 +907,7 @@ static bool checkTopLevelBindingForParentReference(ExpressionStatement *expStmt,
|
||||
SourceLocation location = locationFromRange(expStmt->firstSourceLocation(), expStmt->lastSourceLocation());
|
||||
QString stmtSource = source.mid(int(location.begin()), int(location.length));
|
||||
|
||||
if (stmtSource.contains(QRegExp("(^|\\W)parent\\.")))
|
||||
if (stmtSource.contains(QRegularExpression("(^|\\W)parent\\.")))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
@@ -1562,7 +1562,7 @@ void Check::addMessage(StaticAnalysis::Type type, const SourceLocation &location
|
||||
void Check::scanCommentsForAnnotations()
|
||||
{
|
||||
m_disabledMessageTypesByLine.clear();
|
||||
QRegExp disableCommentPattern(Message::suppressionPattern());
|
||||
const QRegularExpression disableCommentPattern = Message::suppressionPattern();
|
||||
|
||||
foreach (const SourceLocation &commentLoc, _doc->engine()->comments()) {
|
||||
const QString &comment = _doc->source().mid(int(commentLoc.begin()), int(commentLoc.length));
|
||||
@@ -1575,14 +1575,15 @@ void Check::scanCommentsForAnnotations()
|
||||
int lastOffset = -1;
|
||||
QList<MessageTypeAndSuppression> disabledMessageTypes;
|
||||
forever {
|
||||
lastOffset = disableCommentPattern.indexIn(comment, lastOffset + 1);
|
||||
if (lastOffset == -1)
|
||||
const QRegularExpressionMatch match = disableCommentPattern.match(comment, lastOffset + 1);
|
||||
if (!match.hasMatch())
|
||||
break;
|
||||
lastOffset = match.capturedStart();
|
||||
MessageTypeAndSuppression entry;
|
||||
entry.type = static_cast<StaticAnalysis::Type>(disableCommentPattern.cap(1).toInt());
|
||||
entry.type = static_cast<StaticAnalysis::Type>(match.captured(1).toInt());
|
||||
entry.wasSuppressed = false;
|
||||
entry.suppressionSource = SourceLocation(commentLoc.offset + quint32(lastOffset),
|
||||
quint32(disableCommentPattern.matchedLength()),
|
||||
quint32(match.capturedLength()),
|
||||
commentLoc.startLine,
|
||||
commentLoc.startColumn + quint32(lastOffset));
|
||||
disabledMessageTypes += entry;
|
||||
|
||||
@@ -147,8 +147,7 @@ ImportKey::ImportKey(const ImportInfo &info)
|
||||
, majorVersion(info.version().majorVersion())
|
||||
, minorVersion(info.version().minorVersion())
|
||||
{
|
||||
splitPath = QFileInfo(info.path()).canonicalFilePath().split(QLatin1Char('/'),
|
||||
QString::KeepEmptyParts);
|
||||
splitPath = QFileInfo(info.path()).canonicalFilePath().split('/');
|
||||
}
|
||||
|
||||
ImportKey::ImportKey(ImportType::Enum type, const QString &path, int majorVersion, int minorVersion)
|
||||
|
||||
@@ -78,7 +78,7 @@ const int LineInfo::SmallRoof = 40;
|
||||
const int LineInfo::BigRoof = 400;
|
||||
|
||||
LineInfo::LineInfo()
|
||||
: braceX(QRegExp(QLatin1String("^\\s*\\}\\s*(?:else|catch)\\b")))
|
||||
: braceX(QRegularExpression("^\\s*\\}\\s*(?:else|catch)\\b"))
|
||||
{
|
||||
/*
|
||||
The "linizer" is a group of functions and variables to iterate
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
|
||||
#include <qmljs/qmljs_global.h>
|
||||
|
||||
#include <QRegExp>
|
||||
#include <QRegularExpression>
|
||||
#include <QTextBlock>
|
||||
|
||||
namespace QmlJS {
|
||||
@@ -112,7 +112,7 @@ protected:
|
||||
const int *yyBraceDepth;
|
||||
const bool *yyLeftBraceFollows;
|
||||
|
||||
QRegExp braceX;
|
||||
QRegularExpression braceX;
|
||||
};
|
||||
|
||||
} // namespace QmlJS
|
||||
|
||||
@@ -38,6 +38,7 @@
|
||||
#include <utils/algorithm.h>
|
||||
#include <utils/hostosinfo.h>
|
||||
#include <utils/runextensions.h>
|
||||
#include <utils/stringutils.h>
|
||||
|
||||
#include <QDir>
|
||||
#include <QDirIterator>
|
||||
@@ -90,7 +91,7 @@ static QStringList environmentImportPaths()
|
||||
QStringList paths;
|
||||
|
||||
const QStringList importPaths = QString::fromLocal8Bit(qgetenv("QML_IMPORT_PATH")).split(
|
||||
Utils::HostOsInfo::pathListSeparator(), QString::SkipEmptyParts);
|
||||
Utils::HostOsInfo::pathListSeparator(), Utils::SkipEmptyParts);
|
||||
|
||||
for (const QString &path : importPaths) {
|
||||
const QString canonicalPath = QDir(path).canonicalPath();
|
||||
@@ -267,8 +268,10 @@ void ModelManagerInterface::loadQmlTypeDescriptionsInternal(const QString &resou
|
||||
}
|
||||
|
||||
// load the fallbacks for libraries
|
||||
CppQmlTypesLoader::defaultLibraryObjects.unite(
|
||||
CppQmlTypesLoader::loadQmlTypes(qmlTypesFiles, &errors, &warnings));
|
||||
const CppQmlTypesLoader::BuiltinObjects objs =
|
||||
CppQmlTypesLoader::loadQmlTypes(qmlTypesFiles, &errors, &warnings);
|
||||
for (auto it = objs.cbegin(); it != objs.cend(); ++it)
|
||||
CppQmlTypesLoader::defaultLibraryObjects.insert(it.key(), it.value());
|
||||
|
||||
for (const QString &error : qAsConst(errors))
|
||||
writeMessageInternal(error);
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
#include <utils/qtcassert.h>
|
||||
|
||||
#include <QCoreApplication>
|
||||
#include <QRegExp>
|
||||
#include <QRegularExpression>
|
||||
|
||||
using namespace QmlJS;
|
||||
using namespace QmlJS::StaticAnalysis;
|
||||
@@ -317,9 +317,9 @@ QString Message::suppressionString() const
|
||||
return QString::fromLatin1("@disable-check M%1").arg(QString::number(type));
|
||||
}
|
||||
|
||||
QRegExp Message::suppressionPattern()
|
||||
QRegularExpression Message::suppressionPattern()
|
||||
{
|
||||
return QRegExp(QLatin1String("@disable-check M(\\d+)"));
|
||||
return QRegularExpression("@disable-check M(\\d+)");
|
||||
}
|
||||
|
||||
const PrototypeMessageData Message::prototypeForMessageType(Type type)
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
#include <QString>
|
||||
#include <QList>
|
||||
|
||||
QT_FORWARD_DECLARE_CLASS(QRegExp)
|
||||
QT_FORWARD_DECLARE_CLASS(QRegularExpression)
|
||||
|
||||
namespace QmlJS {
|
||||
class DiagnosticMessage;
|
||||
@@ -157,7 +157,7 @@ public:
|
||||
DiagnosticMessage toDiagnosticMessage() const;
|
||||
|
||||
QString suppressionString() const;
|
||||
static QRegExp suppressionPattern();
|
||||
static QRegularExpression suppressionPattern();
|
||||
|
||||
SourceLocation location;
|
||||
QString message;
|
||||
|
||||
@@ -27,6 +27,8 @@
|
||||
|
||||
#include "parser/qmljsast_p.h"
|
||||
|
||||
#include <utils/stringutils.h>
|
||||
|
||||
#include <QColor>
|
||||
#include <QDir>
|
||||
#include <QRegularExpression>
|
||||
@@ -239,7 +241,7 @@ QString QmlJS::modulePath(const QString &name, const QString &version,
|
||||
return QString();
|
||||
|
||||
const QString sanitizedVersion = version == undefinedVersion ? QString() : version;
|
||||
const QStringList parts = name.split(QLatin1Char('.'), QString::SkipEmptyParts);
|
||||
const QStringList parts = name.split('.', Utils::SkipEmptyParts);
|
||||
auto mkpath = [] (const QStringList &xs) -> QString { return xs.join(QLatin1Char('/')); };
|
||||
|
||||
// Regular expression for building candidates by successively removing minor and major
|
||||
|
||||
Reference in New Issue
Block a user