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

Keeps static functions/variables out of the index, see bug 161216

This commit is contained in:
Markus Schorn 2006-10-25 14:32:45 +00:00
parent 8219ea4ef8
commit 429128162f
8 changed files with 80 additions and 50 deletions

View file

@ -49,9 +49,10 @@ public class CFunctionTests extends PDOMTestBase {
}
public void testStaticCFunction() throws Exception {
// static elements cannot be found on global scope, see bug 161216
IBinding[] bindings = findQualifiedName(pdom, "staticCFunction");
assertEquals(1, bindings.length);
assertTrue(((IFunction) bindings[0]).isStatic());
assertEquals(0, bindings.length);
// assertTrue(((IFunction) bindings[0]).isStatic());
}
public void testInlineCFunction() throws Exception {

View file

@ -91,9 +91,10 @@ public class CPPFunctionTests extends PDOMTestBase {
}
public void testStaticCPPFunction() throws Exception {
// static elements cannot be found on global scope, see bug 161216
IBinding[] bindings = findQualifiedName(pdom, "staticCPPFunction");
assertEquals(1, bindings.length);
assertTrue(((ICPPFunction) bindings[0]).isStatic());
assertEquals(0, bindings.length);
// assertTrue(((ICPPFunction) bindings[0]).isStatic());
}
public void testInlineCPPFunction() throws Exception {

View file

@ -64,9 +64,10 @@ public class CPPVariableTests extends PDOMTestBase {
}
public void testCPPStaticVariable() throws Exception {
// static elements cannot be found on global scope, see bug 161216
IBinding[] bindings = findQualifiedName(pdom, "staticCPPVariable");
assertEquals(1, bindings.length);
ICPPVariable variable = (ICPPVariable) bindings[0];
assertTrue(variable.isStatic());
assertEquals(0, bindings.length);
// ICPPVariable variable = (ICPPVariable) bindings[0];
// assertTrue(variable.isStatic());
}
}

View file

@ -64,10 +64,11 @@ public class CVariableTests extends PDOMTestBase {
}
public void testCStaticVariable() throws Exception {
// static elements cannot be found on global scope, see bug 161216
IBinding[] bindings = findQualifiedName(pdom, "staticCVariable");
assertEquals(1, bindings.length);
IVariable variable = (IVariable) bindings[0];
assertTrue(variable.isStatic());
assertEquals(0, bindings.length);
// IVariable variable = (IVariable) bindings[0];
// assertTrue(variable.isStatic());
}
}

View file

