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 |
IPath filePath = project.getProject().getFullPath().append("src").append("simplefile.txt"); |
1354 |
try { |
1355 |
createFile(filePath.toOSString(), "A simple text file"); |
1356 |
assertTrue("Should not receive change", !this.changeReceived); |
1357 |
} finally { |
1358 |
deleteFile(filePath.toOSString()); |
1359 |
h.removeTypeHierarchyChangedListener(this); |
1360 |
} |
1361 |
} |
1362 |
/** |
1363 |
* Additional test - Test that a relevant Java source resource change results in a type hierarchy |
1364 |
* change event. |
1365 |
* |
1366 |
* @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=316654" |
1367 |
* @throws CoreException |
1368 |
*/ |
1369 |
public void testBug316654_a() throws CoreException { |
1370 |
IJavaProject project = getJavaProject("TypeHierarchyNotification"); |
1371 |
ICompilationUnit cu = getCompilationUnit("TypeHierarchyNotification", "src", "p", "X.java"); |
1372 |
IType type= cu.getType("X"); |
1373 |
ITypeHierarchy h = type.newTypeHierarchy(project, null); |
1374 |
h.addTypeHierarchyChangedListener(this); |
1375 |
IPath filePath = project.getProject().getFullPath().append("src").append("p").append("Y.java"); |
1376 |
try { |
1377 |
createFile(filePath.toOSString(), |
1378 |
"package p;\n" + |
1379 |
"class Y extends X{\n" + |
1380 |
"}"); |
1381 |
assertOneChange(h); |
1382 |
} finally { |
1383 |
deleteFile(filePath.toOSString()); |
1384 |
h.removeTypeHierarchyChangedListener(this); |
1385 |
} |
1386 |
} |
1387 |
/** |
1388 |
* Additional test - Test that a relevant archive change results in a type hierarchy |
1389 |
* change event. |
1390 |
* |
1391 |
* @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=316654" |
1392 |
* @throws CoreException |
1393 |
*/ |
1394 |
public void testBug316654_b() throws CoreException { |
1395 |
IJavaProject project = getJavaProject("TypeHierarchyNotification"); |
1396 |
refreshExternalArchives(project); |
1397 |
File jarFile = new File(getExternalJCLPathString()); |
1398 |
long oldTimestamp = jarFile.lastModified(); |
1399 |
assertTrue("File does not exist", jarFile.exists()); |
1400 |
|
1401 |
IType throwableClass = getClassFile("TypeHierarchyNotification", getExternalJCLPathString(), "java.lang", "Throwable.class").getType(); |
1402 |
ITypeHierarchy h = throwableClass.newTypeHierarchy(project, null); |
1403 |
h.addTypeHierarchyChangedListener(this); |
1404 |
reset(); |
1405 |
|
1406 |
try { |
1407 |
jarFile.setLastModified(System.currentTimeMillis()); |
1408 |
refreshExternalArchives(project); |
1409 |
assertOneChange(h); |
1410 |
} finally { |
1411 |
jarFile.setLastModified(oldTimestamp); |
1412 |
h.removeTypeHierarchyChangedListener(this); |
1413 |
} |
1414 |
} |
1415 |
/** |
1337 |
* Make a note of the change |
1416 |
* Make a note of the change |
1338 |
*/ |
1417 |
*/ |
1339 |
public void typeHierarchyChanged(ITypeHierarchy typeHierarchy) { |
1418 |
public void typeHierarchyChanged(ITypeHierarchy typeHierarchy) { |