Use mappedReduce when searching for the usages of a symbol.

This commit is contained in:
Roberto Raggi
2009-12-04 13:04:20 +01:00
parent 425c61f624
commit aae5b92125
3 changed files with 83 additions and 55 deletions

View File

@@ -41,9 +41,8 @@
using namespace CPlusPlus;
FindUsages::FindUsages(Document::Ptr doc, const Snapshot &snapshot, QFutureInterface<Usage> *future)
FindUsages::FindUsages(Document::Ptr doc, const Snapshot &snapshot)
: ASTVisitor(doc->translationUnit()),
_future(future),
_doc(doc),
_snapshot(snapshot),
_source(_doc->source()),
@@ -131,12 +130,8 @@ void FindUsages::reportResult(unsigned tokenIndex)
const int len = tk.f.length;
const Usage u(_doc->fileName(), line, lineText, col, len);
const Usage u(_doc->fileName(), lineText, line, col, len);
_usages.append(u);
if (_future)
_future->reportResult(u);
_references.append(tokenIndex);
}

View File

@@ -34,9 +34,8 @@
#include "CppDocument.h"
#include "CppBindings.h"
#include "Semantic.h"
#include <ASTVisitor.h>
#include <QtCore/QFutureInterface>
#include <QtCore/QSet>
namespace CPlusPlus {
@@ -46,7 +45,7 @@ public:
Usage()
: line(0), col(0), len(0) {}
Usage(const QString &path, int line, const QString &lineText, int col, int len)
Usage(const QString &path, const QString &lineText, int line, int col, int len)
: path(path), lineText(lineText), line(line), col(col), len(len) {}
public:
@@ -60,7 +59,7 @@ public:
class CPLUSPLUS_EXPORT FindUsages: protected ASTVisitor
{
public:
FindUsages(Document::Ptr doc, const Snapshot &snapshot, QFutureInterface<Usage> *future);
FindUsages(Document::Ptr doc, const Snapshot &snapshot);
void setGlobalNamespaceBinding(NamespaceBindingPtr globalNamespaceBinding);
@@ -103,7 +102,6 @@ protected:
virtual void endVisit(SimpleDeclarationAST *);
private:
QFutureInterface<Usage> *_future;
const Identifier *_id;
Symbol *_declSymbol;
Document::Ptr _doc;