forked from qt-creator/qt-creator
LanguageClient: Replace QRegexp by QRegularExpression
Task-number: QTCREATORBUG-24098 Change-Id: Ic8259ded3f721957bd04aa00146b20bd90b41dcd Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
@@ -40,7 +40,6 @@
|
|||||||
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QLoggingCategory>
|
#include <QLoggingCategory>
|
||||||
#include <QRegExp>
|
|
||||||
#include <QRegularExpression>
|
#include <QRegularExpression>
|
||||||
#include <QTextBlock>
|
#include <QTextBlock>
|
||||||
#include <QTextDocument>
|
#include <QTextDocument>
|
||||||
@@ -309,9 +308,10 @@ IAssistProposal *LanguageClientCompletionAssistProcessor::perform(const AssistIn
|
|||||||
m_pos = interface->position();
|
m_pos = interface->position();
|
||||||
if (interface->reason() == IdleEditor) {
|
if (interface->reason() == IdleEditor) {
|
||||||
// Trigger an automatic completion request only when we are on a word with more than 2 "identifier" character
|
// 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;
|
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;
|
++delta;
|
||||||
if (delta < 3)
|
if (delta < 3)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
@@ -955,11 +955,16 @@ bool LanguageFilter::isSupported(const Utils::FilePath &filePath, const QString
|
|||||||
return true;
|
return true;
|
||||||
if (filePattern.isEmpty() && filePath.isEmpty())
|
if (filePattern.isEmpty() && filePath.isEmpty())
|
||||||
return mimeTypes.isEmpty();
|
return mimeTypes.isEmpty();
|
||||||
auto regexps = Utils::transform(filePattern, [](const QString &pattern){
|
const QRegularExpression::PatternOptions options
|
||||||
return QRegExp(pattern, Utils::HostOsInfo::fileNameCaseSensitivity(), QRegExp::Wildcard);
|
= 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 Utils::anyOf(regexps, [filePath](const QRegularExpression ®){
|
||||||
return reg.exactMatch(filePath.toString()) || reg.exactMatch(filePath.fileName());
|
return reg.match(filePath.toString()).hasMatch()
|
||||||
|
|| reg.match(filePath.fileName()).hasMatch();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user