forked from qt-creator/qt-creator
CppLocatorFilters: Remove the old matchesFor() implementation
Move the implementation of CppCurrentDocumentFilter into cpplocatorfilter.h/cpp. Rename CppLocatorFilter into CppAllSymbolsFilter to conform to the other names. Remove some unneeded intermediate classes now. Change-Id: Ia911dc826b83ba11894757fc353ff72211910ff7 Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
@@ -32,7 +32,6 @@ add_qtc_plugin(CppEditor
|
|||||||
cppcompletionassist.cpp cppcompletionassist.h
|
cppcompletionassist.cpp cppcompletionassist.h
|
||||||
cppcompletionassistprocessor.cpp cppcompletionassistprocessor.h
|
cppcompletionassistprocessor.cpp cppcompletionassistprocessor.h
|
||||||
cppcompletionassistprovider.cpp cppcompletionassistprovider.h
|
cppcompletionassistprovider.cpp cppcompletionassistprovider.h
|
||||||
cppcurrentdocumentfilter.cpp cppcurrentdocumentfilter.h
|
|
||||||
cppcursorinfo.h
|
cppcursorinfo.h
|
||||||
cppdoxygen.cpp cppdoxygen.h
|
cppdoxygen.cpp cppdoxygen.h
|
||||||
cppeditor.qrc
|
cppeditor.qrc
|
||||||
|
|||||||
@@ -1,200 +0,0 @@
|
|||||||
// Copyright (C) 2016 The Qt Company Ltd.
|
|
||||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
|
||||||
|
|
||||||
#include "cppcurrentdocumentfilter.h"
|
|
||||||
|
|
||||||
#include "cppeditorconstants.h"
|
|
||||||
#include "cppeditortr.h"
|
|
||||||
#include "cpplocatorfilter.h"
|
|
||||||
#include "cppmodelmanager.h"
|
|
||||||
|
|
||||||
#include <coreplugin/editormanager/editormanager.h>
|
|
||||||
#include <coreplugin/editormanager/ieditor.h>
|
|
||||||
#include <utils/algorithm.h>
|
|
||||||
|
|
||||||
#include <QHash>
|
|
||||||
#include <QRegularExpression>
|
|
||||||
|
|
||||||
using namespace Core;
|
|
||||||
using namespace CPlusPlus;
|
|
||||||
|
|
||||||
namespace CppEditor::Internal {
|
|
||||||
|
|
||||||
CppCurrentDocumentFilter::CppCurrentDocumentFilter()
|
|
||||||
: m_modelManager(CppModelManager::instance())
|
|
||||||
{
|
|
||||||
setId(Constants::CURRENT_DOCUMENT_FILTER_ID);
|
|
||||||
setDisplayName(Tr::tr(Constants::CURRENT_DOCUMENT_FILTER_DISPLAY_NAME));
|
|
||||||
setDescription(Tr::tr(Constants::CURRENT_DOCUMENT_FILTER_DESCRIPTION));
|
|
||||||
setDefaultShortcutString(".");
|
|
||||||
setPriority(High);
|
|
||||||
setDefaultIncludedByDefault(false);
|
|
||||||
|
|
||||||
search.setSymbolsToSearchFor(SymbolSearcher::Declarations |
|
|
||||||
SymbolSearcher::Enums |
|
|
||||||
SymbolSearcher::Functions |
|
|
||||||
SymbolSearcher::Classes);
|
|
||||||
|
|
||||||
connect(m_modelManager, &CppModelManager::documentUpdated,
|
|
||||||
this, &CppCurrentDocumentFilter::onDocumentUpdated);
|
|
||||||
connect(EditorManager::instance(), &EditorManager::currentEditorChanged,
|
|
||||||
this, &CppCurrentDocumentFilter::onCurrentEditorChanged);
|
|
||||||
connect(EditorManager::instance(), &EditorManager::editorAboutToClose,
|
|
||||||
this, &CppCurrentDocumentFilter::onEditorAboutToClose);
|
|
||||||
}
|
|
||||||
|
|
||||||
LocatorMatcherTasks CppCurrentDocumentFilter::matchers()
|
|
||||||
{
|
|
||||||
return CppEditor::cppMatchers(MatcherType::CurrentDocumentSymbols);
|
|
||||||
}
|
|
||||||
|
|
||||||
void CppCurrentDocumentFilter::makeAuxiliary()
|
|
||||||
{
|
|
||||||
setId({});
|
|
||||||
setDisplayName({});
|
|
||||||
setDefaultShortcutString({});
|
|
||||||
setEnabled(false);
|
|
||||||
setHidden(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
QList<LocatorFilterEntry> CppCurrentDocumentFilter::matchesFor(
|
|
||||||
QFutureInterface<LocatorFilterEntry> &future, const QString &entry)
|
|
||||||
{
|
|
||||||
const QRegularExpression regexp = createRegExp(entry);
|
|
||||||
if (!regexp.isValid())
|
|
||||||
return {};
|
|
||||||
|
|
||||||
struct Entry
|
|
||||||
{
|
|
||||||
LocatorFilterEntry entry;
|
|
||||||
IndexItem::Ptr info;
|
|
||||||
};
|
|
||||||
QList<Entry> goodEntries;
|
|
||||||
QList<Entry> betterEntries;
|
|
||||||
const QList<IndexItem::Ptr> items = itemsOfCurrentDocument();
|
|
||||||
for (const IndexItem::Ptr &info : items) {
|
|
||||||
if (future.isCanceled())
|
|
||||||
break;
|
|
||||||
|
|
||||||
QString matchString = info->symbolName();
|
|
||||||
if (info->type() == IndexItem::Declaration)
|
|
||||||
matchString = info->representDeclaration();
|
|
||||||
else if (info->type() == IndexItem::Function)
|
|
||||||
matchString += info->symbolType();
|
|
||||||
|
|
||||||
QRegularExpressionMatch match = regexp.match(matchString);
|
|
||||||
if (match.hasMatch()) {
|
|
||||||
const bool betterMatch = match.capturedStart() == 0;
|
|
||||||
QString name = matchString;
|
|
||||||
QString extraInfo = info->symbolScope();
|
|
||||||
if (info->type() == IndexItem::Function) {
|
|
||||||
if (info->unqualifiedNameAndScope(matchString, &name, &extraInfo)) {
|
|
||||||
name += info->symbolType();
|
|
||||||
match = regexp.match(name);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
LocatorFilterEntry filterEntry;
|
|
||||||
filterEntry.displayName = name;
|
|
||||||
filterEntry.displayIcon = info->icon();
|
|
||||||
filterEntry.linkForEditor = {info->filePath(), info->line(), info->column()};
|
|
||||||
filterEntry.extraInfo = extraInfo;
|
|
||||||
if (match.hasMatch()) {
|
|
||||||
filterEntry.highlightInfo = highlightInfo(match);
|
|
||||||
} else {
|
|
||||||
match = regexp.match(extraInfo);
|
|
||||||
filterEntry.highlightInfo =
|
|
||||||
highlightInfo(match, LocatorFilterEntry::HighlightInfo::ExtraInfo);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (betterMatch)
|
|
||||||
betterEntries.append({filterEntry, info});
|
|
||||||
else
|
|
||||||
goodEntries.append({filterEntry, info});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// entries are unsorted by design!
|
|
||||||
betterEntries += goodEntries;
|
|
||||||
|
|
||||||
QHash<QString, QList<Entry>> possibleDuplicates;
|
|
||||||
for (const Entry &e : std::as_const(betterEntries))
|
|
||||||
possibleDuplicates[e.info->scopedSymbolName() + e.info->symbolType()] << e;
|
|
||||||
for (auto it = possibleDuplicates.cbegin(); it != possibleDuplicates.cend(); ++it) {
|
|
||||||
const QList<Entry> &duplicates = it.value();
|
|
||||||
if (duplicates.size() == 1)
|
|
||||||
continue;
|
|
||||||
QList<Entry> declarations;
|
|
||||||
QList<Entry> definitions;
|
|
||||||
for (const Entry &candidate : duplicates) {
|
|
||||||
const IndexItem::Ptr info = candidate.info;
|
|
||||||
if (info->type() != IndexItem::Function)
|
|
||||||
break;
|
|
||||||
if (info->isFunctionDefinition())
|
|
||||||
definitions << candidate;
|
|
||||||
else
|
|
||||||
declarations << candidate;
|
|
||||||
}
|
|
||||||
if (definitions.size() == 1
|
|
||||||
&& declarations.size() + definitions.size() == duplicates.size()) {
|
|
||||||
for (const Entry &decl : std::as_const(declarations)) {
|
|
||||||
Utils::erase(betterEntries, [&decl](const Entry &e) {
|
|
||||||
return e.info == decl.info;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return Utils::transform(betterEntries, [](const Entry &entry) { return entry.entry; });
|
|
||||||
}
|
|
||||||
|
|
||||||
void CppCurrentDocumentFilter::onDocumentUpdated(Document::Ptr doc)
|
|
||||||
{
|
|
||||||
QMutexLocker locker(&m_mutex);
|
|
||||||
if (m_currentFileName == doc->filePath())
|
|
||||||
m_itemsOfCurrentDoc.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
void CppCurrentDocumentFilter::onCurrentEditorChanged(IEditor *currentEditor)
|
|
||||||
{
|
|
||||||
QMutexLocker locker(&m_mutex);
|
|
||||||
if (currentEditor)
|
|
||||||
m_currentFileName = currentEditor->document()->filePath();
|
|
||||||
else
|
|
||||||
m_currentFileName.clear();
|
|
||||||
m_itemsOfCurrentDoc.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
void CppCurrentDocumentFilter::onEditorAboutToClose(IEditor *editorAboutToClose)
|
|
||||||
{
|
|
||||||
if (!editorAboutToClose)
|
|
||||||
return;
|
|
||||||
|
|
||||||
QMutexLocker locker(&m_mutex);
|
|
||||||
if (m_currentFileName == editorAboutToClose->document()->filePath()) {
|
|
||||||
m_currentFileName.clear();
|
|
||||||
m_itemsOfCurrentDoc.clear();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
QList<IndexItem::Ptr> CppCurrentDocumentFilter::itemsOfCurrentDocument()
|
|
||||||
{
|
|
||||||
QMutexLocker locker(&m_mutex);
|
|
||||||
|
|
||||||
if (m_currentFileName.isEmpty())
|
|
||||||
return QList<IndexItem::Ptr>();
|
|
||||||
|
|
||||||
if (m_itemsOfCurrentDoc.isEmpty()) {
|
|
||||||
const Snapshot snapshot = m_modelManager->snapshot();
|
|
||||||
if (const Document::Ptr thisDocument = snapshot.document(m_currentFileName)) {
|
|
||||||
IndexItem::Ptr rootNode = search(thisDocument);
|
|
||||||
rootNode->visitAllChildren([&](const IndexItem::Ptr &info) {
|
|
||||||
m_itemsOfCurrentDoc.append(info);
|
|
||||||
return IndexItem::Recurse;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return m_itemsOfCurrentDoc;
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace CppEditor::Internal
|
|
||||||
@@ -1,48 +0,0 @@
|
|||||||
// Copyright (C) 2016 The Qt Company Ltd.
|
|
||||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include "searchsymbols.h"
|
|
||||||
|
|
||||||
#include <coreplugin/locator/ilocatorfilter.h>
|
|
||||||
|
|
||||||
namespace Core { class IEditor; }
|
|
||||||
|
|
||||||
namespace CppEditor {
|
|
||||||
|
|
||||||
class CppModelManager;
|
|
||||||
|
|
||||||
namespace Internal {
|
|
||||||
|
|
||||||
// TODO: Move the class into cpplocatorfilter.h
|
|
||||||
class CppCurrentDocumentFilter : public Core::ILocatorFilter
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
public:
|
|
||||||
explicit CppCurrentDocumentFilter();
|
|
||||||
~CppCurrentDocumentFilter() override = default;
|
|
||||||
|
|
||||||
void makeAuxiliary();
|
|
||||||
|
|
||||||
QList<Core::LocatorFilterEntry> matchesFor(QFutureInterface<Core::LocatorFilterEntry> &future,
|
|
||||||
const QString &entry) override;
|
|
||||||
private:
|
|
||||||
Core::LocatorMatcherTasks matchers() final;
|
|
||||||
void onDocumentUpdated(CPlusPlus::Document::Ptr doc);
|
|
||||||
void onCurrentEditorChanged(Core::IEditor *currentEditor);
|
|
||||||
void onEditorAboutToClose(Core::IEditor *currentEditor);
|
|
||||||
|
|
||||||
QList<IndexItem::Ptr> itemsOfCurrentDocument();
|
|
||||||
|
|
||||||
CppModelManager * m_modelManager;
|
|
||||||
SearchSymbols search;
|
|
||||||
|
|
||||||
mutable QMutex m_mutex;
|
|
||||||
Utils::FilePath m_currentFileName;
|
|
||||||
QList<IndexItem::Ptr> m_itemsOfCurrentDoc;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace Internal
|
|
||||||
} // namespace CppEditor
|
|
||||||
@@ -82,8 +82,6 @@ QtcPlugin {
|
|||||||
"cppcompletionassistprocessor.h",
|
"cppcompletionassistprocessor.h",
|
||||||
"cppcompletionassistprovider.cpp",
|
"cppcompletionassistprovider.cpp",
|
||||||
"cppcompletionassistprovider.h",
|
"cppcompletionassistprovider.h",
|
||||||
"cppcurrentdocumentfilter.cpp",
|
|
||||||
"cppcurrentdocumentfilter.h",
|
|
||||||
"cppcursorinfo.h",
|
"cppcursorinfo.h",
|
||||||
"cppdoxygen.cpp",
|
"cppdoxygen.cpp",
|
||||||
"cppdoxygen.h",
|
"cppdoxygen.h",
|
||||||
|
|||||||
@@ -332,7 +332,7 @@ LocatorMatcherTasks cppMatchers(MatcherType type)
|
|||||||
return {creator()};
|
return {creator()};
|
||||||
}
|
}
|
||||||
|
|
||||||
CppLocatorFilter::CppLocatorFilter()
|
CppAllSymbolsFilter::CppAllSymbolsFilter()
|
||||||
{
|
{
|
||||||
setId(Constants::LOCATOR_FILTER_ID);
|
setId(Constants::LOCATOR_FILTER_ID);
|
||||||
setDisplayName(Tr::tr(Constants::LOCATOR_FILTER_DISPLAY_NAME));
|
setDisplayName(Tr::tr(Constants::LOCATOR_FILTER_DISPLAY_NAME));
|
||||||
@@ -341,99 +341,11 @@ CppLocatorFilter::CppLocatorFilter()
|
|||||||
setDefaultIncludedByDefault(false);
|
setDefaultIncludedByDefault(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
LocatorMatcherTasks CppLocatorFilter::matchers()
|
LocatorMatcherTasks CppAllSymbolsFilter::matchers()
|
||||||
{
|
{
|
||||||
return {allSymbolsMatcher()};
|
return {allSymbolsMatcher()};
|
||||||
}
|
}
|
||||||
|
|
||||||
LocatorFilterEntry CppLocatorFilter::filterEntryFromIndexItem(IndexItem::Ptr info)
|
|
||||||
{
|
|
||||||
LocatorFilterEntry filterEntry;
|
|
||||||
filterEntry.displayName = info->scopedSymbolName();
|
|
||||||
filterEntry.displayIcon = info->icon();
|
|
||||||
filterEntry.linkForEditor = {info->filePath(), info->line(), info->column()};
|
|
||||||
if (info->type() == IndexItem::Class || info->type() == IndexItem::Enum)
|
|
||||||
filterEntry.extraInfo = info->shortNativeFilePath();
|
|
||||||
else
|
|
||||||
filterEntry.extraInfo = info->symbolType();
|
|
||||||
|
|
||||||
return filterEntry;
|
|
||||||
}
|
|
||||||
|
|
||||||
QList<LocatorFilterEntry> CppLocatorFilter::matchesFor(
|
|
||||||
QFutureInterface<LocatorFilterEntry> &future, const QString &entry)
|
|
||||||
{
|
|
||||||
QList<LocatorFilterEntry> entries[int(MatchLevel::Count)];
|
|
||||||
const Qt::CaseSensitivity caseSensitivityForPrefix = caseSensitivity(entry);
|
|
||||||
const IndexItem::ItemType wanted = matchTypes();
|
|
||||||
|
|
||||||
const QRegularExpression regexp = createRegExp(entry);
|
|
||||||
if (!regexp.isValid())
|
|
||||||
return {};
|
|
||||||
const bool hasColonColon = entry.contains("::");
|
|
||||||
const QRegularExpression shortRegexp =
|
|
||||||
hasColonColon ? createRegExp(entry.mid(entry.lastIndexOf("::") + 2)) : regexp;
|
|
||||||
|
|
||||||
CppLocatorData *locatorData = CppModelManager::instance()->locatorData();
|
|
||||||
locatorData->filterAllFiles([&](const IndexItem::Ptr &info) -> IndexItem::VisitorResult {
|
|
||||||
if (future.isCanceled())
|
|
||||||
return IndexItem::Break;
|
|
||||||
const IndexItem::ItemType type = info->type();
|
|
||||||
if (type & wanted) {
|
|
||||||
const QString symbolName = info->symbolName();
|
|
||||||
QString matchString = hasColonColon ? info->scopedSymbolName() : symbolName;
|
|
||||||
int matchOffset = hasColonColon ? matchString.size() - symbolName.size() : 0;
|
|
||||||
QRegularExpressionMatch match = regexp.match(matchString);
|
|
||||||
bool matchInParameterList = false;
|
|
||||||
if (!match.hasMatch() && (type == IndexItem::Function)) {
|
|
||||||
matchString += info->symbolType();
|
|
||||||
match = regexp.match(matchString);
|
|
||||||
matchInParameterList = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (match.hasMatch()) {
|
|
||||||
LocatorFilterEntry filterEntry = filterEntryFromIndexItem(info);
|
|
||||||
|
|
||||||
// Highlight the matched characters, therefore it may be necessary
|
|
||||||
// to update the match if the displayName is different from matchString
|
|
||||||
if (QStringView(matchString).mid(matchOffset) != filterEntry.displayName) {
|
|
||||||
match = shortRegexp.match(filterEntry.displayName);
|
|
||||||
matchOffset = 0;
|
|
||||||
}
|
|
||||||
filterEntry.highlightInfo = highlightInfo(match);
|
|
||||||
if (matchInParameterList && filterEntry.highlightInfo.startsDisplay.isEmpty()) {
|
|
||||||
match = regexp.match(filterEntry.extraInfo);
|
|
||||||
filterEntry.highlightInfo
|
|
||||||
= highlightInfo(match, LocatorFilterEntry::HighlightInfo::ExtraInfo);
|
|
||||||
} else if (matchOffset > 0) {
|
|
||||||
for (int &start : filterEntry.highlightInfo.startsDisplay)
|
|
||||||
start -= matchOffset;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (matchInParameterList)
|
|
||||||
entries[int(MatchLevel::Normal)].append(filterEntry);
|
|
||||||
else if (filterEntry.displayName.startsWith(entry, caseSensitivityForPrefix))
|
|
||||||
entries[int(MatchLevel::Best)].append(filterEntry);
|
|
||||||
else if (filterEntry.displayName.contains(entry, caseSensitivityForPrefix))
|
|
||||||
entries[int(MatchLevel::Better)].append(filterEntry);
|
|
||||||
else
|
|
||||||
entries[int(MatchLevel::Good)].append(filterEntry);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (info->type() & IndexItem::Enum)
|
|
||||||
return IndexItem::Continue;
|
|
||||||
else
|
|
||||||
return IndexItem::Recurse;
|
|
||||||
});
|
|
||||||
|
|
||||||
for (auto &entry : entries) {
|
|
||||||
if (entry.size() < 1000)
|
|
||||||
Utils::sort(entry, LocatorFilterEntry::compareLexigraphically);
|
|
||||||
}
|
|
||||||
|
|
||||||
return std::accumulate(std::begin(entries), std::end(entries), QList<LocatorFilterEntry>());
|
|
||||||
}
|
|
||||||
|
|
||||||
CppClassesFilter::CppClassesFilter()
|
CppClassesFilter::CppClassesFilter()
|
||||||
{
|
{
|
||||||
@@ -449,19 +361,6 @@ LocatorMatcherTasks CppClassesFilter::matchers()
|
|||||||
return {classMatcher()};
|
return {classMatcher()};
|
||||||
}
|
}
|
||||||
|
|
||||||
LocatorFilterEntry CppClassesFilter::filterEntryFromIndexItem(IndexItem::Ptr info)
|
|
||||||
{
|
|
||||||
LocatorFilterEntry filterEntry;
|
|
||||||
filterEntry.displayName = info->symbolName();
|
|
||||||
filterEntry.displayIcon = info->icon();
|
|
||||||
filterEntry.linkForEditor = {info->filePath(), info->line(), info->column()};
|
|
||||||
filterEntry.extraInfo = info->symbolScope().isEmpty()
|
|
||||||
? info->shortNativeFilePath()
|
|
||||||
: info->symbolScope();
|
|
||||||
filterEntry.filePath = info->filePath();
|
|
||||||
return filterEntry;
|
|
||||||
}
|
|
||||||
|
|
||||||
CppFunctionsFilter::CppFunctionsFilter()
|
CppFunctionsFilter::CppFunctionsFilter()
|
||||||
{
|
{
|
||||||
setId(Constants::FUNCTIONS_FILTER_ID);
|
setId(Constants::FUNCTIONS_FILTER_ID);
|
||||||
@@ -476,24 +375,19 @@ LocatorMatcherTasks CppFunctionsFilter::matchers()
|
|||||||
return {functionMatcher()};
|
return {functionMatcher()};
|
||||||
}
|
}
|
||||||
|
|
||||||
LocatorFilterEntry CppFunctionsFilter::filterEntryFromIndexItem(IndexItem::Ptr info)
|
CppCurrentDocumentFilter::CppCurrentDocumentFilter()
|
||||||
{
|
{
|
||||||
QString name = info->symbolName();
|
setId(Constants::CURRENT_DOCUMENT_FILTER_ID);
|
||||||
QString extraInfo = info->symbolScope();
|
setDisplayName(Tr::tr(Constants::CURRENT_DOCUMENT_FILTER_DISPLAY_NAME));
|
||||||
info->unqualifiedNameAndScope(name, &name, &extraInfo);
|
setDescription(Tr::tr(Constants::CURRENT_DOCUMENT_FILTER_DESCRIPTION));
|
||||||
if (extraInfo.isEmpty()) {
|
setDefaultShortcutString(".");
|
||||||
extraInfo = info->shortNativeFilePath();
|
setPriority(High);
|
||||||
} else {
|
setDefaultIncludedByDefault(false);
|
||||||
extraInfo.append(" (" + info->filePath().fileName() + ')');
|
}
|
||||||
}
|
|
||||||
|
|
||||||
LocatorFilterEntry filterEntry;
|
LocatorMatcherTasks CppCurrentDocumentFilter::matchers()
|
||||||
filterEntry.displayName = name + info->symbolType();
|
{
|
||||||
filterEntry.displayIcon = info->icon();
|
return {currentDocumentMatcher()};
|
||||||
filterEntry.linkForEditor = {info->filePath(), info->line(), info->column()};
|
|
||||||
filterEntry.extraInfo = extraInfo;
|
|
||||||
|
|
||||||
return filterEntry;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace CppEditor
|
} // namespace CppEditor
|
||||||
|
|||||||
@@ -4,7 +4,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "cppeditor_global.h"
|
#include "cppeditor_global.h"
|
||||||
#include "indexitem.h"
|
|
||||||
|
|
||||||
#include <coreplugin/locator/ilocatorfilter.h>
|
#include <coreplugin/locator/ilocatorfilter.h>
|
||||||
|
|
||||||
@@ -12,50 +11,37 @@ namespace CppEditor {
|
|||||||
|
|
||||||
Core::LocatorMatcherTasks CPPEDITOR_EXPORT cppMatchers(Core::MatcherType type);
|
Core::LocatorMatcherTasks CPPEDITOR_EXPORT cppMatchers(Core::MatcherType type);
|
||||||
|
|
||||||
class CPPEDITOR_EXPORT CppLocatorFilter : public Core::ILocatorFilter
|
class CppAllSymbolsFilter : public Core::ILocatorFilter
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit CppLocatorFilter();
|
CppAllSymbolsFilter();
|
||||||
|
|
||||||
QList<Core::LocatorFilterEntry> matchesFor(QFutureInterface<Core::LocatorFilterEntry> &future,
|
|
||||||
const QString &entry) override;
|
|
||||||
protected:
|
|
||||||
virtual IndexItem::ItemType matchTypes() const { return IndexItem::All; }
|
|
||||||
virtual Core::LocatorFilterEntry filterEntryFromIndexItem(IndexItem::Ptr info);
|
|
||||||
|
|
||||||
private:
|
|
||||||
Core::LocatorMatcherTasks matchers() override;
|
|
||||||
};
|
|
||||||
|
|
||||||
// TODO: Don't derive, flatten the hierarchy
|
|
||||||
class CPPEDITOR_EXPORT CppClassesFilter : public CppLocatorFilter
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
public:
|
|
||||||
explicit CppClassesFilter();
|
|
||||||
|
|
||||||
protected:
|
|
||||||
IndexItem::ItemType matchTypes() const override { return IndexItem::Class; }
|
|
||||||
Core::LocatorFilterEntry filterEntryFromIndexItem(IndexItem::Ptr info) override;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Core::LocatorMatcherTasks matchers() final;
|
Core::LocatorMatcherTasks matchers() final;
|
||||||
};
|
};
|
||||||
|
|
||||||
// TODO: Don't derive, flatten the hierarchy
|
class CppClassesFilter : public Core::ILocatorFilter
|
||||||
class CPPEDITOR_EXPORT CppFunctionsFilter : public CppLocatorFilter
|
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit CppFunctionsFilter();
|
CppClassesFilter();
|
||||||
|
|
||||||
protected:
|
private:
|
||||||
IndexItem::ItemType matchTypes() const override { return IndexItem::Function; }
|
Core::LocatorMatcherTasks matchers() final;
|
||||||
Core::LocatorFilterEntry filterEntryFromIndexItem(IndexItem::Ptr info) override;
|
};
|
||||||
|
|
||||||
|
class CppFunctionsFilter : public Core::ILocatorFilter
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
CppFunctionsFilter();
|
||||||
|
|
||||||
|
private:
|
||||||
|
Core::LocatorMatcherTasks matchers() final;
|
||||||
|
};
|
||||||
|
|
||||||
|
class CppCurrentDocumentFilter : public Core::ILocatorFilter
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
CppCurrentDocumentFilter();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Core::LocatorMatcherTasks matchers() final;
|
Core::LocatorMatcherTasks matchers() final;
|
||||||
|
|||||||
@@ -6,10 +6,10 @@
|
|||||||
#include "abstracteditorsupport.h"
|
#include "abstracteditorsupport.h"
|
||||||
#include "baseeditordocumentprocessor.h"
|
#include "baseeditordocumentprocessor.h"
|
||||||
#include "compileroptionsbuilder.h"
|
#include "compileroptionsbuilder.h"
|
||||||
|
#include "cppbuiltinmodelmanagersupport.h"
|
||||||
#include "cppcanonicalsymbol.h"
|
#include "cppcanonicalsymbol.h"
|
||||||
#include "cppcodemodelinspectordumper.h"
|
#include "cppcodemodelinspectordumper.h"
|
||||||
#include "cppcodemodelsettings.h"
|
#include "cppcodemodelsettings.h"
|
||||||
#include "cppcurrentdocumentfilter.h"
|
|
||||||
#include "cppeditorconstants.h"
|
#include "cppeditorconstants.h"
|
||||||
#include "cppeditortr.h"
|
#include "cppeditortr.h"
|
||||||
#include "cppfindreferences.h"
|
#include "cppfindreferences.h"
|
||||||
@@ -17,7 +17,6 @@
|
|||||||
#include "cppindexingsupport.h"
|
#include "cppindexingsupport.h"
|
||||||
#include "cpplocatordata.h"
|
#include "cpplocatordata.h"
|
||||||
#include "cpplocatorfilter.h"
|
#include "cpplocatorfilter.h"
|
||||||
#include "cppbuiltinmodelmanagersupport.h"
|
|
||||||
#include "cppprojectfile.h"
|
#include "cppprojectfile.h"
|
||||||
#include "cppsourceprocessor.h"
|
#include "cppsourceprocessor.h"
|
||||||
#include "cpptoolsjsextension.h"
|
#include "cpptoolsjsextension.h"
|
||||||
@@ -890,7 +889,7 @@ void CppModelManager::initCppTools()
|
|||||||
&d->m_locatorData, &CppLocatorData::onAboutToRemoveFiles);
|
&d->m_locatorData, &CppLocatorData::onAboutToRemoveFiles);
|
||||||
|
|
||||||
// Set up builtin filters
|
// Set up builtin filters
|
||||||
setLocatorFilter(std::make_unique<CppLocatorFilter>());
|
setLocatorFilter(std::make_unique<CppAllSymbolsFilter>());
|
||||||
setClassesFilter(std::make_unique<CppClassesFilter>());
|
setClassesFilter(std::make_unique<CppClassesFilter>());
|
||||||
setIncludesFilter(std::make_unique<CppIncludesFilter>());
|
setIncludesFilter(std::make_unique<CppIncludesFilter>());
|
||||||
setFunctionsFilter(std::make_unique<CppFunctionsFilter>());
|
setFunctionsFilter(std::make_unique<CppFunctionsFilter>());
|
||||||
|
|||||||
Reference in New Issue
Block a user