forked from qt-creator/qt-creator
Locator: De-duplicate RegExp pattern generation
Change-Id: I3576e1507aebed15245e1f197995bfe9e345e32b Reviewed-by: Orgad Shaneh <orgads@gmail.com> Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
committed by
André Hartmann
parent
e0639d0696
commit
8730dbd4e6
@@ -100,9 +100,8 @@ QList<LocatorFilterEntry> BaseFileFilter::matchesFor(QFutureInterface<LocatorFil
|
|||||||
QList<LocatorFilterEntry> goodEntries;
|
QList<LocatorFilterEntry> goodEntries;
|
||||||
const QString entry = QDir::fromNativeSeparators(origEntry);
|
const QString entry = QDir::fromNativeSeparators(origEntry);
|
||||||
const EditorManager::FilePathInfo fp = EditorManager::splitLineAndColumnNumber(entry);
|
const EditorManager::FilePathInfo fp = EditorManager::splitLineAndColumnNumber(entry);
|
||||||
const QRegularExpression regexp = containsWildcard(entry)
|
|
||||||
? createWildcardRegExp(entry) : CamelHumpMatcher::createCamelHumpRegExp(entry);
|
|
||||||
|
|
||||||
|
const QRegularExpression regexp = createRegExp(entry);
|
||||||
if (!regexp.isValid()) {
|
if (!regexp.isValid()) {
|
||||||
d->m_current.clear(); // free memory
|
d->m_current.clear(); // free memory
|
||||||
return betterEntries;
|
return betterEntries;
|
||||||
|
@@ -26,6 +26,7 @@
|
|||||||
#include "ilocatorfilter.h"
|
#include "ilocatorfilter.h"
|
||||||
|
|
||||||
#include <coreplugin/coreconstants.h>
|
#include <coreplugin/coreconstants.h>
|
||||||
|
#include <utils/camelhumpmatcher.h>
|
||||||
|
|
||||||
#include <QBoxLayout>
|
#include <QBoxLayout>
|
||||||
#include <QCheckBox>
|
#include <QCheckBox>
|
||||||
@@ -212,7 +213,7 @@ bool ILocatorFilter::containsWildcard(const QString &str)
|
|||||||
* The regular expression contains capture groups to allow highlighting
|
* The regular expression contains capture groups to allow highlighting
|
||||||
* matched characters after a match.
|
* matched characters after a match.
|
||||||
*/
|
*/
|
||||||
QRegularExpression ILocatorFilter::createWildcardRegExp(const QString &text)
|
static QRegularExpression createWildcardRegExp(const QString &text)
|
||||||
{
|
{
|
||||||
QString pattern = '(' + text + ')';
|
QString pattern = '(' + text + ')';
|
||||||
pattern.replace('?', ").(");
|
pattern.replace('?', ").(");
|
||||||
@@ -221,6 +222,12 @@ QRegularExpression ILocatorFilter::createWildcardRegExp(const QString &text)
|
|||||||
return QRegularExpression(pattern, QRegularExpression::CaseInsensitiveOption);
|
return QRegularExpression(pattern, QRegularExpression::CaseInsensitiveOption);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QRegularExpression ILocatorFilter::createRegExp(const QString &text)
|
||||||
|
{
|
||||||
|
return containsWildcard(text) ? createWildcardRegExp(text)
|
||||||
|
: CamelHumpMatcher::createCamelHumpRegExp(text);
|
||||||
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
Specifies a title for configuration dialogs.
|
Specifies a title for configuration dialogs.
|
||||||
*/
|
*/
|
||||||
|
@@ -144,7 +144,7 @@ public:
|
|||||||
|
|
||||||
static Qt::CaseSensitivity caseSensitivity(const QString &str);
|
static Qt::CaseSensitivity caseSensitivity(const QString &str);
|
||||||
static bool containsWildcard(const QString &str);
|
static bool containsWildcard(const QString &str);
|
||||||
static QRegularExpression createWildcardRegExp(const QString &text);
|
static QRegularExpression createRegExp(const QString &text);
|
||||||
|
|
||||||
static QString msgConfigureDialogTitle();
|
static QString msgConfigureDialogTitle();
|
||||||
static QString msgPrefixLabel();
|
static QString msgPrefixLabel();
|
||||||
|
@@ -61,9 +61,8 @@ QList<LocatorFilterEntry> OpenDocumentsFilter::matchesFor(QFutureInterface<Locat
|
|||||||
QList<LocatorFilterEntry> goodEntries;
|
QList<LocatorFilterEntry> goodEntries;
|
||||||
QList<LocatorFilterEntry> betterEntries;
|
QList<LocatorFilterEntry> betterEntries;
|
||||||
const EditorManager::FilePathInfo fp = EditorManager::splitLineAndColumnNumber(entry);
|
const EditorManager::FilePathInfo fp = EditorManager::splitLineAndColumnNumber(entry);
|
||||||
const QRegularExpression regexp = containsWildcard(entry)
|
|
||||||
? createWildcardRegExp(entry) : CamelHumpMatcher::createCamelHumpRegExp(entry);
|
|
||||||
|
|
||||||
|
const QRegularExpression regexp = createRegExp(entry);
|
||||||
if (!regexp.isValid())
|
if (!regexp.isValid())
|
||||||
return goodEntries;
|
return goodEntries;
|
||||||
|
|
||||||
|
@@ -67,9 +67,7 @@ QList<Core::LocatorFilterEntry> CppCurrentDocumentFilter::matchesFor(
|
|||||||
QList<Core::LocatorFilterEntry> goodEntries;
|
QList<Core::LocatorFilterEntry> goodEntries;
|
||||||
QList<Core::LocatorFilterEntry> betterEntries;
|
QList<Core::LocatorFilterEntry> betterEntries;
|
||||||
|
|
||||||
const QRegularExpression regexp = containsWildcard(entry)
|
const QRegularExpression regexp = createRegExp(entry);
|
||||||
? createWildcardRegExp(entry) : CamelHumpMatcher::createCamelHumpRegExp(entry);
|
|
||||||
|
|
||||||
if (!regexp.isValid())
|
if (!regexp.isValid())
|
||||||
return goodEntries;
|
return goodEntries;
|
||||||
|
|
||||||
|
@@ -76,9 +76,8 @@ QList<Core::LocatorFilterEntry> CppLocatorFilter::matchesFor(
|
|||||||
const Qt::CaseSensitivity caseSensitivityForPrefix = caseSensitivity(entry);
|
const Qt::CaseSensitivity caseSensitivityForPrefix = caseSensitivity(entry);
|
||||||
bool hasColonColon = entry.contains(QLatin1String("::"));
|
bool hasColonColon = entry.contains(QLatin1String("::"));
|
||||||
const IndexItem::ItemType wanted = matchTypes();
|
const IndexItem::ItemType wanted = matchTypes();
|
||||||
const QRegularExpression regexp = containsWildcard(entry)
|
|
||||||
? createWildcardRegExp(entry) : CamelHumpMatcher::createCamelHumpRegExp(entry);
|
|
||||||
|
|
||||||
|
const QRegularExpression regexp = createRegExp(entry);
|
||||||
if (!regexp.isValid())
|
if (!regexp.isValid())
|
||||||
return goodEntries;
|
return goodEntries;
|
||||||
|
|
||||||
|
@@ -61,9 +61,8 @@ QList<Core::LocatorFilterEntry> FunctionFilter::matchesFor(
|
|||||||
QList<Core::LocatorFilterEntry> betterEntries;
|
QList<Core::LocatorFilterEntry> betterEntries;
|
||||||
QList<Core::LocatorFilterEntry> bestEntries;
|
QList<Core::LocatorFilterEntry> bestEntries;
|
||||||
const Qt::CaseSensitivity caseSensitivityForPrefix = caseSensitivity(entry);
|
const Qt::CaseSensitivity caseSensitivityForPrefix = caseSensitivity(entry);
|
||||||
const QRegularExpression regexp = containsWildcard(entry)
|
|
||||||
? createWildcardRegExp(entry) : CamelHumpMatcher::createCamelHumpRegExp(entry);
|
|
||||||
|
|
||||||
|
const QRegularExpression regexp = createRegExp(entry);
|
||||||
if (!regexp.isValid())
|
if (!regexp.isValid())
|
||||||
return goodEntries;
|
return goodEntries;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user