mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
junit test for bug 161216, static functions/vars in PDOM
This commit is contained in:
parent
b202de6bec
commit
9b75c68712
3 changed files with 35 additions and 0 deletions
|
@ -22,7 +22,11 @@ import org.eclipse.cdt.core.dom.IPDOMNode;
|
||||||
import org.eclipse.cdt.core.dom.IPDOMVisitor;
|
import org.eclipse.cdt.core.dom.IPDOMVisitor;
|
||||||
import org.eclipse.cdt.core.dom.ast.IEnumeration;
|
import org.eclipse.cdt.core.dom.ast.IEnumeration;
|
||||||
import org.eclipse.cdt.core.dom.ast.IEnumerator;
|
import org.eclipse.cdt.core.dom.ast.IEnumerator;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IFunction;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IVariable;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPField;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespace;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespace;
|
||||||
import org.eclipse.cdt.core.index.IIndex;
|
import org.eclipse.cdt.core.index.IIndex;
|
||||||
import org.eclipse.cdt.core.index.IIndexBinding;
|
import org.eclipse.cdt.core.index.IIndexBinding;
|
||||||
|
@ -112,6 +116,16 @@ public class IndexSearchTest extends BaseTestCase {
|
||||||
assertTrue(binding instanceof IEnumeration);
|
assertTrue(binding instanceof IEnumeration);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void checkIsFunction(IIndexBinding binding) {
|
||||||
|
assertTrue(binding instanceof IFunction);
|
||||||
|
assertTrue(!(binding instanceof ICPPMethod));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void checkIsVariable(IIndexBinding binding) {
|
||||||
|
assertTrue(binding instanceof IVariable);
|
||||||
|
assertTrue(!(binding instanceof ICPPField));
|
||||||
|
}
|
||||||
|
|
||||||
public void testFindClassInNamespace() throws CoreException {
|
public void testFindClassInNamespace() throws CoreException {
|
||||||
Pattern pcl= Pattern.compile("C160913");
|
Pattern pcl= Pattern.compile("C160913");
|
||||||
Pattern pns= Pattern.compile("ns160913");
|
Pattern pns= Pattern.compile("ns160913");
|
||||||
|
@ -220,6 +234,23 @@ public class IndexSearchTest extends BaseTestCase {
|
||||||
checkIsEnumeration(bindings[0]);
|
checkIsEnumeration(bindings[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void _testFindStatic_161216() throws CoreException {
|
||||||
|
Pattern pFunc= Pattern.compile("staticFunc20061017");
|
||||||
|
Pattern pVar= Pattern.compile("staticVar20061017");
|
||||||
|
|
||||||
|
IIndexBinding[] bindings;
|
||||||
|
|
||||||
|
bindings= fIndex.findBindings(pFunc, true, INDEX_FILTER, NPM);
|
||||||
|
assertEquals(2, bindings.length);
|
||||||
|
checkIsFunction(bindings[0]);
|
||||||
|
checkIsFunction(bindings[1]);
|
||||||
|
|
||||||
|
bindings= fIndex.findBindings(pVar, true, INDEX_FILTER, NPM);
|
||||||
|
assertEquals(2, bindings.length);
|
||||||
|
checkIsVariable(bindings[0]);
|
||||||
|
checkIsVariable(bindings[1]);
|
||||||
|
}
|
||||||
|
|
||||||
public void testSanityOfMayHaveChildren() throws CoreException {
|
public void testSanityOfMayHaveChildren() throws CoreException {
|
||||||
PDOM pdom= (PDOM) ((CIndex) fIndex).getPrimaryFragments()[0];
|
PDOM pdom= (PDOM) ((CIndex) fIndex).getPrimaryFragments()[0];
|
||||||
pdom.accept(new IPDOMVisitor() {
|
pdom.accept(new IPDOMVisitor() {
|
||||||
|
|
|
@ -0,0 +1,2 @@
|
||||||
|
static int staticFunc20061017();
|
||||||
|
static int staticVar20061017;
|
|
@ -0,0 +1,2 @@
|
||||||
|
static int staticFunc20061017();
|
||||||
|
static int staticVar20061017;
|
Loading…
Add table
Reference in a new issue