Commit 395de23c authored by Fawzi Mohamed's avatar Fawzi Mohamed
Browse files

Qmljs: removing unneeded Snapshot in find usages

removed snapshot from find usages, as now it is reachable through the
context

Change-Id: Ie470d275ae1b71caad4169234e6fc9af8687c7f0
Reviewed-on: http://codereview.qt.nokia.com/341

Reviewed-by: default avatarFawzi Mohamed <fawzi.mohamed@nokia.com>
parent fe564852
...@@ -77,9 +77,8 @@ class FindUsages: protected Visitor ...@@ -77,9 +77,8 @@ class FindUsages: protected Visitor
public: public:
typedef QList<AST::SourceLocation> Result; typedef QList<AST::SourceLocation> Result;
FindUsages(Document::Ptr doc, const Snapshot &snapshot, Context *context) FindUsages(Document::Ptr doc, Context *context)
: _doc(doc) : _doc(doc)
, _snapshot(snapshot)
, _context(context) , _context(context)
, _builder(context, doc) , _builder(context, doc)
{ {
...@@ -292,7 +291,6 @@ private: ...@@ -292,7 +291,6 @@ private:
Result _usages; Result _usages;
Document::Ptr _doc; Document::Ptr _doc;
Snapshot _snapshot;
Context *_context; Context *_context;
ScopeBuilder _builder; ScopeBuilder _builder;
...@@ -694,32 +692,30 @@ static QString matchingLine(unsigned position, const QString &source) ...@@ -694,32 +692,30 @@ static QString matchingLine(unsigned position, const QString &source)
class ProcessFile: public std::unary_function<QString, QList<FindReferences::Usage> > class ProcessFile: public std::unary_function<QString, QList<FindReferences::Usage> >
{ {
const Snapshot &snapshot;
const Context &context; const Context &context;
typedef FindReferences::Usage Usage; typedef FindReferences::Usage Usage;
QString name; QString name;
const ObjectValue *scope; const ObjectValue *scope;
public: public:
ProcessFile(const Snapshot &snapshot, ProcessFile(const Context &context,
const Context &context,
QString name, QString name,
const ObjectValue *scope) const ObjectValue *scope)
: snapshot(snapshot), context(context), name(name), scope(scope) : context(context), name(name), scope(scope)
{ } { }
QList<Usage> operator()(const QString &fileName) QList<Usage> operator()(const QString &fileName)
{ {
QList<Usage> usages; QList<Usage> usages;
Document::Ptr doc = snapshot.document(fileName); Document::Ptr doc = context.snapshot().document(fileName);
if (!doc) if (!doc)
return usages; return usages;
Context contextCopy(context); Context contextCopy(context);
// find all idenfifier expressions, try to resolve them and check if the result is in scope // find all idenfifier expressions, try to resolve them and check if the result is in scope
FindUsages findUsages(doc, snapshot, &contextCopy); FindUsages findUsages(doc, &contextCopy);
FindUsages::Result results = findUsages(name, scope); FindUsages::Result results = findUsages(name, scope);
foreach (const AST::SourceLocation &loc, results) foreach (const AST::SourceLocation &loc, results)
usages.append(Usage(fileName, matchingLine(loc.offset, doc->source()), loc.startLine, loc.startColumn - 1, loc.length)); usages.append(Usage(fileName, matchingLine(loc.offset, doc->source()), loc.startLine, loc.startColumn - 1, loc.length));
...@@ -864,7 +860,7 @@ static void find_helper(QFutureInterface<FindReferences::Usage> &future, ...@@ -864,7 +860,7 @@ static void find_helper(QFutureInterface<FindReferences::Usage> &future,
// report a dummy usage to indicate the search is starting // report a dummy usage to indicate the search is starting
future.reportResult(FindReferences::Usage()); future.reportResult(FindReferences::Usage());
ProcessFile process(snapshot, context, name, scope); ProcessFile process(context, name, scope);
UpdateUI reduce(&future); UpdateUI reduce(&future);
QtConcurrent::blockingMappedReduced<QList<FindReferences::Usage> > (files, process, reduce); QtConcurrent::blockingMappedReduced<QList<FindReferences::Usage> > (files, process, reduce);
......
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