Commit 91a50a74 authored by Roberto Raggi's avatar Roberto Raggi

Changed the signature of findReferences()

parent e7b96347
...@@ -211,20 +211,20 @@ CppFindReferences::~CppFindReferences() ...@@ -211,20 +211,20 @@ CppFindReferences::~CppFindReferences()
} }
static void find_helper(QFutureInterface<Core::Utils::FileSearchResult> &future, static void find_helper(QFutureInterface<Core::Utils::FileSearchResult> &future,
QString word, Snapshot snapshot,
QString fileName, Symbol *symbol)
Snapshot snapshot)
{ {
QTime tm; QTime tm;
tm.start(); tm.start();
const QString fileName = QString::fromUtf8(symbol->fileName(), symbol->fileNameLength());
QStringList files(fileName); QStringList files(fileName);
files += snapshot.dependsOn(fileName); files += snapshot.dependsOn(fileName);
qDebug() << "done in:" << tm.elapsed() << "number of files to parse:" << files.size(); qDebug() << "done in:" << tm.elapsed() << "number of files to parse:" << files.size();
future.setProgressRange(0, files.size()); future.setProgressRange(0, files.size());
const QByteArray literal = word.toLatin1();
tm.start(); tm.start();
for (int i = 0; i < files.size(); ++i) { for (int i = 0; i < files.size(); ++i) {
const QString &fn = files.at(i); const QString &fn = files.at(i);
...@@ -238,8 +238,11 @@ static void find_helper(QFutureInterface<Core::Utils::FileSearchResult> &future, ...@@ -238,8 +238,11 @@ static void find_helper(QFutureInterface<Core::Utils::FileSearchResult> &future,
Document::Ptr doc = snapshot.documentFromSource(preprocessedCode, fn); Document::Ptr doc = snapshot.documentFromSource(preprocessedCode, fn);
doc->tokenize(); doc->tokenize();
Identifier *symbolId = symbol->identifier();
Q_ASSERT(symbolId != 0);
Control *control = doc->control(); Control *control = doc->control();
if (Identifier *id = control->findIdentifier(literal.constData(), literal.size())) { if (Identifier *id = control->findIdentifier(symbolId->chars(), symbolId->size())) {
doc->check(); doc->check();
TranslationUnit *unit = doc->translationUnit(); TranslationUnit *unit = doc->translationUnit();
Process process(future, doc, snapshot); Process process(future, doc, snapshot);
...@@ -249,17 +252,15 @@ static void find_helper(QFutureInterface<Core::Utils::FileSearchResult> &future, ...@@ -249,17 +252,15 @@ static void find_helper(QFutureInterface<Core::Utils::FileSearchResult> &future,
future.setProgressValue(files.size()); future.setProgressValue(files.size());
} }
void CppFindReferences::findAll(const QString &fileName, const QString &text) void CppFindReferences::findAll(const Snapshot &snapshot, Symbol *symbol)
{ {
_resultWindow->clearContents(); _resultWindow->clearContents();
_resultWindow->popup(true); _resultWindow->popup(true);
Core::ProgressManager *progressManager = Core::ICore::instance()->progressManager(); Core::ProgressManager *progressManager = Core::ICore::instance()->progressManager();
const Snapshot snapshot = _modelManager->snapshot();
QFuture<Core::Utils::FileSearchResult> result = QFuture<Core::Utils::FileSearchResult> result =
QtConcurrent::run(&find_helper, text, fileName, snapshot); QtConcurrent::run(&find_helper, snapshot, symbol);
m_watcher.setFuture(result); m_watcher.setFuture(result);
......
...@@ -37,9 +37,14 @@ ...@@ -37,9 +37,14 @@
#include <utils/filesearch.h> #include <utils/filesearch.h>
namespace Find { namespace Find {
class SearchResultWindow; class SearchResultWindow;
} // end of namespace Find } // end of namespace Find
namespace CPlusPlus {
class Snapshot;
class Symbol;
} // end of namespace CPlusPlus
namespace CppTools { namespace CppTools {
namespace Internal { namespace Internal {
...@@ -57,7 +62,7 @@ Q_SIGNALS: ...@@ -57,7 +62,7 @@ Q_SIGNALS:
void changed(); void changed();
public: public:
void findAll(const QString &fileName, const QString &text); void findAll(const CPlusPlus::Snapshot &snapshot, CPlusPlus::Symbol *symbol);
private Q_SLOTS: private Q_SLOTS:
void displayResult(int); void displayResult(int);
......
...@@ -720,10 +720,8 @@ void CppModelManager::removeEditorSupport(AbstractEditorSupport *editorSupport) ...@@ -720,10 +720,8 @@ void CppModelManager::removeEditorSupport(AbstractEditorSupport *editorSupport)
void CppModelManager::findReferences(CPlusPlus::Symbol *symbol) void CppModelManager::findReferences(CPlusPlus::Symbol *symbol)
{ {
if (Identifier *id = symbol->identifier()) { if (symbol->identifier())
QString word = QString::fromLatin1(id->chars(), id->size()); m_findReferences->findAll(snapshot(), symbol);
m_findReferences->findAll(symbol->fileName(), word);
}
} }
QMap<QString, QString> CppModelManager::buildWorkingCopyList() QMap<QString, QString> CppModelManager::buildWorkingCopyList()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment