forked from qt-creator/qt-creator
Save the usages.
This commit is contained in:
@@ -57,17 +57,23 @@ void FindUsages::setGlobalNamespaceBinding(NamespaceBindingPtr globalNamespaceBi
|
||||
_globalNamespaceBinding = globalNamespaceBinding;
|
||||
}
|
||||
|
||||
QList<int> FindUsages::operator()(Symbol *symbol, const Identifier *id, AST *ast)
|
||||
QList<Usage> FindUsages::usages() const
|
||||
{ return _usages; }
|
||||
|
||||
QList<int> FindUsages::references() const
|
||||
{ return _references; }
|
||||
|
||||
void FindUsages::operator()(Symbol *symbol, const Identifier *id, AST *ast)
|
||||
{
|
||||
_processed.clear();
|
||||
_references.clear();
|
||||
_usages.clear();
|
||||
_declSymbol = symbol;
|
||||
_id = id;
|
||||
if (_declSymbol && _id) {
|
||||
_exprDoc = Document::create("<references>");
|
||||
accept(ast);
|
||||
}
|
||||
return _references;
|
||||
}
|
||||
|
||||
QString FindUsages::matchingLine(const Token &tk) const
|
||||
@@ -120,9 +126,11 @@ void FindUsages::reportResult(unsigned tokenIndex)
|
||||
|
||||
const int len = tk.f.length;
|
||||
|
||||
if (_future) {
|
||||
_future->reportResult(Usage(_doc->fileName(), line, lineText, col, len));
|
||||
}
|
||||
const Usage u(_doc->fileName(), line, lineText, col, len);
|
||||
_usages.append(u);
|
||||
|
||||
if (_future)
|
||||
_future->reportResult(u);
|
||||
|
||||
_references.append(tokenIndex);
|
||||
}
|
||||
|
@@ -47,12 +47,12 @@ public:
|
||||
: line(0), col(0), len(0) {}
|
||||
|
||||
Usage(const QString &path, int line, const QString &lineText, int col, int len)
|
||||
: path(path), line(line), lineText(lineText), col(col), len(len) {}
|
||||
: path(path), lineText(lineText), line(line), col(col), len(len) {}
|
||||
|
||||
public:
|
||||
QString path;
|
||||
int line;
|
||||
QString lineText;
|
||||
int line;
|
||||
int col;
|
||||
int len;
|
||||
};
|
||||
@@ -64,7 +64,10 @@ public:
|
||||
|
||||
void setGlobalNamespaceBinding(NamespaceBindingPtr globalNamespaceBinding);
|
||||
|
||||
QList<int> operator()(Symbol *symbol, const Identifier *id, AST *ast);
|
||||
void operator()(Symbol *symbol, const Identifier *id, AST *ast);
|
||||
|
||||
QList<Usage> usages() const;
|
||||
QList<int> references() const;
|
||||
|
||||
protected:
|
||||
using ASTVisitor::visit;
|
||||
@@ -112,6 +115,7 @@ private:
|
||||
QList<PostfixExpressionAST *> _postfixExpressionStack;
|
||||
QList<QualifiedNameAST *> _qualifiedNameStack;
|
||||
QList<int> _references;
|
||||
QList<Usage> _usages;
|
||||
LookupContext _previousContext;
|
||||
int _inSimpleDeclaration;
|
||||
QSet<unsigned> _processed;
|
||||
|
@@ -91,9 +91,10 @@ QList<int> CppFindReferences::references(Symbol *symbol,
|
||||
TranslationUnit *translationUnit = doc->translationUnit();
|
||||
Q_ASSERT(translationUnit != 0);
|
||||
|
||||
FindUsages process(doc, snapshot, /*future = */ 0);
|
||||
process.setGlobalNamespaceBinding(bind(doc, snapshot));
|
||||
references = process(symbol, id, translationUnit->ast());
|
||||
FindUsages findUsages(doc, snapshot, /*future = */ 0);
|
||||
findUsages.setGlobalNamespaceBinding(bind(doc, snapshot));
|
||||
findUsages(symbol, id, translationUnit->ast());
|
||||
references = findUsages.references();
|
||||
|
||||
return references;
|
||||
}
|
||||
@@ -229,7 +230,10 @@ void CppFindReferences::findAll_helper(Symbol *symbol)
|
||||
const QMap<QString, QString> wl = _modelManager->workingCopy();
|
||||
|
||||
Core::ProgressManager *progressManager = Core::ICore::instance()->progressManager();
|
||||
QFuture<Usage> result = QtConcurrent::run(&find_helper, wl, snapshot, symbol);
|
||||
|
||||
QFuture<Usage> result;
|
||||
|
||||
result = QtConcurrent::run(&find_helper, wl, snapshot, symbol);
|
||||
m_watcher.setFuture(result);
|
||||
|
||||
Core::FutureProgress *progress = progressManager->addTask(result, tr("Searching..."),
|
||||
|
Reference in New Issue
Block a user