### 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.108 diff -u -r1.108 TypeHierarchy.java --- model/org/eclipse/jdt/internal/core/hierarchy/TypeHierarchy.java 3 Nov 2009 15:21:59 -0000 1.108 +++ model/org/eclipse/jdt/internal/core/hierarchy/TypeHierarchy.java 15 Jun 2010 11:40:30 -0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2009 IBM Corporation and others. + * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -960,11 +960,11 @@ } } } - if ((flags & IJavaElementDelta.F_REMOVED_FROM_CLASSPATH) > 0 || (flags & IJavaElementDelta.F_CONTENT) > 0) { + if ((flags & IJavaElementDelta.F_REMOVED_FROM_CLASSPATH) > 0 || (flags & IJavaElementDelta.F_ARCHIVE_CONTENT_CHANGED) > 0) { // 1. removed from classpath - if it contains packages we are interested in // the the type hierarchy has changed // 2. content of a jar changed - if it contains packages we are interested in - // the the type hierarchy has changed + // then the type hierarchy has changed IJavaElement[] pkgs = this.packageRegion.getElements(); for (int i = 0; i < pkgs.length; i++) { if (pkgs[i].getParent().equals(element)) { #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.33 diff -u -r1.33 TypeHierarchyNotificationTests.java --- src/org/eclipse/jdt/core/tests/model/TypeHierarchyNotificationTests.java 3 Nov 2009 15:21:55 -0000 1.33 +++ src/org/eclipse/jdt/core/tests/model/TypeHierarchyNotificationTests.java 15 Jun 2010 11:40:36 -0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2009 IBM Corporation and others. + * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -16,6 +16,7 @@ import org.eclipse.core.resources.*; import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.Path; import org.eclipse.jdt.core.*; @@ -1334,6 +1335,47 @@ } } /** + * @bug 316654: ITypeHierarchyChangedListener receive spurious callbacks + * + * Test that a non-Java resource added to a folder package fragment root doesn't + * result in a type hierarchy changed event. + * + * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=316654" + * @throws CoreException + */ +public void testAddNonJavaToPackageFragmentRoot() throws CoreException { + IJavaProject project = getJavaProject("TypeHierarchyNotification"); + ICompilationUnit cu = getCompilationUnit("TypeHierarchyNotification", "src", "p", "X.java"); + IType type= cu.getType("X"); + ITypeHierarchy h = type.newTypeHierarchy(project, null); + h.addTypeHierarchyChangedListener(this); + + try { + createFile(project.getProject().getFullPath().append("src").append("simplefile.txt").toOSString(), "A simple text file"); + assertTrue("Should not receive change", !this.changeReceived); + } finally { + h.removeTypeHierarchyChangedListener(this); + } +} +public void testAddNonJavaToPackageFragmentRoot1() throws CoreException { + IJavaProject project = getJavaProject("TypeHierarchyNotification"); + ICompilationUnit cu = getCompilationUnit("TypeHierarchyNotification", "src", "p", "X.java"); + IType type= cu.getType("X"); + ITypeHierarchy h = type.newTypeHierarchy(project, null); + h.addTypeHierarchyChangedListener(this); + IPath filePath = project.getProject().getFullPath().append("src").append("p").append("Y.java"); + try { + createFile(filePath.toOSString(), + "package p;\n" + + "class Y extends X{\n" + + "}"); + assertOneChange(h); + } finally { + deleteFile(filePath.toOSString()); + h.removeTypeHierarchyChangedListener(this); + } +} +/** * Make a note of the change */ public void typeHierarchyChanged(ITypeHierarchy typeHierarchy) {