forked from qt-creator/qt-creator
		
	Changed the signature of findReferences()
This commit is contained in:
		@@ -211,20 +211,20 @@ CppFindReferences::~CppFindReferences()
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void find_helper(QFutureInterface<Core::Utils::FileSearchResult> &future,
 | 
			
		||||
                        QString word,
 | 
			
		||||
                        QString fileName,
 | 
			
		||||
                        Snapshot snapshot)
 | 
			
		||||
                        Snapshot snapshot,
 | 
			
		||||
                        Symbol *symbol)
 | 
			
		||||
{
 | 
			
		||||
    QTime tm;
 | 
			
		||||
    tm.start();
 | 
			
		||||
 | 
			
		||||
    const QString fileName = QString::fromUtf8(symbol->fileName(), symbol->fileNameLength());
 | 
			
		||||
 | 
			
		||||
    QStringList files(fileName);
 | 
			
		||||
    files += snapshot.dependsOn(fileName);
 | 
			
		||||
    qDebug() << "done in:" << tm.elapsed() << "number of files to parse:" << files.size();
 | 
			
		||||
 | 
			
		||||
    future.setProgressRange(0, files.size());
 | 
			
		||||
 | 
			
		||||
    const QByteArray literal = word.toLatin1();
 | 
			
		||||
 | 
			
		||||
    tm.start();
 | 
			
		||||
    for (int i = 0; i < files.size(); ++i) {
 | 
			
		||||
        const QString &fn = files.at(i);
 | 
			
		||||
@@ -238,8 +238,11 @@ static void find_helper(QFutureInterface<Core::Utils::FileSearchResult> &future,
 | 
			
		||||
        Document::Ptr doc = snapshot.documentFromSource(preprocessedCode, fn);
 | 
			
		||||
        doc->tokenize();
 | 
			
		||||
 | 
			
		||||
        Identifier *symbolId = symbol->identifier();
 | 
			
		||||
        Q_ASSERT(symbolId != 0);
 | 
			
		||||
 | 
			
		||||
        Control *control = doc->control();
 | 
			
		||||
        if (Identifier *id = control->findIdentifier(literal.constData(), literal.size())) {
 | 
			
		||||
        if (Identifier *id = control->findIdentifier(symbolId->chars(), symbolId->size())) {
 | 
			
		||||
            doc->check();
 | 
			
		||||
            TranslationUnit *unit = doc->translationUnit();
 | 
			
		||||
            Process process(future, doc, snapshot);
 | 
			
		||||
@@ -249,17 +252,15 @@ static void find_helper(QFutureInterface<Core::Utils::FileSearchResult> &future,
 | 
			
		||||
    future.setProgressValue(files.size());
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void CppFindReferences::findAll(const QString &fileName, const QString &text)
 | 
			
		||||
void CppFindReferences::findAll(const Snapshot &snapshot, Symbol *symbol)
 | 
			
		||||
{
 | 
			
		||||
    _resultWindow->clearContents();
 | 
			
		||||
    _resultWindow->popup(true);
 | 
			
		||||
 | 
			
		||||
    Core::ProgressManager *progressManager = Core::ICore::instance()->progressManager();
 | 
			
		||||
 | 
			
		||||
    const Snapshot snapshot = _modelManager->snapshot();
 | 
			
		||||
 | 
			
		||||
    QFuture<Core::Utils::FileSearchResult> result =
 | 
			
		||||
            QtConcurrent::run(&find_helper, text, fileName, snapshot);
 | 
			
		||||
            QtConcurrent::run(&find_helper, snapshot, symbol);
 | 
			
		||||
 | 
			
		||||
    m_watcher.setFuture(result);
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -37,9 +37,14 @@
 | 
			
		||||
#include <utils/filesearch.h>
 | 
			
		||||
 | 
			
		||||
namespace Find {
 | 
			
		||||
class SearchResultWindow;
 | 
			
		||||
    class SearchResultWindow;
 | 
			
		||||
} // end of namespace Find
 | 
			
		||||
 | 
			
		||||
namespace CPlusPlus {
 | 
			
		||||
    class Snapshot;
 | 
			
		||||
    class Symbol;
 | 
			
		||||
} // end of namespace CPlusPlus
 | 
			
		||||
 | 
			
		||||
namespace CppTools {
 | 
			
		||||
namespace Internal {
 | 
			
		||||
 | 
			
		||||
@@ -57,7 +62,7 @@ Q_SIGNALS:
 | 
			
		||||
    void changed();
 | 
			
		||||
 | 
			
		||||
public:
 | 
			
		||||
    void findAll(const QString &fileName, const QString &text);
 | 
			
		||||
    void findAll(const CPlusPlus::Snapshot &snapshot, CPlusPlus::Symbol *symbol);
 | 
			
		||||
 | 
			
		||||
private Q_SLOTS:
 | 
			
		||||
    void displayResult(int);
 | 
			
		||||
 
 | 
			
		||||
@@ -720,10 +720,8 @@ void CppModelManager::removeEditorSupport(AbstractEditorSupport *editorSupport)
 | 
			
		||||
 | 
			
		||||
void CppModelManager::findReferences(CPlusPlus::Symbol *symbol)
 | 
			
		||||
{
 | 
			
		||||
    if (Identifier *id = symbol->identifier()) {
 | 
			
		||||
        QString word = QString::fromLatin1(id->chars(), id->size());
 | 
			
		||||
        m_findReferences->findAll(symbol->fileName(), word);
 | 
			
		||||
    }
 | 
			
		||||
    if (symbol->identifier())
 | 
			
		||||
        m_findReferences->findAll(snapshot(), symbol);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
QMap<QString, QString> CppModelManager::buildWorkingCopyList()
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user