forked from qt-creator/qt-creator
Core: Merge Find and Locator into Core plugin
Change-Id: I7053310272235d854c9f409670ff52a10a7add8b Reviewed-by: Christian Kandeler <christian.kandeler@digia.com> Reviewed-by: Orgad Shaneh <orgads@gmail.com> Reviewed-by: Eike Ziller <eike.ziller@digia.com>
This commit is contained in:
@@ -92,7 +92,7 @@ public:
|
||||
~BuiltinSymbolSearcher()
|
||||
{}
|
||||
|
||||
void runSearch(QFutureInterface<Find::SearchResultItem> &future)
|
||||
void runSearch(QFutureInterface<Core::SearchResultItem> &future)
|
||||
{
|
||||
future.setProgressRange(0, m_snapshot.size());
|
||||
future.setProgressValue(0);
|
||||
@@ -102,11 +102,11 @@ public:
|
||||
search.setSymbolsToSearchFor(m_parameters.types);
|
||||
CPlusPlus::Snapshot::const_iterator it = m_snapshot.begin();
|
||||
|
||||
QString findString = (m_parameters.flags & Find::FindRegularExpression
|
||||
QString findString = (m_parameters.flags & Core::FindRegularExpression
|
||||
? m_parameters.text : QRegExp::escape(m_parameters.text));
|
||||
if (m_parameters.flags & Find::FindWholeWords)
|
||||
if (m_parameters.flags & Core::FindWholeWords)
|
||||
findString = QString::fromLatin1("\\b%1\\b").arg(findString);
|
||||
QRegExp matcher(findString, (m_parameters.flags & Find::FindCaseSensitively
|
||||
QRegExp matcher(findString, (m_parameters.flags & Core::FindCaseSensitively
|
||||
? Qt::CaseSensitive : Qt::CaseInsensitive));
|
||||
while (it != m_snapshot.end()) {
|
||||
if (future.isPaused())
|
||||
@@ -114,7 +114,7 @@ public:
|
||||
if (future.isCanceled())
|
||||
break;
|
||||
if (m_fileNames.isEmpty() || m_fileNames.contains(it.value()->fileName())) {
|
||||
QVector<Find::SearchResultItem> resultItems;
|
||||
QVector<Core::SearchResultItem> resultItems;
|
||||
QList<ModelItemInfo> modelInfos = search(it.value());
|
||||
foreach (const ModelItemInfo &info, modelInfos) {
|
||||
int index = matcher.indexIn(info.symbolName);
|
||||
@@ -130,7 +130,7 @@ public:
|
||||
info.symbolType);
|
||||
}
|
||||
|
||||
Find::SearchResultItem item;
|
||||
Core::SearchResultItem item;
|
||||
item.path = scope.split(QLatin1String("::"), QString::SkipEmptyParts);
|
||||
item.text = text;
|
||||
item.textMarkPos = -1;
|
||||
|
||||
@@ -50,10 +50,10 @@ QList<QList<CppTools::ModelItemInfo> > CppClassesFilter::itemsToMatchUserInputAg
|
||||
return QList<QList<CppTools::ModelItemInfo> >() << m_data->classes();
|
||||
}
|
||||
|
||||
Locator::FilterEntry CppClassesFilter::filterEntryFromModelItemInfo(const ModelItemInfo &info)
|
||||
Core::LocatorFilterEntry CppClassesFilter::filterEntryFromModelItemInfo(const ModelItemInfo &info)
|
||||
{
|
||||
const QVariant id = qVariantFromValue(info);
|
||||
Locator::FilterEntry filterEntry(this, info.symbolName, id, info.icon);
|
||||
Core::LocatorFilterEntry filterEntry(this, info.symbolName, id, info.icon);
|
||||
filterEntry.extraInfo = info.symbolScope.isEmpty()
|
||||
? info.shortNativeFilePath()
|
||||
: info.symbolScope;
|
||||
|
||||
@@ -46,7 +46,7 @@ public:
|
||||
|
||||
private:
|
||||
QList<QList<CppTools::ModelItemInfo> > itemsToMatchUserInputAgainst() const;
|
||||
Locator::FilterEntry filterEntryFromModelItemInfo(const ModelItemInfo &info);
|
||||
Core::LocatorFilterEntry filterEntryFromModelItemInfo(const ModelItemInfo &info);
|
||||
};
|
||||
|
||||
} // namespace CppTools
|
||||
|
||||
@@ -57,11 +57,11 @@ CppCurrentDocumentFilter::CppCurrentDocumentFilter(CppModelManager *manager)
|
||||
this, SLOT(onEditorAboutToClose(Core::IEditor*)));
|
||||
}
|
||||
|
||||
QList<Locator::FilterEntry> CppCurrentDocumentFilter::matchesFor(QFutureInterface<Locator::FilterEntry> &future, const QString & origEntry)
|
||||
QList<Core::LocatorFilterEntry> CppCurrentDocumentFilter::matchesFor(QFutureInterface<Core::LocatorFilterEntry> &future, const QString & origEntry)
|
||||
{
|
||||
QString entry = trimWildcards(origEntry);
|
||||
QList<Locator::FilterEntry> goodEntries;
|
||||
QList<Locator::FilterEntry> betterEntries;
|
||||
QList<Core::LocatorFilterEntry> goodEntries;
|
||||
QList<Core::LocatorFilterEntry> betterEntries;
|
||||
QStringMatcher matcher(entry, Qt::CaseInsensitive);
|
||||
const QChar asterisk = QLatin1Char('*');
|
||||
QRegExp regexp(asterisk + entry + asterisk, Qt::CaseInsensitive, QRegExp::Wildcard);
|
||||
@@ -102,7 +102,7 @@ QList<Locator::FilterEntry> CppCurrentDocumentFilter::matchesFor(QFutureInterfac
|
||||
if (info.unqualifiedNameAndScope(matchString, &name, &extraInfo))
|
||||
name += info.symbolType;
|
||||
}
|
||||
Locator::FilterEntry filterEntry(this, name, id, info.icon);
|
||||
Core::LocatorFilterEntry filterEntry(this, name, id, info.icon);
|
||||
filterEntry.extraInfo = extraInfo;
|
||||
|
||||
if (matchString.startsWith(entry, caseSensitivityForPrefix))
|
||||
@@ -118,7 +118,7 @@ QList<Locator::FilterEntry> CppCurrentDocumentFilter::matchesFor(QFutureInterfac
|
||||
return betterEntries;
|
||||
}
|
||||
|
||||
void CppCurrentDocumentFilter::accept(Locator::FilterEntry selection) const
|
||||
void CppCurrentDocumentFilter::accept(Core::LocatorFilterEntry selection) const
|
||||
{
|
||||
ModelItemInfo info = qvariant_cast<CppTools::ModelItemInfo>(selection.internalData);
|
||||
Core::EditorManager::openEditorAt(info.fileName, info.line, info.column);
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
|
||||
#include "searchsymbols.h"
|
||||
|
||||
#include <locator/ilocatorfilter.h>
|
||||
#include <coreplugin/locator/ilocatorfilter.h>
|
||||
|
||||
namespace Core { class IEditor; }
|
||||
|
||||
@@ -40,7 +40,7 @@ namespace Internal {
|
||||
|
||||
class CppModelManager;
|
||||
|
||||
class CppCurrentDocumentFilter : public Locator::ILocatorFilter
|
||||
class CppCurrentDocumentFilter : public Core::ILocatorFilter
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
@@ -48,8 +48,8 @@ public:
|
||||
explicit CppCurrentDocumentFilter(CppModelManager *manager);
|
||||
~CppCurrentDocumentFilter() {}
|
||||
|
||||
QList<Locator::FilterEntry> matchesFor(QFutureInterface<Locator::FilterEntry> &future, const QString &entry);
|
||||
void accept(Locator::FilterEntry selection) const;
|
||||
QList<Core::LocatorFilterEntry> matchesFor(QFutureInterface<Core::LocatorFilterEntry> &future, const QString &entry);
|
||||
void accept(Core::LocatorFilterEntry selection) const;
|
||||
void refresh(QFutureInterface<void> &future);
|
||||
|
||||
private slots:
|
||||
|
||||
@@ -325,15 +325,15 @@ void CppFindReferences::findUsages(CPlusPlus::Symbol *symbol,
|
||||
bool replace)
|
||||
{
|
||||
Overview overview;
|
||||
Find::SearchResult *search = Find::SearchResultWindow::instance()->startNewSearch(tr("C++ Usages:"),
|
||||
Core::SearchResult *search = Core::SearchResultWindow::instance()->startNewSearch(tr("C++ Usages:"),
|
||||
QString(),
|
||||
overview.prettyName(context.fullyQualifiedName(symbol)),
|
||||
replace ? Find::SearchResultWindow::SearchAndReplace
|
||||
: Find::SearchResultWindow::SearchOnly,
|
||||
replace ? Core::SearchResultWindow::SearchAndReplace
|
||||
: Core::SearchResultWindow::SearchOnly,
|
||||
QLatin1String("CppEditor"));
|
||||
search->setTextToReplace(replacement);
|
||||
connect(search, SIGNAL(replaceButtonClicked(QString,QList<Find::SearchResultItem>,bool)),
|
||||
SLOT(onReplaceButtonClicked(QString,QList<Find::SearchResultItem>,bool)));
|
||||
connect(search, SIGNAL(replaceButtonClicked(QString,QList<Core::SearchResultItem>,bool)),
|
||||
SLOT(onReplaceButtonClicked(QString,QList<Core::SearchResultItem>,bool)));
|
||||
connect(search, SIGNAL(paused(bool)), this, SLOT(setPaused(bool)));
|
||||
search->setSearchAgainSupported(true);
|
||||
connect(search, SIGNAL(searchAgainRequested()), this, SLOT(searchAgain()));
|
||||
@@ -354,7 +354,7 @@ void CppFindReferences::renameUsages(CPlusPlus::Symbol *symbol, const CPlusPlus:
|
||||
}
|
||||
}
|
||||
|
||||
void CppFindReferences::findAll_helper(Find::SearchResult *search, CPlusPlus::Symbol *symbol,
|
||||
void CppFindReferences::findAll_helper(Core::SearchResult *search, CPlusPlus::Symbol *symbol,
|
||||
const CPlusPlus::LookupContext &context)
|
||||
{
|
||||
if (!(symbol && symbol->identifier())) {
|
||||
@@ -362,10 +362,10 @@ void CppFindReferences::findAll_helper(Find::SearchResult *search, CPlusPlus::Sy
|
||||
return;
|
||||
}
|
||||
connect(search, SIGNAL(cancelled()), this, SLOT(cancel()));
|
||||
connect(search, SIGNAL(activated(Find::SearchResultItem)),
|
||||
this, SLOT(openEditor(Find::SearchResultItem)));
|
||||
connect(search, SIGNAL(activated(Core::SearchResultItem)),
|
||||
this, SLOT(openEditor(Core::SearchResultItem)));
|
||||
|
||||
Find::SearchResultWindow::instance()->popup(IOutputPane::ModeSwitch | IOutputPane::WithFocus);
|
||||
Core::SearchResultWindow::instance()->popup(IOutputPane::ModeSwitch | IOutputPane::WithFocus);
|
||||
const CppModelManagerInterface::WorkingCopy workingCopy = m_modelManager->workingCopy();
|
||||
QFuture<Usage> result;
|
||||
result = QtConcurrent::run(&find_helper, workingCopy, context, this, symbol);
|
||||
@@ -378,19 +378,19 @@ void CppFindReferences::findAll_helper(Find::SearchResult *search, CPlusPlus::Sy
|
||||
}
|
||||
|
||||
void CppFindReferences::onReplaceButtonClicked(const QString &text,
|
||||
const QList<Find::SearchResultItem> &items,
|
||||
const QList<Core::SearchResultItem> &items,
|
||||
bool preserveCase)
|
||||
{
|
||||
const QStringList fileNames = TextEditor::BaseFileFind::replaceAll(text, items, preserveCase);
|
||||
if (!fileNames.isEmpty()) {
|
||||
m_modelManager->updateSourceFiles(fileNames);
|
||||
Find::SearchResultWindow::instance()->hide();
|
||||
Core::SearchResultWindow::instance()->hide();
|
||||
}
|
||||
}
|
||||
|
||||
void CppFindReferences::searchAgain()
|
||||
{
|
||||
Find::SearchResult *search = qobject_cast<Find::SearchResult *>(sender());
|
||||
Core::SearchResult *search = qobject_cast<Core::SearchResult *>(sender());
|
||||
CppFindReferencesParameters parameters = search->userData().value<CppFindReferencesParameters>();
|
||||
Snapshot snapshot = CppModelManagerInterface::instance()->snapshot();
|
||||
search->restart();
|
||||
@@ -470,7 +470,7 @@ CPlusPlus::Symbol *CppFindReferences::findSymbol(const CppFindReferencesParamete
|
||||
void CppFindReferences::displayResults(int first, int last)
|
||||
{
|
||||
QFutureWatcher<Usage> *watcher = static_cast<QFutureWatcher<Usage> *>(sender());
|
||||
Find::SearchResult *search = m_watchers.value(watcher);
|
||||
Core::SearchResult *search = m_watchers.value(watcher);
|
||||
if (!search) {
|
||||
// search was deleted while it was running
|
||||
watcher->cancel();
|
||||
@@ -489,7 +489,7 @@ void CppFindReferences::displayResults(int first, int last)
|
||||
void CppFindReferences::searchFinished()
|
||||
{
|
||||
QFutureWatcher<Usage> *watcher = static_cast<QFutureWatcher<Usage> *>(sender());
|
||||
Find::SearchResult *search = m_watchers.value(watcher);
|
||||
Core::SearchResult *search = m_watchers.value(watcher);
|
||||
if (search)
|
||||
search->finishSearch(watcher->isCanceled());
|
||||
m_watchers.remove(watcher);
|
||||
@@ -498,7 +498,7 @@ void CppFindReferences::searchFinished()
|
||||
|
||||
void CppFindReferences::cancel()
|
||||
{
|
||||
Find::SearchResult *search = qobject_cast<Find::SearchResult *>(sender());
|
||||
Core::SearchResult *search = qobject_cast<Core::SearchResult *>(sender());
|
||||
QTC_ASSERT(search, return);
|
||||
QFutureWatcher<Usage> *watcher = m_watchers.key(search);
|
||||
QTC_ASSERT(watcher, return);
|
||||
@@ -507,7 +507,7 @@ void CppFindReferences::cancel()
|
||||
|
||||
void CppFindReferences::setPaused(bool paused)
|
||||
{
|
||||
Find::SearchResult *search = qobject_cast<Find::SearchResult *>(sender());
|
||||
Core::SearchResult *search = qobject_cast<Core::SearchResult *>(sender());
|
||||
QTC_ASSERT(search, return);
|
||||
QFutureWatcher<Usage> *watcher = m_watchers.key(search);
|
||||
QTC_ASSERT(watcher, return);
|
||||
@@ -515,7 +515,7 @@ void CppFindReferences::setPaused(bool paused)
|
||||
watcher->setPaused(paused);
|
||||
}
|
||||
|
||||
void CppFindReferences::openEditor(const Find::SearchResultItem &item)
|
||||
void CppFindReferences::openEditor(const Core::SearchResultItem &item)
|
||||
{
|
||||
if (item.path.size() > 0) {
|
||||
EditorManager::openEditorAt(QDir::fromNativeSeparators(item.path.first()),
|
||||
@@ -634,22 +634,22 @@ void CppFindReferences::findMacroUses(const Macro ¯o)
|
||||
|
||||
void CppFindReferences::findMacroUses(const Macro ¯o, const QString &replacement, bool replace)
|
||||
{
|
||||
Find::SearchResult *search = Find::SearchResultWindow::instance()->startNewSearch(
|
||||
Core::SearchResult *search = Core::SearchResultWindow::instance()->startNewSearch(
|
||||
tr("C++ Macro Usages:"),
|
||||
QString(),
|
||||
QString::fromUtf8(macro.name()),
|
||||
replace ? Find::SearchResultWindow::SearchAndReplace
|
||||
: Find::SearchResultWindow::SearchOnly,
|
||||
replace ? Core::SearchResultWindow::SearchAndReplace
|
||||
: Core::SearchResultWindow::SearchOnly,
|
||||
QLatin1String("CppEditor"));
|
||||
|
||||
search->setTextToReplace(replacement);
|
||||
connect(search, SIGNAL(replaceButtonClicked(QString,QList<Find::SearchResultItem>,bool)),
|
||||
SLOT(onReplaceButtonClicked(QString,QList<Find::SearchResultItem>,bool)));
|
||||
connect(search, SIGNAL(replaceButtonClicked(QString,QList<Core::SearchResultItem>,bool)),
|
||||
SLOT(onReplaceButtonClicked(QString,QList<Core::SearchResultItem>,bool)));
|
||||
|
||||
Find::SearchResultWindow::instance()->popup(IOutputPane::ModeSwitch | IOutputPane::WithFocus);
|
||||
Core::SearchResultWindow::instance()->popup(IOutputPane::ModeSwitch | IOutputPane::WithFocus);
|
||||
|
||||
connect(search, SIGNAL(activated(Find::SearchResultItem)),
|
||||
this, SLOT(openEditor(Find::SearchResultItem)));
|
||||
connect(search, SIGNAL(activated(Core::SearchResultItem)),
|
||||
this, SLOT(openEditor(Core::SearchResultItem)));
|
||||
connect(search, SIGNAL(cancelled()), this, SLOT(cancel()));
|
||||
connect(search, SIGNAL(paused(bool)), this, SLOT(setPaused(bool)));
|
||||
|
||||
@@ -714,7 +714,7 @@ void CppFindReferences::setDependencyTable(const CPlusPlus::DependencyTable &new
|
||||
m_deps = newTable;
|
||||
}
|
||||
|
||||
void CppFindReferences::createWatcher(const QFuture<Usage> &future, Find::SearchResult *search)
|
||||
void CppFindReferences::createWatcher(const QFuture<Usage> &future, Core::SearchResult *search)
|
||||
{
|
||||
QFutureWatcher<Usage> *watcher = new QFutureWatcher<Usage>();
|
||||
watcher->setPendingResultsLimit(1);
|
||||
|
||||
@@ -41,10 +41,10 @@
|
||||
|
||||
QT_FORWARD_DECLARE_CLASS(QTimer)
|
||||
|
||||
namespace Find {
|
||||
namespace Core {
|
||||
class SearchResultItem;
|
||||
class SearchResult;
|
||||
} // namespace Find
|
||||
} // namespace Core
|
||||
|
||||
namespace CppTools {
|
||||
class CppModelManagerInterface;
|
||||
@@ -86,8 +86,8 @@ private slots:
|
||||
void searchFinished();
|
||||
void cancel();
|
||||
void setPaused(bool paused);
|
||||
void openEditor(const Find::SearchResultItem &item);
|
||||
void onReplaceButtonClicked(const QString &text, const QList<Find::SearchResultItem> &items, bool preserveCase);
|
||||
void openEditor(const Core::SearchResultItem &item);
|
||||
void onReplaceButtonClicked(const QString &text, const QList<Core::SearchResultItem> &items, bool preserveCase);
|
||||
void searchAgain();
|
||||
|
||||
private:
|
||||
@@ -95,17 +95,17 @@ private:
|
||||
const QString &replacement, bool replace);
|
||||
void findMacroUses(const CPlusPlus::Macro ¯o, const QString &replacement,
|
||||
bool replace);
|
||||
void findAll_helper(Find::SearchResult *search, CPlusPlus::Symbol *symbol,
|
||||
void findAll_helper(Core::SearchResult *search, CPlusPlus::Symbol *symbol,
|
||||
const CPlusPlus::LookupContext &context);
|
||||
CPlusPlus::DependencyTable dependencyTable() const;
|
||||
void setDependencyTable(const CPlusPlus::DependencyTable &newTable);
|
||||
void createWatcher(const QFuture<CPlusPlus::Usage> &future, Find::SearchResult *search);
|
||||
void createWatcher(const QFuture<CPlusPlus::Usage> &future, Core::SearchResult *search);
|
||||
CPlusPlus::Symbol *findSymbol(const CppFindReferencesParameters ¶meters,
|
||||
const CPlusPlus::Snapshot &snapshot, CPlusPlus::LookupContext *context);
|
||||
|
||||
private:
|
||||
QPointer<CppModelManagerInterface> m_modelManager;
|
||||
QMap<QFutureWatcher<CPlusPlus::Usage> *, QPointer<Find::SearchResult> > m_watchers;
|
||||
QMap<QFutureWatcher<CPlusPlus::Usage> *, QPointer<Core::SearchResult> > m_watchers;
|
||||
|
||||
mutable QMutex m_depsLock;
|
||||
CPlusPlus::DependencyTable m_deps;
|
||||
|
||||
@@ -49,7 +49,7 @@ QList<QList<CppTools::ModelItemInfo> > CppFunctionsFilter::itemsToMatchUserInput
|
||||
return QList<QList<CppTools::ModelItemInfo> >() << m_data->functions();
|
||||
}
|
||||
|
||||
Locator::FilterEntry CppFunctionsFilter::filterEntryFromModelItemInfo(const CppTools::ModelItemInfo &info)
|
||||
Core::LocatorFilterEntry CppFunctionsFilter::filterEntryFromModelItemInfo(const CppTools::ModelItemInfo &info)
|
||||
{
|
||||
const QVariant id = qVariantFromValue(info);
|
||||
|
||||
@@ -59,7 +59,7 @@ Locator::FilterEntry CppFunctionsFilter::filterEntryFromModelItemInfo(const CppT
|
||||
if (extraInfo.isEmpty())
|
||||
extraInfo = info.shortNativeFilePath();
|
||||
|
||||
Locator::FilterEntry filterEntry(this, name + info.symbolType, id, info.icon);
|
||||
Core::LocatorFilterEntry filterEntry(this, name + info.symbolType, id, info.icon);
|
||||
filterEntry.extraInfo = extraInfo;
|
||||
|
||||
return filterEntry;
|
||||
|
||||
@@ -46,7 +46,7 @@ public:
|
||||
|
||||
private:
|
||||
QList<QList<ModelItemInfo> > itemsToMatchUserInputAgainst() const;
|
||||
Locator::FilterEntry filterEntryFromModelItemInfo(const ModelItemInfo &info);
|
||||
Core::LocatorFilterEntry filterEntryFromModelItemInfo(const ModelItemInfo &info);
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
|
||||
@@ -34,8 +34,8 @@
|
||||
|
||||
#include "cppmodelmanagerinterface.h"
|
||||
|
||||
#include <find/searchresultwindow.h>
|
||||
#include <find/textfindconstants.h>
|
||||
#include <coreplugin/find/searchresultwindow.h>
|
||||
#include <coreplugin/find/textfindconstants.h>
|
||||
|
||||
#include <QFuture>
|
||||
#include <QStringList>
|
||||
@@ -64,7 +64,7 @@ public:
|
||||
struct Parameters
|
||||
{
|
||||
QString text;
|
||||
Find::FindFlags flags;
|
||||
Core::FindFlags flags;
|
||||
SymbolTypes types;
|
||||
SearchScope scope;
|
||||
};
|
||||
@@ -73,7 +73,7 @@ public:
|
||||
public:
|
||||
SymbolSearcher(QObject *parent = 0);
|
||||
virtual ~SymbolSearcher() = 0;
|
||||
virtual void runSearch(QFutureInterface<Find::SearchResultItem> &future) = 0;
|
||||
virtual void runSearch(QFutureInterface<Core::SearchResultItem> &future) = 0;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -47,10 +47,10 @@ CppLocatorFilter::~CppLocatorFilter()
|
||||
{
|
||||
}
|
||||
|
||||
Locator::FilterEntry CppLocatorFilter::filterEntryFromModelItemInfo(const CppTools::ModelItemInfo &info)
|
||||
Core::LocatorFilterEntry CppLocatorFilter::filterEntryFromModelItemInfo(const CppTools::ModelItemInfo &info)
|
||||
{
|
||||
const QVariant id = qVariantFromValue(info);
|
||||
Locator::FilterEntry filterEntry(this, info.scopedSymbolName(), id, info.icon);
|
||||
Core::LocatorFilterEntry filterEntry(this, info.scopedSymbolName(), id, info.icon);
|
||||
filterEntry.extraInfo = info.type == ModelItemInfo::Class || info.type == ModelItemInfo::Enum
|
||||
? info.shortNativeFilePath()
|
||||
: info.symbolType;
|
||||
@@ -71,17 +71,17 @@ QList<QList<CppTools::ModelItemInfo> > CppLocatorFilter::itemsToMatchUserInputAg
|
||||
<< m_data->enums();
|
||||
}
|
||||
|
||||
static bool compareLexigraphically(const Locator::FilterEntry &a,
|
||||
const Locator::FilterEntry &b)
|
||||
static bool compareLexigraphically(const Core::LocatorFilterEntry &a,
|
||||
const Core::LocatorFilterEntry &b)
|
||||
{
|
||||
return a.displayName < b.displayName;
|
||||
}
|
||||
|
||||
QList<Locator::FilterEntry> CppLocatorFilter::matchesFor(QFutureInterface<Locator::FilterEntry> &future, const QString &origEntry)
|
||||
QList<Core::LocatorFilterEntry> CppLocatorFilter::matchesFor(QFutureInterface<Core::LocatorFilterEntry> &future, const QString &origEntry)
|
||||
{
|
||||
QString entry = trimWildcards(origEntry);
|
||||
QList<Locator::FilterEntry> goodEntries;
|
||||
QList<Locator::FilterEntry> betterEntries;
|
||||
QList<Core::LocatorFilterEntry> goodEntries;
|
||||
QList<Core::LocatorFilterEntry> betterEntries;
|
||||
const QChar asterisk = QLatin1Char('*');
|
||||
QStringMatcher matcher(entry, Qt::CaseInsensitive);
|
||||
QRegExp regexp(asterisk + entry+ asterisk, Qt::CaseInsensitive, QRegExp::Wildcard);
|
||||
@@ -99,7 +99,7 @@ QList<Locator::FilterEntry> CppLocatorFilter::matchesFor(QFutureInterface<Locato
|
||||
const QString matchString = hasColonColon ? info.scopedSymbolName() : info.symbolName;
|
||||
if ((hasWildcard && regexp.exactMatch(matchString))
|
||||
|| (!hasWildcard && matcher.indexIn(matchString) != -1)) {
|
||||
const Locator::FilterEntry filterEntry = filterEntryFromModelItemInfo(info);
|
||||
const Core::LocatorFilterEntry filterEntry = filterEntryFromModelItemInfo(info);
|
||||
if (matchString.startsWith(entry, caseSensitivityForPrefix))
|
||||
betterEntries.append(filterEntry);
|
||||
else
|
||||
@@ -117,7 +117,7 @@ QList<Locator::FilterEntry> CppLocatorFilter::matchesFor(QFutureInterface<Locato
|
||||
return betterEntries;
|
||||
}
|
||||
|
||||
void CppLocatorFilter::accept(Locator::FilterEntry selection) const
|
||||
void CppLocatorFilter::accept(Core::LocatorFilterEntry selection) const
|
||||
{
|
||||
ModelItemInfo info = qvariant_cast<CppTools::ModelItemInfo>(selection.internalData);
|
||||
Core::EditorManager::openEditorAt(info.fileName, info.line, info.column);
|
||||
|
||||
@@ -33,14 +33,14 @@
|
||||
#include "cpplocatordata.h"
|
||||
#include "searchsymbols.h"
|
||||
|
||||
#include <locator/ilocatorfilter.h>
|
||||
#include <coreplugin/locator/ilocatorfilter.h>
|
||||
|
||||
namespace CppTools {
|
||||
namespace Internal {
|
||||
|
||||
class CppModelManager;
|
||||
|
||||
class CppLocatorFilter : public Locator::ILocatorFilter
|
||||
class CppLocatorFilter : public Core::ILocatorFilter
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
@@ -48,13 +48,13 @@ public:
|
||||
CppLocatorFilter(CppLocatorData *locatorData);
|
||||
~CppLocatorFilter();
|
||||
|
||||
QList<Locator::FilterEntry> matchesFor(QFutureInterface<Locator::FilterEntry> &future, const QString &entry);
|
||||
void accept(Locator::FilterEntry selection) const;
|
||||
QList<Core::LocatorFilterEntry> matchesFor(QFutureInterface<Core::LocatorFilterEntry> &future, const QString &entry);
|
||||
void accept(Core::LocatorFilterEntry selection) const;
|
||||
void refresh(QFutureInterface<void> &future);
|
||||
|
||||
private:
|
||||
virtual QList<QList<ModelItemInfo> > itemsToMatchUserInputAgainst() const;
|
||||
virtual Locator::FilterEntry filterEntryFromModelItemInfo(const ModelItemInfo &info);
|
||||
virtual Core::LocatorFilterEntry filterEntryFromModelItemInfo(const ModelItemInfo &info);
|
||||
|
||||
protected:
|
||||
CppLocatorData *m_data;
|
||||
|
||||
@@ -39,7 +39,7 @@
|
||||
#include <coreplugin/editormanager/editormanager.h>
|
||||
#include <coreplugin/testdatadir.h>
|
||||
#include <extensionsystem/pluginmanager.h>
|
||||
#include <locator/locatorfiltertest.h>
|
||||
#include <coreplugin/locator/locatorfiltertest.h>
|
||||
#include <utils/fileutils.h>
|
||||
|
||||
#include <QDebug>
|
||||
@@ -50,8 +50,6 @@ using namespace Core;
|
||||
using namespace Core::Tests;
|
||||
using namespace CppTools::Internal;
|
||||
using namespace ExtensionSystem;
|
||||
using namespace Locator;
|
||||
using namespace Locator::Tests;
|
||||
using namespace Utils;
|
||||
|
||||
Q_DECLARE_METATYPE(ILocatorFilter *)
|
||||
|
||||
@@ -8,10 +8,8 @@ QtcPlugin {
|
||||
|
||||
Depends { name: "Qt.widgets" }
|
||||
Depends { name: "Core" }
|
||||
Depends { name: "Find" }
|
||||
Depends { name: "TextEditor" }
|
||||
Depends { name: "ProjectExplorer" }
|
||||
Depends { name: "Locator" }
|
||||
Depends { name: "CPlusPlus" }
|
||||
Depends { name: "LanguageUtils" }
|
||||
|
||||
|
||||
@@ -5,6 +5,4 @@ QTC_LIB_DEPENDS += \
|
||||
QTC_PLUGIN_DEPENDS += \
|
||||
coreplugin \
|
||||
projectexplorer \
|
||||
texteditor \
|
||||
locator \
|
||||
find
|
||||
texteditor
|
||||
|
||||
@@ -62,10 +62,10 @@ public:
|
||||
return m_symbolName == other.m_symbolName && m_scope == other.m_scope;
|
||||
}
|
||||
|
||||
static ResultDataList fromSearchResultList(const QList<Find::SearchResultItem> &entries)
|
||||
static ResultDataList fromSearchResultList(const QList<Core::SearchResultItem> &entries)
|
||||
{
|
||||
ResultDataList result;
|
||||
foreach (const Find::SearchResultItem &entry, entries)
|
||||
foreach (const Core::SearchResultItem &entry, entries)
|
||||
result << ResultData(entry.text, entry.path.join(QLatin1String("::")));
|
||||
return result;
|
||||
}
|
||||
@@ -108,7 +108,7 @@ public:
|
||||
CppIndexingSupport *indexingSupport = m_modelManager->indexingSupport();
|
||||
SymbolSearcher *symbolSearcher = indexingSupport->createSymbolSearcher(searchParameters,
|
||||
QSet<QString>() << testFile);
|
||||
QFuture<Find::SearchResultItem> search
|
||||
QFuture<Core::SearchResultItem> search
|
||||
= QtConcurrent::run(&SymbolSearcher::runSearch, symbolSearcher);
|
||||
search.waitForFinished();
|
||||
ResultDataList results = ResultData::fromSearchResultList(search.results());
|
||||
|
||||
@@ -84,35 +84,35 @@ bool SymbolsFindFilter::isEnabled() const
|
||||
|
||||
void SymbolsFindFilter::cancel()
|
||||
{
|
||||
Find::SearchResult *search = qobject_cast<Find::SearchResult *>(sender());
|
||||
Core::SearchResult *search = qobject_cast<Core::SearchResult *>(sender());
|
||||
QTC_ASSERT(search, return);
|
||||
QFutureWatcher<Find::SearchResultItem> *watcher = m_watchers.key(search);
|
||||
QFutureWatcher<Core::SearchResultItem> *watcher = m_watchers.key(search);
|
||||
QTC_ASSERT(watcher, return);
|
||||
watcher->cancel();
|
||||
}
|
||||
|
||||
void SymbolsFindFilter::setPaused(bool paused)
|
||||
{
|
||||
Find::SearchResult *search = qobject_cast<Find::SearchResult *>(sender());
|
||||
Core::SearchResult *search = qobject_cast<Core::SearchResult *>(sender());
|
||||
QTC_ASSERT(search, return);
|
||||
QFutureWatcher<Find::SearchResultItem> *watcher = m_watchers.key(search);
|
||||
QFutureWatcher<Core::SearchResultItem> *watcher = m_watchers.key(search);
|
||||
QTC_ASSERT(watcher, return);
|
||||
if (!paused || watcher->isRunning()) // guard against pausing when the search is finished
|
||||
watcher->setPaused(paused);
|
||||
}
|
||||
|
||||
Find::FindFlags SymbolsFindFilter::supportedFindFlags() const
|
||||
Core::FindFlags SymbolsFindFilter::supportedFindFlags() const
|
||||
{
|
||||
return Find::FindCaseSensitively | Find::FindRegularExpression | Find::FindWholeWords;
|
||||
return Core::FindCaseSensitively | Core::FindRegularExpression | Core::FindWholeWords;
|
||||
}
|
||||
|
||||
void SymbolsFindFilter::findAll(const QString &txt, Find::FindFlags findFlags)
|
||||
void SymbolsFindFilter::findAll(const QString &txt, Core::FindFlags findFlags)
|
||||
{
|
||||
Find::SearchResultWindow *window = Find::SearchResultWindow::instance();
|
||||
Find::SearchResult *search = window->startNewSearch(label(), toolTip(findFlags), txt);
|
||||
Core::SearchResultWindow *window = Core::SearchResultWindow::instance();
|
||||
Core::SearchResult *search = window->startNewSearch(label(), toolTip(findFlags), txt);
|
||||
search->setSearchAgainSupported(true);
|
||||
connect(search, SIGNAL(activated(Find::SearchResultItem)),
|
||||
this, SLOT(openEditor(Find::SearchResultItem)));
|
||||
connect(search, SIGNAL(activated(Core::SearchResultItem)),
|
||||
this, SLOT(openEditor(Core::SearchResultItem)));
|
||||
connect(search, SIGNAL(cancelled()), this, SLOT(cancel()));
|
||||
connect(search, SIGNAL(paused(bool)), this, SLOT(setPaused(bool)));
|
||||
connect(search, SIGNAL(searchAgainRequested()), this, SLOT(searchAgain()));
|
||||
@@ -128,7 +128,7 @@ void SymbolsFindFilter::findAll(const QString &txt, Find::FindFlags findFlags)
|
||||
startSearch(search);
|
||||
}
|
||||
|
||||
void SymbolsFindFilter::startSearch(Find::SearchResult *search)
|
||||
void SymbolsFindFilter::startSearch(Core::SearchResult *search)
|
||||
{
|
||||
SymbolSearcher::Parameters parameters = search->userData().value<SymbolSearcher::Parameters>();
|
||||
QSet<QString> projectFileNames;
|
||||
@@ -137,7 +137,7 @@ void SymbolsFindFilter::startSearch(Find::SearchResult *search)
|
||||
projectFileNames += project->files(ProjectExplorer::Project::AllFiles).toSet();
|
||||
}
|
||||
|
||||
QFutureWatcher<Find::SearchResultItem> *watcher = new QFutureWatcher<Find::SearchResultItem>();
|
||||
QFutureWatcher<Core::SearchResultItem> *watcher = new QFutureWatcher<Core::SearchResultItem>();
|
||||
m_watchers.insert(watcher, search);
|
||||
connect(watcher, SIGNAL(finished()),
|
||||
this, SLOT(finish()));
|
||||
@@ -148,38 +148,38 @@ void SymbolsFindFilter::startSearch(Find::SearchResult *search)
|
||||
symbolSearcher, SLOT(deleteLater()));
|
||||
watcher->setFuture(QtConcurrent::run(&SymbolSearcher::runSearch, symbolSearcher));
|
||||
FutureProgress *progress = ProgressManager::addTask(watcher->future(), tr("Searching"),
|
||||
Find::Constants::TASK_SEARCH);
|
||||
Core::Constants::TASK_SEARCH);
|
||||
connect(progress, SIGNAL(clicked()), search, SLOT(popup()));
|
||||
}
|
||||
|
||||
void SymbolsFindFilter::addResults(int begin, int end)
|
||||
{
|
||||
QFutureWatcher<Find::SearchResultItem> *watcher =
|
||||
static_cast<QFutureWatcher<Find::SearchResultItem> *>(sender());
|
||||
Find::SearchResult *search = m_watchers.value(watcher);
|
||||
QFutureWatcher<Core::SearchResultItem> *watcher =
|
||||
static_cast<QFutureWatcher<Core::SearchResultItem> *>(sender());
|
||||
Core::SearchResult *search = m_watchers.value(watcher);
|
||||
if (!search) {
|
||||
// search was removed from search history while the search is running
|
||||
watcher->cancel();
|
||||
return;
|
||||
}
|
||||
QList<Find::SearchResultItem> items;
|
||||
QList<Core::SearchResultItem> items;
|
||||
for (int i = begin; i < end; ++i)
|
||||
items << watcher->resultAt(i);
|
||||
search->addResults(items, Find::SearchResult::AddSorted);
|
||||
search->addResults(items, Core::SearchResult::AddSorted);
|
||||
}
|
||||
|
||||
void SymbolsFindFilter::finish()
|
||||
{
|
||||
QFutureWatcher<Find::SearchResultItem> *watcher =
|
||||
static_cast<QFutureWatcher<Find::SearchResultItem> *>(sender());
|
||||
Find::SearchResult *search = m_watchers.value(watcher);
|
||||
QFutureWatcher<Core::SearchResultItem> *watcher =
|
||||
static_cast<QFutureWatcher<Core::SearchResultItem> *>(sender());
|
||||
Core::SearchResult *search = m_watchers.value(watcher);
|
||||
if (search)
|
||||
search->finishSearch(watcher->isCanceled());
|
||||
m_watchers.remove(watcher);
|
||||
watcher->deleteLater();
|
||||
}
|
||||
|
||||
void SymbolsFindFilter::openEditor(const Find::SearchResultItem &item)
|
||||
void SymbolsFindFilter::openEditor(const Core::SearchResultItem &item)
|
||||
{
|
||||
if (!item.userData.canConvert<ModelItemInfo>())
|
||||
return;
|
||||
@@ -229,7 +229,7 @@ void SymbolsFindFilter::onAllTasksFinished(Core::Id type)
|
||||
|
||||
void SymbolsFindFilter::searchAgain()
|
||||
{
|
||||
Find::SearchResult *search = qobject_cast<Find::SearchResult *>(sender());
|
||||
Core::SearchResult *search = qobject_cast<Core::SearchResult *>(sender());
|
||||
QTC_ASSERT(search, return);
|
||||
search->restart();
|
||||
startSearch(search);
|
||||
@@ -240,7 +240,7 @@ QString SymbolsFindFilter::label() const
|
||||
return tr("C++ Symbols:");
|
||||
}
|
||||
|
||||
QString SymbolsFindFilter::toolTip(Find::FindFlags findFlags) const
|
||||
QString SymbolsFindFilter::toolTip(Core::FindFlags findFlags) const
|
||||
{
|
||||
QStringList types;
|
||||
if (m_symbolsToSearch & SymbolSearcher::Classes)
|
||||
@@ -254,7 +254,7 @@ QString SymbolsFindFilter::toolTip(Find::FindFlags findFlags) const
|
||||
return tr("Scope: %1\nTypes: %2\nFlags: %3")
|
||||
.arg(searchScope() == SymbolSearcher::SearchGlobal ? tr("All") : tr("Projects"))
|
||||
.arg(types.join(tr(", ")))
|
||||
.arg(Find::IFindFilter::descriptionForFindFlags(findFlags));
|
||||
.arg(Core::IFindFilter::descriptionForFindFlags(findFlags));
|
||||
}
|
||||
|
||||
// #pragma mark -- SymbolsFindFilterConfigWidget
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
|
||||
#include "searchsymbols.h"
|
||||
|
||||
#include <find/ifindfilter.h>
|
||||
#include <coreplugin/find/ifindfilter.h>
|
||||
|
||||
#include <QFutureWatcher>
|
||||
#include <QPointer>
|
||||
@@ -45,7 +45,7 @@ namespace Internal {
|
||||
|
||||
class CppModelManager;
|
||||
|
||||
class SymbolsFindFilter : public Find::IFindFilter
|
||||
class SymbolsFindFilter : public Core::IFindFilter
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
@@ -58,9 +58,9 @@ public:
|
||||
QString id() const;
|
||||
QString displayName() const;
|
||||
bool isEnabled() const;
|
||||
Find::FindFlags supportedFindFlags() const;
|
||||
Core::FindFlags supportedFindFlags() const;
|
||||
|
||||
void findAll(const QString &txt, Find::FindFlags findFlags);
|
||||
void findAll(const QString &txt, Core::FindFlags findFlags);
|
||||
|
||||
QWidget *createConfigWidget();
|
||||
void writeSettings(QSettings *settings);
|
||||
@@ -76,7 +76,7 @@ signals:
|
||||
void symbolsToSearchChanged();
|
||||
|
||||
private slots:
|
||||
void openEditor(const Find::SearchResultItem &item);
|
||||
void openEditor(const Core::SearchResultItem &item);
|
||||
|
||||
void addResults(int begin, int end);
|
||||
void finish();
|
||||
@@ -88,13 +88,13 @@ private slots:
|
||||
|
||||
private:
|
||||
QString label() const;
|
||||
QString toolTip(Find::FindFlags findFlags) const;
|
||||
void startSearch(Find::SearchResult *search);
|
||||
QString toolTip(Core::FindFlags findFlags) const;
|
||||
void startSearch(Core::SearchResult *search);
|
||||
|
||||
CppModelManager *m_manager;
|
||||
bool m_enabled;
|
||||
QMap<QFutureWatcher<Find::SearchResultItem> *, QPointer<Find::SearchResult> > m_watchers;
|
||||
QPointer<Find::SearchResult> m_currentSearch;
|
||||
QMap<QFutureWatcher<Core::SearchResultItem> *, QPointer<Core::SearchResult> > m_watchers;
|
||||
QPointer<Core::SearchResult> m_currentSearch;
|
||||
SearchSymbols::SymbolTypes m_symbolsToSearch;
|
||||
SearchScope m_scope;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user