Use more QRegularExpressionMatch::capturedRef

GIT_SILENT
parent 10b99175
......@@ -31,7 +31,7 @@ namespace KDevelop
{
void initializeFilteredItem(FilteredItem& item, const ErrorFormat& filter, const QRegularExpressionMatch& match)
{
item.lineNo = match.captured( filter.lineGroup ).toInt() - 1;
item.lineNo = match.capturedRef(filter.lineGroup).toInt() - 1;
item.columnNo = filter.columnNumber(match);
}
......@@ -322,7 +322,7 @@ FilteredItem CompilerFilterStrategy::errorInLine(const QString& line)
}
initializeFilteredItem(item, curErrFilter, match);
const QString txt = match.captured(curErrFilter.textGroup);
const QStringRef txt = match.capturedRef(curErrFilter.textGroup);
// Find the indicator which happens most early.
int earliestIndicatorIdx = txt.length();
......
......@@ -49,7 +49,7 @@ ActionFormat::ActionFormat(int file, const QString& regExp)
int ErrorFormat::columnNumber(const QRegularExpressionMatch& match) const
{
return columnGroup < 0 ? 0 : std::max(match.captured(columnGroup).toInt() - 1, 0);
return columnGroup < 0 ? 0 : std::max(match.capturedRef(columnGroup).toInt() - 1, 0);
}
}
......
......@@ -1057,7 +1057,7 @@ QUrl DocumentController::nextEmptyDocumentUrl()
if (DocumentController::isEmptyDocumentUrl(doc->url())) {
const auto match = pattern.match(doc->url().toDisplayString(QUrl::PreferLocalFile));
if (match.hasMatch()) {
const int num = match.captured(1).toInt();
const int num = match.capturedRef(1).toInt();
nextEmptyDocNumber = qMax(nextEmptyDocNumber, num + 1);
} else {
nextEmptyDocNumber = qMax(nextEmptyDocNumber, 1);
......
......@@ -230,9 +230,9 @@ void KDevelop::expandVariables(QMap<QString, QString>& variables, const QProcess
for (auto& value : variables) {
QRegularExpressionMatch m;
while ((m = rVar.match(value)).hasMatch()) {
if (environment.contains(m.captured(1).midRef(1).toString())) {
if (environment.contains(m.capturedRef(1).mid(1).toString())) {
value.replace(m.capturedStart(0), m.capturedLength(0),
environment.value(m.captured(0).midRef(1).toString()));
environment.value(m.capturedRef(0).mid(1).toString()));
} else {
//TODO: an warning
value.remove(m.capturedStart(0), m.capturedLength(0));
......
......@@ -73,7 +73,7 @@ KTextEditor::Cursor KTextEditorHelpers::extractCursor(const QString& input, int*
int line = match.capturedRef(1).toInt() - 1;
// captured(2) for pattern2 will yield null QString, toInt() thus 0, so no need for if-else
// don't use an invalid column when the line is valid
int column = qMax(0, match.captured(2).toInt() - 1);
int column = qMax(0, match.capturedRef(2).toInt() - 1);
if (pathLength)
*pathLength = match.capturedStart(0);
......
......@@ -186,7 +186,7 @@ public:
appendSpecifer = match.hasMatch(); // assume non-modern if no standard is specified
if (appendSpecifer) {
const auto standard = match.captured(1);
const auto standard = match.capturedRef(1);
appendSpecifer = (standard != QLatin1String("98") && standard != QLatin1String("03"));
}
}
......
......@@ -129,11 +129,11 @@ Replacement ReplacementParser::nextNode(const QRegularExpressionMatch& smatch)
{
Replacement repl;
if (smatch.captured(1) != m_sourceFile) {
if (smatch.capturedRef(1) != m_sourceFile) {
return repl; // Parsing output from only one file.
}
int off{ smatch.captured(2).toInt() };
int len{ smatch.captured(3).toInt() };
const int off = smatch.capturedRef(2).toInt();
const int len = smatch.capturedRef(3).toInt();
repl.range = composeNextNodeRange(off, len);
if (repl.range.isValid()) {
repl.offset = off;
......
......@@ -187,8 +187,8 @@ void Job::postProcessStderr(const QStringList& lines)
// "real" jobs, created with public constructor.
const auto document = m_timer.isNull() ? match.captured(1) : QFileInfo(match.captured(1)).canonicalFilePath();
const int line = match.captured(2).toInt() - 1;
const int column = match.captured(3).toInt() - 1;
const int line = match.capturedRef(2).toInt() - 1;
const int column = match.capturedRef(3).toInt() - 1;
// TODO add KDevelop::IProblem::FinalLocationMode::ToEnd type ?
KTextEditor::Range range(line, column, line, 1000);
......
......@@ -138,7 +138,7 @@ public:
setState(HEADING);
html += match.captured(2);
setState(EMPTY);
if (match.captured(1).size() == 1) {
if (match.capturedRef(1).size() == 1) {
html += QStringLiteral("<hr>");
}
}
......
......@@ -85,7 +85,7 @@ void Job::postProcessStdout(const QStringList& lines)
match = percentRegex.match(line);
if (match.hasMatch()) {
setPercent(match.captured(1).toULong());
setPercent(match.capturedRef(1).toULong());
continue;
}
}
......
......@@ -199,7 +199,7 @@ QStringList Parameters::commandLine(QString& infoMessage) const
auto match = mocHeaderRegex.match(QString::fromUtf8(qtHeader.readLine()));
if (match.hasMatch()) {
mocDefineFound = true;
result << QLatin1String("-DQ_MOC_OUTPUT_REVISION=") + match.captured(1);
result << QLatin1String("-DQ_MOC_OUTPUT_REVISION=") + match.capturedRef(1);
break;
}
}
......
......@@ -575,7 +575,7 @@ PathResolutionResult MakeFileResolver::processOutput(const QString& fullOutput,
if (QDir::isRelativePath(path))
path = workingDirectory + QLatin1Char('/') + path;
const auto& internedPath = internPath(path);
const auto& type = match.captured(1);
const auto type = match.capturedRef(1);
const auto isFramework = type.startsWith(QLatin1String("-iframework"))
|| type.startsWith(QLatin1String("-F"));
if (isFramework) {
......
......@@ -432,7 +432,7 @@ void DebugSession::handleVersion(const QStringList& s)
int version[] = {0, 0, 0};
if (match.hasMatch()) {
for (int i = 0; i != 3; ++i) {
version[i] = match.captured(i+1).toInt();
version[i] = match.capturedRef(i+1).toInt();
}
}
......
......@@ -97,7 +97,7 @@ void ActionsQuickOpenProvider::setFilterText(const QString& text)
QString display = action->text();
QRegularExpressionMatch match = mnemonicRx.match(display);
if (match.hasMatch()) {
display = match.captured(1) + match.captured(2);
display = match.capturedRef(1) + match.capturedRef(2);
}
if (display.contains(text, Qt::CaseInsensitive)) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment