Commit 319a0e2a authored by Roberto Raggi's avatar Roberto Raggi

Search for possible uses of local symbols in template arguments and removed some deprecated code.

parent 06abe6b8
......@@ -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;
}
......@@ -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
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment