C++: fix 'find usages' for templates

Fix find usages for template class(class name and template parameters)
or template function(template parameters).

Fixed:
* marking
* find usages
* follow symbol

Change-Id: I22fdbc11260cbd8ee9aafdd76aaeee0f4f49f9fd
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
This commit is contained in:
Przemyslaw Gorszkowski
2013-06-07 08:15:19 +02:00
committed by Erik Verbruggen
parent afe1d5ee65
commit 94dd4e740a
3 changed files with 146 additions and 7 deletions

View File

@@ -207,10 +207,36 @@ bool FindUsages::checkCandidates(const QList<LookupItem> &candidates) const
}
if (isLocalScope(_declSymbol->enclosingScope()) || isLocalScope(s->enclosingScope())) {
if (s->enclosingScope()->isTemplate()) {
if (_declSymbol->isClass() && _declSymbol->enclosingScope()->isTemplate()
&& s->isClass() && s->enclosingScope()->isTemplate()) {
// for definition of functions of class defined outside the class definition
Scope *templEnclosingDeclSymbol = _declSymbol->enclosingScope();
Scope *scopeOfTemplEnclosingDeclSymbol
= templEnclosingDeclSymbol->enclosingScope();
Scope *templEnclosingCandidateSymbol = s->enclosingScope();
Scope *scopeOfTemplEnclosingCandidateSymbol
= templEnclosingCandidateSymbol->enclosingScope();
if (scopeOfTemplEnclosingCandidateSymbol != scopeOfTemplEnclosingDeclSymbol)
return false;
} else if (_declSymbol->isClass() && _declSymbol->enclosingScope()->isTemplate()
&& s->enclosingScope()->isClass()
&& s->enclosingScope()->enclosingScope()->isTemplate()) {
// for declaration inside template class
Scope *templEnclosingDeclSymbol = _declSymbol->enclosingScope();
Scope *scopeOfTemplEnclosingDeclSymbol
= templEnclosingDeclSymbol->enclosingScope();
Scope *templEnclosingCandidateSymbol = s->enclosingScope()->enclosingScope();
Scope *scopeOfTemplEnclosingCandidateSymbol
= templEnclosingCandidateSymbol->enclosingScope();
if (scopeOfTemplEnclosingCandidateSymbol != scopeOfTemplEnclosingDeclSymbol)
return false;
} else if (s->enclosingScope()->isTemplate() && ! _declSymbol->isTypenameArgument()) {
if (s->enclosingScope()->enclosingScope() != _declSymbol->enclosingScope())
return false;
} else if (! s->isUsingDeclaration() && s->enclosingScope() != _declSymbol->enclosingScope()) {
} else if (! s->isUsingDeclaration()
&& s->enclosingScope() != _declSymbol->enclosingScope()) {
return false;
}
}