1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-06-06 17:26:01 +02:00

Patch for Bryan - 180784 - implement hashCode for PDOM nodes.

This commit is contained in:
Doug Schaefer 2007-04-10 01:10:53 +00:00
parent 97186148e9
commit 16be9da24e
3 changed files with 33 additions and 0 deletions

View file

@ -16,8 +16,12 @@ import junit.framework.TestSuite;
import org.eclipse.cdt.core.dom.ast.IASTName;
import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.IScope;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassTemplate;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespace;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPSpecialization;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameter;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPVariable;
import org.eclipse.cdt.core.parser.util.ObjectMap;
/**
* For testing PDOM binding resolution
@ -161,6 +165,27 @@ public class IndexBindingResolutionBugs extends IndexBindingResolutionTestBase {
IScope scope= binding.getScope();
}
// template<class T, class U, class V>
// class A {};
// template<>
// class A<int, bool, double> {};
public void testBug180784() throws Exception {
IBinding b0= getBindingFromASTName("A<int, bool, double> {};", 20);
assertInstance(b0, ICPPSpecialization.class);
ICPPSpecialization s= (ICPPSpecialization) b0;
ObjectMap map= s.getArgumentMap();
IBinding b1= s.getSpecializedBinding();
assertInstance(b1, ICPPClassTemplate.class);
ICPPClassTemplate t= (ICPPClassTemplate) b1;
ICPPTemplateParameter[] ps = t.getTemplateParameters();
assertNotNull(ps);
assertEquals(3, ps.length);
assertNotNull(map.get(ps[0]));
assertNotNull(map.get(ps[1]));
assertNotNull(map.get(ps[2]));
}
// class A{};
//
// template<typename T>

View file

@ -100,4 +100,8 @@ public abstract class CompositeIndexBinding implements IIndexBinding {
return super.equals(obj);
}
public int hashCode() {
return rbinding.hashCode();
}
}

View file

@ -77,6 +77,10 @@ public abstract class PDOMNode implements IPDOMNode {
return super.equals(obj);
}
public int hashCode() {
return 31 * pdom.getPath().hashCode() + 41 * record;
}
public void accept(IPDOMVisitor visitor) throws CoreException {
// No children here.
}