diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/libs/qmljs/jsoncheck.cpp | 6 | ||||
-rw-r--r-- | src/libs/qmljs/qmljsdocument.cpp | 32 | ||||
-rw-r--r-- | src/libs/qmljs/qmljsfindexportedcpptypes.cpp | 9 | ||||
-rw-r--r-- | src/libs/qmljs/qmljsindenter.cpp | 10 | ||||
-rw-r--r-- | src/libs/qmljs/qmljsindenter.h | 4 | ||||
-rw-r--r-- | src/libs/qmljs/qmljsmodelmanagerinterface.cpp | 1 | ||||
-rw-r--r-- | src/libs/qmljs/qmljsscopechain.cpp | 10 |
7 files changed, 39 insertions, 33 deletions
diff --git a/src/libs/qmljs/jsoncheck.cpp b/src/libs/qmljs/jsoncheck.cpp index d2beb507cc..20370d0d58 100644 --- a/src/libs/qmljs/jsoncheck.cpp +++ b/src/libs/qmljs/jsoncheck.cpp @@ -30,7 +30,7 @@ #include <QDebug> #include <QLatin1String> -#include <QRegExp> +#include <QRegularExpression> #include <cmath> @@ -273,8 +273,8 @@ bool JsonCheck::visit(StringLiteral *ast) const QString &pattern = m_schema->pattern(); if (!pattern.isEmpty()) { - QRegExp regExp(pattern); - if (regExp.indexIn(literal.toString()) == -1) { + const QRegularExpression regExp(pattern); + if (regExp.match(literal.toString()).hasMatch()) { analysis()->m_messages.append(Message(ErrInvalidStringValuePattern, ast->firstSourceLocation(), QString(), QString(), false)); diff --git a/src/libs/qmljs/qmljsdocument.cpp b/src/libs/qmljs/qmljsdocument.cpp index 25e505e584..79840e7bb6 100644 --- a/src/libs/qmljs/qmljsdocument.cpp +++ b/src/libs/qmljs/qmljsdocument.cpp @@ -35,7 +35,7 @@ #include <QCryptographicHash> #include <QDir> #include <QFileInfo> -#include <QRegExp> +#include <QRegularExpression> #include <algorithm> @@ -510,17 +510,19 @@ void Snapshot::insertLibraryInfo(const QString &path, const LibraryInfo &info) } QStringList splitPath = path.split(QLatin1Char('/')); - QRegExp vNr(QLatin1String("^(.+)\\.([0-9]+)(?:\\.([0-9]+))?$")); - QRegExp safeName(QLatin1String("^[a-zA-Z_][[a-zA-Z0-9_]*$")); + const QRegularExpression vNr(QLatin1String("^(.+)\\.([0-9]+)(?:\\.([0-9]+))?$")); + const QRegularExpression safeName(QLatin1String("^[a-zA-Z_][[a-zA-Z0-9_]*$")); foreach (const ImportKey &importKey, packages) { if (importKey.splitPath.size() == 1 && importKey.splitPath.at(0).isEmpty() && splitPath.length() > 0) { // relocatable QStringList myPath = splitPath; - if (vNr.indexIn(myPath.last()) == 0) - myPath.last() = vNr.cap(1); + QRegularExpressionMatch match = vNr.match(myPath.last()); + if (match.hasMatch()) + myPath.last() = match.captured(1); for (int iPath = myPath.size(); iPath != 1; ) { --iPath; - if (safeName.indexIn(myPath.at(iPath)) != 0) + match = safeName.match(myPath.at(iPath)); + if (!match.hasMatch()) break; ImportKey iKey(ImportType::Library, QStringList(myPath.mid(iPath)).join(QLatin1Char('.')), importKey.majorVersion, importKey.minorVersion); @@ -534,8 +536,8 @@ void Snapshot::insertLibraryInfo(const QString &path, const LibraryInfo &info) } } if (cImport.possibleExports.isEmpty() && splitPath.size() > 0) { - QRegExp vNr(QLatin1String("^(.+)\\.([0-9]+)(?:\\.([0-9]+))?$")); - QRegExp safeName(QLatin1String("^[a-zA-Z_][[a-zA-Z0-9_]*$")); + const QRegularExpression vNr(QLatin1String("^(.+)\\.([0-9]+)(?:\\.([0-9]+))?$")); + const QRegularExpression safeName(QLatin1String("^[a-zA-Z_][[a-zA-Z0-9_]*$")); int majorVersion = LanguageUtils::ComponentVersion::NoVersion; int minorVersion = LanguageUtils::ComponentVersion::NoVersion; @@ -546,20 +548,22 @@ void Snapshot::insertLibraryInfo(const QString &path, const LibraryInfo &info) minorVersion = component.minorVersion; } - if (vNr.indexIn(splitPath.last()) == 0) { - splitPath.last() = vNr.cap(1); + QRegularExpressionMatch match = vNr.match(splitPath.last()); + if (match.hasMatch()) { + splitPath.last() = match.captured(1); bool ok; - majorVersion = vNr.cap(2).toInt(&ok); + majorVersion = match.captured(2).toInt(&ok); if (!ok) majorVersion = LanguageUtils::ComponentVersion::NoVersion; - minorVersion = vNr.cap(3).toInt(&ok); - if (vNr.cap(3).isEmpty() || !ok) + minorVersion = match.captured(3).toInt(&ok); + if (match.captured(3).isEmpty() || !ok) minorVersion = LanguageUtils::ComponentVersion::NoVersion; } for (int iPath = splitPath.size(); iPath != 1; ) { --iPath; - if (safeName.indexIn(splitPath.at(iPath)) != 0) + match = safeName.match(splitPath.at(iPath)); + if (!match.hasMatch()) break; ImportKey iKey(ImportType::Library, QStringList(splitPath.mid(iPath)).join(QLatin1Char('.')), majorVersion, minorVersion); diff --git a/src/libs/qmljs/qmljsfindexportedcpptypes.cpp b/src/libs/qmljs/qmljsfindexportedcpptypes.cpp index 7b3749ab51..a677e7fbd8 100644 --- a/src/libs/qmljs/qmljsfindexportedcpptypes.cpp +++ b/src/libs/qmljs/qmljsfindexportedcpptypes.cpp @@ -34,7 +34,7 @@ #include <utils/qtcassert.h> #include <QList> -#include <QRegExp> +#include <QRegularExpression> //using namespace QmlJS; @@ -294,7 +294,7 @@ protected: } if (packageName.isEmpty() && _compound) { // check the comments in _compound for annotations - QRegExp uriAnnotation(QLatin1String("@uri\\s*([\\w\\.]*)")); + const QRegularExpression uriAnnotation(QLatin1String("@uri\\s*([\\w\\.]*)")); // scan every comment between the pipes in // {| @@ -312,8 +312,9 @@ protected: continue; } const QString comment = stringOf(commentToken); - if (uriAnnotation.indexIn(comment) != -1) { - packageName = uriAnnotation.cap(1); + const QRegularExpressionMatch match = uriAnnotation.match(comment); + if (match.hasMatch()) { + packageName = match.captured(1); break; } } diff --git a/src/libs/qmljs/qmljsindenter.cpp b/src/libs/qmljs/qmljsindenter.cpp index 3852d65c2a..bb3f3736cf 100644 --- a/src/libs/qmljs/qmljsindenter.cpp +++ b/src/libs/qmljs/qmljsindenter.cpp @@ -79,11 +79,11 @@ using namespace QmlJS; QmlJSIndenter::QmlJSIndenter() - : caseOrDefault(QRegExp(QLatin1String( - "\\s*(?:" + : caseOrDefault(QRegularExpression(QLatin1String( + "^\\s*(?:" "case\\b[^:]+|" "default)" - "\\s*:.*"))) + "\\s*:.*$"))) { @@ -534,7 +534,7 @@ int QmlJSIndenter::indentForStandaloneLine() readLine(); int indentChange = - *yyBraceDepth; - if (caseOrDefault.exactMatch(*yyLine)) + if (caseOrDefault.match(*yyLine).hasMatch()) ++indentChange; /* @@ -598,7 +598,7 @@ int QmlJSIndenter::indentForBottomLine(QTextBlock begin, QTextBlock end, QChar t */ indent -= ppIndentSize; } else if (okay(typedIn, QLatin1Char(':'))) { - if (caseOrDefault.exactMatch(bottomLine)) { + if (caseOrDefault.match(bottomLine).hasMatch()) { /* Move a case label (or the ':' in front of a constructor initialization list) one level to the diff --git a/src/libs/qmljs/qmljsindenter.h b/src/libs/qmljs/qmljsindenter.h index 97cf1eb6ab..6e9d018f21 100644 --- a/src/libs/qmljs/qmljsindenter.h +++ b/src/libs/qmljs/qmljsindenter.h @@ -28,7 +28,7 @@ #include <qmljs/qmljs_global.h> #include <qmljs/qmljslineinfo.h> -#include <QRegExp> +#include <QRegularExpression> QT_FORWARD_DECLARE_CLASS(QTextBlock) @@ -67,7 +67,7 @@ private: int ppCommentOffset; private: - QRegExp caseOrDefault; + QRegularExpression caseOrDefault; }; } // namespace QmlJS diff --git a/src/libs/qmljs/qmljsmodelmanagerinterface.cpp b/src/libs/qmljs/qmljsmodelmanagerinterface.cpp index dc4c855c26..20635ee586 100644 --- a/src/libs/qmljs/qmljsmodelmanagerinterface.cpp +++ b/src/libs/qmljs/qmljsmodelmanagerinterface.cpp @@ -45,7 +45,6 @@ #include <QFile> #include <QFileInfo> #include <QMetaObject> -#include <QRegExp> #include <QTextDocument> #include <QTextStream> #include <QTimer> diff --git a/src/libs/qmljs/qmljsscopechain.cpp b/src/libs/qmljs/qmljsscopechain.cpp index bbddcbfd04..305919d643 100644 --- a/src/libs/qmljs/qmljsscopechain.cpp +++ b/src/libs/qmljs/qmljsscopechain.cpp @@ -29,7 +29,7 @@ #include "qmljsmodelmanagerinterface.h" #include "parser/qmljsengine_p.h" -#include <QRegExp> +#include <QRegularExpression> using namespace QmlJS; @@ -286,18 +286,20 @@ void ScopeChain::update() const static void addInstantiatingComponents(ContextPtr context, QmlComponentChain *chain) { - const QRegExp importCommentPattern(QLatin1String("@scope\\s+(.*)")); + const QRegularExpression importCommentPattern(QLatin1String("@scope\\s+(.*)")); foreach (const SourceLocation &commentLoc, chain->document()->engine()->comments()) { const QString &comment = chain->document()->source().mid(commentLoc.begin(), commentLoc.length); // find all @scope annotations QStringList additionalScopes; int lastOffset = -1; + QRegularExpressionMatch match; forever { - lastOffset = importCommentPattern.indexIn(comment, lastOffset + 1); + match = importCommentPattern.match(comment, lastOffset + 1); + lastOffset = match.capturedStart(); if (lastOffset == -1) break; - additionalScopes << QFileInfo(chain->document()->path() + QLatin1Char('/') + importCommentPattern.cap(1).trimmed()).absoluteFilePath(); + additionalScopes << QFileInfo(chain->document()->path() + QLatin1Char('/') + match.captured(1).trimmed()).absoluteFilePath(); } foreach (const QmlComponentChain *c, chain->instantiatingComponents()) |