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 / +79 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 10-21 Link Here
10
 *******************************************************************************/
10
 *******************************************************************************/
11
package org.eclipse.jdt.core.tests.model;
11
package org.eclipse.jdt.core.tests.model;
12
12
13
import java.io.File;
13
import java.io.IOException;
14
import java.io.IOException;
14
15
15
import junit.framework.Test;
16
import junit.framework.Test;
16
17
17
import org.eclipse.core.resources.*;
18
import org.eclipse.core.resources.*;
18
import org.eclipse.core.runtime.CoreException;
19
import org.eclipse.core.runtime.CoreException;
20
import org.eclipse.core.runtime.IPath;
19
import org.eclipse.core.runtime.IProgressMonitor;
21
import org.eclipse.core.runtime.IProgressMonitor;
20
import org.eclipse.core.runtime.Path;
22
import org.eclipse.core.runtime.Path;
21
import org.eclipse.jdt.core.*;
23
import org.eclipse.jdt.core.*;
Lines 1334-1339 Link Here
1334
	}
1336
	}
1335
}
1337
}
1336
/**
1338
/**
1339
 * @bug 316654: ITypeHierarchyChangedListener receive spurious callbacks
1340
 * 
1341
 * Test that a non-Java resource added to a folder package fragment root doesn't
1342
 * result in a type hierarchy changed event.
1343
 * 
1344
 * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=316654"
1345
 * @throws CoreException
1346
 */
1347
public void testBug316654() throws CoreException {
1348
	IJavaProject project = getJavaProject("TypeHierarchyNotification");
1349
	ICompilationUnit cu = getCompilationUnit("TypeHierarchyNotification", "src", "p", "X.java");
1350
	IType type= cu.getType("X");
1351
	ITypeHierarchy h = type.newTypeHierarchy(project, null);
1352
	h.addTypeHierarchyChangedListener(this);
1353
1354
	try {
1355
		createFile(project.getProject().getFullPath().append("src").append("simplefile.txt").toOSString(), "A simple text file");
1356
		assertTrue("Should not receive change", !this.changeReceived);
1357
	} finally {
1358
		h.removeTypeHierarchyChangedListener(this);
1359
	}
1360
}
1361
/**
1362
 * Additional test - Test that a relevant Java source resource change results in a type hierarchy 
1363
 * change event.  
1364
 * 
1365
 * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=316654"
1366
 * @throws CoreException
1367
 */
1368
public void testBug316654_a() throws CoreException {
1369
	IJavaProject project = getJavaProject("TypeHierarchyNotification");
1370
	ICompilationUnit cu = getCompilationUnit("TypeHierarchyNotification", "src", "p", "X.java");
1371
	IType type= cu.getType("X");
1372
	ITypeHierarchy h = type.newTypeHierarchy(project, null);
1373
	h.addTypeHierarchyChangedListener(this);
1374
	IPath filePath = project.getProject().getFullPath().append("src").append("p").append("Y.java");
1375
	try {
1376
		createFile(filePath.toOSString(), 
1377
					"package p;\n" +
1378
					"class Y extends X{\n" +
1379
					"}");
1380
		assertOneChange(h);
1381
	} finally {
1382
		deleteFile(filePath.toOSString());
1383
		h.removeTypeHierarchyChangedListener(this);
1384
	}
1385
}
1386
/**
1387
 * Additional test - Test that a relevant archive change results in a type hierarchy 
1388
 * change event.  
1389
 * 
1390
 * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=316654"
1391
 * @throws CoreException
1392
 */
1393
public void testBug316654_b() throws Exception {
1394
	IJavaProject project = getJavaProject("TypeHierarchyNotification");
1395
	refreshExternalArchives(project);
1396
	File jarFile = new File(getExternalJCLPathString());
1397
	long oldTimestamp = jarFile.lastModified();
1398
	assertTrue("File does not exist", jarFile.exists());
1399
1400
	IType throwableClass = getClassFile("TypeHierarchyNotification", getExternalJCLPathString(), "java.lang", "Throwable.class").getType();
1401
	ITypeHierarchy h = throwableClass.newTypeHierarchy(project, null);
1402
	h.addTypeHierarchyChangedListener(this);
1403
	reset();
1404
	
1405
	try {
1406
		jarFile.setLastModified(System.currentTimeMillis());
1407
		refreshExternalArchives(project);
1408
		assertOneChange(h);
1409
	} finally {
1410
		jarFile.setLastModified(oldTimestamp);
1411
		h.removeTypeHierarchyChangedListener(this);
1412
	}
1413
}
1414
/**
1337
 * Make a note of the change
1415
 * Make a note of the change
1338
 */
1416
 */
1339
public void typeHierarchyChanged(ITypeHierarchy typeHierarchy) {
1417
public void typeHierarchyChanged(ITypeHierarchy typeHierarchy) {

Return to bug 316654