mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Fix for 201279, [Call Hierarchy] no indication for multiple calls
This commit is contained in:
parent
883825add9
commit
259d11d79b
8 changed files with 91 additions and 36 deletions
|
@ -232,7 +232,7 @@ public class BasicCallHierarchyTest extends CallHierarchyBaseTest {
|
|||
editor.selectAndReveal(content.indexOf("mem2"), 0);
|
||||
openCallHierarchy(editor);
|
||||
checkTreeNode(tree, 0, "s2::mem2");
|
||||
checkTreeNode(tree, 0, 0, "main()");
|
||||
checkTreeNode(tree, 0, 0, "main() (2 matches)");
|
||||
|
||||
editor.selectAndReveal(content.indexOf("mem3"), 0);
|
||||
openCallHierarchy(editor);
|
||||
|
@ -255,7 +255,7 @@ public class BasicCallHierarchyTest extends CallHierarchyBaseTest {
|
|||
editor.selectAndReveal(content.indexOf("mem2; //ref"), 0);
|
||||
openCallHierarchy(editor);
|
||||
checkTreeNode(tree, 0, "s2::mem2");
|
||||
checkTreeNode(tree, 0, 0, "main()");
|
||||
checkTreeNode(tree, 0, 0, "main() (2 matches)");
|
||||
|
||||
editor.selectAndReveal(content.indexOf("mem4."), 0);
|
||||
openCallHierarchy(editor);
|
||||
|
@ -279,7 +279,7 @@ public class BasicCallHierarchyTest extends CallHierarchyBaseTest {
|
|||
editor.selectAndReveal(content.indexOf("mem2"), 0);
|
||||
openCallHierarchy(editor);
|
||||
checkTreeNode(tree, 0, "s2::mem2");
|
||||
checkTreeNode(tree, 0, 0, "main()");
|
||||
checkTreeNode(tree, 0, 0, "main() (2 matches)");
|
||||
|
||||
editor.selectAndReveal(content.indexOf("mem3"), 0);
|
||||
openCallHierarchy(editor);
|
||||
|
@ -302,7 +302,7 @@ public class BasicCallHierarchyTest extends CallHierarchyBaseTest {
|
|||
editor.selectAndReveal(content.indexOf("mem2; //ref"), 0);
|
||||
openCallHierarchy(editor);
|
||||
checkTreeNode(tree, 0, "s2::mem2");
|
||||
checkTreeNode(tree, 0, 0, "main()");
|
||||
checkTreeNode(tree, 0, 0, "main() (2 matches)");
|
||||
|
||||
editor.selectAndReveal(content.indexOf("mem4."), 0);
|
||||
openCallHierarchy(editor);
|
||||
|
@ -418,7 +418,7 @@ public class BasicCallHierarchyTest extends CallHierarchyBaseTest {
|
|||
editor.selectAndReveal(content.indexOf("mem2"), 0);
|
||||
openCallHierarchy(editor);
|
||||
checkTreeNode(tree, 0, "u2::mem2");
|
||||
checkTreeNode(tree, 0, 0, "main()");
|
||||
checkTreeNode(tree, 0, 0, "main() (2 matches)");
|
||||
|
||||
editor.selectAndReveal(content.indexOf("mem3"), 0);
|
||||
openCallHierarchy(editor);
|
||||
|
@ -441,7 +441,7 @@ public class BasicCallHierarchyTest extends CallHierarchyBaseTest {
|
|||
editor.selectAndReveal(content.indexOf("mem2; //ref"), 0);
|
||||
openCallHierarchy(editor);
|
||||
checkTreeNode(tree, 0, "u2::mem2");
|
||||
checkTreeNode(tree, 0, 0, "main()");
|
||||
checkTreeNode(tree, 0, 0, "main() (2 matches)");
|
||||
|
||||
editor.selectAndReveal(content.indexOf("mem4."), 0);
|
||||
openCallHierarchy(editor);
|
||||
|
@ -465,7 +465,7 @@ public class BasicCallHierarchyTest extends CallHierarchyBaseTest {
|
|||
editor.selectAndReveal(content.indexOf("mem2"), 0);
|
||||
openCallHierarchy(editor);
|
||||
checkTreeNode(tree, 0, "u2::mem2");
|
||||
checkTreeNode(tree, 0, 0, "main()");
|
||||
checkTreeNode(tree, 0, 0, "main() (2 matches)");
|
||||
|
||||
editor.selectAndReveal(content.indexOf("mem3"), 0);
|
||||
openCallHierarchy(editor);
|
||||
|
@ -488,7 +488,7 @@ public class BasicCallHierarchyTest extends CallHierarchyBaseTest {
|
|||
editor.selectAndReveal(content.indexOf("mem2; //ref"), 0);
|
||||
openCallHierarchy(editor);
|
||||
checkTreeNode(tree, 0, "u2::mem2");
|
||||
checkTreeNode(tree, 0, 0, "main()");
|
||||
checkTreeNode(tree, 0, 0, "main() (2 matches)");
|
||||
|
||||
editor.selectAndReveal(content.indexOf("mem4."), 0);
|
||||
openCallHierarchy(editor);
|
||||
|
|
|
@ -17,6 +17,7 @@ import org.eclipse.jface.text.ITextSelection;
|
|||
import org.eclipse.jface.viewers.TreeViewer;
|
||||
import org.eclipse.swt.SWTException;
|
||||
import org.eclipse.swt.widgets.TreeItem;
|
||||
import org.eclipse.ui.IViewReference;
|
||||
import org.eclipse.ui.IWorkbenchPage;
|
||||
import org.eclipse.ui.PartInitException;
|
||||
import org.eclipse.ui.PlatformUI;
|
||||
|
@ -52,6 +53,12 @@ public class CallHierarchyBaseTest extends BaseUITestCase {
|
|||
fCProject= CProjectHelper.createCCProject(prjName, "bin", IPDOMManager.ID_FAST_INDEXER);
|
||||
CCorePlugin.getIndexManager().joinIndexer(INDEXER_WAIT_TIME, NPM);
|
||||
fIndex= CCorePlugin.getIndexManager().getIndex(fCProject);
|
||||
IWorkbenchPage page= PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
|
||||
IViewReference[] refs= page.getViewReferences();
|
||||
for (int i = 0; i < refs.length; i++) {
|
||||
IViewReference viewReference = refs[i];
|
||||
page.setPartState(viewReference, IWorkbenchPage.STATE_RESTORED);
|
||||
}
|
||||
}
|
||||
|
||||
protected void tearDown() throws Exception {
|
||||
|
|
|
@ -17,6 +17,7 @@ import java.util.Iterator;
|
|||
import org.eclipse.jface.resource.ImageDescriptor;
|
||||
import org.eclipse.jface.viewers.IColorProvider;
|
||||
import org.eclipse.jface.viewers.LabelProvider;
|
||||
import org.eclipse.osgi.util.NLS;
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.graphics.Color;
|
||||
import org.eclipse.swt.graphics.Image;
|
||||
|
@ -72,16 +73,22 @@ public class CHLabelProvider extends LabelProvider implements IColorProvider {
|
|||
CHNode node= (CHNode) element;
|
||||
ICElement decl= node.getOneRepresentedDeclaration();
|
||||
if (decl != null) {
|
||||
String label;
|
||||
if (node.isMultiDef()) {
|
||||
int options= fCLabelProvider.getTextFlags();
|
||||
fCLabelProvider.setTextFlags(LABEL_OPTIONS_SIMPLE);
|
||||
String result= fCLabelProvider.getText(decl);
|
||||
label= fCLabelProvider.getText(decl);
|
||||
fCLabelProvider.setTextFlags(options);
|
||||
return result;
|
||||
}
|
||||
String label= fCLabelProvider.getText(decl);
|
||||
if (node.isInitializer()) {
|
||||
label= addInitializerDecoration(label);
|
||||
else {
|
||||
label= fCLabelProvider.getText(decl);
|
||||
if (node.isInitializer()) {
|
||||
label= addInitializerDecoration(label);
|
||||
}
|
||||
}
|
||||
int refCount= node.getReferenceCount();
|
||||
if (refCount > 1) {
|
||||
label += NLS.bind(" ({0} {1})", new Integer(refCount), CHMessages.CHLabelProvider_matches); //$NON-NLS-1$
|
||||
}
|
||||
return label;
|
||||
}
|
||||
|
|
|
@ -22,6 +22,7 @@ public class CHMessages extends NLS {
|
|||
public static String CHHistoryListAction_HistoryList_label;
|
||||
public static String CHHistoryListAction_OpenHistory_label;
|
||||
public static String CHHistoryListAction_Remove_label;
|
||||
public static String CHLabelProvider_matches;
|
||||
public static String CHViewPart_emptyPageMessage;
|
||||
public static String CHViewPart_FilterVariables_label;
|
||||
public static String CHViewPart_FilterVariables_tooltip;
|
||||
|
|
|
@ -34,6 +34,7 @@ CHViewPart_Title_callees=Calls from {0} - in {1}
|
|||
CHViewPart_FocusOn_label=Focus On ''{0}''
|
||||
CHViewPart_Open_label=Open
|
||||
CHViewPart_Open_tooltip=Open
|
||||
CHLabelProvider_matches=matches
|
||||
CHViewPart_OpenReference_label=Open Reference
|
||||
CHHistoryDropDownAction_ClearHistory_label=Clear History
|
||||
CHHistoryListAction_HistoryDialog_title=Call Hierarchy History
|
||||
|
|
|
@ -0,0 +1,44 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2007 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
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* 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;
|
||||
|
||||
/**
|
||||
* Represents a node in the include browser
|
||||
*/
|
||||
public class CHMultiDefChildNode extends CHNode {
|
||||
|
||||
/**
|
||||
* Creates a new node for the include browser
|
||||
*/
|
||||
public CHMultiDefChildNode(CHMultiDefNode parent, ITranslationUnit fileOfReferences, long timestamp, ICElement decl) {
|
||||
super(parent, fileOfReferences, timestamp, decl);
|
||||
}
|
||||
|
||||
public int getReferenceCount() {
|
||||
return getParent().getReferenceCount();
|
||||
}
|
||||
|
||||
public CHReferenceInfo getReference(int idx) {
|
||||
return getParent().getReference(idx);
|
||||
}
|
||||
|
||||
public int getFirstReferenceOffset() {
|
||||
return getParent().getFirstReferenceOffset();
|
||||
}
|
||||
|
||||
public void addReference(CHReferenceInfo info) {
|
||||
assert false;
|
||||
}
|
||||
}
|
|
@ -26,7 +26,7 @@ public class CHMultiDefNode extends CHNode {
|
|||
fChildren= new CHNode[elements.length];
|
||||
for (int i = 0; i < elements.length; i++) {
|
||||
ICElement element = elements[i];
|
||||
fChildren[i]= new CHNode(this, null, 0, element);
|
||||
fChildren[i]= new CHMultiDefChildNode(this, tu, timestamp, element);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -332,7 +332,7 @@ public class CHViewPart extends ViewPart {
|
|||
}
|
||||
|
||||
private void createActions() {
|
||||
// action gruops
|
||||
// action groups
|
||||
fOpenViewActionGroup= new OpenViewActionGroup(this);
|
||||
fOpenViewActionGroup.setSuppressCallHierarchy(true);
|
||||
fOpenViewActionGroup.setSuppressProperties(true);
|
||||
|
@ -564,8 +564,14 @@ public class CHViewPart extends ViewPart {
|
|||
}
|
||||
|
||||
protected void onShowSelectedReference(ISelection selection) {
|
||||
fNavigationDetail= 0;
|
||||
fNavigationNode= selectionToNode(selection);
|
||||
CHNode node= selectionToNode(selection);
|
||||
if (node != null && node == fNavigationNode && node.getReferenceCount() > 0) {
|
||||
fNavigationDetail= (fNavigationDetail + 1) % node.getReferenceCount();
|
||||
}
|
||||
else {
|
||||
fNavigationDetail= 0;
|
||||
}
|
||||
fNavigationNode= node;
|
||||
showReference();
|
||||
}
|
||||
|
||||
|
@ -719,27 +725,26 @@ public class CHViewPart extends ViewPart {
|
|||
}
|
||||
|
||||
private void showReference() {
|
||||
CHNode node= getReferenceNode();
|
||||
if (node != null) {
|
||||
ITranslationUnit file= node.getFileOfReferences();
|
||||
if (fNavigationNode != null) {
|
||||
ITranslationUnit file= fNavigationNode.getFileOfReferences();
|
||||
if (file != null) {
|
||||
IWorkbenchPage page= getSite().getPage();
|
||||
if (node.getReferenceCount() > 0) {
|
||||
long timestamp= node.getTimestamp();
|
||||
if (fNavigationNode.getReferenceCount() > 0) {
|
||||
long timestamp= fNavigationNode.getTimestamp();
|
||||
if (fNavigationDetail < 0) {
|
||||
fNavigationDetail= 0;
|
||||
}
|
||||
else if (fNavigationDetail >= node.getReferenceCount()-1) {
|
||||
fNavigationDetail= node.getReferenceCount()-1;
|
||||
else if (fNavigationDetail >= fNavigationNode.getReferenceCount()-1) {
|
||||
fNavigationDetail= fNavigationNode.getReferenceCount()-1;
|
||||
}
|
||||
|
||||
CHReferenceInfo ref= node.getReference(fNavigationDetail);
|
||||
CHReferenceInfo ref= fNavigationNode.getReference(fNavigationDetail);
|
||||
Region region= new Region(ref.getOffset(), ref.getLength());
|
||||
EditorOpener.open(page, file, region, timestamp);
|
||||
}
|
||||
else {
|
||||
try {
|
||||
EditorOpener.open(page, node.getRepresentedDeclaration());
|
||||
EditorOpener.open(page, fNavigationNode.getRepresentedDeclaration());
|
||||
} catch (CModelException e) {
|
||||
CUIPlugin.getDefault().log(e);
|
||||
}
|
||||
|
@ -748,16 +753,6 @@ public class CHViewPart extends ViewPart {
|
|||
}
|
||||
}
|
||||
|
||||
private CHNode getReferenceNode() {
|
||||
if (fNavigationNode != null) {
|
||||
CHNode parent = fNavigationNode.getParent();
|
||||
if (parent instanceof CHMultiDefNode) {
|
||||
return parent;
|
||||
}
|
||||
}
|
||||
return fNavigationNode;
|
||||
}
|
||||
|
||||
private int getReferenceCount(CHNode node) {
|
||||
if (node != null) {
|
||||
CHNode parent = node.getParent();
|
||||
|
|
Loading…
Add table
Reference in a new issue