diff --git a/src/plugins/cppeditor/cppeditor.cpp b/src/plugins/cppeditor/cppeditor.cpp index 7947f4c4b4a81dfedc27baba86d26ca48784fb97..ba09cff487d88146ed069e649c180aa9a9e87e62 100644 --- a/src/plugins/cppeditor/cppeditor.cpp +++ b/src/plugins/cppeditor/cppeditor.cpp @@ -155,6 +155,9 @@ private: virtual bool visit(Function *function) { return processScope(function->members()); } + virtual bool visit(ObjCMethod *method) + { return processScope(method->members()); } + bool processScope(Scope *scope) { if (_scope || ! scope) @@ -258,9 +261,15 @@ protected: } virtual bool visit(SimpleNameAST *ast) + { return findMemberForToken(ast->firstToken(), ast); } + + virtual bool visit(ObjCMessageArgumentDeclarationAST *ast) + { return findMemberForToken(ast->param_name_token, ast); } + + bool findMemberForToken(unsigned tokenIdx, NameAST *ast) { unsigned line, column; - getTokenStartPosition(ast->firstToken(), &line, &column); + getTokenStartPosition(tokenIdx, &line, &column); Scope *scope = findScope(line, column, _functionScope->owner(), @@ -273,6 +282,12 @@ protected: return false; else if (findMember(fun->arguments(), ast, line, column)) return false; + } else if (scope->isObjCMethodScope()) { + ObjCMethod *method = scope->owner()->asObjCMethod(); + if (findMember(method->members(), ast, line, column)) + return false; + else if (findMember(method->arguments(), ast, line, column)) + return false; } else if (scope->isBlockScope()) { if (findMember(scope, ast, line, column)) return false; @@ -395,6 +410,12 @@ protected: return false; } + + virtual bool visit(ObjCMethodPrototypeAST *ast) + { + accept(ast->argument_list); + return false; + } }; diff --git a/src/shared/cplusplus/Scope.cpp b/src/shared/cplusplus/Scope.cpp index 86503826d7f91bad0a1d0897f8626004aa0927ea..9743e98e449d436c5d3078a13438b995a85c3b77 100644 --- a/src/shared/cplusplus/Scope.cpp +++ b/src/shared/cplusplus/Scope.cpp @@ -187,6 +187,14 @@ bool Scope::isFunctionScope() const return false; } +bool Scope::isObjCMethodScope() const +{ + ObjCMethod *m = 0; + if (_owner && 0 != (m = _owner->asObjCMethod())) + return m->arguments() != this; + return false; +} + void Scope::enterSymbol(Symbol *symbol) { if (++_symbolCount == _allocatedSymbols) { diff --git a/src/shared/cplusplus/Scope.h b/src/shared/cplusplus/Scope.h index a31b6459be6c1d8b552d85b1bd24ca9de61f6256..25df03a25e7d27bb501fe86cddd098346e06a2fb 100644 --- a/src/shared/cplusplus/Scope.h +++ b/src/shared/cplusplus/Scope.h @@ -114,6 +114,9 @@ public: /// Returns true if this scope's owner is an ObjCClass Symbol. bool isObjCClassScope() const; + /// Returns true if this scope's owner is an ObjCMethod symbol. + bool isObjCMethodScope() const; + /// Adds a Symbol to this Scope. void enterSymbol(Symbol *symbol);