mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
make sure template parameters have all their declarations added
This commit is contained in:
parent
cc677cd35b
commit
19b964b6f1
2 changed files with 11 additions and 6 deletions
|
@ -176,6 +176,8 @@ public abstract class CPPTemplateDefinition implements ICPPTemplateDefinition, I
|
||||||
if( paramName.getBinding() != null ){
|
if( paramName.getBinding() != null ){
|
||||||
binding = paramName.getBinding();
|
binding = paramName.getBinding();
|
||||||
name.setBinding( binding );
|
name.setBinding( binding );
|
||||||
|
if( binding instanceof ICPPInternalBinding )
|
||||||
|
((ICPPInternalBinding)binding).addDeclaration( name );
|
||||||
return binding;
|
return binding;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -198,8 +200,10 @@ public abstract class CPPTemplateDefinition implements ICPPTemplateDefinition, I
|
||||||
temp = template.getTemplateParameters()[i];
|
temp = template.getTemplateParameters()[i];
|
||||||
|
|
||||||
IASTName n = CPPTemplates.getTemplateParameterName( temp );
|
IASTName n = CPPTemplates.getTemplateParameterName( temp );
|
||||||
if( n != name ) {
|
if( n != name && n.getBinding() == null ) {
|
||||||
n.setBinding( binding );
|
n.setBinding( binding );
|
||||||
|
if( binding instanceof ICPPInternalBinding )
|
||||||
|
((ICPPInternalBinding)binding).addDeclaration( n );
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -131,15 +131,16 @@ public class CPPTemplateParameter implements ICPPTemplateParameter, ICPPInternal
|
||||||
if( declarations == null )
|
if( declarations == null )
|
||||||
declarations = new IASTName[] { name };
|
declarations = new IASTName[] { name };
|
||||||
else {
|
else {
|
||||||
|
if( declarations.length > 0 && declarations[0] == node )
|
||||||
|
return;
|
||||||
//keep the lowest offset declaration in [0]
|
//keep the lowest offset declaration in [0]
|
||||||
if( declarations.length > 0 && ((ASTNode)node).getOffset() < ((ASTNode)declarations[0]).getOffset() ){
|
if( declarations.length > 0 && ((ASTNode)node).getOffset() < ((ASTNode)declarations[0]).getOffset() ){
|
||||||
IASTName temp = declarations[0];
|
declarations = (IASTName[]) ArrayUtil.prepend( IASTName.class, declarations, name );
|
||||||
declarations[0] = name;
|
} else {
|
||||||
name = temp;
|
|
||||||
}
|
|
||||||
declarations = (IASTName[]) ArrayUtil.append( IASTName.class, declarations, name );
|
declarations = (IASTName[]) ArrayUtil.append( IASTName.class, declarations, name );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
public void removeDeclaration(IASTNode node) {
|
public void removeDeclaration(IASTNode node) {
|
||||||
if( declarations != null ) {
|
if( declarations != null ) {
|
||||||
for (int i = 0; i < declarations.length; i++) {
|
for (int i = 0; i < declarations.length; i++) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue