From 119a3c1ce99420e578af1a10195f779d5d33a83b Mon Sep 17 00:00:00 2001 From: Christian Stenger Date: Thu, 18 Jun 2020 13:06:27 +0200 Subject: [PATCH] LanguageClient: Replace QRegexp by QRegularExpression Task-number: QTCREATORBUG-24098 Change-Id: Ic8259ded3f721957bd04aa00146b20bd90b41dcd Reviewed-by: hjk --- .../languageclientcompletionassist.cpp | 6 +++--- .../languageclient/languageclientsettings.cpp | 13 +++++++++---- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/src/plugins/languageclient/languageclientcompletionassist.cpp b/src/plugins/languageclient/languageclientcompletionassist.cpp index 0bccccbff6c..8a279b0dac0 100644 --- a/src/plugins/languageclient/languageclientcompletionassist.cpp +++ b/src/plugins/languageclient/languageclientcompletionassist.cpp @@ -40,7 +40,6 @@ #include #include -#include #include #include #include @@ -309,9 +308,10 @@ IAssistProposal *LanguageClientCompletionAssistProcessor::perform(const AssistIn m_pos = interface->position(); if (interface->reason() == IdleEditor) { // Trigger an automatic completion request only when we are on a word with more than 2 "identifier" character - const QRegExp regexp("[_a-zA-Z0-9]*"); + const QRegularExpression regexp("[_a-zA-Z0-9]+"); + auto hasMatch = [®exp](const QString &txt) { return regexp.match(txt).hasMatch(); }; int delta = 0; - while (m_pos - delta > 0 && regexp.exactMatch(interface->textAt(m_pos - delta - 1, delta + 1))) + while (m_pos - delta > 0 && hasMatch(interface->textAt(m_pos - delta - 1, delta + 1))) ++delta; if (delta < 3) return nullptr; diff --git a/src/plugins/languageclient/languageclientsettings.cpp b/src/plugins/languageclient/languageclientsettings.cpp index 87530aaf3d2..1cb53dafffe 100644 --- a/src/plugins/languageclient/languageclientsettings.cpp +++ b/src/plugins/languageclient/languageclientsettings.cpp @@ -955,11 +955,16 @@ bool LanguageFilter::isSupported(const Utils::FilePath &filePath, const QString return true; if (filePattern.isEmpty() && filePath.isEmpty()) return mimeTypes.isEmpty(); - auto regexps = Utils::transform(filePattern, [](const QString &pattern){ - return QRegExp(pattern, Utils::HostOsInfo::fileNameCaseSensitivity(), QRegExp::Wildcard); + const QRegularExpression::PatternOptions options + = Utils::HostOsInfo::fileNameCaseSensitivity() == Qt::CaseInsensitive + ? QRegularExpression::CaseInsensitiveOption : QRegularExpression::NoPatternOption; + auto regexps = Utils::transform(filePattern, [&options](const QString &pattern){ + return QRegularExpression(QRegularExpression::wildcardToRegularExpression(pattern), + options); }); - return Utils::anyOf(regexps, [filePath](const QRegExp ®){ - return reg.exactMatch(filePath.toString()) || reg.exactMatch(filePath.fileName()); + return Utils::anyOf(regexps, [filePath](const QRegularExpression ®){ + return reg.match(filePath.toString()).hasMatch() + || reg.match(filePath.fileName()).hasMatch(); }); }