forked from qt-creator/qt-creator
Return the class declaration as canonical symbol for ctors, dtors, and class names.
This commit is contained in:
@@ -504,10 +504,29 @@ void LookupContext::expand(Scope *scope,
|
|||||||
Symbol *LookupContext::canonicalSymbol(Symbol *symbol)
|
Symbol *LookupContext::canonicalSymbol(Symbol *symbol)
|
||||||
{
|
{
|
||||||
Symbol *canonical = symbol;
|
Symbol *canonical = symbol;
|
||||||
|
Class *canonicalClass = 0;
|
||||||
|
|
||||||
for (; symbol; symbol = symbol->next()) {
|
for (; symbol; symbol = symbol->next()) {
|
||||||
if (symbol->name() == canonical->name())
|
if (symbol->identifier() == canonical->identifier()) {
|
||||||
canonical = symbol;
|
canonical = symbol;
|
||||||
|
|
||||||
|
if (Class *klass = symbol->asClass())
|
||||||
|
canonicalClass = klass;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (canonicalClass) {
|
||||||
|
Q_ASSERT(canonical != 0);
|
||||||
|
|
||||||
|
if (canonical->isForwardClassDeclaration())
|
||||||
|
return canonicalClass; // prefer class declarations when available.
|
||||||
|
}
|
||||||
|
|
||||||
|
if (canonical && canonical->scope()->isClassScope()) {
|
||||||
|
Class *enclosingClass = canonical->scope()->owner()->asClass();
|
||||||
|
|
||||||
|
if (enclosingClass->identifier() == canonical->identifier())
|
||||||
|
return enclosingClass;
|
||||||
}
|
}
|
||||||
|
|
||||||
return canonical;
|
return canonical;
|
||||||
|
@@ -304,14 +304,22 @@ protected:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ast->unqualified_name) {
|
if (NameAST *unqualified_name = ast->unqualified_name) {
|
||||||
SimpleNameAST *simple_name = ast->unqualified_name->asSimpleName();
|
unsigned identifier_token = 0;
|
||||||
|
|
||||||
|
if (SimpleNameAST *simple_name = unqualified_name->asSimpleName())
|
||||||
|
identifier_token = simple_name->identifier_token;
|
||||||
|
|
||||||
|
else if (DestructorNameAST *dtor_name = unqualified_name->asDestructorName())
|
||||||
|
identifier_token = dtor_name->identifier_token;
|
||||||
|
|
||||||
TemplateIdAST *template_id = 0;
|
TemplateIdAST *template_id = 0;
|
||||||
if (! simple_name) {
|
if (! identifier_token) {
|
||||||
template_id = ast->unqualified_name->asTemplateId();
|
template_id = unqualified_name->asTemplateId();
|
||||||
|
|
||||||
if (template_id) {
|
if (template_id) {
|
||||||
|
identifier_token = template_id->identifier_token;
|
||||||
|
|
||||||
for (TemplateArgumentListAST *template_arguments = template_id->template_arguments;
|
for (TemplateArgumentListAST *template_arguments = template_id->template_arguments;
|
||||||
template_arguments; template_arguments = template_arguments->next) {
|
template_arguments; template_arguments = template_arguments->next) {
|
||||||
accept(template_arguments->template_argument);
|
accept(template_arguments->template_argument);
|
||||||
@@ -319,15 +327,9 @@ protected:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (simple_name || template_id) {
|
if (identifier_token && identifier(identifier_token) == _id)
|
||||||
const unsigned identifier_token = simple_name
|
|
||||||
? simple_name->identifier_token
|
|
||||||
: template_id->identifier_token;
|
|
||||||
|
|
||||||
if (identifier(identifier_token) == _id)
|
|
||||||
checkExpression(ast->firstToken(), identifier_token);
|
checkExpression(ast->firstToken(), identifier_token);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user