forked from qt-creator/qt-creator
More QRegularExpression and include for Qt 6
Task-number: QTCREATORBUG-24098 Change-Id: Ia537e26efd3f37319c38d906e569b255768371f9 Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
@@ -74,8 +74,8 @@ static int parseVersion(const QString &text)
|
|||||||
const QRegularExpression rx("([2-9]{1})\\.([0-9]{2})(\\.[1-9]{1})?$");
|
const QRegularExpression rx("([2-9]{1})\\.([0-9]{2})(\\.[1-9]{1})?$");
|
||||||
const QRegularExpressionMatch match = rx.match(text);
|
const QRegularExpressionMatch match = rx.match(text);
|
||||||
if (match.hasMatch()) {
|
if (match.hasMatch()) {
|
||||||
const int major = match.capturedRef(1).toInt() * 100;
|
const int major = match.captured(1).toInt() * 100;
|
||||||
const int minor = match.capturedRef(2).toInt();
|
const int minor = match.captured(2).toInt();
|
||||||
return major + minor;
|
return major + minor;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
@@ -31,6 +31,10 @@
|
|||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
#include <QPair>
|
#include <QPair>
|
||||||
|
|
||||||
|
QT_BEGIN_NAMESPACE
|
||||||
|
class QTextCodec;
|
||||||
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
namespace Git {
|
namespace Git {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
|
@@ -49,7 +49,7 @@
|
|||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
#include <QMap>
|
#include <QMap>
|
||||||
#include <QMenu>
|
#include <QMenu>
|
||||||
#include <QRegExp>
|
#include <QRegularExpression>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
#include <QTextBrowser>
|
#include <QTextBrowser>
|
||||||
@@ -263,7 +263,7 @@ void SearchWidget::contextMenuEvent(QContextMenuEvent *contextMenuEvent)
|
|||||||
|
|
||||||
QStringList SearchWidget::currentSearchTerms() const
|
QStringList SearchWidget::currentSearchTerms() const
|
||||||
{
|
{
|
||||||
return searchEngine->searchInput().split(QRegExp("\\W+"), Utils::SkipEmptyParts);
|
return searchEngine->searchInput().split(QRegularExpression("\\W+"), Utils::SkipEmptyParts);
|
||||||
}
|
}
|
||||||
|
|
||||||
// #pragma mark -- SearchSideBarItem
|
// #pragma mark -- SearchSideBarItem
|
||||||
|
@@ -36,7 +36,7 @@
|
|||||||
|
|
||||||
#include <QFileInfo>
|
#include <QFileInfo>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#include <QRegExp>
|
#include <QRegularExpression>
|
||||||
#include <QStandardPaths>
|
#include <QStandardPaths>
|
||||||
|
|
||||||
using namespace ProjectExplorer;
|
using namespace ProjectExplorer;
|
||||||
@@ -96,7 +96,7 @@ QStringList CMakeCommandBuilder::defaultArguments()
|
|||||||
|
|
||||||
QString CMakeCommandBuilder::setMultiProcessArg(QString args)
|
QString CMakeCommandBuilder::setMultiProcessArg(QString args)
|
||||||
{
|
{
|
||||||
QRegExp regExp("\\s*\\-j\\s+\\d+");
|
QRegularExpression regExp("\\s*\\-j\\s+\\d+");
|
||||||
args.remove(regExp);
|
args.remove(regExp);
|
||||||
args.append(" -- -j 200");
|
args.append(" -- -j 200");
|
||||||
|
|
||||||
|
@@ -36,7 +36,7 @@
|
|||||||
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QFileInfo>
|
#include <QFileInfo>
|
||||||
#include <QRegExp>
|
#include <QRegularExpression>
|
||||||
|
|
||||||
using namespace ProjectExplorer;
|
using namespace ProjectExplorer;
|
||||||
|
|
||||||
@@ -84,13 +84,14 @@ QString MakeCommandBuilder::setMultiProcessArg(QString args)
|
|||||||
|
|
||||||
// jom -j 200
|
// jom -j 200
|
||||||
if (fileInfo.baseName().compare("jom", Qt::CaseSensitivity::CaseInsensitive) == 0) {
|
if (fileInfo.baseName().compare("jom", Qt::CaseSensitivity::CaseInsensitive) == 0) {
|
||||||
QRegExp regExp("\\s*\\-j\\s+\\d+");
|
QRegularExpression regExp("\\s*\\-j\\s+\\d+");
|
||||||
args.remove(regExp);
|
args.remove(regExp);
|
||||||
args.append(" -j 200");
|
args.append(" -j 200");
|
||||||
}
|
}
|
||||||
// make -j200
|
// make -j200
|
||||||
else if ((fileInfo.baseName().compare("make", Qt::CaseSensitivity::CaseInsensitive) == 0) || (fileInfo.baseName().compare("gmake", Qt::CaseSensitivity::CaseInsensitive) == 0)) {
|
else if ((fileInfo.baseName().compare("make", Qt::CaseSensitivity::CaseInsensitive) == 0)
|
||||||
QRegExp regExp("\\s*\\-j\\d+");
|
|| (fileInfo.baseName().compare("gmake", Qt::CaseSensitivity::CaseInsensitive) == 0)) {
|
||||||
|
QRegularExpression regExp("\\s*\\-j\\d+");
|
||||||
args.remove(regExp);
|
args.remove(regExp);
|
||||||
args.append(" -j200");
|
args.append(" -j200");
|
||||||
}
|
}
|
||||||
|
@@ -377,16 +377,17 @@ void PythonBuildSystem::parse()
|
|||||||
*/
|
*/
|
||||||
static void expandEnvironmentVariables(const QProcessEnvironment &env, QString &string)
|
static void expandEnvironmentVariables(const QProcessEnvironment &env, QString &string)
|
||||||
{
|
{
|
||||||
static QRegExp candidate(QLatin1String("\\$\\$\\((.+)\\)"));
|
const QRegularExpression candidate("\\$\\$\\((.+)\\)");
|
||||||
|
|
||||||
int index = candidate.indexIn(string);
|
QRegularExpressionMatch match;
|
||||||
|
int index = string.indexOf(candidate, 0, &match);
|
||||||
while (index != -1) {
|
while (index != -1) {
|
||||||
const QString value = env.value(candidate.cap(1));
|
const QString value = env.value(match.captured(1));
|
||||||
|
|
||||||
string.replace(index, candidate.matchedLength(), value);
|
string.replace(index, match.capturedLength(), value);
|
||||||
index += value.length();
|
index += value.length();
|
||||||
|
|
||||||
index = candidate.indexIn(string, index);
|
index = string.indexOf(candidate, index, &match);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -86,7 +86,7 @@ private:
|
|||||||
if (match.hasMatch()) {
|
if (match.hasMatch()) {
|
||||||
const LinkSpec link(match.capturedStart(2), match.capturedLength(2), match.captured(2));
|
const LinkSpec link(match.capturedStart(2), match.capturedLength(2), match.captured(2));
|
||||||
const auto fileName = FilePath::fromString(match.captured(3));
|
const auto fileName = FilePath::fromString(match.captured(3));
|
||||||
const int lineNumber = match.capturedRef(4).toInt();
|
const int lineNumber = match.captured(4).toInt();
|
||||||
m_tasks.append({Task::Warning, QString(), fileName, lineNumber, category});
|
m_tasks.append({Task::Warning, QString(), fileName, lineNumber, category});
|
||||||
return {Status::InProgress, {link}};
|
return {Status::InProgress, {link}};
|
||||||
}
|
}
|
||||||
@@ -121,7 +121,7 @@ private:
|
|||||||
if (!match.hasMatch())
|
if (!match.hasMatch())
|
||||||
return false;
|
return false;
|
||||||
const QString fileName = match.captured(3);
|
const QString fileName = match.captured(3);
|
||||||
const int lineNumber = match.capturedRef(4).toInt();
|
const int lineNumber = match.captured(4).toInt();
|
||||||
Core::EditorManager::openEditorAt(fileName, lineNumber);
|
Core::EditorManager::openEditorAt(fileName, lineNumber);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@@ -44,14 +44,13 @@ using namespace QmakeProjectManager::Internal;
|
|||||||
const char qt_file_dialog_filter_reg_exp[] =
|
const char qt_file_dialog_filter_reg_exp[] =
|
||||||
"^(.*)\\(([a-zA-Z0-9_.*? +;#\\-\\[\\]@\\{\\}/!<>\\$%&=^~:\\|]*)\\)$";
|
"^(.*)\\(([a-zA-Z0-9_.*? +;#\\-\\[\\]@\\{\\}/!<>\\$%&=^~:\\|]*)\\)$";
|
||||||
|
|
||||||
// taken from qfiledialog.cpp
|
static QStringList qt_clean_filter_list(const QString &filter)
|
||||||
QStringList qt_clean_filter_list(const QString &filter)
|
|
||||||
{
|
{
|
||||||
QRegExp regexp(QString::fromLatin1(qt_file_dialog_filter_reg_exp));
|
const QRegularExpression regexp(qt_file_dialog_filter_reg_exp);
|
||||||
|
const QRegularExpressionMatch match = regexp.match(filter);
|
||||||
QString f = filter;
|
QString f = filter;
|
||||||
int i = regexp.indexIn(f);
|
if (match.hasMatch())
|
||||||
if (i >= 0)
|
f = match.captured(2);
|
||||||
f = regexp.cap(2);
|
|
||||||
return f.split(QLatin1Char(' '), Utils::SkipEmptyParts);
|
return f.split(QLatin1Char(' '), Utils::SkipEmptyParts);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -65,12 +64,16 @@ static bool validateLibraryPath(const Utils::FilePath &filePath,
|
|||||||
|
|
||||||
const QString fileName = filePath.fileName();
|
const QString fileName = filePath.fileName();
|
||||||
|
|
||||||
QStringList filters = qt_clean_filter_list(pathChooser->promptDialogFilter());
|
QRegularExpression::PatternOption option =
|
||||||
for (int i = 0; i < filters.count(); i++) {
|
Utils::HostOsInfo::fileNameCaseSensitivity() == Qt::CaseInsensitive
|
||||||
QRegExp regExp(filters.at(i));
|
? QRegularExpression::CaseInsensitiveOption
|
||||||
regExp.setCaseSensitivity(Utils::HostOsInfo::fileNameCaseSensitivity());
|
: QRegularExpression::NoPatternOption;
|
||||||
regExp.setPatternSyntax(QRegExp::Wildcard);
|
|
||||||
if (regExp.exactMatch(fileName))
|
const QStringList filters = qt_clean_filter_list(pathChooser->promptDialogFilter());
|
||||||
|
for (const QString &filter : filters) {
|
||||||
|
QString pattern = QRegularExpression::wildcardToRegularExpression(filter);
|
||||||
|
QRegularExpression regExp(pattern, option);
|
||||||
|
if (regExp.match(fileName).hasMatch())
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
Reference in New Issue
Block a user