### Eclipse Workspace Patch 1.0 #P org.eclipse.jdt.core Index: model/org/eclipse/jdt/internal/core/SourceType.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/SourceType.java,v retrieving revision 1.146 diff -u -r1.146 SourceType.java --- model/org/eclipse/jdt/internal/core/SourceType.java 10 Oct 2008 07:28:57 -0000 1.146 +++ model/org/eclipse/jdt/internal/core/SourceType.java 20 Nov 2008 15:31:08 -0000 @@ -767,9 +767,11 @@ * @see IType */ public ITypeHierarchy newTypeHierarchy(IProgressMonitor monitor) throws JavaModelException { - CreateTypeHierarchyOperation op= new CreateTypeHierarchyOperation(this, null, SearchEngine.createWorkspaceScope(), true); - op.runOperation(monitor); - return op.getResult(); + + // https://bugs.eclipse.org/bugs/show_bug.cgi?id=228845, The new type hierarchy should consider changes in primary + // working copy. + + return newTypeHierarchy(DefaultWorkingCopyOwner.PRIMARY, monitor); } /* * @see IType#newTypeHierarchy(ICompilationUnit[], IProgressMonitor) #P org.eclipse.jdt.core.tests.model Index: src/org/eclipse/jdt/core/tests/model/HierarchyOnWorkingCopiesTests.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/HierarchyOnWorkingCopiesTests.java,v retrieving revision 1.18 diff -u -r1.18 HierarchyOnWorkingCopiesTests.java --- src/org/eclipse/jdt/core/tests/model/HierarchyOnWorkingCopiesTests.java 27 Jun 2008 16:02:38 -0000 1.18 +++ src/org/eclipse/jdt/core/tests/model/HierarchyOnWorkingCopiesTests.java 20 Nov 2008 15:31:11 -0000 @@ -104,5 +104,44 @@ } } } +//https://bugs.eclipse.org/bugs/show_bug.cgi?id=228845 +//make sure uncommitted changes to primary working copy shows up in hierarchy +public void test228845() throws CoreException { + String newContents = + "package x.y;\n" + + "public class A extends B {\n" + + "}"; + + ICompilationUnit primaryCu = this.copy.getPrimary(); + primaryCu.becomeWorkingCopy(null); + + primaryCu.getBuffer().setContents(newContents); + primaryCu.reconcile(ICompilationUnit.NO_AST, false, null, null); + + IFile file = null; + try { + file = this.createFile( + "P/src/x/y/B.java", + "package x.y;\n" + + "public class B {\n" + + "}"); + + IType type = this.getCompilationUnit("P/src/x/y/B.java").getType("B"); + ITypeHierarchy h = type.newTypeHierarchy(null); // no working copies explicitly passed, should still honor primary working copies. + + assertHierarchyEquals( + "Focus: B [in B.java [in x.y [in src [in P]]]]\n" + + "Super types:\n" + + " Object [in Object.class [in java.lang [in "+ getExternalJCLPathString() + "]]]\n" + + "Sub types:\n" + + " A [in [Working copy] A.java [in x.y [in src [in P]]]]\n", + h); + } finally { + primaryCu.discardWorkingCopy(); + if (file != null) { + this.deleteResource(file); + } + } +} }