### Eclipse Workspace Patch 1.0 #P org.eclipse.jdt.core Index: model/org/eclipse/jdt/internal/core/hierarchy/TypeHierarchy.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/hierarchy/TypeHierarchy.java,v retrieving revision 1.107 diff -u -r1.107 TypeHierarchy.java --- model/org/eclipse/jdt/internal/core/hierarchy/TypeHierarchy.java 7 Mar 2009 01:08:09 -0000 1.107 +++ model/org/eclipse/jdt/internal/core/hierarchy/TypeHierarchy.java 14 Sep 2009 07:32:41 -0000 @@ -984,6 +984,9 @@ protected boolean isAffectedByOpenable(IJavaElementDelta delta, IJavaElement element, int eventType) { if (element instanceof CompilationUnit) { CompilationUnit cu = (CompilationUnit)element; + if (delta.getKind() == IJavaElementDelta.ADDED && !cu.isPrimary()) + return false; + ChangeCollector collector = this.changeCollector; if (collector == null) { collector = new ChangeCollector(this); #P org.eclipse.jdt.core.tests.model Index: src/org/eclipse/jdt/core/tests/model/TypeHierarchyNotificationTests.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/TypeHierarchyNotificationTests.java,v retrieving revision 1.32 diff -u -r1.32 TypeHierarchyNotificationTests.java --- src/org/eclipse/jdt/core/tests/model/TypeHierarchyNotificationTests.java 28 Apr 2009 17:49:27 -0000 1.32 +++ src/org/eclipse/jdt/core/tests/model/TypeHierarchyNotificationTests.java 14 Sep 2009 07:32:46 -0000 @@ -1244,6 +1244,55 @@ h.removeTypeHierarchyChangedListener(this); } } + +/* + * Ensures that getting a non-primary working copy does NOT trigger + * a type hierarchy notification for the concerned hierarchy. + * See https://bugs.eclipse.org/bugs/show_bug.cgi?id=275805 + */ +public void testGetWorkingCopy() throws CoreException { + ITypeHierarchy h = null; + ICompilationUnit superCopy = null; + ICompilationUnit aWorkingCopy = null; + + try { + + createJavaProject("P"); + createFolder("/P/p"); + createFile( + "/P/p/IX.java", + "package p;\n" + + "public interface IX {\n" + + "}" + ); + + createFile( + "/P/p/X.java", + "package p;\n" + + "public class X implements IX{\n" + + "}" + ); + + superCopy = getCompilationUnit("/P/p/IX.java"); + superCopy.becomeWorkingCopy(null/*no progress*/); + h = superCopy.getType("IX").newTypeHierarchy(null); + h.addTypeHierarchyChangedListener(this); + + aWorkingCopy = getCompilationUnit("P/p/X.java").getWorkingCopy(null); + + assertTrue("Should receive NO change", !this.changeReceived); + } finally { + if (h != null) + h.removeTypeHierarchyChangedListener(this); + if (aWorkingCopy != null) + aWorkingCopy.discardWorkingCopy(); + if (superCopy!= null) + superCopy.discardWorkingCopy(); + + deleteProject("P"); + } +} + /** * Make a note of the change */