mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-09-10 12:03:16 +02:00
Comparison of owners, bug 281782.
This commit is contained in:
parent
3261b83ecb
commit
10107c0d8e
2 changed files with 25 additions and 29 deletions
|
@ -1993,7 +1993,7 @@ public class IndexBugsTests extends BaseTestCase {
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// enum E { e2 };
|
// enum E { e2 };
|
||||||
public void _testDisambiguationByReachability_281782() throws Exception {
|
public void testDisambiguationByReachability_281782() throws Exception {
|
||||||
waitForIndexer();
|
waitForIndexer();
|
||||||
|
|
||||||
String[] testData = getContentsForTest(3);
|
String[] testData = getContentsForTest(3);
|
||||||
|
|
|
@ -44,41 +44,37 @@ abstract class PDOMCPPBinding extends PDOMBinding implements ICPPBinding {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean isSameOwner(IBinding owner1, IBinding owner2) {
|
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 {
|
try {
|
||||||
while(owner1 instanceof ICPPNamespace && owner2 instanceof ICPPNamespace) {
|
// ignore unnamed namespaces
|
||||||
final char[] n1 = owner1.getNameCharArray();
|
while(owner1 instanceof ICPPNamespace && owner1.getNameCharArray().length == 0)
|
||||||
// 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;
|
|
||||||
|
|
||||||
owner1= owner1.getOwner();
|
owner1= owner1.getOwner();
|
||||||
|
// ignore unnamed namespaces
|
||||||
|
while(owner2 instanceof ICPPNamespace && owner2.getNameCharArray().length == 0)
|
||||||
owner2= owner2.getOwner();
|
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) {
|
} catch (DOMException e) {
|
||||||
CCorePlugin.log(e);
|
CCorePlugin.log(e);
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
return owner1 == null && owner2 == null;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
final public char[][] getQualifiedNameCharArray() throws DOMException {
|
final public char[][] getQualifiedNameCharArray() throws DOMException {
|
||||||
|
|
Loading…
Add table
Reference in a new issue