forked from qt-creator/qt-creator
C++: name of function of class problem
It fixes: * highlighing * find usage * follow symbol when function of class has the same name as: * local variable * template parameter * other struct/union/class/enum * function argument in function scope. Task-number: QTCREATORBUG-8902 Change-Id: Iddc0f764af689babb40d39460d174bac7b919b31 Reviewed-by: Orgad Shaneh <orgads@gmail.com> Reviewed-by: Sergey Shambir <sergey.shambir.auto@gmail.com> Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
This commit is contained in:
committed by
Erik Verbruggen
parent
9c2a352027
commit
bde6667240
@@ -1240,6 +1240,7 @@ bool CheckSymbols::maybeAddFunction(const QList<LookupItem> &candidates, NameAST
|
||||
{
|
||||
unsigned startToken = ast->firstToken();
|
||||
bool isDestructor = false;
|
||||
bool isConstructor = false;
|
||||
if (DestructorNameAST *dtor = ast->asDestructorName()) {
|
||||
isDestructor = true;
|
||||
if (dtor->unqualified_name)
|
||||
@@ -1264,6 +1265,8 @@ bool CheckSymbols::maybeAddFunction(const QList<LookupItem> &candidates, NameAST
|
||||
if (isDestructor != c->name()->isDestructorNameId())
|
||||
continue;
|
||||
|
||||
isConstructor = isConstructorDeclaration(c);
|
||||
|
||||
Function *funTy = c->type()->asFunctionType();
|
||||
if (! funTy) {
|
||||
//Try to find a template function
|
||||
@@ -1296,7 +1299,9 @@ bool CheckSymbols::maybeAddFunction(const QList<LookupItem> &candidates, NameAST
|
||||
}
|
||||
|
||||
if (matchType != Match_None) {
|
||||
// decide how constructor and destructor should be highlighted
|
||||
if (highlightCtorDtorAsType
|
||||
&& (isConstructor || isDestructor)
|
||||
&& maybeType(ast->name)
|
||||
&& kind == SemanticInfo::FunctionUse) {
|
||||
return false;
|
||||
@@ -1399,3 +1404,12 @@ void CheckSymbols::flush()
|
||||
_usages.clear();
|
||||
_usages.reserve(cap);
|
||||
}
|
||||
|
||||
bool CheckSymbols::isConstructorDeclaration(Symbol *declaration)
|
||||
{
|
||||
Class *clazz = declaration->enclosingClass();
|
||||
if (clazz && clazz->name())
|
||||
return declaration->name()->isEqualTo(clazz->name());
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user