View | Details | Raw Unified | Return to bug 316654 | Differences between
and this patch

Collapse All | Expand All

(-)model/org/eclipse/jdt/internal/core/hierarchy/TypeHierarchy.java (-3 / +3 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2009 IBM Corporation and others.
2
 * Copyright (c) 2000, 2010 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 960-970 Link Here
960
					}
960
					}
961
				}
961
				}
962
			}
962
			}
963
			if ((flags & IJavaElementDelta.F_REMOVED_FROM_CLASSPATH) > 0 || (flags & IJavaElementDelta.F_CONTENT) > 0) {
963
			if ((flags & IJavaElementDelta.F_REMOVED_FROM_CLASSPATH) > 0 || (flags & IJavaElementDelta.F_ARCHIVE_CONTENT_CHANGED) > 0) {
964
				// 1. removed from classpath - if it contains packages we are interested in
964
				// 1. removed from classpath - if it contains packages we are interested in
965
				// the the type hierarchy has changed
965
				// the the type hierarchy has changed
966
				// 2. content of a jar changed - if it contains packages we are interested in
966
				// 2. content of a jar changed - if it contains packages we are interested in
967
				// the the type hierarchy has changed
967
				// then the type hierarchy has changed
968
				IJavaElement[] pkgs = this.packageRegion.getElements();
968
				IJavaElement[] pkgs = this.packageRegion.getElements();
969
				for (int i = 0; i < pkgs.length; i++) {
969
				for (int i = 0; i < pkgs.length; i++) {
970
					if (pkgs[i].getParent().equals(element)) {
970
					if (pkgs[i].getParent().equals(element)) {
(-)src/org/eclipse/jdt/core/tests/model/TypeHierarchyNotificationTests.java (-1 / +43 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2009 IBM Corporation and others.
2
 * Copyright (c) 2000, 2010 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 16-21 Link Here
16
16
17
import org.eclipse.core.resources.*;
17
import org.eclipse.core.resources.*;
18
import org.eclipse.core.runtime.CoreException;
18
import org.eclipse.core.runtime.CoreException;
19
import org.eclipse.core.runtime.IPath;
19
import org.eclipse.core.runtime.IProgressMonitor;
20
import org.eclipse.core.runtime.IProgressMonitor;
20
import org.eclipse.core.runtime.Path;
21
import org.eclipse.core.runtime.Path;
21
import org.eclipse.jdt.core.*;
22
import org.eclipse.jdt.core.*;
Lines 1334-1339 Link Here
1334
	}
1335
	}
1335
}
1336
}
1336
/**
1337
/**
1338
 * @bug 316654: ITypeHierarchyChangedListener receive spurious callbacks
1339
 * 
1340
 * Test that a non-Java resource added to a folder package fragment root doesn't
1341
 * result in a type hierarchy changed event.
1342
 * 
1343
 * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=316654"
1344
 * @throws CoreException
1345
 */
1346
public void testAddNonJavaToPackageFragmentRoot() throws CoreException {
1347
	IJavaProject project = getJavaProject("TypeHierarchyNotification");
1348
	ICompilationUnit cu = getCompilationUnit("TypeHierarchyNotification", "src", "p", "X.java");
1349
	IType type= cu.getType("X");
1350
	ITypeHierarchy h = type.newTypeHierarchy(project, null);
1351
	h.addTypeHierarchyChangedListener(this);
1352
1353
	try {
1354
		createFile(project.getProject().getFullPath().append("src").append("simplefile.txt").toOSString(), "A simple text file");
1355
		assertTrue("Should not receive change", !this.changeReceived);
1356
	} finally {
1357
		h.removeTypeHierarchyChangedListener(this);
1358
	}
1359
}
1360
public void testAddNonJavaToPackageFragmentRoot1() throws CoreException {
1361
	IJavaProject project = getJavaProject("TypeHierarchyNotification");
1362
	ICompilationUnit cu = getCompilationUnit("TypeHierarchyNotification", "src", "p", "X.java");
1363
	IType type= cu.getType("X");
1364
	ITypeHierarchy h = type.newTypeHierarchy(project, null);
1365
	h.addTypeHierarchyChangedListener(this);
1366
	IPath filePath = project.getProject().getFullPath().append("src").append("p").append("Y.java");
1367
	try {
1368
		createFile(filePath.toOSString(), 
1369
					"package p;\n" +
1370
					"class Y extends X{\n" +
1371
					"}");
1372
		assertOneChange(h);
1373
	} finally {
1374
		deleteFile(filePath.toOSString());
1375
		h.removeTypeHierarchyChangedListener(this);
1376
	}
1377
}
1378
/**
1337
 * Make a note of the change
1379
 * Make a note of the change
1338
 */
1380
 */
1339
public void typeHierarchyChanged(ITypeHierarchy typeHierarchy) {
1381
public void typeHierarchyChanged(ITypeHierarchy typeHierarchy) {

Return to bug 316654