1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-09-10 03:53:21 +02:00

Comparison of owners, bug 281782.

This commit is contained in:
Markus Schorn 2009-07-02 13:51:53 +00:00
parent 3261b83ecb
commit 10107c0d8e
2 changed files with 25 additions and 29 deletions

View file

@ -1993,7 +1993,7 @@ public class IndexBugsTests extends BaseTestCase {
// }
// enum E { e2 };
public void _testDisambiguationByReachability_281782() throws Exception {
public void testDisambiguationByReachability_281782() throws Exception {
waitForIndexer();
String[] testData = getContentsForTest(3);

View file

@ -44,41 +44,37 @@ abstract class PDOMCPPBinding extends PDOMBinding implements ICPPBinding {
}
protected boolean isSameOwner(IBinding owner1, IBinding owner2) {
if (owner1 == null)
return owner2 == null;
if (owner2 == null)
return false;
if (owner1 instanceof IType) {
if (owner2 instanceof IType) {
return ((IType) owner1).isSameType((IType) owner2);
}
return false;
}
try {
while(owner1 instanceof ICPPNamespace && owner2 instanceof ICPPNamespace) {
final char[] n1 = owner1.getNameCharArray();
// ignore unknown namespaces
if (n1.length == 0) {
owner1= owner1.getOwner();
continue;
}
final char[] n2= owner2.getNameCharArray();
if (n2.length == 0) {
owner2= owner2.getOwner();
continue;
}
if (!CharArrayUtils.equals(n1, n2))
return false;
// ignore unnamed namespaces
while(owner1 instanceof ICPPNamespace && owner1.getNameCharArray().length == 0)
owner1= owner1.getOwner();
// ignore unnamed namespaces
while(owner2 instanceof ICPPNamespace && owner2.getNameCharArray().length == 0)
owner2= owner2.getOwner();
if (owner1 == null)
return owner2 == null;
if (owner2 == null)
return false;
if (owner1 instanceof IType) {
if (owner2 instanceof IType) {
return ((IType) owner1).isSameType((IType) owner2);
}
return false;
}
if (owner1 instanceof ICPPNamespace) {
if (owner2 instanceof ICPPNamespace) {
if (!CharArrayUtils.equals(owner1.getNameCharArray(), owner2.getNameCharArray()))
return false;
return isSameOwner(owner1.getOwner(), owner2.getOwner());
}
return false;
}
} catch (DOMException e) {
CCorePlugin.log(e);
return false;
}
return owner1 == null && owner2 == null;
return false;
}
final public char[][] getQualifiedNameCharArray() throws DOMException {