summaryrefslogtreecommitdiff
path: root/src/shared/cplusplus/CheckDeclaration.cpp
diff options
context:
space:
mode:
authorRoberto Raggi <roberto.raggi@nokia.com>2009-06-25 11:02:02 +0200
committerRoberto Raggi <roberto.raggi@nokia.com>2009-06-25 12:48:55 +0200
commit27f92695cff70da2f6cb3effb5a8e12682bf3a37 (patch)
tree118502c10f127509c3450513c4c7085e94c94141 /src/shared/cplusplus/CheckDeclaration.cpp
parent44d8b28a9f444e7cd29a5575e7b2fdabcbad815f (diff)
downloadqt-creator-27f92695cff70da2f6cb3effb5a8e12682bf3a37.tar.gz
Initial work on smart highlight of local symbols. For-statements and symbols genarated from a macro expansion are not yet highlighted.
Diffstat (limited to 'src/shared/cplusplus/CheckDeclaration.cpp')
-rw-r--r--src/shared/cplusplus/CheckDeclaration.cpp35
1 files changed, 26 insertions, 9 deletions
diff --git a/src/shared/cplusplus/CheckDeclaration.cpp b/src/shared/cplusplus/CheckDeclaration.cpp
index 79392bf4e7..ef71c79809 100644
--- a/src/shared/cplusplus/CheckDeclaration.cpp
+++ b/src/shared/cplusplus/CheckDeclaration.cpp
@@ -122,6 +122,18 @@ void CheckDeclaration::checkFunctionArguments(Function *fun)
}
}
+unsigned CheckDeclaration::locationOfDeclaratorId(DeclaratorAST *declarator) const
+{
+ if (declarator && declarator->core_declarator) {
+ if (DeclaratorIdAST *declaratorId = declarator->core_declarator->asDeclaratorId())
+ return declaratorId->firstToken();
+ else if (NestedDeclaratorAST *nested = declarator->core_declarator->asNestedDeclarator())
+ return locationOfDeclaratorId(nested->declarator);
+ }
+
+ return 0;
+}
+
bool CheckDeclaration::visit(SimpleDeclarationAST *ast)
{
FullySpecifiedType ty = semantic()->check(ast->decl_specifier_seq, _scope);
@@ -164,11 +176,13 @@ bool CheckDeclaration::visit(SimpleDeclarationAST *ast)
FullySpecifiedType declTy = semantic()->check(it->declarator, qualTy,
_scope, &name);
- unsigned location = 0;
- if (it->declarator)
- location = it->declarator->firstToken();
- else
- location = ast->firstToken();
+ unsigned location = locationOfDeclaratorId(it->declarator);
+ if (! location) {
+ if (it->declarator)
+ location = it->declarator->firstToken();
+ else
+ location = ast->firstToken();
+ }
Function *fun = 0;
if (declTy && 0 != (fun = declTy->asFunctionType())) {
@@ -355,10 +369,13 @@ bool CheckDeclaration::visit(NamespaceAliasDefinitionAST *)
bool CheckDeclaration::visit(ParameterDeclarationAST *ast)
{
- unsigned sourceLocation = 0;
-
- if (ast->declarator)
- sourceLocation = ast->declarator->firstToken();
+ unsigned sourceLocation = locationOfDeclaratorId(ast->declarator);
+ if (! sourceLocation) {
+ if (ast->declarator)
+ sourceLocation = ast->declarator->firstToken();
+ else
+ sourceLocation = ast->firstToken();
+ }
Name *argName = 0;
FullySpecifiedType ty = semantic()->check(ast->type_specifier, _scope);