diff options
author | Alessandro Portale <[email protected]> | 2024-11-20 12:19:53 +0100 |
---|---|---|
committer | Alessandro Portale <[email protected]> | 2024-11-20 12:19:42 +0000 |
commit | 116d5224e9409c4ed9b914a92b9d5ca9675fb357 (patch) | |
tree | 312e400b0381e73cbc91b20472c847b0ff278dd8 /src | |
parent | 7c97a2b9f81adefc4fa03908e84865d77f5c4b5a (diff) |
Plugins M-V: Make static QRegularExpression instances static const
Change-Id: I291e61ac30786dfceda330d3dc73352da719c7d0
Reviewed-by: hjk <[email protected]>
Diffstat (limited to 'src')
32 files changed, 57 insertions, 48 deletions
diff --git a/src/plugins/mercurial/mercurialcommitwidget.cpp b/src/plugins/mercurial/mercurialcommitwidget.cpp index d1d1a7b37b9..fb74e8af7aa 100644 --- a/src/plugins/mercurial/mercurialcommitwidget.cpp +++ b/src/plugins/mercurial/mercurialcommitwidget.cpp @@ -169,8 +169,8 @@ QString MercurialCommitWidget::repoRoot() const QString MercurialCommitWidget::cleanupDescription(const QString &input) const { - const QRegularExpression commentLine(QLatin1String("^HG:[^\\n]*(\\n|$)"), - QRegularExpression::MultilineOption); + static const QRegularExpression commentLine(QLatin1String("^HG:[^\\n]*(\\n|$)"), + QRegularExpression::MultilineOption); QString message = input; message.remove(commentLine); return message; diff --git a/src/plugins/mesonprojectmanager/buildoptionsmodel.cpp b/src/plugins/mesonprojectmanager/buildoptionsmodel.cpp index 702176b517a..8019be45566 100644 --- a/src/plugins/mesonprojectmanager/buildoptionsmodel.cpp +++ b/src/plugins/mesonprojectmanager/buildoptionsmodel.cpp @@ -15,9 +15,9 @@ namespace MesonProjectManager::Internal { -static QRegularExpression ®Exp() +static const QRegularExpression ®Exp() { - static QRegularExpression s_regexp{R"('([^']+)'+|([^', ]+)[, ]*)"}; + static const QRegularExpression s_regexp{R"('([^']+)'+|([^', ]+)[, ]*)"}; return s_regexp; } diff --git a/src/plugins/nim/project/nimtoolchain.cpp b/src/plugins/nim/project/nimtoolchain.cpp index d333e618537..e083ae5b172 100644 --- a/src/plugins/nim/project/nimtoolchain.cpp +++ b/src/plugins/nim/project/nimtoolchain.cpp @@ -107,7 +107,7 @@ bool NimToolchain::parseVersion(const FilePath &path, std::tuple<int, int, int> const QString version = process.readAllStandardOutput().section('\n', 0, 0); if (version.isEmpty()) return false; - const QRegularExpression regex("(\\d+)\\.(\\d+)\\.(\\d+)"); + static const QRegularExpression regex("(\\d+)\\.(\\d+)\\.(\\d+)"); const QRegularExpressionMatch match = regex.match(version); if (!match.hasMatch()) return false; diff --git a/src/plugins/perforce/pendingchangesdialog.cpp b/src/plugins/perforce/pendingchangesdialog.cpp index 84b10a8a072..61ab54514ea 100644 --- a/src/plugins/perforce/pendingchangesdialog.cpp +++ b/src/plugins/perforce/pendingchangesdialog.cpp @@ -29,7 +29,7 @@ PendingChangesDialog::PendingChangesDialog(const QString &data, QWidget *parent) connect(buttonBox, &QDialogButtonBox::rejected, this, &QDialog::reject); if (!data.isEmpty()) { - const QRegularExpression r(QLatin1String("Change\\s(\\d+?).*?\\s\\*?pending\\*?\\s(.+?)\n")); + static const QRegularExpression r("Change\\s(\\d+?).*?\\s\\*?pending\\*?\\s(.+?)\n"); QListWidgetItem *item; QRegularExpressionMatchIterator it = r.globalMatch(data); while (it.hasNext()) { diff --git a/src/plugins/perforce/perforceplugin.cpp b/src/plugins/perforce/perforceplugin.cpp index 665f54b5769..389879afe96 100644 --- a/src/plugins/perforce/perforceplugin.cpp +++ b/src/plugins/perforce/perforceplugin.cpp @@ -731,7 +731,8 @@ void PerforcePluginPrivate::startSubmitProject() const QStringList filesLines = filesResult.stdOut.split(QLatin1Char('\n')); QStringList depotFileNames; for (const QString &line : filesLines) { - depotFileNames.append(line.left(line.lastIndexOf(QRegularExpression("#[0-9]+\\s-\\s")))); + static const QRegularExpression regexp("#[0-9]+\\s-\\s"); + depotFileNames.append(line.left(line.lastIndexOf(regexp))); } if (depotFileNames.isEmpty()) { VcsOutputWindow::appendWarning(Tr::tr("Project has no files")); @@ -1447,7 +1448,7 @@ QString PerforcePluginPrivate::clientFilePath(const QString &serverFilePath) if (response.error) return {}; - const QRegularExpression r("\\.\\.\\.\\sclientFile\\s(.+?)\n"); + static const QRegularExpression r("\\.\\.\\.\\sclientFile\\s(.+?)\n"); const QRegularExpressionMatch match = r.match(response.stdOut); return match.hasMatch() ? match.captured(1).trimmed() : QString(); } @@ -1462,7 +1463,7 @@ QString PerforcePluginPrivate::pendingChangesData() if (userResponse.error) return {}; - const QRegularExpression r("User\\sname:\\s(\\S+?)\\s*?\n"); + static const QRegularExpression r("User\\sname:\\s(\\S+?)\\s*?\n"); QTC_ASSERT(r.isValid(), return QString()); const QRegularExpressionMatch match = r.match(userResponse.stdOut); const QString user = match.hasMatch() ? match.captured(1).trimmed() : QString(); diff --git a/src/plugins/perforce/perforcesubmiteditor.cpp b/src/plugins/perforce/perforcesubmiteditor.cpp index 9b6f8240d4c..e066cb367e6 100644 --- a/src/plugins/perforce/perforcesubmiteditor.cpp +++ b/src/plugins/perforce/perforcesubmiteditor.cpp @@ -48,7 +48,7 @@ bool PerforceSubmitEditor::setFileContents(const QByteArray &contents) bool PerforceSubmitEditor::parseText(QString text) { - QRegularExpression formField(QLatin1String("^\\S+:")); + static const QRegularExpression formField("^\\S+:"); const QString newLine = QString(QLatin1Char('\n')); int matchLen; @@ -94,7 +94,7 @@ void PerforceSubmitEditor::updateFields() lines.removeFirst(); // that is the line break after 'Description:' lines.removeLast(); // that is the empty line at the end - const QRegularExpression leadingTabPattern("^\\t"); + static const QRegularExpression leadingTabPattern("^\\t"); QTC_CHECK(leadingTabPattern.isValid()); lines.replaceInStrings(leadingTabPattern, QString()); @@ -122,7 +122,8 @@ void PerforceSubmitEditor::updateEntries() while (!lines.empty() && lines.last().isEmpty()) lines.removeLast(); // Description - lines.replaceInStrings(QRegularExpression("^"), tab); + static const QRegularExpression regexp("^"); + lines.replaceInStrings(regexp, tab); m_entries.insert(QLatin1String("Description"), newLine + lines.join(newLine) + QLatin1String("\n\n")); QString files = newLine; // Re-build the file spec '<tab>file#add' from the user data diff --git a/src/plugins/projectexplorer/abi.cpp b/src/plugins/projectexplorer/abi.cpp index 3f6b392f1e4..1cde394ec8e 100644 --- a/src/plugins/projectexplorer/abi.cpp +++ b/src/plugins/projectexplorer/abi.cpp @@ -472,7 +472,8 @@ Abi Abi::abiFromTargetTriplet(const QString &triple) if (machine.isEmpty()) return {}; - const QStringList parts = machine.split(QRegularExpression("[ /-]")); + static const QRegularExpression splitRegexp("[ /-]"); + const QStringList parts = machine.split(splitRegexp); Architecture arch = UnknownArchitecture; OS os = UnknownOS; diff --git a/src/plugins/projectexplorer/gcctoolchain.cpp b/src/plugins/projectexplorer/gcctoolchain.cpp index e1382e6f22e..9b4513e203b 100644 --- a/src/plugins/projectexplorer/gcctoolchain.cpp +++ b/src/plugins/projectexplorer/gcctoolchain.cpp @@ -454,7 +454,7 @@ void GccToolchain::setInstallDir(const FilePath &installDir) QString GccToolchain::defaultDisplayName() const { QString type = typeDisplayName(); - const QRegularExpression regexp(binaryRegexp); + static const QRegularExpression regexp(binaryRegexp); const QRegularExpressionMatch match = regexp.match(compilerCommand().fileName()); if (match.lastCapturedIndex() >= 1) type += ' ' + match.captured(1); diff --git a/src/plugins/projectexplorer/kitmanagerconfigwidget.cpp b/src/plugins/projectexplorer/kitmanagerconfigwidget.cpp index dd2014dca8c..5cdca7c87be 100644 --- a/src/plugins/projectexplorer/kitmanagerconfigwidget.cpp +++ b/src/plugins/projectexplorer/kitmanagerconfigwidget.cpp @@ -60,7 +60,7 @@ KitManagerConfigWidget::KitManagerConfigWidget(Kit *k, bool &isDefaultKit, bool "which for example determines the name of the shadow build directory." "</p></body></html>").arg(QLatin1String("Kit:FileSystemName")); m_fileSystemFriendlyNameLineEdit->setToolTip(toolTip); - QRegularExpression fileSystemFriendlyNameRegexp(QLatin1String("^[A-Za-z0-9_-]*$")); + static const QRegularExpression fileSystemFriendlyNameRegexp(QLatin1String("^[A-Za-z0-9_-]*$")); Q_ASSERT(fileSystemFriendlyNameRegexp.isValid()); m_fileSystemFriendlyNameLineEdit->setValidator(new QRegularExpressionValidator(fileSystemFriendlyNameRegexp, m_fileSystemFriendlyNameLineEdit)); diff --git a/src/plugins/projectexplorer/msvctoolchain.cpp b/src/plugins/projectexplorer/msvctoolchain.cpp index 132c9afe8a4..e977f776f8c 100644 --- a/src/plugins/projectexplorer/msvctoolchain.cpp +++ b/src/plugins/projectexplorer/msvctoolchain.cpp @@ -2284,8 +2284,8 @@ ClangClInfo ClangClInfo::getInfo(const FilePath &filePath) static const auto parser = [](const QString &stdOut, const QString &) { ClangClInfo info; - const QRegularExpressionMatch versionMatch - = QRegularExpression("clang version (\\d+(\\.\\d+)+)").match(stdOut); + static const QRegularExpression regexp("clang version (\\d+(\\.\\d+)+)"); + const QRegularExpressionMatch versionMatch = regexp.match(stdOut); if (versionMatch.hasMatch()) info.m_version = QVersionNumber::fromString(versionMatch.captured(1)); const QString targetKey = "Target:"; diff --git a/src/plugins/projectexplorer/userfileaccessor.cpp b/src/plugins/projectexplorer/userfileaccessor.cpp index 173594c19f8..e3854d69008 100644 --- a/src/plugins/projectexplorer/userfileaccessor.cpp +++ b/src/plugins/projectexplorer/userfileaccessor.cpp @@ -176,7 +176,8 @@ namespace { static QString generateSuffix(const QString &suffix) { QString result = suffix; - result.replace(QRegularExpression("[^a-zA-Z0-9_.-]"), QString('_')); // replace fishy character + static const QRegularExpression regexp("[^a-zA-Z0-9_.-]"); + result.replace(regexp, QString('_')); // replace fishy character if (!result.startsWith('.')) result.prepend('.'); return result; diff --git a/src/plugins/python/pyside.cpp b/src/plugins/python/pyside.cpp index 7010e099ffa..bdccde1f3fb 100644 --- a/src/plugins/python/pyside.cpp +++ b/src/plugins/python/pyside.cpp @@ -74,7 +74,7 @@ QString PySideInstaller::usedPySide(const QString &text, const QString &mimeType { using namespace Python::Constants; if (mimeType == C_PY_MIMETYPE || mimeType == C_PY3_MIMETYPE || mimeType == C_PY_GUI_MIMETYPE) { - static QRegularExpression + static const QRegularExpression scanner("^\\s*(import|from)\\s+(PySide\\d)", QRegularExpression::MultilineOption); const QRegularExpressionMatch match = scanner.match(text); return match.captured(2); diff --git a/src/plugins/python/pythonbuildsystem.cpp b/src/plugins/python/pythonbuildsystem.cpp index 619e59ad527..f091aea2bc7 100644 --- a/src/plugins/python/pythonbuildsystem.cpp +++ b/src/plugins/python/pythonbuildsystem.cpp @@ -370,7 +370,7 @@ void PythonBuildSystem::parse() */ static void expandEnvironmentVariables(const Environment &env, QString &string) { - const QRegularExpression candidate("\\$\\$\\((.+)\\)"); + static const QRegularExpression candidate("\\$\\$\\((.+)\\)"); QRegularExpressionMatch match; int index = string.indexOf(candidate, 0, &match); diff --git a/src/plugins/qbsprojectmanager/defaultpropertyprovider.cpp b/src/plugins/qbsprojectmanager/defaultpropertyprovider.cpp index f3caa25d261..0ea8d83e55d 100644 --- a/src/plugins/qbsprojectmanager/defaultpropertyprovider.cpp +++ b/src/plugins/qbsprojectmanager/defaultpropertyprovider.cpp @@ -361,7 +361,7 @@ QVariantMap DefaultPropertyProvider::autoGeneratedProperties(const ProjectExplor } if (targetAbi.os() == ProjectExplorer::Abi::DarwinOS) { // Reverse engineer the Xcode developer path from the compiler path - const QRegularExpression compilerRe( + static const QRegularExpression compilerRe( QStringLiteral("^(?<developerpath>.*)/Toolchains/(?:.+)\\.xctoolchain/usr/bin$")); const QRegularExpressionMatch compilerReMatch = compilerRe.match(cxxCompilerPath.absolutePath().toString()); if (compilerReMatch.hasMatch()) { diff --git a/src/plugins/qbsprojectmanager/qbsprofilemanager.cpp b/src/plugins/qbsprojectmanager/qbsprofilemanager.cpp index b7f831b8dee..8fea3e1a2ed 100644 --- a/src/plugins/qbsprojectmanager/qbsprofilemanager.cpp +++ b/src/plugins/qbsprojectmanager/qbsprofilemanager.cpp @@ -48,7 +48,8 @@ static QString toJSLiteral(const bool b) static QString toJSLiteral(const QString &str) { QString js = str; - js.replace(QRegularExpression("([\\\\\"])"), "\\\\1"); + static const QRegularExpression regexp("([\\\\\"])"); + js.replace(regexp, "\\\\1"); js.prepend('"'); js.append('"'); return js; diff --git a/src/plugins/qmakeprojectmanager/addlibrarywizard.cpp b/src/plugins/qmakeprojectmanager/addlibrarywizard.cpp index c6500df0cfd..01c172823a7 100644 --- a/src/plugins/qmakeprojectmanager/addlibrarywizard.cpp +++ b/src/plugins/qmakeprojectmanager/addlibrarywizard.cpp @@ -32,7 +32,7 @@ const char qt_file_dialog_filter_reg_exp[] = static QStringList qt_clean_filter_list(const QString &filter) { - const QRegularExpression regexp(qt_file_dialog_filter_reg_exp); + static const QRegularExpression regexp(qt_file_dialog_filter_reg_exp); const QRegularExpressionMatch match = regexp.match(filter); QString f = filter; if (match.hasMatch()) diff --git a/src/plugins/qmakeprojectmanager/customwidgetwizard/plugingenerator.cpp b/src/plugins/qmakeprojectmanager/customwidgetwizard/plugingenerator.cpp index 0a36120a64b..6f77db462a4 100644 --- a/src/plugins/qmakeprojectmanager/customwidgetwizard/plugingenerator.cpp +++ b/src/plugins/qmakeprojectmanager/customwidgetwizard/plugingenerator.cpp @@ -24,7 +24,8 @@ namespace QmakeProjectManager::Internal { static QString headerGuard(const QString &header) { - return header.toUpper().replace(QRegularExpression("[^A-Z0-9]+"), QString("_")); + static const QRegularExpression regexp("[^A-Z0-9]+"); + return header.toUpper().replace(regexp, QString("_")); } struct ProjectContents { diff --git a/src/plugins/qmljseditor/qmljshoverhandler.cpp b/src/plugins/qmljseditor/qmljshoverhandler.cpp index c1ef69982f7..f17ec289254 100644 --- a/src/plugins/qmljseditor/qmljshoverhandler.cpp +++ b/src/plugins/qmljseditor/qmljshoverhandler.cpp @@ -158,7 +158,7 @@ bool QmlJSHoverHandler::setQmlTypeHelp(const ScopeChain &scopeChain, const Docum const HelpItem::Links links = helpItem.links(); // Check if the module name contains a major version. - static QRegularExpression version("^([^\\d]*)(\\d+)\\.*\\d*$"); + static const QRegularExpression version("^([^\\d]*)(\\d+)\\.*\\d*$"); const QRegularExpressionMatch m = version.match(moduleName); if (m.hasMatch()) { QMap<QString, QUrl> filteredUrlMap; diff --git a/src/plugins/qmlprofiler/qmlprofilermodelmanager.cpp b/src/plugins/qmlprofiler/qmlprofilermodelmanager.cpp index fa0c9f77db1..75834aaf60c 100644 --- a/src/plugins/qmlprofiler/qmlprofilermodelmanager.cpp +++ b/src/plugins/qmlprofiler/qmlprofilermodelmanager.cpp @@ -219,7 +219,7 @@ static QString getInitialDetails(const QmlEventType &event) if (event.rangeType() == Javascript) details = Tr::tr("anonymous function"); } else { - QRegularExpression rewrite(QLatin1String("^\\(function \\$(\\w+)\\(\\) \\{ (return |)(.+) \\}\\)$")); + static const QRegularExpression rewrite("^\\(function \\$(\\w+)\\(\\) \\{ (return |)(.+) \\}\\)$"); QRegularExpressionMatch match = rewrite.match(details); if (match.hasMatch()) details = match.captured(1) + QLatin1String(": ") + match.captured(3); diff --git a/src/plugins/qmlprojectmanager/projectfilecontenttools.cpp b/src/plugins/qmlprojectmanager/projectfilecontenttools.cpp index e432967624d..7b12642ce29 100644 --- a/src/plugins/qmlprojectmanager/projectfilecontenttools.cpp +++ b/src/plugins/qmlprojectmanager/projectfilecontenttools.cpp @@ -84,7 +84,7 @@ const QString getMainQmlFile(const Utils::FilePath &projectFilePath) { const QString defaultReturn = "content/App.qml"; const QString data = readFileContents(projectFilePath); - QRegularExpression regexp(R"x(mainFile: "(.*)")x"); + static const QRegularExpression regexp(R"x(mainFile: "(.*)")x"); QRegularExpressionMatch match = regexp.match(data); if (!match.hasMatch()) return defaultReturn; @@ -105,8 +105,8 @@ const Resolution resolutionFromConstants(const Utils::FilePath &projectFilePath) if (!reader.fetch(Utils::FilePath::fromString(fileName))) return {}; const QByteArray data = reader.data(); - const QRegularExpression regexpWidth(R"x(readonly\s+property\s+int\s+width:\s+(\d*))x"); - const QRegularExpression regexpHeight(R"x(readonly\s+property\s+int\s+height:\s+(\d*))x"); + static const QRegularExpression regexpWidth(R"x(readonly\s+property\s+int\s+width:\s+(\d*))x"); + static const QRegularExpression regexpHeight(R"x(readonly\s+property\s+int\s+height:\s+(\d*))x"); int width = -1; int height = -1; QRegularExpressionMatch match = regexpHeight.match(QString::fromUtf8(data)); diff --git a/src/plugins/qnx/qnxversionnumber.cpp b/src/plugins/qnx/qnxversionnumber.cpp index ea7521a4b2c..c9abf93b4ba 100644 --- a/src/plugins/qnx/qnxversionnumber.cpp +++ b/src/plugins/qnx/qnxversionnumber.cpp @@ -66,7 +66,8 @@ QString QnxVersionNumber::segment(int index) const QnxVersionNumber QnxVersionNumber::fromTargetName(const QString &targetName) { - return fromFileName(targetName, QRegularExpression("^target_(.*)$")); + static const QRegularExpression regexp("^target_(.*)$"); + return fromFileName(targetName, regexp); } QnxVersionNumber QnxVersionNumber::fromFileName(const QString &fileName, const QRegularExpression ®Exp) diff --git a/src/plugins/qnx/slog2inforunner.cpp b/src/plugins/qnx/slog2inforunner.cpp index 2c7bf6716c8..6feaad06aa3 100644 --- a/src/plugins/qnx/slog2inforunner.cpp +++ b/src/plugins/qnx/slog2inforunner.cpp @@ -106,8 +106,8 @@ void Slog2InfoRunner::processLogLine(const QString &line) // The "\\s+(\\b.*)?$" represents a space followed by a message. We are unable to determinate // how many spaces represent separators and how many are a part of the messages, so resulting // messages has all whitespaces at the beginning of the message trimmed. - static QRegularExpression regexp(QLatin1String( - "^[a-zA-Z]+\\s+([0-9]+ [0-9]+:[0-9]+:[0-9]+.[0-9]+)\\s+(\\S+)(\\s+(\\S+))?\\s+([0-9]+)\\s+(.*)?$")); + static const QRegularExpression regexp( + "^[a-zA-Z]+\\s+([0-9]+ [0-9]+:[0-9]+:[0-9]+.[0-9]+)\\s+(\\S+)(\\s+(\\S+))?\\s+([0-9]+)\\s+(.*)?$"); const QRegularExpressionMatch match = regexp.match(line); if (!match.hasMatch()) diff --git a/src/plugins/qtsupport/baseqtversion.cpp b/src/plugins/qtsupport/baseqtversion.cpp index 98aaeb3b657..28cc8b9c672 100644 --- a/src/plugins/qtsupport/baseqtversion.cpp +++ b/src/plugins/qtsupport/baseqtversion.cpp @@ -1824,7 +1824,7 @@ FilePath QtVersionPrivate::mkspecFromVersionInfo(const QHash<ProKey, ProString> if (temp.size() == 2) { QString possibleFullPath = QString::fromLocal8Bit(temp.at(1).trimmed().constData()); if (possibleFullPath.contains('$')) { // QTBUG-28792 - const QRegularExpression rex("\\binclude\\(([^)]+)/qmake\\.conf\\)"); + static const QRegularExpression rex("\\binclude\\(([^)]+)/qmake\\.conf\\)"); const QRegularExpressionMatch match = rex.match(QString::fromLocal8Bit(f2.readAll())); if (match.hasMatch()) { possibleFullPath = mkspecFullPath.toString() + '/' @@ -2134,7 +2134,8 @@ static QStringList extractFieldsFromBuildString(const QByteArray &buildString) if (buildString.isEmpty() || buildString.size() > 4096) return {}; - const QRegularExpression buildStringMatcher("^Qt " + static const QRegularExpression buildStringMatcher( + "^Qt " "([\\d\\.a-zA-Z]*) " // Qt version "\\(" "([\\w_-]+) " // Abi information diff --git a/src/plugins/scxmleditor/common/structure.cpp b/src/plugins/scxmleditor/common/structure.cpp index f709379d34d..1ea5d9bb7a0 100644 --- a/src/plugins/scxmleditor/common/structure.cpp +++ b/src/plugins/scxmleditor/common/structure.cpp @@ -41,8 +41,8 @@ QWidget *TreeItemDelegate::createEditor(QWidget *parent, const QStyleOptionViewI if (index.isValid()) { auto edit = new QLineEdit(parent); edit->setFocusPolicy(Qt::StrongFocus); - QRegularExpression rx("^(?!xml)[_a-z][a-z0-9-._]*$"); - rx.setPatternOptions(QRegularExpression::CaseInsensitiveOption); + static const QRegularExpression rx("^(?!xml)[_a-z][a-z0-9-._]*$", + QRegularExpression::CaseInsensitiveOption); edit->setValidator(new QRegularExpressionValidator(rx, parent)); return edit; } diff --git a/src/plugins/scxmleditor/plugin_interface/scattributeitemdelegate.cpp b/src/plugins/scxmleditor/plugin_interface/scattributeitemdelegate.cpp index 0121ddf191a..4e322f7849f 100644 --- a/src/plugins/scxmleditor/plugin_interface/scattributeitemdelegate.cpp +++ b/src/plugins/scxmleditor/plugin_interface/scattributeitemdelegate.cpp @@ -28,9 +28,8 @@ QWidget *SCAttributeItemDelegate::createEditor(QWidget *parent, const QStyleOpti if (index.column() == 0) { auto edit = new QLineEdit(parent); edit->setFocusPolicy(Qt::StrongFocus); - QRegularExpression rx("^(?!xml)[_a-z][a-z0-9-._]*$"); - rx.setPatternOptions(QRegularExpression::CaseInsensitiveOption); - + static const QRegularExpression rx("^(?!xml)[_a-z][a-z0-9-._]*$", + QRegularExpression::CaseInsensitiveOption); edit->setValidator(new QRegularExpressionValidator(rx, parent)); return edit; } diff --git a/src/plugins/squish/objectsmapeditorwidget.cpp b/src/plugins/squish/objectsmapeditorwidget.cpp index e689a5a2962..6819c0f3866 100644 --- a/src/plugins/squish/objectsmapeditorwidget.cpp +++ b/src/plugins/squish/objectsmapeditorwidget.cpp @@ -514,7 +514,7 @@ void ObjectsMapEditorWidget::onPasteSymbolicNameTriggered() return; // if name is not valid at all refuse to do anything - const QRegularExpression validName("^:[^\t\n\r\f\b\v\a]+$"); + static const QRegularExpression validName("^:[^\t\n\r\f\b\v\a]+$"); if (!validName.match(symbolicName).hasMatch()) return; diff --git a/src/plugins/squish/propertyitemdelegate.cpp b/src/plugins/squish/propertyitemdelegate.cpp index d859db864b7..fa21bc8f9ed 100644 --- a/src/plugins/squish/propertyitemdelegate.cpp +++ b/src/plugins/squish/propertyitemdelegate.cpp @@ -137,7 +137,7 @@ ValidatingPropertyNameLineEdit::ValidatingPropertyNameLineEdit(const QStringList if (!edit) return false; - const QRegularExpression identifier("^[a-zA-Z0-9_]+$"); + static const QRegularExpression identifier("^[a-zA-Z0-9_]+$"); const QString &value = edit->text(); return !m_forbidden.contains(value) && identifier.match(value).hasMatch(); diff --git a/src/plugins/terminal/terminalsettings.cpp b/src/plugins/terminal/terminalsettings.cpp index f14766918da..4ac13061798 100644 --- a/src/plugins/terminal/terminalsettings.cpp +++ b/src/plugins/terminal/terminalsettings.cpp @@ -87,7 +87,7 @@ static expected_str<void> loadXdefaults(const FilePath &path) if (!readResult) return make_unexpected(readResult.error()); - QRegularExpression re(R"(.*\*(color[0-9]{1,2}|foreground|background):\s*(#[0-9a-f]{6}))"); + static const QRegularExpression re(R"(.*\*(color[0-9]{1,2}|foreground|background):\s*(#[0-9a-f]{6}))"); for (const QByteArray &line : readResult->split('\n')) { if (line.trimmed().startsWith('!')) diff --git a/src/plugins/texteditor/codeassist/documentcontentcompletion.cpp b/src/plugins/texteditor/codeassist/documentcontentcompletion.cpp index d994238f4a3..d825e6049f5 100644 --- a/src/plugins/texteditor/codeassist/documentcontentcompletion.cpp +++ b/src/plugins/texteditor/codeassist/documentcontentcompletion.cpp @@ -80,7 +80,7 @@ IAssistProposal *DocumentContentCompletionProcessor::performAsync() const QString wordUnderCursor = interface()->textAt(pos, length); const QString text = interface()->textDocument()->toPlainText(); - const QRegularExpression wordRE("([\\p{L}_][\\p{L}0-9_]{2,})"); + static const QRegularExpression wordRE("([\\p{L}_][\\p{L}0-9_]{2,})"); QSet<QString> words; QRegularExpressionMatchIterator it = wordRE.globalMatch(text); int wordUnderCursorFound = 0; diff --git a/src/plugins/texteditor/storagesettings.cpp b/src/plugins/texteditor/storagesettings.cpp index 81b9ceace46..69026ab9152 100644 --- a/src/plugins/texteditor/storagesettings.cpp +++ b/src/plugins/texteditor/storagesettings.cpp @@ -66,7 +66,7 @@ bool StorageSettings::removeTrailingWhitespace(const QString &fileName) const const QString ignoreFileTypesRegExp(R"(\s*((?>\*\.)?[\w\d\.\*]+)[,;]?\s*)"); // use the ignore-files regex to extract the specified file patterns - QRegularExpression re(ignoreFileTypesRegExp); + static const QRegularExpression re(ignoreFileTypesRegExp); QRegularExpressionMatchIterator iter = re.globalMatch(m_ignoreFileTypes); while (iter.hasNext()) { diff --git a/src/plugins/texteditor/texteditor.cpp b/src/plugins/texteditor/texteditor.cpp index 1ae3b953b73..f44fa7b7baf 100644 --- a/src/plugins/texteditor/texteditor.cpp +++ b/src/plugins/texteditor/texteditor.cpp @@ -2457,7 +2457,8 @@ void TextEditorWidget::joinLines() QString cutLine = c.selectedText(); // Collapse leading whitespaces to one or insert whitespace - cutLine.replace(QRegularExpression(QLatin1String("^\\s*")), QLatin1String(" ")); + static const QRegularExpression regexp("^\\s*"); + cutLine.replace(regexp, QLatin1String(" ")); c.movePosition(QTextCursor::Right, QTextCursor::KeepAnchor); c.removeSelectedText(); @@ -8815,7 +8816,7 @@ void TextEditorWidget::autoIndent() void TextEditorWidget::rewrapParagraph() { const int paragraphWidth = marginSettings().m_marginColumn; - const QRegularExpression anyLettersOrNumbers("\\w"); + static const QRegularExpression anyLettersOrNumbers("\\w"); const TabSettings ts = d->m_document->tabSettings(); QTextCursor cursor = textCursor(); @@ -8868,7 +8869,7 @@ void TextEditorWidget::rewrapParagraph() } // Find end of paragraph. - const QRegularExpression immovableDoxygenCommand(doxygenPrefix + "[@\\\\][a-zA-Z]{2,}"); + static const QRegularExpression immovableDoxygenCommand(doxygenPrefix + "[@\\\\][a-zA-Z]{2,}"); QTC_CHECK(immovableDoxygenCommand.isValid()); while (cursor.movePosition(QTextCursor::NextBlock, QTextCursor::KeepAnchor)) { QString text = cursor.block().text(); diff --git a/src/plugins/valgrind/memchecktool.cpp b/src/plugins/valgrind/memchecktool.cpp index 5b4fa2365a3..b7430ca8eb7 100644 --- a/src/plugins/valgrind/memchecktool.cpp +++ b/src/plugins/valgrind/memchecktool.cpp @@ -1155,7 +1155,8 @@ HeobDialog::HeobDialog(QWidget *parent) : QtcSettings *settings = Core::ICore::settings(); bool hasSelProfile = settings->contains(heobProfileC); const QString selProfile = hasSelProfile ? settings->value(heobProfileC).toString() : "Heob"; - m_profiles = settings->childGroups().filter(QRegularExpression("^Heob\\.Profile\\.")); + static const QRegularExpression regexp("^Heob\\.Profile\\."); + m_profiles = settings->childGroups().filter(regexp); auto layout = new QVBoxLayout; // disable resizing |