diff options
author | Roberto Raggi <roberto.raggi@nokia.com> | 2009-10-06 11:53:01 +0200 |
---|---|---|
committer | Roberto Raggi <roberto.raggi@nokia.com> | 2009-10-06 11:56:29 +0200 |
commit | 319a0e2ad176ad03f19af344cec4d5477c25269e (patch) | |
tree | 019065f81800b891010a962d3f4f77fe307e0c51 /src | |
parent | 06abe6b813841837cfee2491aee43114138c4a3c (diff) | |
download | qt-creator-319a0e2ad176ad03f19af344cec4d5477c25269e.tar.gz |
Search for possible uses of local symbols in template arguments and removed some deprecated code.
Diffstat (limited to 'src')
-rw-r--r-- | src/plugins/cppeditor/cppeditor.cpp | 46 | ||||
-rw-r--r-- | src/plugins/cppeditor/cppeditor.h | 13 |
2 files changed, 21 insertions, 38 deletions
diff --git a/src/plugins/cppeditor/cppeditor.cpp b/src/plugins/cppeditor/cppeditor.cpp index b03e4ca346..d8ebf6af6a 100644 --- a/src/plugins/cppeditor/cppeditor.cpp +++ b/src/plugins/cppeditor/cppeditor.cpp @@ -195,12 +195,10 @@ public: // local and external uses. SemanticInfo::LocalUseMap localUses; - SemanticInfo::ExternalUseMap externalUses; void operator()(FunctionDefinitionAST *ast) { localUses.clear(); - externalUses.clear(); if (ast && ast->symbol) { _functionScope = ast->symbol->members(); @@ -232,6 +230,18 @@ protected: return false; } + void searchUsesInTemplateArguments(NameAST *name) + { + if (! name) + return; + + else if (TemplateIdAST *template_id = name->asTemplateId()) { + for (TemplateArgumentListAST *it = template_id->template_arguments; it; it = it->next) { + accept(it->template_argument); + } + } + } + virtual bool visit(SimpleNameAST *ast) { unsigned line, column; @@ -258,14 +268,14 @@ protected: scope = scope->enclosingScope(); } - Identifier *id = identifier(ast->identifier_token); - externalUses[id].append(SemanticInfo::Use(line, column, id->size())); - return false; } virtual bool visit(TemplateIdAST *ast) { + for (TemplateArgumentListAST *arg = ast->template_arguments; arg; arg = arg->next) + accept(arg->template_argument); + unsigned line, column; getTokenStartPosition(ast->firstToken(), &line, &column); @@ -290,34 +300,15 @@ protected: scope = scope->enclosingScope(); } - Identifier *id = identifier(ast->identifier_token); - externalUses[id].append(SemanticInfo::Use(line, column, id->size())); - - for (TemplateArgumentListAST *arg = ast->template_arguments; arg; arg = arg->next) - accept(arg); - return false; } virtual bool visit(QualifiedNameAST *ast) { - if (! ast->global_scope_token) { - if (ast->nested_name_specifier) { - accept(ast->nested_name_specifier->class_or_namespace_name); - - for (NestedNameSpecifierAST *it = ast->nested_name_specifier->next; it; it = it->next) { - if (NameAST *class_or_namespace_name = it->class_or_namespace_name) { - if (TemplateIdAST *template_id = class_or_namespace_name->asTemplateId()) { - for (TemplateArgumentListAST *arg = template_id->template_arguments; arg; arg = arg->next) - accept(arg); - } - } - } - } - - accept(ast->unqualified_name); - } + for (NestedNameSpecifierAST *it = ast->nested_name_specifier; it; it = it->next) + searchUsesInTemplateArguments(it->class_or_namespace_name); + searchUsesInTemplateArguments(ast->unqualified_name); return false; } @@ -2111,7 +2102,6 @@ SemanticInfo SemanticHighlighter::semanticInfo(const Source &source) semanticInfo.snapshot = snapshot; semanticInfo.doc = doc; semanticInfo.localUses = useTable.localUses; - semanticInfo.externalUses = useTable.externalUses; return semanticInfo; } diff --git a/src/plugins/cppeditor/cppeditor.h b/src/plugins/cppeditor/cppeditor.h index 6c853672bf..dfba054375 100644 --- a/src/plugins/cppeditor/cppeditor.h +++ b/src/plugins/cppeditor/cppeditor.h @@ -70,28 +70,21 @@ public: unsigned column; unsigned length; - Use() - : line(0), column(0), length(0) {} - - Use(unsigned line, unsigned column, unsigned length) - : line(line), column(column), length(length) {} + Use(unsigned line = 0, unsigned column = 0, unsigned length = 0) + : line(line), column(column), length(length) {} }; typedef QHash<CPlusPlus::Symbol *, QList<Use> > LocalUseMap; typedef QHashIterator<CPlusPlus::Symbol *, QList<Use> > LocalUseIterator; - typedef QHash<CPlusPlus::Identifier *, QList<Use> > ExternalUseMap; - typedef QHashIterator<CPlusPlus::Identifier *, QList<Use> > ExternalUseIterator; - SemanticInfo() - : revision(-1) + : revision(-1) { } int revision; CPlusPlus::Snapshot snapshot; CPlusPlus::Document::Ptr doc; LocalUseMap localUses; - ExternalUseMap externalUses; }; class SemanticHighlighter: public QThread |