mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-01 14:15:23 +02:00
fixing template problems
- finding class definitions for classes nested in templates. - comparing defered template instances
This commit is contained in:
parent
1786169b2b
commit
e7864031ca
3 changed files with 21 additions and 9 deletions
|
@ -233,6 +233,10 @@ public class CPPClassType implements ICPPClassType, ICPPInternalClassType {
|
|||
{
|
||||
IBinding binding = name.resolveBinding();
|
||||
if( binding == CPPClassType.this ){
|
||||
if( name instanceof ICPPASTQualifiedName ){
|
||||
IASTName [] ns = ((ICPPASTQualifiedName)name).getNames();
|
||||
name = ns[ ns.length - 1 ];
|
||||
}
|
||||
result = name;
|
||||
return PROCESS_ABORT;
|
||||
}
|
||||
|
@ -241,7 +245,9 @@ public class CPPClassType implements ICPPClassType, ICPPInternalClassType {
|
|||
}
|
||||
|
||||
public int visit( IASTDeclaration declaration ){
|
||||
return (declaration instanceof IASTSimpleDeclaration ) ? PROCESS_CONTINUE : PROCESS_SKIP;
|
||||
if( declaration instanceof IASTSimpleDeclaration || declaration instanceof ICPPASTTemplateDeclaration )
|
||||
return PROCESS_CONTINUE;
|
||||
return PROCESS_SKIP;
|
||||
}
|
||||
public int visit( IASTDeclSpecifier declSpec ){
|
||||
return (declSpec instanceof ICPPASTCompositeTypeSpecifier ) ? PROCESS_CONTINUE : PROCESS_SKIP;
|
||||
|
@ -254,6 +260,10 @@ public class CPPClassType implements ICPPClassType, ICPPInternalClassType {
|
|||
FindDefinitionAction action = new FindDefinitionAction();
|
||||
IASTNode node = CPPVisitor.getContainingBlockItem( getPhysicalNode() ).getParent();
|
||||
|
||||
if( node instanceof ICPPASTCompositeTypeSpecifier )
|
||||
node = CPPVisitor.getContainingBlockItem( node.getParent() );
|
||||
while( node instanceof ICPPASTTemplateDeclaration )
|
||||
node = node.getParent();
|
||||
node.accept( action );
|
||||
definition = action.result;
|
||||
|
||||
|
|
|
@ -168,13 +168,12 @@ public class CPPDeferredClassInstance extends CPPInstance implements ICPPClassTy
|
|||
return true;
|
||||
|
||||
//allow some fuzziness here.
|
||||
if( !(type instanceof CPPDeferredClassInstance ) )
|
||||
return false;
|
||||
|
||||
ICPPClassTemplate typeClass = (ICPPClassTemplate) ((CPPDeferredClassInstance)type).getSpecializedBinding();
|
||||
if( typeClass != classTemplate )
|
||||
return false;
|
||||
|
||||
return true;
|
||||
if( type instanceof CPPDeferredClassInstance ){
|
||||
ICPPClassTemplate typeClass = (ICPPClassTemplate) ((CPPDeferredClassInstance)type).getSpecializedBinding();
|
||||
return (typeClass == classTemplate );
|
||||
} else if( type instanceof ICPPClassTemplate && classTemplate == type ){
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -892,6 +892,9 @@ public class CPPVisitor {
|
|||
if( binding == null ){
|
||||
binding = CPPSemantics.resolveBinding( name );
|
||||
name.setBinding( binding );
|
||||
if( name instanceof ICPPASTTemplateId && binding instanceof ICPPSpecialization ){
|
||||
((ICPPASTTemplateId)name).getTemplateName().setBinding( ((ICPPSpecialization)binding).getSpecializedBinding() );
|
||||
}
|
||||
}
|
||||
return binding;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue