mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-01 06:05:24 +02:00
Adding member before container (bug 203170).
This commit is contained in:
parent
6e5eb0ce2a
commit
fc6192a14f
3 changed files with 26 additions and 14 deletions
|
@ -1188,4 +1188,23 @@ public class IndexBugsTests extends BaseTestCase {
|
|||
IIndexBinding[] bindings= fIndex.findBindings("ok".toCharArray(), IndexFilter.ALL, NPM);
|
||||
assertEquals(1, bindings.length);
|
||||
}
|
||||
|
||||
// inline void MyClass::method() {}
|
||||
|
||||
// class MyClass {
|
||||
// void method();
|
||||
// };
|
||||
// #include "MyClass_inline.h"
|
||||
public void testAddingMemberBeforeContainer_Bug203170() throws Exception {
|
||||
StringBuffer[] contents= getContentsForTest(2);
|
||||
final IIndexManager indexManager = CCorePlugin.getIndexManager();
|
||||
TestSourceReader.createFile(fCProject.getProject(), "MyClass_inline.h", contents[0].toString());
|
||||
TestSourceReader.createFile(fCProject.getProject(), "source.cpp", contents[1].toString());
|
||||
indexManager.reindex(fCProject);
|
||||
waitForIndexer();
|
||||
IIndexBinding[] bindings= fIndex.findBindings(new char[][]{"MyClass".toCharArray(), "method".toCharArray()}, IndexFilter.ALL, NPM);
|
||||
assertEquals(1, bindings.length);
|
||||
IIndexName[] decls= fIndex.findDeclarations(bindings[0]);
|
||||
assertEquals(2, decls.length);
|
||||
}
|
||||
}
|
|
@ -223,8 +223,7 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants {
|
|||
}
|
||||
else {
|
||||
try {
|
||||
boolean addParent = shouldAddParent(binding);
|
||||
PDOMNode parent = getAdaptedParent(binding, true, addParent);
|
||||
PDOMNode parent = getAdaptedParent(binding, true, true);
|
||||
if (parent == null)
|
||||
return null;
|
||||
pdomBinding = addBinding(parent, binding);
|
||||
|
@ -258,15 +257,6 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants {
|
|||
return false;
|
||||
}
|
||||
|
||||
private boolean shouldAddParent(IBinding binding) throws CoreException {
|
||||
if (binding instanceof ICPPTemplateParameter) {
|
||||
return true;
|
||||
} else if (binding instanceof ICPPSpecialization) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private PDOMBinding addBinding(PDOMNode parent, IBinding binding) throws CoreException, DOMException {
|
||||
PDOMBinding pdomBinding= null;
|
||||
|
||||
|
|
|
@ -21,6 +21,8 @@ import org.eclipse.ui.IWorkbenchPage;
|
|||
import org.eclipse.ui.PlatformUI;
|
||||
import org.eclipse.ui.ide.IDE;
|
||||
|
||||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
|
||||
import org.eclipse.cdt.internal.ui.editor.CEditor;
|
||||
|
||||
|
||||
|
@ -187,6 +189,7 @@ public class CppCallHierarchyTest extends CallHierarchyBaseTest {
|
|||
IFile sourceFile2= createFile(getProject(), "testMethods2.cpp", source2);
|
||||
|
||||
CEditor editor= openFile(sourceFile1);
|
||||
CCorePlugin.getIndexManager().reindex(fCProject);
|
||||
waitForIndexer(fIndex, sourceFile2, CallHierarchyBaseTest.INDEXER_WAIT_TIME);
|
||||
|
||||
editor.selectAndReveal(source1.indexOf("method3"), 2);
|
||||
|
@ -194,9 +197,9 @@ public class CppCallHierarchyTest extends CallHierarchyBaseTest {
|
|||
TreeViewer tv = getCHTreeViewer();
|
||||
|
||||
TreeItem item= checkTreeNode(tv.getTree(), 0, "MyClass::method3()");
|
||||
TreeItem item0= checkTreeNode(item, 0, "MyClass::method1()");
|
||||
TreeItem item1= checkTreeNode(item, 1, "MyClass::method2()");
|
||||
checkTreeNode(item, 2, null); item= null;
|
||||
TreeItem item0= checkTreeNode(tv.getTree(), 0, 0, "MyClass::method1()");
|
||||
TreeItem item1= checkTreeNode(tv.getTree(), 0, 1, "MyClass::method2()");
|
||||
checkTreeNode(tv.getTree(), 0, 2, null); item= null;
|
||||
|
||||
// method 1
|
||||
tv.setExpandedState(item0.getData(), true);
|
||||
|
|
Loading…
Add table
Reference in a new issue