diff --git a/core/org.eclipse.cdt.ui/browser/ChangeLog-browser b/core/org.eclipse.cdt.ui/browser/ChangeLog-browser index ea82b4535aa..75e4904d377 100644 --- a/core/org.eclipse.cdt.ui/browser/ChangeLog-browser +++ b/core/org.eclipse.cdt.ui/browser/ChangeLog-browser @@ -1,3 +1,23 @@ +2004-08-31 Chris Wiebe + + Fix for 68883 + * browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/CBrowsingContentProvider.java + * browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/CBrowsingElementComparer.java + * browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/CBrowsingPart.java + * browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/CBrowsingPerspectiveFactory.java + * browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/MembersView.java + * browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/MembersViewContentProvider.java + * browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/NamespacesView.java + * browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/ProjectsView.java + * browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/TypesView.java + * browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/FocusOnTypeAction.java + * browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/HierarchyViewerSorter.java + * browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/MethodsLabelProvider.java + * browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/OpenTypeHierarchyAction.java + * browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/OpenTypeHierarchyUtil.java + * browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/TypeHierarchyContentProvider.java + * browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/TypeHierarchyViewPart.java + 2004-06-21 Chris Wiebe This mini-patch gets rid of unnecessary "could not locate type" error diff --git a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/CBrowsingContentProvider.java b/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/CBrowsingContentProvider.java index 16ac1af168c..76102fa12ac 100644 --- a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/CBrowsingContentProvider.java +++ b/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/CBrowsingContentProvider.java @@ -12,36 +12,31 @@ package org.eclipse.cdt.internal.ui.browser.cbrowsing; import java.util.Collection; -import org.eclipse.cdt.core.model.CModelException; +import org.eclipse.cdt.core.browser.AllTypesCache; +import org.eclipse.cdt.core.browser.ITypeCacheChangedListener; import org.eclipse.cdt.core.model.CoreModel; -import org.eclipse.cdt.core.model.ElementChangedEvent; -import org.eclipse.cdt.core.model.IArchive; -import org.eclipse.cdt.core.model.IBinary; -import org.eclipse.cdt.core.model.ICElement; -import org.eclipse.cdt.core.model.ICElementDelta; -import org.eclipse.cdt.core.model.IElementChangedListener; -import org.eclipse.cdt.core.model.ITranslationUnit; +import org.eclipse.cdt.core.model.ICProject; import org.eclipse.cdt.core.model.IWorkingCopy; import org.eclipse.cdt.internal.ui.BaseCElementContentProvider; -import org.eclipse.cdt.ui.CUIPlugin; +import org.eclipse.core.resources.IProject; import org.eclipse.jface.viewers.ITreeContentProvider; import org.eclipse.jface.viewers.StructuredViewer; import org.eclipse.jface.viewers.Viewer; import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.Display; -public abstract class CBrowsingContentProvider extends BaseCElementContentProvider implements ITreeContentProvider, IElementChangedListener { +public abstract class CBrowsingContentProvider extends BaseCElementContentProvider + implements ITreeContentProvider, ITypeCacheChangedListener { protected StructuredViewer fViewer; protected Object fInput; protected CBrowsingPart fBrowsingPart; protected int fReadsInDisplayThread; - protected static final Object[] NO_CHILDREN = new Object[0]; public CBrowsingContentProvider(CBrowsingPart browsingPart) { fBrowsingPart= browsingPart; fViewer= fBrowsingPart.getViewer(); - CoreModel.getDefault().addElementChangedListener(this); + AllTypesCache.addTypeCacheChangedListener(this); } /* (non-Javadoc) @@ -63,12 +58,17 @@ public abstract class CBrowsingContentProvider extends BaseCElementContentProvid * @see org.eclipse.jface.viewers.IContentProvider#dispose() */ public void dispose() { - CoreModel.getDefault().removeElementChangedListener(this); + AllTypesCache.removeTypeCacheChangedListener(this); } - /* (non-Javadoc) + public void typeCacheChanged(IProject project) { + ICProject cproject = CoreModel.getDefault().create(project); + postRefresh(cproject); + } + +/* (non-Javadoc) * @see org.eclipse.cdt.core.model.IElementChangedListener#elementChanged(org.eclipse.cdt.core.model.ElementChangedEvent) - */ + public void elementChanged(ElementChangedEvent event) { try { processDelta(event.getDelta()); @@ -89,11 +89,11 @@ public abstract class CBrowsingContentProvider extends BaseCElementContentProvid (flags & ICElementDelta.F_CHANGED_PATHENTRY_INCLUDE) != 0)); } - /** + *//** * Processes a delta recursively. When more than two children are affected the * tree is fully refreshed starting at this node. The delta is processed in the * current thread but the viewer updates are posted to the UI thread. - */ + *//* protected void processDelta(ICElementDelta delta) throws CModelException { int kind= delta.getKind(); int flags= delta.getFlags(); @@ -132,7 +132,7 @@ public abstract class CBrowsingContentProvider extends BaseCElementContentProvid processDelta(affectedChildren[i]); } } - +*/ private void postRefresh(final Object element) { //System.out.println("UI refresh:" + root); postRunnable(new Runnable() { @@ -154,7 +154,7 @@ public abstract class CBrowsingContentProvider extends BaseCElementContentProvid }); } - private void postAdd(final Object parent, final Object element) { +/* private void postAdd(final Object parent, final Object element) { //System.out.println("UI add:" + parent + " " + element); postRunnable(new Runnable() { public void run() { @@ -196,7 +196,7 @@ public abstract class CBrowsingContentProvider extends BaseCElementContentProvid } }); } - +*/ private void postRunnable(final Runnable r) { Control ctrl= fViewer.getControl(); if (ctrl != null && !ctrl.isDisposed()) { diff --git a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/CBrowsingElementComparer.java b/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/CBrowsingElementComparer.java new file mode 100644 index 00000000000..f4c778b079c --- /dev/null +++ b/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/CBrowsingElementComparer.java @@ -0,0 +1,76 @@ +/******************************************************************************* + * Copyright (c) 2000, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Common Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.cdt.internal.ui.browser.cbrowsing; + +import org.eclipse.cdt.core.browser.TypeUtil; +import org.eclipse.cdt.core.model.ICElement; +import org.eclipse.cdt.core.model.ITranslationUnit; +import org.eclipse.cdt.core.model.IWorkingCopy; +import org.eclipse.jface.viewers.IElementComparer; + +public class CBrowsingElementComparer implements IElementComparer { + + public boolean equals(Object o1, Object o2) { + if (o1 == o2) // this handles also the case that both are null + return true; + if (o1 == null) + return false; // o2 != null if we reach this point + if (o1.equals(o2)) + return true; + + // Assume they are CElements + ICElement c1= (o1 instanceof ICElement) ? (ICElement)o1 : null; + ICElement c2= (o2 instanceof ICElement) ? (ICElement)o2 : null; + if (c1 == null || c2 == null) + return false; + + // compare identical elements across working copies + if (c1.getElementType() == c2.getElementType() + && c1.getElementName().equals(c2.getElementName())) { + if (TypeUtil.getFullyQualifiedName(c1).equals(TypeUtil.getFullyQualifiedName(c2))) { + return c1.getUnderlyingResource().equals(c2.getUnderlyingResource()); + } + } + + if (c1 instanceof ITranslationUnit) { + ITranslationUnit t1 = (ITranslationUnit)o1; + if (t1.isWorkingCopy()) { + c1 = ((IWorkingCopy)t1).getOriginalElement(); + } + } + if (c2 instanceof ITranslationUnit) { + ITranslationUnit t2 = (ITranslationUnit)o2; + if (t2.isWorkingCopy()) { + c2 = ((IWorkingCopy)t2).getOriginalElement(); + } + } + if (c1 == null || c2 == null) { + return false; + } + return c1.equals(c2); + } + + public int hashCode(Object o1) { + ICElement c1= (o1 instanceof ICElement) ? (ICElement)o1 : null; + if (c1 == null) + return o1.hashCode(); + if (c1 instanceof ITranslationUnit) { + ITranslationUnit t1= (ITranslationUnit)c1; + if (t1.isWorkingCopy()) { + c1= ((IWorkingCopy)t1).getOriginalElement(); + } + } + if (c1 == null) { + return o1.hashCode(); + } + return c1.hashCode(); + } +} diff --git a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/CBrowsingPart.java b/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/CBrowsingPart.java index d9b00348b66..07ef28f9f91 100644 --- a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/CBrowsingPart.java +++ b/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/CBrowsingPart.java @@ -20,14 +20,11 @@ import org.eclipse.cdt.core.browser.AllTypesCache; import org.eclipse.cdt.core.browser.ITypeInfo; import org.eclipse.cdt.core.browser.ITypeReference; import org.eclipse.cdt.core.browser.TypeSearchScope; -import org.eclipse.cdt.core.browser.TypeUtil; import org.eclipse.cdt.core.model.CModelException; import org.eclipse.cdt.core.model.CoreModel; import org.eclipse.cdt.core.model.ICElement; -import org.eclipse.cdt.core.model.ICElementVisitor; import org.eclipse.cdt.core.model.ICModel; import org.eclipse.cdt.core.model.ICProject; -import org.eclipse.cdt.core.model.IParent; import org.eclipse.cdt.core.model.ISourceRoot; import org.eclipse.cdt.core.model.ITranslationUnit; import org.eclipse.cdt.core.resources.FileStorage; @@ -48,7 +45,6 @@ import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IResource; import org.eclipse.core.resources.IStorage; -import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IAdaptable; import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IProgressMonitor; @@ -106,10 +102,10 @@ import org.eclipse.ui.texteditor.ITextEditor; public abstract class CBrowsingPart extends ViewPart implements IMenuListener, ISelectionListener, IViewPartInputProvider { - private static final String TAG_SELECTED_ELEMENTS= "selectedElements"; //$NON-NLS-1$ - private static final String TAG_SELECTED_ELEMENT= "selectedElement"; //$NON-NLS-1$ - private static final String TAG_LOGICAL_PACKAGE= "logicalPackage"; //$NON-NLS-1$ - private static final String TAG_SELECTED_ELEMENT_PATH= "selectedElementPath"; //$NON-NLS-1$ +// private static final String TAG_SELECTED_ELEMENTS= "selectedElements"; //$NON-NLS-1$ +// private static final String TAG_SELECTED_ELEMENT= "selectedElement"; //$NON-NLS-1$ +// private static final String TAG_LOGICAL_PACKAGE= "logicalPackage"; //$NON-NLS-1$ +// private static final String TAG_SELECTED_ELEMENT_PATH= "selectedElementPath"; //$NON-NLS-1$ private LabelProvider fLabelProvider; private ILabelProvider fTitleProvider; @@ -309,6 +305,8 @@ public abstract class CBrowsingPart extends ViewPart implements IMenuListener, I fViewer.setSorter(createTypeInfoSorter()); fViewer.setUseHashlookup(true); fTitleProvider= createTitleProvider(); + + fViewer.setComparer(new CBrowsingElementComparer()); createContextMenu(); getSite().setSelectionProvider(fViewer); @@ -681,160 +679,6 @@ public abstract class CBrowsingPart extends ViewPart implements IMenuListener, I return false; } - protected Object getNamespaceInput(Object element) { - if (element instanceof ICModel) { - return null; - } - - if (element instanceof ICProject || element instanceof ISourceRoot) { - if (exists(element)) - return element; - } - - if (element instanceof ITypeInfo) { - ITypeInfo info = (ITypeInfo)element; - ISourceRoot root = findSourceRoot(info); - if (exists(root)) - return root; - ICProject cProject = findCProject(info); - if (exists(cProject)) - return cProject; - } - - if (element instanceof ICElement) { - ICElement cElem = (ICElement)element; - ISourceRoot root = findSourceRoot(cElem); - if (exists(root)) - return root; - ICProject cProject = findCProject(cElem); - if (exists(cProject)) - return cProject; - } - - return null; - } - - private static boolean hasChild(final ICElement parent, final ICElement child) { - final boolean foundChild[] = { false }; - final ICElementVisitor visitor = new ICElementVisitor() { - public boolean visit(ICElement element) throws CoreException { - if (foundChild[0]) - return false; - if (element.equals(child)) { - foundChild[0] = true; - return false; - } - return true; - } - }; - try { - parent.accept(visitor); - } catch (CoreException e) { - } - return foundChild[0]; - } - - protected Object getTypesInput(Object element) { - if (element instanceof ICModel || element instanceof ICProject || element instanceof ISourceRoot) { - return null; - } - - if (element instanceof ICElement) { - //TODO optimization needed here - how do we get back parent ITypeInfo - TypeSearchScope scope = new TypeSearchScope(); - ICElement cElem = ((ICElement)element).getParent(); - ISourceRoot root = findSourceRoot(cElem); - if (root != null) { - scope.add(root); - } else { - ICProject cProject = findCProject(cElem); - if (cProject != null) { - scope.add(cProject); - } - } - ITypeInfo[] namespaces = AllTypesCache.getNamespaces(scope, true); - if (namespaces != null) { - for (int i = 0; i < namespaces.length; ++i) { - ITypeInfo[] enclosedTypes = namespaces[i].getEnclosedTypes(); - for (int j = 0; j < enclosedTypes.length; ++j) { - ITypeInfo enclosedType = enclosedTypes[j]; - if (enclosedType.getResolvedReference() != null) { - ICElement typeElem = TypeUtil.getElementForType(enclosedType); - if (typeElem != null && (typeElem.equals(cElem) || (typeElem instanceof IParent && hasChild(typeElem, cElem)))) { - return namespaces[i]; - } - } - } - } - } - return null; - } - - if (element instanceof ITypeInfo) { - ITypeInfo info = (ITypeInfo) element; - if (info.getCElementType() == ICElement.C_NAMESPACE) { - if (exists(info)) - return info; - } - ITypeInfo namespace = info.getEnclosingType(new int[]{ICElement.C_NAMESPACE}); - if (namespace == null) { - namespace = info.getRootNamespace(true); - } - if (exists(namespace)) - return namespace; - } - - return null; - } - - protected Object getMembersInput(Object element) { - if (element instanceof ICModel || element instanceof ICProject || element instanceof ISourceRoot) { - return null; - } - - if (element instanceof ITypeInfo) { - ITypeInfo info = (ITypeInfo) element; - if (info.getCElementType() != ICElement.C_NAMESPACE) { - if (exists(info)) - return info; - } - } - - if (element instanceof ICElement) { - //TODO optimization needed here - how do we get back parent ITypeInfo - TypeSearchScope scope = new TypeSearchScope(); - ICElement cElem = ((ICElement)element).getParent(); - ISourceRoot root = findSourceRoot(cElem); - if (root != null) { - scope.add(root); - } else { - ICProject cProject = findCProject(cElem); - if (cProject != null) { - scope.add(cProject); - } - } - ITypeInfo[] namespaces = AllTypesCache.getNamespaces(scope, true); - if (namespaces != null) { - for (int i = 0; i < namespaces.length; ++i) { - ITypeInfo[] enclosedTypes = namespaces[i].getEnclosedTypes(); - for (int j = 0; j < enclosedTypes.length; ++j) { - ITypeInfo enclosedType = enclosedTypes[j]; - if (enclosedType.getResolvedReference() != null) { - ICElement typeElem = TypeUtil.getElementForType(enclosedType); - if (typeElem != null && (typeElem.equals(cElem) || (typeElem instanceof IParent && hasChild(typeElem, cElem)))) { - return enclosedType; - } - - } - } - } - } - return null; - } - - return null; - } - /** * Answers if the given element is a valid * element for this part. @@ -1196,6 +1040,7 @@ public abstract class CBrowsingPart extends ViewPart implements IMenuListener, I } else if (element instanceof ITypeInfo) { openTypeInEditor((ITypeInfo)element); } + restoreSelection(); } // IAction open= fOpenEditorGroup.getOpenAction(); // if (open.isEnabled()) { @@ -1207,7 +1052,10 @@ public abstract class CBrowsingPart extends ViewPart implements IMenuListener, I } protected void openTypeInEditor(ITypeInfo info) { - if (info == info.getCache().getGlobalNamespace()) { + if (!info.exists()) + return; + + if (info == info.getCache().getGlobalNamespace()) { return; // nothing to open } ITypeReference location = info.getResolvedReference(); @@ -1322,8 +1170,9 @@ public abstract class CBrowsingPart extends ViewPart implements IMenuListener, I Object elementToSelect= getSuitableElement(findElementToSelect(o)); Object newInput= findInputForElement(o); Object oldInput= null; - if (getInput() instanceof ICElement || getInput() instanceof ITypeInfo) - oldInput = getInput(); + Object viewerInput = getInput(); + if (viewerInput instanceof ICElement || viewerInput instanceof ITypeInfo) + oldInput = viewerInput; if (elementToSelect == null && !isValidInput(newInput) && (newInput == null && !isAncestorOf(o, oldInput))) // Clear input @@ -1360,20 +1209,20 @@ public abstract class CBrowsingPart extends ViewPart implements IMenuListener, I } /** - * Finds the closest Java element which can be used as input for - * this part and has the given Java element as child + * Finds the closest C element which can be used as input for + * this part and has the given C element as child * - * @param je the Java element for which to search the closest input - * @return the closest Java element used as input for this part + * @param element the C element for which to search the closest input + * @return the closest C element used as input for this part */ abstract protected Object findInputForElement(Object element); /** * Finds the element which has to be selected in this part. * - * @param je the Java element which has the focus + * @param element the C element which has the focus */ - abstract protected Object findElementToSelect(Object obj); + abstract protected Object findElementToSelect(Object element); /** * Converts the given Java element to one which is suitable for this diff --git a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/CBrowsingPerspectiveFactory.java b/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/CBrowsingPerspectiveFactory.java index 5ebbee95b88..05f532d6d7c 100644 --- a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/CBrowsingPerspectiveFactory.java +++ b/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/CBrowsingPerspectiveFactory.java @@ -1,10 +1,15 @@ +/******************************************************************************* + * Copyright (c) 2000, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Common Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ package org.eclipse.cdt.internal.ui.browser.cbrowsing; -/* - * (c) Copyright IBM Corp. 2000, 2001. - * All Rights Reserved. - */ - import org.eclipse.cdt.core.model.ICElement; import org.eclipse.cdt.ui.CUIPlugin; import org.eclipse.cdt.ui.PreferenceConstants; diff --git a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/MembersView.java b/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/MembersView.java index a287aa13617..af234c06ce8 100644 --- a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/MembersView.java +++ b/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/MembersView.java @@ -10,11 +10,12 @@ *******************************************************************************/ package org.eclipse.cdt.internal.ui.browser.cbrowsing; +import org.eclipse.cdt.core.browser.AllTypesCache; import org.eclipse.cdt.core.browser.ITypeInfo; +import org.eclipse.cdt.core.browser.TypeUtil; import org.eclipse.cdt.core.model.ICElement; import org.eclipse.cdt.core.model.ICModel; import org.eclipse.cdt.core.model.ICProject; -import org.eclipse.cdt.core.model.IMember; import org.eclipse.cdt.core.model.ISourceRoot; import org.eclipse.cdt.internal.ui.ICHelpContextIds; import org.eclipse.cdt.internal.ui.util.ProblemTreeViewer; @@ -166,16 +167,16 @@ public class MembersView extends CBrowsingPart implements IPropertyChangeListene }); } - boolean isInputAWorkingCopy() { +/* boolean isInputAWorkingCopy() { Object input= getViewer().getInput(); -// if (input instanceof ICElement) { -// ICompilationUnit cu= (ICompilationUnit)((IJavaElement)input).getAncestor(IJavaElement.COMPILATION_UNIT); -// if (cu != null) -// return cu.isWorkingCopy(); -// } + if (input instanceof ICElement) { + ICompilationUnit cu= (ICompilationUnit)((IJavaElement)input).getAncestor(IJavaElement.COMPILATION_UNIT); + if (cu != null) + return cu.isWorkingCopy(); + } return false; } - +*/ protected void restoreSelection() { IEditorPart editor= getViewSite().getPage().getActiveEditor(); if (editor != null) @@ -214,24 +215,36 @@ public class MembersView extends CBrowsingPart implements IPropertyChangeListene * @see org.eclipse.cdt.internal.ui.browser.cbrowsing.CBrowsingPart#findInputForElement(java.lang.Object) */ protected Object findInputForElement(Object element) { - return getMembersInput(element); + if (element instanceof ICModel || element instanceof ICProject || element instanceof ISourceRoot) { + return null; + } + + if (element instanceof ITypeInfo) { + return element; + } + + if (element instanceof ICElement) { + ICElement parent = TypeUtil.getDeclaringContainerType((ICElement)element); + if (parent != null) { + ITypeInfo info = AllTypesCache.getTypeForElement(parent, true, true, null); + if (info != null) + return info; + } + return null; + } + + return null; } /* (non-Javadoc) * @see org.eclipse.cdt.internal.ui.browser.cbrowsing.CBrowsingPart#findElementToSelect(java.lang.Object) */ protected Object findElementToSelect(Object element) { - if (element instanceof ICModel || element instanceof ICProject || element instanceof ISourceRoot) { - return null; - } - - if (element instanceof ICElement) { - ICElement parent = (ICElement)element; - while (parent != null) { - if (parent instanceof IMember && exists(parent)) - return parent; - parent = parent.getParent(); - } + if (element instanceof ICElement && TypeUtil.isDeclaredType((ICElement)element)) { + ICElement parent = TypeUtil.getDeclaringContainerType((ICElement)element); + if (parent != null) { + return element; + } } return null; diff --git a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/MembersViewContentProvider.java b/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/MembersViewContentProvider.java index 9509f085a40..f786dd6120b 100644 --- a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/MembersViewContentProvider.java +++ b/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/MembersViewContentProvider.java @@ -10,27 +10,17 @@ *******************************************************************************/ package org.eclipse.cdt.internal.ui.browser.cbrowsing; -import java.lang.reflect.InvocationTargetException; import java.util.Iterator; import org.eclipse.cdt.core.browser.AllTypesCache; import org.eclipse.cdt.core.browser.ITypeInfo; -import org.eclipse.cdt.core.browser.ITypeReference; -import org.eclipse.cdt.core.browser.TypeUtil; import org.eclipse.cdt.core.model.CModelException; import org.eclipse.cdt.core.model.ICElement; import org.eclipse.cdt.core.model.IParent; -import org.eclipse.cdt.internal.ui.browser.opentype.OpenTypeMessages; -import org.eclipse.cdt.internal.ui.util.ExceptionHandler; import org.eclipse.cdt.ui.CUIPlugin; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.jface.dialogs.MessageDialog; -import org.eclipse.jface.operation.IRunnableWithProgress; import org.eclipse.jface.util.Assert; import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.swt.widgets.Shell; -import org.eclipse.ui.PlatformUI; -import org.eclipse.ui.progress.IProgressService; class MembersViewContentProvider extends CBrowsingContentProvider { @@ -99,7 +89,7 @@ class MembersViewContentProvider extends CBrowsingContentProvider { if (info.getCElementType() == ICElement.C_NAMESPACE) { return NO_CHILDREN; // shouldn't get here... } - ICElement elem = getCElement(info); + ICElement elem = AllTypesCache.getElementForType(info, true, true, null); if (elem != null && elem instanceof IParent) { return ((IParent)elem).getChildren(); } @@ -122,21 +112,22 @@ class MembersViewContentProvider extends CBrowsingContentProvider { * @see org.eclipse.jface.viewers.ITreeContentProvider#getParent(java.lang.Object) */ public Object getParent(Object element) { - if (element == null || (element instanceof ITypeInfo && !((ITypeInfo)element).exists())) { + return fInput; +/* if (element instanceof ICModel || element instanceof ICProject || element instanceof ISourceRoot) { return null; } - + + if (element instanceof ITypeInfo) { + return null; + } + try { startReadInDisplayThread(); - if (element instanceof ITypeInfo) { - ITypeInfo info = (ITypeInfo)element; - if (info.isEnclosedType()) { - return info.getEnclosingType(); - } else { -// return info.getEnclosingProject(); - return null; - } + if (element instanceof ICElement) { + ICElement parent = ((ICElement)element).getParent(); + if (parent != null) + return AllTypesCache.getTypeForElement(parent, true, true, null); } return null; @@ -145,7 +136,7 @@ class MembersViewContentProvider extends CBrowsingContentProvider { } finally { finishedReadInDisplayThread(); } - } +*/ } /* (non-Javadoc) * @see org.eclipse.jface.viewers.IStructuredContentProvider#getElements(java.lang.Object) @@ -154,48 +145,6 @@ class MembersViewContentProvider extends CBrowsingContentProvider { return getChildren(inputElement); } - private ICElement getCElement(ITypeInfo info) { - ITypeReference location = info.getResolvedReference(); - if (location == null) { - final ITypeInfo[] typesToResolve = new ITypeInfo[] { info }; - IRunnableWithProgress runnable = new IRunnableWithProgress() { - public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { - AllTypesCache.resolveTypeLocation(typesToResolve[0], monitor); - if (monitor.isCanceled()) { - throw new InterruptedException(); - } - } - }; - - IProgressService service = PlatformUI.getWorkbench().getProgressService(); - try { - service.busyCursorWhile(runnable); - } catch (InvocationTargetException e) { - String title = OpenTypeMessages.getString("OpenTypeAction.exception.title"); //$NON-NLS-1$ - String message = OpenTypeMessages.getString("OpenTypeAction.exception.message"); //$NON-NLS-1$ - ExceptionHandler.handle(e, title, message); - return null; - } catch (InterruptedException e) { - // cancelled by user - return null; - } - - location = info.getResolvedReference(); - } - - ICElement elem = null; - if (location != null) - elem = TypeUtil.getElementForType(info); - - if (location == null) { - // could not resolve location - String title = OpenTypeMessages.getString("OpenTypeAction.errorTitle"); //$NON-NLS-1$ - String message = OpenTypeMessages.getFormattedString("OpenTypeAction.errorTypeNotFound", info.getQualifiedTypeName().toString()); //$NON-NLS-1$ - MessageDialog.openError(getShell(), title, message); - } - return elem; - } - protected Shell getShell() { return CUIPlugin.getActiveWorkbenchShell(); } diff --git a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/NamespacesView.java b/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/NamespacesView.java index 03d8700160c..a727377b908 100644 --- a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/NamespacesView.java +++ b/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/NamespacesView.java @@ -10,8 +10,15 @@ *******************************************************************************/ package org.eclipse.cdt.internal.ui.browser.cbrowsing; +import org.eclipse.cdt.core.browser.AllTypesCache; +import org.eclipse.cdt.core.browser.ITypeInfo; +import org.eclipse.cdt.core.model.ICElement; +import org.eclipse.cdt.core.model.ICModel; import org.eclipse.cdt.core.model.ICProject; +import org.eclipse.cdt.core.model.IEnumeration; import org.eclipse.cdt.core.model.ISourceRoot; +import org.eclipse.cdt.core.model.IStructure; +import org.eclipse.cdt.core.model.ITypeDef; import org.eclipse.cdt.internal.ui.ICHelpContextIds; import org.eclipse.cdt.internal.ui.util.ProblemTableViewer; import org.eclipse.cdt.ui.CUIPlugin; @@ -144,13 +151,72 @@ public class NamespacesView extends CBrowsingPart { * @see org.eclipse.cdt.internal.ui.browser.cbrowsing.CBrowsingPart#findInputForElement(java.lang.Object) */ protected Object findInputForElement(Object element) { - return getNamespaceInput(element); + if (element instanceof ICModel) { + return null; + } + + if (element instanceof ICProject || element instanceof ISourceRoot) { + if (exists(element)) + return element; + } + + if (element instanceof ITypeInfo) { + ITypeInfo info = (ITypeInfo)element; + ISourceRoot root = findSourceRoot(info); + if (exists(root)) + return root; + ICProject cProject = findCProject(info); + if (exists(cProject)) + return cProject; + } + + if (element instanceof ICElement) { + ICElement cElem = (ICElement)element; + ISourceRoot root = findSourceRoot(cElem); + if (exists(root)) + return root; + ICProject cProject = findCProject(cElem); + if (exists(cProject)) + return cProject; + } + + return null; } /* (non-Javadoc) * @see org.eclipse.cdt.internal.ui.browser.cbrowsing.CBrowsingPart#findElementToSelect(java.lang.Object) */ protected Object findElementToSelect(Object element) { - return getTypesInput(element); + if (element instanceof ICModel || element instanceof ICProject || element instanceof ISourceRoot) { + return null; + } + + if (element instanceof ICElement) { + ICElement parent = (ICElement)element; + while (parent != null) { + if ((parent instanceof IStructure + || parent instanceof IEnumeration + || parent instanceof ITypeDef) + && parent.exists()) { + ITypeInfo info = AllTypesCache.getTypeForElement(parent, true, true, null); + if (info != null) { + return info.getEnclosingNamespace(true); + } + } + parent = parent.getParent(); + } + return null; + } + + if (element instanceof ITypeInfo) { + ITypeInfo info = (ITypeInfo) element; + if (info.getCElementType() == ICElement.C_NAMESPACE && info.exists()) { + return info; + } else { + return info.getEnclosingNamespace(true); + } + } + + return null; } } diff --git a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/ProjectsView.java b/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/ProjectsView.java index 3a61470c40c..4948d24ffab 100644 --- a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/ProjectsView.java +++ b/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/ProjectsView.java @@ -10,12 +10,17 @@ *******************************************************************************/ package org.eclipse.cdt.internal.ui.browser.cbrowsing; +import org.eclipse.cdt.core.browser.AllTypesCache; import org.eclipse.cdt.core.browser.ITypeInfo; import org.eclipse.cdt.core.model.CoreModel; import org.eclipse.cdt.core.model.ICContainer; import org.eclipse.cdt.core.model.ICElement; import org.eclipse.cdt.core.model.ICModel; import org.eclipse.cdt.core.model.ICProject; +import org.eclipse.cdt.core.model.IEnumeration; +import org.eclipse.cdt.core.model.ISourceRoot; +import org.eclipse.cdt.core.model.IStructure; +import org.eclipse.cdt.core.model.ITypeDef; import org.eclipse.cdt.internal.ui.ICHelpContextIds; import org.eclipse.cdt.internal.ui.util.ProblemTreeViewer; import org.eclipse.cdt.ui.CUIPlugin; @@ -189,6 +194,50 @@ public class ProjectsView extends CBrowsingPart { * @see org.eclipse.cdt.internal.ui.browser.cbrowsing.CBrowsingPart#findElementToSelect(java.lang.Object) */ protected Object findElementToSelect(Object element) { - return getNamespaceInput(element); + if (element instanceof ICModel) { + return null; + } + + if (element instanceof ICProject || element instanceof ISourceRoot) { + if (exists(element)) + return element; + return null; + } + + if (element instanceof ITypeInfo) { + ITypeInfo info = (ITypeInfo)element; + ISourceRoot root = findSourceRoot(info); + if (exists(root)) + return root; + ICProject cProject = findCProject(info); + if (exists(cProject)) + return cProject; + return null; + } + + if (element instanceof ICElement) { + ICElement parent = (ICElement)element; + while (parent != null) { + if ((parent instanceof IStructure + || parent instanceof IEnumeration + || parent instanceof ITypeDef) + && parent.exists()) { + ITypeInfo info = AllTypesCache.getTypeForElement(parent, true, true, null); + if (info != null) { + ISourceRoot root = findSourceRoot(info); + if (exists(root)) + return root; + ICProject cProject = findCProject(info); + if (exists(cProject)) + return cProject; + return null; + } + } + parent = parent.getParent(); + } + return null; + } + + return null; } } diff --git a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/TypesView.java b/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/TypesView.java index 6353049eb7b..55073a0843d 100644 --- a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/TypesView.java +++ b/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/TypesView.java @@ -10,8 +10,16 @@ *******************************************************************************/ package org.eclipse.cdt.internal.ui.browser.cbrowsing; +import org.eclipse.cdt.core.browser.AllTypesCache; import org.eclipse.cdt.core.browser.ITypeInfo; +import org.eclipse.cdt.core.browser.TypeUtil; import org.eclipse.cdt.core.model.ICElement; +import org.eclipse.cdt.core.model.ICModel; +import org.eclipse.cdt.core.model.ICProject; +import org.eclipse.cdt.core.model.IEnumeration; +import org.eclipse.cdt.core.model.ISourceRoot; +import org.eclipse.cdt.core.model.IStructure; +import org.eclipse.cdt.core.model.ITypeDef; import org.eclipse.cdt.internal.ui.ICHelpContextIds; import org.eclipse.cdt.internal.ui.util.ProblemTableViewer; import org.eclipse.cdt.ui.CUIPlugin; @@ -154,13 +162,63 @@ public class TypesView extends CBrowsingPart { * @see org.eclipse.cdt.internal.ui.browser.cbrowsing.CBrowsingPart#findInputForElement(java.lang.Object) */ protected Object findInputForElement(Object element) { - return getTypesInput(element); + if (element instanceof ICModel || element instanceof ICProject || element instanceof ISourceRoot) { + return null; + } + + if (element instanceof ICElement) { + ICElement parent = TypeUtil.getDeclaringContainerType((ICElement)element); + if (parent != null) { + ITypeInfo info = AllTypesCache.getTypeForElement(parent, true, true, null); + if (info != null) + return info.getEnclosingNamespace(true); + } + return null; + } + + if (element instanceof ITypeInfo) { + ITypeInfo info = (ITypeInfo) element; + if (info.getCElementType() == ICElement.C_NAMESPACE) { + if (exists(info)) + return info; + return null; + } + return info.getEnclosingNamespace(true); + } + + return null; } /* (non-Javadoc) * @see org.eclipse.cdt.internal.ui.browser.cbrowsing.CBrowsingPart#findElementToSelect(java.lang.Object) */ protected Object findElementToSelect(Object element) { - return getMembersInput(element); + if (element instanceof ICModel || element instanceof ICProject || element instanceof ISourceRoot) { + return null; + } + + if (element instanceof ICElement) { + ICElement parent = (ICElement)element; + while (parent != null) { + if ((parent instanceof IStructure + || parent instanceof IEnumeration + || parent instanceof ITypeDef)) { + ITypeInfo info = AllTypesCache.getTypeForElement(parent, true, true, null); + return info; + } + parent = parent.getParent(); + } + return null; + } + + if (element instanceof ITypeInfo) { + ITypeInfo info = (ITypeInfo) element; + if (info.getCElementType() != ICElement.C_NAMESPACE) { + return info; + } + return null; + } + + return null; } } diff --git a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/FocusOnTypeAction.java b/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/FocusOnTypeAction.java index d63738511bf..2240855f3b5 100644 --- a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/FocusOnTypeAction.java +++ b/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/FocusOnTypeAction.java @@ -16,7 +16,6 @@ import org.eclipse.cdt.core.browser.AllTypesCache; import org.eclipse.cdt.core.browser.ITypeInfo; import org.eclipse.cdt.core.browser.ITypeSearchScope; import org.eclipse.cdt.core.browser.TypeSearchScope; -import org.eclipse.cdt.core.browser.TypeUtil; import org.eclipse.cdt.core.model.ICElement; import org.eclipse.cdt.internal.ui.ICHelpContextIds; import org.eclipse.cdt.internal.ui.browser.opentype.OpenTypeMessages; @@ -101,7 +100,7 @@ public class FocusOnTypeAction extends Action { final ICElement[] foundElement = new ICElement[] { null }; IRunnableWithProgress runnable = new IRunnableWithProgress() { public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { - foundElement[0] = TypeUtil.getElementForType(typesToResolve[0], monitor); + foundElement[0] = AllTypesCache.getElementForType(typesToResolve[0], true, true, monitor); } }; diff --git a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/HierarchyViewerSorter.java b/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/HierarchyViewerSorter.java index 434ebc1a610..e9523d9acf4 100644 --- a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/HierarchyViewerSorter.java +++ b/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/HierarchyViewerSorter.java @@ -141,7 +141,7 @@ public class HierarchyViewerSorter extends ViewerSorter { } private ICElement getDefiningType(ITypeHierarchy hierarchy, IMethodDeclaration method) throws CModelException { - ICElement declaringType= TypeUtil.getDeclaringType(method); + ICElement declaringType= TypeUtil.getDeclaringClass(method); if ((method.getVisibility() == ASTAccessVisibility.PRIVATE) || method.isStatic() || method.isConstructor() || method.isDestructor()) { return null; } @@ -150,7 +150,7 @@ public class HierarchyViewerSorter extends ViewerSorter { if (res == null || method.equals(res)) { return null; } - return TypeUtil.getDeclaringType(res); + return TypeUtil.getDeclaringClass(res); } diff --git a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/MethodsLabelProvider.java b/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/MethodsLabelProvider.java index 81da430f368..9244d305b18 100644 --- a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/MethodsLabelProvider.java +++ b/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/MethodsLabelProvider.java @@ -61,7 +61,7 @@ public class MethodsLabelProvider extends StandardCElementLabelProvider //extend if (kind != ICElement.C_METHOD_DECLARATION && kind != ICElement.C_FIELD) { return null; } - ICElement declaringType= TypeUtil.getDeclaringType(elem); + ICElement declaringType= TypeUtil.getDeclaringClass(elem); if (kind != ICElement.C_METHOD_DECLARATION) { return declaringType; } @@ -77,7 +77,7 @@ public class MethodsLabelProvider extends StandardCElementLabelProvider //extend if (res == null || method.equals(res)) { return declaringType; } - return TypeUtil.getDeclaringType(res); + return TypeUtil.getDeclaringClass(res); } /* (non-Javadoc) @@ -119,7 +119,7 @@ public class MethodsLabelProvider extends StandardCElementLabelProvider //extend public Color getForeground(Object element) { if (fMethodsViewer.isShowInheritedMethods() && element instanceof IMethod) { IMethod curr= (IMethod) element; - ICElement declaringType= TypeUtil.getDeclaringType(curr); + ICElement declaringType= TypeUtil.getDeclaringClass(curr); if (declaringType.equals(fMethodsViewer.getInput())) { if (fResolvedBackground == null) { diff --git a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/OpenTypeHierarchyAction.java b/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/OpenTypeHierarchyAction.java index 20a0a2fa76b..e664c926376 100644 --- a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/OpenTypeHierarchyAction.java +++ b/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/OpenTypeHierarchyAction.java @@ -185,7 +185,7 @@ public class OpenTypeHierarchyAction extends SelectionDispatchAction { if (types != null) { List elements = new ArrayList(types.length); for (int i = 0; i < types.length; ++i) { - ICElement e = TypeUtil.getElementForType(types[i], monitor); + ICElement e = AllTypesCache.getElementForType(types[i], true, true, monitor); if (e != null && !elements.contains(e)) elements.add(e); } diff --git a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/OpenTypeHierarchyUtil.java b/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/OpenTypeHierarchyUtil.java index 82402076dbb..fe925771ed9 100644 --- a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/OpenTypeHierarchyUtil.java +++ b/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/OpenTypeHierarchyUtil.java @@ -107,7 +107,7 @@ public class OpenTypeHierarchyUtil { // if (input.getElementType() != ITypeElement.TYPE) { if (TypeUtil.isClassOrStruct(input)) { // perspectiveInput= ((IMember)input).getDeclaringType(); - perspectiveInput= TypeUtil.getDeclaringType(input); + perspectiveInput= TypeUtil.getDeclaringClass(input); } else { perspectiveInput= input; } @@ -152,7 +152,7 @@ public class OpenTypeHierarchyUtil { case ICElement.C_UNION: case ICElement.C_ENUMERATION: case ICElement.C_TYPEDEF: - return new ICElement[] { TypeUtil.getDeclaringType(elem) }; + return new ICElement[] { TypeUtil.getDeclaringClass(elem) }; case ICElement.C_CLASS: case ICElement.C_STRUCT: return new ICElement[] { elem }; diff --git a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/TypeHierarchyContentProvider.java b/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/TypeHierarchyContentProvider.java index 901e8604523..f809bbcda85 100644 --- a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/TypeHierarchyContentProvider.java +++ b/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/TypeHierarchyContentProvider.java @@ -193,7 +193,7 @@ public abstract class TypeHierarchyContentProvider implements ITreeContentProvid if (methods != null && methods.length > 0) { for (int i= 0; i < fMemberFilter.length; i++) { IMember member= fMemberFilter[i]; - if (parent.equals(TypeUtil.getDeclaringType(member))) { + if (parent.equals(TypeUtil.getDeclaringClass(member))) { if (!children.contains(member)) { children.add(member); } @@ -236,7 +236,7 @@ public abstract class TypeHierarchyContentProvider implements ITreeContentProvid if (methods != null && methods.length > 0) { for (int i= 0; i < fMemberFilter.length; i++) { IMember member= fMemberFilter[i]; - if (type.equals(TypeUtil.getDeclaringType(member))) { + if (type.equals(TypeUtil.getDeclaringClass(member))) { return true; } else if (member instanceof IMethodDeclaration) { IMethodDeclaration curr= (IMethodDeclaration)member; @@ -290,7 +290,7 @@ public abstract class TypeHierarchyContentProvider implements ITreeContentProvid if (parents != null && parents.length == 1) return parents[0]; } - return TypeUtil.getDeclaringType(member); + return TypeUtil.getDeclaringClass(member); } return null; } diff --git a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/TypeHierarchyViewPart.java b/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/TypeHierarchyViewPart.java index b2e7492fac7..527ac1d038a 100644 --- a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/TypeHierarchyViewPart.java +++ b/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/TypeHierarchyViewPart.java @@ -410,7 +410,7 @@ public class TypeHierarchyViewPart extends ViewPart implements ITypeHierarchyVie public void setInputElement(ICElement element) { if (element != null) { if (!(element instanceof IStructure)) { - element = TypeUtil.getDeclaringType(element); + element = TypeUtil.getDeclaringClass(element); } if (element == null || !element.exists()) { MessageDialog.openError(getSite().getShell(), TypeHierarchyMessages.getString("TypeHierarchyViewPart.error.title"), TypeHierarchyMessages.getString("TypeHierarchyViewPart.error.message")); //$NON-NLS-1$ //$NON-NLS-2$