diff --git a/src/plugins/cpptools/cppfindreferences.cpp b/src/plugins/cpptools/cppfindreferences.cpp index 81d7caadf97..4d167039634 100644 --- a/src/plugins/cpptools/cppfindreferences.cpp +++ b/src/plugins/cpptools/cppfindreferences.cpp @@ -64,45 +64,19 @@ using namespace CppTools::Internal; using namespace CPlusPlus; -CppFindReferences::CppFindReferences(CppTools::CppModelManagerInterface *modelManager) - : QObject(modelManager), - _modelManager(modelManager), - _resultWindow(ExtensionSystem::PluginManager::instance()->getObject()) +namespace { + +class ProcessFile: public std::unary_function > { - m_watcher.setPendingResultsLimit(1); - connect(&m_watcher, SIGNAL(resultsReadyAt(int,int)), this, SLOT(displayResults(int,int))); - connect(&m_watcher, SIGNAL(finished()), this, SLOT(searchFinished())); -} - -CppFindReferences::~CppFindReferences() -{ -} - -QList CppFindReferences::references(Symbol *symbol, - Document::Ptr doc, - const Snapshot& snapshot) const -{ - QList references; - - FindUsages findUsages(doc, snapshot); - findUsages.setGlobalNamespaceBinding(bind(doc, snapshot)); - findUsages(symbol); - references = findUsages.references(); - - return references; -} - -class MyProcess: public std::unary_function > -{ - const QMap wl; + const QMap workingList; const Snapshot snapshot; Symbol *symbol; public: - MyProcess(const QMap wl, + ProcessFile(const QMap workingList, const Snapshot snapshot, Symbol *symbol) - : wl(wl), snapshot(snapshot), symbol(symbol) + : workingList(workingList), snapshot(snapshot), symbol(symbol) { } QList operator()(const QString &fileName) @@ -118,8 +92,8 @@ public: QByteArray source; - if (wl.contains(fileName)) - source = snapshot.preprocessedCode(wl.value(fileName), fileName); + if (workingList.contains(fileName)) + source = snapshot.preprocessedCode(workingList.value(fileName), fileName); else { QFile file(fileName); if (! file.open(QFile::ReadOnly)) @@ -147,12 +121,12 @@ public: } }; -class MyReduce: public std::binary_function &, QList, void> +class UpdateUI: public std::binary_function &, QList, void> { QFutureInterface *future; public: - MyReduce(QFutureInterface *future): future(future) {} + UpdateUI(QFutureInterface *future): future(future) {} void operator()(QList &, const QList &usages) { @@ -163,6 +137,36 @@ public: } }; +} // end of anonymous namespace + +CppFindReferences::CppFindReferences(CppTools::CppModelManagerInterface *modelManager) + : QObject(modelManager), + _modelManager(modelManager), + _resultWindow(ExtensionSystem::PluginManager::instance()->getObject()) +{ + m_watcher.setPendingResultsLimit(1); + connect(&m_watcher, SIGNAL(resultsReadyAt(int,int)), this, SLOT(displayResults(int,int))); + connect(&m_watcher, SIGNAL(finished()), this, SLOT(searchFinished())); +} + +CppFindReferences::~CppFindReferences() +{ +} + +QList CppFindReferences::references(Symbol *symbol, + Document::Ptr doc, + const Snapshot& snapshot) const +{ + QList references; + + FindUsages findUsages(doc, snapshot); + findUsages.setGlobalNamespaceBinding(bind(doc, snapshot)); + findUsages(symbol); + references = findUsages.references(); + + return references; +} + static void find_helper(QFutureInterface &future, const QMap wl, Snapshot snapshot, @@ -195,8 +199,8 @@ static void find_helper(QFutureInterface &future, future.setProgressRange(0, files.size()); - MyProcess process(wl, snapshot, symbol); - MyReduce reduce(&future); + ProcessFile process(wl, snapshot, symbol); + UpdateUI reduce(&future); QtConcurrent::blockingMappedReduced > (files, process, reduce);