@ -227,12 +227,18 @@ public class DefDeclTests extends PDOMTestBase {
public void testStaticBindings_f08_unexpected() throws Exception {
// should be 2 bindings, otherwise how to distinguish proper def/decl
// pairs?
// static elements cannot be found on global scope, see bug 161216
String elName = "foo" + "08";
IBinding binding = findSingleBinding(elName);
checkDefinition(binding, "def" + "08", 2);
checkReference(binding, "ref" + "08", 2);
checkDefinition(binding, "defS" + "08", 2);
checkReference(binding, "refS" + "08", 2);
IBinding[] binds = pdom.findBindings(Pattern.compile(elName), true,
IndexFilter.ALL, new NullProgressMonitor());
assertEquals(0, binds.length);
// assertEquals(elName, binds[0].getName());
// IBinding element = binds[0];
// IBinding binding = element;
// checkDefinition(binding, "def" + "08", 2);
// checkReference(binding, "ref" + "08", 2);
// checkDefinition(binding, "defS" + "08", 2);
// checkReference(binding, "refS" + "08", 2);
}
public void testSimpleGlobalWrite_v09() throws Exception {

View file

@ -104,41 +104,54 @@ class PDOMCLinkage extends PDOMLinkage {
return null;
PDOMBinding pdomBinding = adaptBinding(binding);
if (pdomBinding == null) {
PDOMNode parent = getAdaptedParent(binding);
if (parent == null)
return null;
try {
if (pdomBinding == null) {
PDOMNode parent = getAdaptedParent(binding);
if (parent == null)
return null;
if (binding instanceof IParameter)
return null; // skip parameters
else if (binding instanceof IField) { // must be before IVariable
if (parent instanceof IPDOMMemberOwner)
pdomBinding = new PDOMCField(pdom, (IPDOMMemberOwner)parent, name);
} else if (binding instanceof IVariable)
pdomBinding = new PDOMCVariable(pdom, parent, name);
else if (binding instanceof IFunction)
pdomBinding = new PDOMCFunction(pdom, parent, name);
else if (binding instanceof ICompositeType)
pdomBinding = new PDOMCStructure(pdom, parent, name);
else if (binding instanceof IEnumeration)
pdomBinding = new PDOMCEnumeration(pdom, parent, name);
else if (binding instanceof IEnumerator) {
try {
IEnumeration enumeration = (IEnumeration)((IEnumerator)binding).getType();
PDOMBinding pdomEnumeration = adaptBinding(enumeration);
if (pdomEnumeration instanceof PDOMCEnumeration)
pdomBinding = new PDOMCEnumerator(pdom, parent, name,
(PDOMCEnumeration)pdomEnumeration);
} catch (DOMException e) {
throw new CoreException(Util.createStatus(e));
if (binding instanceof IParameter)
return null; // skip parameters
else if (binding instanceof IField) { // must be before IVariable
if (parent instanceof IPDOMMemberOwner)
pdomBinding = new PDOMCField(pdom, (IPDOMMemberOwner)parent, name);
} else if (binding instanceof IVariable) {
IVariable var= (IVariable) binding;
if (!var.isStatic()) { // bug 161216
pdomBinding = new PDOMCVariable(pdom, parent, name);
}
}
else if (binding instanceof IFunction) {
IFunction func= (IFunction) binding;
if (!func.isStatic()) { // bug 161216
pdomBinding = new PDOMCFunction(pdom, parent, name);
}
}
else if (binding instanceof ICompositeType)
pdomBinding = new PDOMCStructure(pdom, parent, name);
else if (binding instanceof IEnumeration)
pdomBinding = new PDOMCEnumeration(pdom, parent, name);
else if (binding instanceof IEnumerator) {
try {
IEnumeration enumeration = (IEnumeration)((IEnumerator)binding).getType();
PDOMBinding pdomEnumeration = adaptBinding(enumeration);
if (pdomEnumeration instanceof PDOMCEnumeration)
pdomBinding = new PDOMCEnumerator(pdom, parent, name,
(PDOMCEnumeration)pdomEnumeration);
} catch (DOMException e) {
throw new CoreException(Util.createStatus(e));
}
} else if (binding instanceof ITypedef)
pdomBinding = new PDOMCTypedef(pdom, parent, name, (ITypedef)binding);
if(pdomBinding!=null) {
parent.addChild(pdomBinding);
}
} else if (binding instanceof ITypedef)
pdomBinding = new PDOMCTypedef(pdom, parent, name, (ITypedef)binding);
if(pdomBinding!=null) {
parent.addChild(pdomBinding);
}
}
catch (DOMException e) {
throw new CoreException(Util.createStatus(e));
}
if (pdomBinding != null)
new PDOMName(pdom, name, file, pdomBinding);

View file

@ -136,8 +136,12 @@ class PDOMCPPLinkage extends PDOMLinkage {
if (binding instanceof ICPPField && parent instanceof PDOMCPPClassType)
pdomBinding = new PDOMCPPField(pdom, (PDOMCPPClassType)parent, name);
else if (binding instanceof ICPPVariable) {
if (!(binding.getScope() instanceof CPPBlockScope))
pdomBinding = new PDOMCPPVariable(pdom, parent, name);
if (!(binding.getScope() instanceof CPPBlockScope)) {
ICPPVariable var= (ICPPVariable) binding;
if (!var.isStatic()) { // bug 161216
pdomBinding = new PDOMCPPVariable(pdom, parent, name);
}
}
} else if (binding instanceof ICPPMethod && parent instanceof PDOMCPPClassType) {
pdomBinding = new PDOMCPPMethod(pdom, parent, name);
} else if (binding instanceof CPPImplicitMethod && parent instanceof PDOMCPPClassType) {
@ -147,7 +151,10 @@ class PDOMCPPLinkage extends PDOMLinkage {
pdomBinding = new PDOMCPPMethod(pdom, parent, name);
}
} else if (binding instanceof ICPPFunction) {
pdomBinding = new PDOMCPPFunction(pdom, parent, name);
ICPPFunction func= (ICPPFunction) binding;
if (!func.isStatic()) { // bug 161216
pdomBinding = new PDOMCPPFunction(pdom, parent, name);
}
} else if (binding instanceof ICPPClassType) {
pdomBinding = new PDOMCPPClassType(pdom, parent, name);
} else if (binding instanceof ICPPNamespaceAlias) {

View file

@ -97,7 +97,7 @@ public class CallHierarchyBaseTest extends BaseUITestCase {
try {
TreeItem root= tree.getItem(i0);
TreeItem item= root.getItem(i1);
for (int i=0; i<20; i++) {
for (int i=0; i<40; i++) {
if (!"...".equals(item.getText())) {
break;
}