From 9f49cd05b63eec13085b08204847b27b5d33ceab Mon Sep 17 00:00:00 2001 From: Roberto Raggi Date: Tue, 29 Sep 2009 13:02:15 +0200 Subject: [PATCH] Handle mem initializers. --- src/plugins/cpptools/cppfindreferences.cpp | 26 +++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/src/plugins/cpptools/cppfindreferences.cpp b/src/plugins/cpptools/cppfindreferences.cpp index faa7fc944a8..1d2fdba2f6b 100644 --- a/src/plugins/cpptools/cppfindreferences.cpp +++ b/src/plugins/cpptools/cppfindreferences.cpp @@ -168,13 +168,37 @@ protected: return LookupContext(lastVisibleSymbol, _exprDoc, _doc, _snapshot); } + void ensureNameIsValid(NameAST *ast) + { + if (ast && ! ast->name) + ast->name = _sem.check(ast, /*scope = */ 0); + } + + virtual bool visit(MemInitializerAST *ast) + { + if (ast->name && ast->name->asSimpleName() != 0) { + ensureNameIsValid(ast->name); + + SimpleNameAST *simple = ast->name->asSimpleName(); + qDebug() << identifier(simple->identifier_token) << _id; + if (identifier(simple->identifier_token) == _id) { + LookupContext context = currentContext(ast); + const QList candidates = context.resolve(simple->name); + if (checkCandidates(candidates)) + reportResult(simple->identifier_token); + } + } + accept(ast->expression); + return false; + } + virtual bool visit(PostfixExpressionAST *ast) { _postfixExpressionStack.append(ast); return true; } - virtual void endVisit(PostfixExpressionAST *ast) + virtual void endVisit(PostfixExpressionAST *) { _postfixExpressionStack.removeLast(); }