Utils: Replace QRegExp by QRegularExpression

..inside the template engine.

Task-number: QTCREATORBUG-24098
Change-Id: I9a1190eda4e57d36f8be750604796849ed672537
Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
Christian Stenger
2020-06-19 14:00:54 +02:00
parent f82b96107f
commit f9be969c10

View File

@@ -28,7 +28,7 @@
#include "qtcassert.h" #include "qtcassert.h"
#include <QJSEngine> #include <QJSEngine>
#include <QRegExp> #include <QRegularExpression>
#include <QStack> #include <QStack>
namespace Utils { namespace Utils {
@@ -73,10 +73,10 @@ private:
void reset(); void reset();
PreprocessorSection preprocessorLine(const QString & in, QString *ifExpression) const; PreprocessorSection preprocessorLine(const QString & in, QString *ifExpression) const;
mutable QRegExp m_ifPattern; mutable QRegularExpression m_ifPattern;
mutable QRegExp m_elsifPattern; mutable QRegularExpression m_elsifPattern;
mutable QRegExp m_elsePattern; mutable QRegularExpression m_elsePattern;
mutable QRegExp m_endifPattern; mutable QRegularExpression m_endifPattern;
QStack<PreprocessStackEntry> m_sectionStack; QStack<PreprocessStackEntry> m_sectionStack;
QJSEngine m_scriptEngine; QJSEngine m_scriptEngine;
@@ -105,20 +105,24 @@ void PreprocessContext::reset()
PreprocessorSection PreprocessContext::preprocessorLine(const QString &in, PreprocessorSection PreprocessContext::preprocessorLine(const QString &in,
QString *ifExpression) const QString *ifExpression) const
{ {
if (m_ifPattern.exactMatch(in)) { QRegularExpressionMatch match = m_ifPattern.match(in);
*ifExpression = m_ifPattern.cap(2).trimmed(); if (match.hasMatch()) {
*ifExpression = match.captured(2).trimmed();
return IfSection; return IfSection;
} }
if (m_elsifPattern.exactMatch(in)) { match = m_elsifPattern.match(in);
*ifExpression = m_elsifPattern.cap(2).trimmed(); if (match.hasMatch()) {
*ifExpression = match.captured(2).trimmed();
return ElsifSection; return ElsifSection;
} }
ifExpression->clear(); ifExpression->clear();
if (m_elsePattern.exactMatch(in)) match = m_elsePattern.match(in);
if (match.hasMatch())
return ElseSection; return ElseSection;
if (m_endifPattern.exactMatch(in)) match = m_endifPattern.match(in);
if (match.hasMatch())
return EndifSection; return EndifSection;
return OtherSection; return OtherSection;
} }