diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/typehierarchy/TypeHierarchyBaseTest.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/typehierarchy/TypeHierarchyBaseTest.java index a5317a955b4..32a4dd57855 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/typehierarchy/TypeHierarchyBaseTest.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/typehierarchy/TypeHierarchyBaseTest.java @@ -76,13 +76,11 @@ public class TypeHierarchyBaseTest extends BaseUITestCase { } protected void openTypeHierarchy(CEditor editor) { - TypeHierarchyUI.setIsJUnitTest(true); TypeHierarchyUI.open(editor, (ITextSelection) editor.getSelectionProvider().getSelection()); runEventQueue(200); } protected void openTypeHierarchy(CEditor editor, int mode) { - TypeHierarchyUI.setIsJUnitTest(true); TypeHierarchyUI.open(editor, (ITextSelection) editor.getSelectionProvider().getSelection()); runEventQueue(0); THViewPart th= null; diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CallHierarchyUI.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CallHierarchyUI.java index 6f691f3dda6..6e56a7ed297 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CallHierarchyUI.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CallHierarchyUI.java @@ -138,12 +138,9 @@ public class CallHierarchyUI { else { ICElement[] elems= IndexUI.findAllDefinitions(index, binding); if (elems.length == 0) { - elems= IndexUI.findAllDefinitions(index, binding); - if (elems.length == 0) { - ICElement elem= IndexUI.findAnyDeclaration(index, project, binding); - if (elems != null) { - elems= new ICElement[]{elem}; - } + ICElement elem= IndexUI.findAnyDeclaration(index, project, binding); + if (elems != null) { + elems= new ICElement[]{elem}; } } return elems; diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/WorkInProgressPreferencePage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/WorkInProgressPreferencePage.java index a8ce2043d7b..5f2a3374ecd 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/WorkInProgressPreferencePage.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/WorkInProgressPreferencePage.java @@ -86,7 +86,6 @@ public class WorkInProgressPreferencePage extends PreferencePage implements IWor // Add your controls here addCheckBox(result, "Use new model builder", CCorePlugin.PREF_USE_NEW_MODEL_BUILDER); //$NON-NLS-1$ - addCheckBox(result, "Show context menus for type hierarchy", "showCtxMenuTypeHierarchy"); //$NON-NLS-1$ //$NON-NLS-2$ applyDialogFont(result); return result; diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/THDropTargetListener.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/THDropTargetListener.java index 968c2876deb..ed4c08376dd 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/THDropTargetListener.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/THDropTargetListener.java @@ -21,18 +21,18 @@ import org.eclipse.swt.dnd.DND; import org.eclipse.swt.dnd.DropTargetEvent; import org.eclipse.swt.dnd.DropTargetListener; import org.eclipse.swt.widgets.Display; +import org.eclipse.ui.IWorkbenchWindow; import org.eclipse.cdt.core.model.ICElement; public class THDropTargetListener implements DropTargetListener { - - private THViewPart fTypeHierarchy; private ICElement fInput; private boolean fEnabled= true; + private IWorkbenchWindow fWindow; public THDropTargetListener(THViewPart view) { - fTypeHierarchy= view; + fWindow= view.getSite().getWorkbenchWindow(); } public void setEnabled(boolean val) { @@ -87,7 +87,7 @@ public class THDropTargetListener implements DropTargetListener { Display.getCurrent().beep(); } else { - fTypeHierarchy.setInput(fInput); + TypeHierarchyUI.open(fInput, fWindow); } } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/THGraph.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/THGraph.java index e74cb00045b..e6d7220641f 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/THGraph.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/THGraph.java @@ -219,24 +219,26 @@ class THGraph { THGraphNode graphNode= addNode(elem); try { IBinding binding = IndexUI.elementToBinding(index, elem); - IIndexName[] names= index.findNames(binding, IIndex.FIND_REFERENCES | IIndex.FIND_DEFINITIONS); - for (int i = 0; i < names.length; i++) { - if (monitor.isCanceled()) { - return; - } - IIndexName indexName = names[i]; - if (indexName.isBaseSpecifier()) { - IIndexName subClassDef= indexName.getEnclosingDefinition(); - if (subClassDef != null) { - IBinding subClass= index.findBinding(subClassDef); - ICElementHandle[] subClassElems= IndexUI.findRepresentative(index, subClass); - if (subClassElems.length > 0) { - ICElementHandle subClassElem= subClassElems[0]; - THGraphNode subGraphNode= addNode(subClassElem); - addMembers(index, subGraphNode, subClass); - addEdge(subGraphNode, graphNode); - if (handled.add(subClassElem)) { - stack.add(subClassElem); + if (binding != null) { + IIndexName[] names= index.findNames(binding, IIndex.FIND_REFERENCES | IIndex.FIND_DEFINITIONS); + for (int i = 0; i < names.length; i++) { + if (monitor.isCanceled()) { + return; + } + IIndexName indexName = names[i]; + if (indexName.isBaseSpecifier()) { + IIndexName subClassDef= indexName.getEnclosingDefinition(); + if (subClassDef != null) { + IBinding subClass= index.findBinding(subClassDef); + ICElementHandle[] subClassElems= IndexUI.findRepresentative(index, subClass); + if (subClassElems.length > 0) { + ICElementHandle subClassElem= subClassElems[0]; + THGraphNode subGraphNode= addNode(subClassElem); + addMembers(index, subGraphNode, subClass); + addEdge(subGraphNode, graphNode); + if (handled.add(subClassElem)) { + stack.add(subClassElem); + } } } } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/THHierarchyModel.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/THHierarchyModel.java index 7a2afc159c7..daad179be2e 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/THHierarchyModel.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/THHierarchyModel.java @@ -92,7 +92,7 @@ class THHierarchyModel { public void setShowInheritedMembers(boolean showInheritedMembers) { fShowInheritedMembers = showInheritedMembers; - computeSelectedMember(); + updateSelectedMember(); updateImplementors(); } @@ -107,9 +107,11 @@ class THHierarchyModel { // // } - synchronized public void setInput(ICElement input) { + synchronized public void setInput(ICElement input, ICElement member) { stopGraphComputation(); fInput= input; + fSelectedMember= member; + fMemberSignatureToSelect= TypeHierarchyUI.getLocalElementSignature(fSelectedMember); fRootNodes= null; fSelectedTypeNode= null; fTypeToSelect= input; @@ -223,14 +225,14 @@ class THHierarchyModel { } if (fSelectedTypeNode != null) { fTypeToSelect= fSelectedTypeNode.getElement(); - computeSelectedMember(); + updateSelectedMember(); } fRootNodes= (THNode[]) roots.toArray(new THNode[roots.size()]); updateImplementors(); } - private void computeSelectedMember() { + private void updateSelectedMember() { ICElement oldSelection= fSelectedMember; fSelectedMember= null; if (fSelectedTypeNode != null && fMemberSignatureToSelect != null) { @@ -315,7 +317,7 @@ class THHierarchyModel { if (node != null) { fTypeToSelect= node.getElement(); } - computeSelectedMember(); + updateSelectedMember(); updateImplementors(); } @@ -357,7 +359,7 @@ class THHierarchyModel { } private boolean isImplementor(ICElement element) { - if (element == null || fSelectedMember == null) { + if (element == null || fSelectedMember == null || fMemberSignatureToSelect == null) { return false; } THGraphNode gnode= fGraph.getNode(element); @@ -369,8 +371,7 @@ class THHierarchyModel { if (member == fSelectedMember) { return true; } - if (fMemberSignatureToSelect != null && - fMemberSignatureToSelect.equals(TypeHierarchyUI.getLocalElementSignature(member))) { + if (fMemberSignatureToSelect.equals(TypeHierarchyUI.getLocalElementSignature(member))) { return true; } } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/THHistoryAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/THHistoryAction.java index 6901fca9ba9..37fd5ae0701 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/THHistoryAction.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/THHistoryAction.java @@ -53,7 +53,7 @@ public class THHistoryAction extends Action { * @see Action#run() */ public void run() { - fViewPart.setInput(fElement); + fViewPart.setInput(fElement, null); } } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/THHistoryDropDownAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/THHistoryDropDownAction.java index 5bdb15f7392..4e9ced3b325 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/THHistoryDropDownAction.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/THHistoryDropDownAction.java @@ -36,7 +36,7 @@ public class THHistoryDropDownAction extends Action implements IMenuCreator { public void run() { fView.setHistoryEntries(new ICElement[0]); - fView.setInput(null); + fView.setInput(null, null); } } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/THHistoryListAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/THHistoryListAction.java index 36e89a04580..13c803a8d08 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/THHistoryListAction.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/THHistoryListAction.java @@ -174,7 +174,7 @@ public class THHistoryListAction extends Action { HistoryListDialog dialog= new HistoryListDialog(fView.getSite().getShell(), historyEntries); if (dialog.open() == Window.OK) { fView.setHistoryEntries(dialog.getRemaining()); - fView.setInput(dialog.getResult()); + fView.setInput(dialog.getResult(), null); } } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/THViewPart.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/THViewPart.java index 18812077549..d600a0f82cd 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/THViewPart.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/THViewPart.java @@ -185,20 +185,20 @@ public class THViewPart extends ViewPart { updateActionEnablement(); } - void setInput(ICElement input) { - if (input == null) { + void setInput(ICElement inputType, ICElement inputMember) { + if (inputType == null) { setMessage(Messages.THViewPart_instruction); fHierarchyTreeViewer.setInput(null); fMemberViewer.setInput(null); return; } fShowsMessage= false; - fModel.setInput(input); + fModel.setInput(inputType, inputMember); fHierarchyTreeViewer.setInput(fModel); fMemberViewer.setInput(fModel); fPagebook.showPage(fSplitter); updateDescription(); - updateHistory(input); + updateHistory(inputType); updateActionEnablement(); fModel.computeGraph(); } @@ -365,7 +365,7 @@ public class THViewPart extends ViewPart { }); menu.appendToGroup(IContextMenuConstants.GROUP_OPEN, new Action(label) { public void run() { - setInput(elem); + setInput(elem, null); } }); } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/TypeHierarchyUI.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/TypeHierarchyUI.java index be07093a29b..355fb5f6d90 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/TypeHierarchyUI.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/TypeHierarchyUI.java @@ -29,9 +29,13 @@ import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit; import org.eclipse.cdt.core.dom.ast.IBinding; import org.eclipse.cdt.core.dom.ast.ICompositeType; import org.eclipse.cdt.core.dom.ast.IEnumeration; +import org.eclipse.cdt.core.dom.ast.IEnumerator; +import org.eclipse.cdt.core.dom.ast.IType; import org.eclipse.cdt.core.dom.ast.ITypedef; +import org.eclipse.cdt.core.dom.ast.cpp.ICPPMember; import org.eclipse.cdt.core.index.IIndex; import org.eclipse.cdt.core.index.IIndexManager; +import org.eclipse.cdt.core.index.IIndexName; import org.eclipse.cdt.core.model.CModelException; import org.eclipse.cdt.core.model.ICElement; import org.eclipse.cdt.core.model.ICProject; @@ -40,32 +44,40 @@ import org.eclipse.cdt.core.model.ITranslationUnit; import org.eclipse.cdt.core.model.IWorkingCopy; import org.eclipse.cdt.ui.CUIPlugin; -import org.eclipse.cdt.internal.ui.actions.OpenActionUtil; import org.eclipse.cdt.internal.ui.editor.CEditor; import org.eclipse.cdt.internal.ui.util.ExceptionHandler; -import org.eclipse.cdt.internal.ui.viewsupport.CElementLabels; import org.eclipse.cdt.internal.ui.viewsupport.FindNameForSelectionVisitor; import org.eclipse.cdt.internal.ui.viewsupport.IndexUI; public class TypeHierarchyUI { - private static boolean sIsJUnitTest= false; - - public static void setIsJUnitTest(boolean val) { - sIsJUnitTest= val; - } - public static THViewPart open(ICElement input, IWorkbenchWindow window) { - if (input != null) { - return openInViewPart(window, input); + if (!isValidInput(input)) { + return null; + } + ICElement memberInput= null; + if (!isValidTypeInput(input)) { + memberInput= input; + input= memberInput.getParent(); + if (!isValidTypeInput(input)) { + ICElement[] inputs= findInput(memberInput); + if (inputs != null) { + input= inputs[0]; + memberInput= inputs[1]; + } + } + } + + if (isValidTypeInput(input)) { + return openInViewPart(window, input, memberInput); } return null; } - private static THViewPart openInViewPart(IWorkbenchWindow window, ICElement input) { + private static THViewPart openInViewPart(IWorkbenchWindow window, ICElement input, ICElement member) { IWorkbenchPage page= window.getActivePage(); try { THViewPart result= (THViewPart)page.showView(CUIPlugin.ID_TYPE_HIERARCHY); - result.setInput(input); + result.setInput(input, member); return result; } catch (CoreException e) { ExceptionHandler.handle(e, window.getShell(), Messages.TypeHierarchyUI_OpenTypeHierarchy, null); @@ -73,29 +85,6 @@ public class TypeHierarchyUI { return null; } - private static THViewPart openInViewPart(IWorkbenchWindow window, ICElement[] input) { - ICElement elem = null; - switch (input.length) { - case 0: - break; - case 1: - elem = input[0]; - break; - default: - if (sIsJUnitTest) { - throw new RuntimeException("ambigous input"); //$NON-NLS-1$ - } - elem = OpenActionUtil.selectCElement(input, window.getShell(), - Messages.TypeHierarchyUI_OpenTypeHierarchy, Messages.TypeHierarchyUI_SelectFromList, - CElementLabels.ALL_DEFAULT | CElementLabels.MF_POST_FILE_QUALIFIED, 0); - break; - } - if (elem != null) { - return openInViewPart(window, elem); - } - return null; - } - public static void open(final CEditor editor, final ITextSelection sel) { if (editor != null) { final ICProject project= editor.getInputCElement().getCProject(); @@ -105,11 +94,11 @@ public class TypeHierarchyUI { Job job= new Job(Messages.TypeHierarchyUI_OpenTypeHierarchy) { protected IStatus run(IProgressMonitor monitor) { try { - final ICElement[] elems= findDefinitions(project, editorInput, sel); - if (elems != null && elems.length > 0) { + final ICElement[] elems= findInput(project, editorInput, sel); + if (elems != null && elems.length == 2) { display.asyncExec(new Runnable() { public void run() { - openInViewPart(editor.getSite().getWorkbenchWindow(), elems); + openInViewPart(editor.getSite().getWorkbenchWindow(), elems[0], elems[1]); }}); } return Status.OK_STATUS; @@ -124,7 +113,7 @@ public class TypeHierarchyUI { } } - private static ICElement[] findDefinitions(ICProject project, IEditorInput editorInput, ITextSelection sel) throws CoreException { + private static ICElement[] findInput(ICProject project, IEditorInput editorInput, ITextSelection sel) throws CoreException { try { IIndex index= CCorePlugin.getIndexManager().getIndex(project, IIndexManager.ADD_DEPENDENCIES | IIndexManager.ADD_DEPENDENT); @@ -133,25 +122,19 @@ public class TypeHierarchyUI { IASTName name= getSelectedName(index, editorInput, sel); if (name != null) { IBinding binding= name.resolveBinding(); - if (isValidInput(binding)) { - if (name.isDefinition()) { - ICElement elem= IndexUI.getCElementForName(project, index, name); - if (elem != null) { - return new ICElement[]{elem}; - } - } - else { - ICElement[] elems= IndexUI.findAllDefinitions(index, binding); - if (elems.length == 0) { - elems= IndexUI.findAllDefinitions(index, binding); - if (elems.length == 0) { - ICElement elem= IndexUI.findAnyDeclaration(index, project, binding); - if (elems != null) { - elems= new ICElement[]{elem}; - } - } - } - return elems; + if (!isValidInput(binding)) { + return null; + } + ICElement member= null; + if (!isValidTypeInput(binding)) { + member= findDeclaration(project, index, name, binding); + name= null; + binding= findTypeBinding(binding); + } + if (isValidTypeInput(binding)) { + ICElement input= findDefinition(project, index, name, binding); + if (input != null) { + return new ICElement[] {input, member}; } } } @@ -173,6 +156,81 @@ public class TypeHierarchyUI { return null; } + private static ICElement[] findInput(ICElement member) { + ICProject project= member.getCProject(); + try { + IIndex index= CCorePlugin.getIndexManager().getIndex(project, IIndexManager.ADD_DEPENDENCIES | IIndexManager.ADD_DEPENDENT); + index.acquireReadLock(); + try { + IIndexName name= IndexUI.elementToName(index, member); + if (name != null) { + member= IndexUI.getCElementForName(project, index, name); + IBinding binding= index.findBinding(name); + binding= findTypeBinding(binding); + if (isValidTypeInput(binding)) { + ICElement input= findDefinition(project, index, null, binding); + if (input != null) { + return new ICElement[] {input, member}; + } + } + } + } + finally { + if (index != null) { + index.releaseReadLock(); + } + } + } + catch (CoreException e) { + CUIPlugin.getDefault().log(e); + } + catch (DOMException e) { + CUIPlugin.getDefault().log(e); + } + catch (InterruptedException e) { + } + return null; + } + + private static IBinding findTypeBinding(IBinding memberBinding) throws DOMException { + if (memberBinding instanceof IEnumerator) { + IType type= ((IEnumerator) memberBinding).getType(); + if (type instanceof IBinding) { + return (IBinding) type; + } + } + else if (memberBinding instanceof ICPPMember) { + return ((ICPPMember) memberBinding).getClassOwner(); + } + return null; + } + + private static ICElement findDefinition(ICProject project, IIndex index, + IASTName name, IBinding binding) throws CoreException, DOMException { + if (name != null && name.isDefinition()) { + return IndexUI.getCElementForName(project, index, name); + } + + ICElement[] elems= IndexUI.findAllDefinitions(index, binding); + if (elems.length > 0) { + return elems[0]; + } + return IndexUI.findAnyDeclaration(index, project, binding); + } + + private static ICElement findDeclaration(ICProject project, IIndex index, + IASTName name, IBinding binding) throws CoreException, DOMException { + if (name != null && name.isDefinition()) { + return IndexUI.getCElementForName(project, index, name); + } + + ICElement[] elems= IndexUI.findAllDefinitions(index, binding); + if (elems.length > 0) { + return elems[0]; + } + return IndexUI.findAnyDeclaration(index, project, binding); + } + private static IASTName getSelectedName(IIndex index, IEditorInput editorInput, ITextSelection selection) throws CoreException { int selectionStart = selection.getOffset(); int selectionLength = selection.getLength(); @@ -189,16 +247,43 @@ public class TypeHierarchyUI { } public static boolean isValidInput(IBinding binding) { + if (isValidTypeInput(binding) + || binding instanceof ICPPMember + || binding instanceof IEnumerator) { + return true; + } + return false; + } + + public static boolean isValidTypeInput(IBinding binding) { if (binding instanceof ICompositeType || binding instanceof IEnumeration || binding instanceof ITypedef) { -// binding instanceof IField || binding instanceof ICPPMethod) { return true; } return false; } public static boolean isValidInput(ICElement elem) { + if (elem == null) { + return false; + } + if (isValidTypeInput(elem)) { + return true; + } + switch (elem.getElementType()) { + case ICElement.C_FIELD: + case ICElement.C_METHOD: + case ICElement.C_METHOD_DECLARATION: + case ICElement.C_TEMPLATE_METHOD: + case ICElement.C_TEMPLATE_METHOD_DECLARATION: + case ICElement.C_ENUMERATOR: + return true; + } + return false; + } + + public static boolean isValidTypeInput(ICElement elem) { if (elem == null) { return false; } @@ -211,11 +296,6 @@ public class TypeHierarchyUI { case ICElement.C_UNION_DECLARATION: case ICElement.C_ENUMERATION: case ICElement.C_TYPEDEF: -// case ICElement.C_FIELD: -// case ICElement.C_METHOD: -// case ICElement.C_METHOD_DECLARATION: -// case ICElement.C_TEMPLATE_METHOD: -// case ICElement.C_TEMPLATE_METHOD_DECLARATION: return true; } return false; diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/IndexUI.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/IndexUI.java index f589e907d11..e7e4c80b10b 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/IndexUI.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/IndexUI.java @@ -72,7 +72,7 @@ public class IndexUI { String elementName= element.getElementName(); int idx= elementName.lastIndexOf(":")+1; //$NON-NLS-1$ ISourceRange pos= sf.getSourceRange(); - IRegion region= new Region(pos.getIdStartPos()+idx, pos.getIdLength()); + IRegion region= new Region(pos.getIdStartPos()+idx, pos.getIdLength()-idx); IPositionConverter converter= CCorePlugin.getPositionTrackerManager().findPositionConverter(tu, file.getTimestamp()); if (converter != null) { region= converter.actualToHistoric(region); diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/CElementImageDescriptor.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/CElementImageDescriptor.java index 714294d4a38..17320307c72 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/CElementImageDescriptor.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/CElementImageDescriptor.java @@ -188,6 +188,7 @@ public class CElementImageDescriptor extends CompositeImageDescriptor { drawTopRight(); drawBottomRight(); drawBottomLeft(); + drawTopLeft(); } private void drawTopRight() { @@ -208,10 +209,6 @@ public class CElementImageDescriptor extends CompositeImageDescriptor { x-= data.width; drawImage(data, x, 0); } - if ((fFlags & DEFINES) != 0) { - data= CPluginImages.DESC_OVR_DEFINES.getImageData(); - drawImage(data, 0, 0); - } if ((fFlags & TEMPLATE) != 0) { data= CPluginImages.DESC_OVR_TEMPLATE.getImageData(); x-= data.width; @@ -260,6 +257,14 @@ public class CElementImageDescriptor extends CompositeImageDescriptor { // } } + private void drawTopLeft() { + ImageData data= null; + if ((fFlags & DEFINES) != 0) { + data= CPluginImages.DESC_OVR_DEFINES.getImageData(); + drawImage(data, 0, 0); + } + } + private void drawBottomLeft() { Point size= getSize(); int x= 0; diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/OpenViewActionGroup.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/OpenViewActionGroup.java index fd475299fb4..0b277b59e20 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/OpenViewActionGroup.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/OpenViewActionGroup.java @@ -27,7 +27,6 @@ import org.eclipse.ui.dialogs.PropertyDialogAction; import org.eclipse.ui.part.Page; import org.eclipse.cdt.core.model.ICElement; -import org.eclipse.cdt.ui.CUIPlugin; import org.eclipse.cdt.internal.ui.IContextMenuConstants; import org.eclipse.cdt.internal.ui.callhierarchy.CHViewPart; @@ -101,9 +100,7 @@ public class OpenViewActionGroup extends ActionGroup { fOpenTypeHierarchy= new OpenTypeHierarchyAction(part); fOpenTypeHierarchy.setActionDefinitionId(ICEditorActionDefinitionIds.OPEN_TYPE_HIERARCHY); - if (useTypeHierarchy()) { - part.setAction("OpenTypeHierarchy", fOpenTypeHierarchy); //$NON-NLS-1$ - } + part.setAction("OpenTypeHierarchy", fOpenTypeHierarchy); //$NON-NLS-1$ fOpenCallHierarchy= new OpenCallHierarchyAction(part); fOpenCallHierarchy.setActionDefinitionId(ICEditorActionDefinitionIds.OPEN_CALL_HIERARCHY); @@ -112,10 +109,6 @@ public class OpenViewActionGroup extends ActionGroup { initialize(part.getEditorSite()); } - private boolean useTypeHierarchy() { - return CUIPlugin.getDefault().getPluginPreferences().getBoolean("showCtxMenuTypeHierarchy"); //$NON-NLS-1$ - } - private void createSiteActions(IWorkbenchSite site) { // fOpenSuperImplementation= new OpenSuperImplementationAction(site); // fOpenSuperImplementation.setActionDefinitionId(IJavaEditorActionDefinitionIds.OPEN_SUPER_IMPLEMENTATION); @@ -172,7 +165,7 @@ public class OpenViewActionGroup extends ActionGroup { public void fillContextMenu(IMenuManager menu) { super.fillContextMenu(menu); if (!fEditorIsOwner) { - if (useTypeHierarchy() && !fIsTypeHiararchyViewerOwner && fOpenTypeHierarchy.isEnabled()) { + if (!fIsTypeHiararchyViewerOwner && fOpenTypeHierarchy.isEnabled()) { menu.appendToGroup(fGroupName, fOpenTypeHierarchy); } if (!fIsCallHiararchyViewerOwner && fOpenCallHierarchy.isEnabled()) {