diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/callhierarchy/CallHierarchyBugs.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/callhierarchy/CallHierarchyBugs.java index f7b2e522212..ae423f5d01b 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/callhierarchy/CallHierarchyBugs.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/callhierarchy/CallHierarchyBugs.java @@ -279,4 +279,62 @@ public class CallHierarchyBugs extends CallHierarchyBaseTest { TreeItem item= checkTreeNode(chTree, 0, 0, "test()"); checkTreeNode(chTree, 0, 1, null); } + + // class Base { + // public: + // virtual void First() {} + // virtual void Second() {} + // }; + // + // class Derived: public Base { + // public: + // virtual void First() {} + // virtual void Second() {} + // }; + // + // void func(Base *base) { + // base->First(); + // base->Second(); + // } + // + // int main() { + // Derived derived; + // func(&derived); + // return 0; + // } + public void testMultiplePolyMorphicMethodCalls_244987() throws Exception { + String content= getContentsForTest(1)[0].toString(); + IFile file= createFile(getProject(), "SomeClass244987.cpp", content); + waitForIndexer(fIndex, file, CallHierarchyBaseTest.INDEXER_WAIT_TIME); + + final CHViewPart ch= (CHViewPart) activateView(CUIPlugin.ID_CALL_HIERARCHY); + final IWorkbenchWindow workbenchWindow = ch.getSite().getWorkbenchWindow(); + + // open editor, check outline + CEditor editor= openEditor(file); + int idx = content.indexOf("main"); + editor.selectAndReveal(idx, 0); + openCallHierarchy(editor, false); + + Tree chTree= checkTreeNode(ch, 0, "main()").getParent(); + TreeItem ti= checkTreeNode(chTree, 0, 0, "func(Base *)"); + expandTreeItem(ti); + checkTreeNode(chTree, 0, 1, null); + + TreeItem ti1= checkTreeNode(ti, 0, "Base::First()"); + expandTreeItem(ti1); + TreeItem ti2= checkTreeNode(ti, 1, "Base::Second()"); + expandTreeItem(ti2); + checkTreeNode(ti, 2, null); + + checkTreeNode(ti1, 0, "Base::First()"); + checkTreeNode(ti1, 1, "Derived::First()"); + checkTreeNode(ti1, 2, null); + + checkTreeNode(ti2, 0, "Base::Second()"); + checkTreeNode(ti2, 1, "Derived::Second()"); + checkTreeNode(ti2, 2, null); + + } + } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHMultiDefNode.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHMultiDefNode.java index aa19b549e4f..422eed6288d 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHMultiDefNode.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHMultiDefNode.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2006, 2007 Wind River Systems, Inc. and others. + * Copyright (c) 2006, 2008 Wind River Systems, Inc. and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -8,12 +8,13 @@ * Contributors: * Markus Schorn - initial API and implementation *******************************************************************************/ - package org.eclipse.cdt.internal.ui.callhierarchy; import org.eclipse.cdt.core.model.ICElement; import org.eclipse.cdt.core.model.ITranslationUnit; +import org.eclipse.cdt.internal.ui.util.CoreUtility; + public class CHMultiDefNode extends CHNode { private CHNode[] fChildren; @@ -23,6 +24,7 @@ public class CHMultiDefNode extends CHNode { if (elements.length == 0) { throw new IllegalArgumentException(); } + fHashCode+= elements[0].hashCode(); fChildren= new CHNode[elements.length]; for (int i = 0; i < elements.length; i++) { ICElement element = elements[i]; @@ -54,4 +56,14 @@ public class CHMultiDefNode extends CHNode { public boolean isMultiDef() { return true; } + + @Override + public boolean equals(Object o) { + if (!super.equals(o) || !(o instanceof CHMultiDefNode)) + return false; + + final CHMultiDefNode rhs = (CHMultiDefNode) o; + return CoreUtility.safeEquals(getOneRepresentedDeclaration(), rhs.getOneRepresentedDeclaration()); + } + } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHNode.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHNode.java index cc708fb72a6..8191a0c8829 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHNode.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHNode.java @@ -33,7 +33,7 @@ public class CHNode implements IAdaptable { private ITranslationUnit fFileOfReferences; private List fReferences; - private int fHashCode; + protected int fHashCode; private long fTimestamp; private boolean fIsRecursive; private boolean fIsInitializer; @@ -54,7 +54,7 @@ public class CHNode implements IAdaptable { } private int computeHashCode() { - int hashCode= 0; + int hashCode= 1; if (fParent != null) { hashCode= fParent.hashCode() * 31; }