### Eclipse Workspace Patch 1.0 #P org.eclipse.jdt.core.tests.model Index: src/org/eclipse/jdt/core/tests/model/TypeHierarchyTests.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/TypeHierarchyTests.java,v retrieving revision 1.75 diff -u -r1.75 TypeHierarchyTests.java --- src/org/eclipse/jdt/core/tests/model/TypeHierarchyTests.java 21 Nov 2007 16:48:42 -0000 1.75 +++ src/org/eclipse/jdt/core/tests/model/TypeHierarchyTests.java 3 Dec 2007 12:27:10 -0000 @@ -1443,6 +1443,21 @@ hierarchy); } /* + * Ensures that a super type hierarchy on a local type in a method declaration with an error is correct. + * (regression test for https://bugs.eclipse.org/bugs/show_bug.cgi?id=210498 ) + */ +public void testLocalType5() throws JavaModelException { + IType typeX = getCompilationUnit("TypeHierarchy", "src", "q9", "X.java").getType("X"); + IType type = typeX.getMethod("foo", new String[] {}).getType("Local", 1); + ITypeHierarchy hierarchy = type.newTypeHierarchy(null); + assertTypesEqual( + "Unexpected types in hierarchy", + "java.lang.Object\n" + + "q9.X\n" + + "q9.X$Local\n", + hierarchy.getAllTypes()); +} +/* * Ensures that a type hierarchy on a member type with subtypes in another project is correct * (regression test for bug 101019 RC3: Type Hierarchy does not find implementers/extenders of inner class/interface in other project) */ Index: workspace/TypeHierarchy/src/q9/X.java =================================================================== RCS file: workspace/TypeHierarchy/src/q9/X.java diff -N workspace/TypeHierarchy/src/q9/X.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ workspace/TypeHierarchy/src/q9/X.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,11 @@ +package q9; +public class X { + void foo() { + class Local extends X { + ZorkLocal z; + } + } +} +interface Y { + String value(); +} #P org.eclipse.jdt.core Index: model/org/eclipse/jdt/internal/core/hierarchy/HierarchyResolver.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/hierarchy/HierarchyResolver.java,v retrieving revision 1.76 diff -u -r1.76 HierarchyResolver.java --- model/org/eclipse/jdt/internal/core/hierarchy/HierarchyResolver.java 21 Nov 2007 16:48:44 -0000 1.76 +++ model/org/eclipse/jdt/internal/core/hierarchy/HierarchyResolver.java 3 Dec 2007 12:27:11 -0000 @@ -457,7 +457,7 @@ * Reports the hierarchy from the remembered bindings. * Note that 'binaryTypeBinding' is null if focus type is a source type. */ -private void reportHierarchy(IType focus, CompilationUnitDeclaration parsedUnit, ReferenceBinding binaryTypeBinding) { +private void reportHierarchy(IType focus, TypeDeclaration focusLocalType, ReferenceBinding binaryTypeBinding) { // set focus type binding if (focus != null) { @@ -466,19 +466,13 @@ this.focusType = binaryTypeBinding; } else { // source type - Member declaringMember = ((Member)focus).getOuterMostLocalContext(); - if (declaringMember == null) { + if (focusLocalType != null) { + // anonymous or local type + this.focusType = focusLocalType.binding; + } else { // top level or member type char[] fullyQualifiedName = focus.getFullyQualifiedName().toCharArray(); setFocusType(CharOperation.splitOn('.', fullyQualifiedName)); - } else { - // anonymous or local type - if (parsedUnit != null) { - TypeDeclaration typeDecl = new ASTNodeFinder(parsedUnit).findType(focus); - if (typeDecl != null) { - this.focusType = typeDecl.binding; - } - } } } } @@ -695,6 +689,13 @@ } } + // remember type declaration of focus if local/anonymous early (see https://bugs.eclipse.org/bugs/show_bug.cgi?id=210498) + TypeDeclaration focusLocalType = null; + if (focus != null && focusBinaryBinding == null && focusUnit != null && ((Member)focus).getOuterMostLocalContext() != null) { + focusLocalType = new ASTNodeFinder(focusUnit).findType(focus); + } + + for (int i = 0; i <= this.typeIndex; i++) { IGenericType suppliedType = this.typeModels[i]; if (suppliedType != null && suppliedType.isBinaryType()) { @@ -753,7 +754,7 @@ return; } - reportHierarchy(focus, focusUnit, focusBinaryBinding); + reportHierarchy(focus, focusLocalType, focusBinaryBinding); } catch (ClassCastException e){ // work-around for 1GF5W1S - can happen in case duplicates are fed to the hierarchy with binaries hiding sources } catch (AbortCompilation e) { // ignore this exception for now since it typically means we cannot find java.lang.Object