forked from qt-creator/qt-creator
LanguageClient: Fix current document filter
The DocumentSymbol is an hierarchical symbol format so we also need to take childrens into account when using the current document locator filter. Change-Id: I57f11e8f1781893613719102f87e5a2b2d0af941 Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
@@ -111,6 +111,15 @@ Core::LocatorFilterEntry generateLocatorEntry(const SymbolInformation &info,
|
||||
return entry;
|
||||
}
|
||||
|
||||
QList<Core::LocatorFilterEntry> generateLocatorEntries(const SymbolInformation &info,
|
||||
Core::ILocatorFilter *filter,
|
||||
const QRegularExpression ®exp)
|
||||
{
|
||||
if (!regexp.match(info.name()).hasMatch())
|
||||
return { generateLocatorEntry(info, filter) };
|
||||
return {};
|
||||
}
|
||||
|
||||
Core::LocatorFilterEntry generateLocatorEntry(const DocumentSymbol &info,
|
||||
Core::ILocatorFilter *filter)
|
||||
{
|
||||
@@ -125,6 +134,19 @@ Core::LocatorFilterEntry generateLocatorEntry(const DocumentSymbol &info,
|
||||
return entry;
|
||||
}
|
||||
|
||||
QList<Core::LocatorFilterEntry> generateLocatorEntries(const DocumentSymbol &info,
|
||||
Core::ILocatorFilter *filter,
|
||||
const QRegularExpression ®exp)
|
||||
{
|
||||
QList<Core::LocatorFilterEntry> entries;
|
||||
if (regexp.match(info.name()).hasMatch())
|
||||
entries << generateLocatorEntry(info, filter);
|
||||
const QList<DocumentSymbol> children = info.children().value_or(QList<DocumentSymbol>());
|
||||
for (const DocumentSymbol &child : children)
|
||||
entries << generateLocatorEntries(child, filter, regexp);
|
||||
return entries;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
QList<Core::LocatorFilterEntry> DocumentLocatorFilter::generateEntries(const QList<T> &list,
|
||||
const QString &filter)
|
||||
@@ -138,11 +160,8 @@ QList<Core::LocatorFilterEntry> DocumentLocatorFilter::generateEntries(const QLi
|
||||
if (!regexp.isValid())
|
||||
return entries;
|
||||
|
||||
for (const T &item : list) {
|
||||
QRegularExpressionMatch match = regexp.match(item.name());
|
||||
if (match.hasMatch())
|
||||
entries << generateLocatorEntry(item, this);
|
||||
}
|
||||
for (const T &item : list)
|
||||
entries << generateLocatorEntries(item, this, regexp);
|
||||
return entries;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user