Lines 1244-1249
Link Here
|
1244 |
h.removeTypeHierarchyChangedListener(this); |
1244 |
h.removeTypeHierarchyChangedListener(this); |
1245 |
} |
1245 |
} |
1246 |
} |
1246 |
} |
|
|
1247 |
|
1248 |
/* |
1249 |
* Ensures that getting a non-primary working copy does NOT trigger |
1250 |
* a type hierarchy notification for the concerned hierarchy. |
1251 |
* See https://bugs.eclipse.org/bugs/show_bug.cgi?id=275805 |
1252 |
*/ |
1253 |
public void testGetWorkingCopy() throws CoreException { |
1254 |
ITypeHierarchy h = null; |
1255 |
ICompilationUnit superCopy = null; |
1256 |
ICompilationUnit aWorkingCopy = null; |
1257 |
try { |
1258 |
|
1259 |
createJavaProject("P"); |
1260 |
createFolder("/P/p"); |
1261 |
createFile( |
1262 |
"/P/p/IX.java", |
1263 |
"package p;\n" + |
1264 |
"public interface IX {\n" + |
1265 |
"}" |
1266 |
); |
1267 |
|
1268 |
createFile( |
1269 |
"/P/p/X.java", |
1270 |
"package p;\n" + |
1271 |
"public class X implements IX{\n" + |
1272 |
"}" |
1273 |
); |
1274 |
|
1275 |
superCopy = getCompilationUnit("/P/p/IX.java"); |
1276 |
superCopy.becomeWorkingCopy(null/*no progress*/); |
1277 |
h = superCopy.getType("IX").newTypeHierarchy(null); |
1278 |
h.addTypeHierarchyChangedListener(this); |
1279 |
|
1280 |
aWorkingCopy = getCompilationUnit("P/p/X.java").getWorkingCopy(null); |
1281 |
|
1282 |
assertTrue("Should receive NO change", !this.changeReceived); |
1283 |
} finally { |
1284 |
if (h != null) |
1285 |
h.removeTypeHierarchyChangedListener(this); |
1286 |
if (aWorkingCopy != null) |
1287 |
aWorkingCopy.discardWorkingCopy(); |
1288 |
if (superCopy!= null) |
1289 |
superCopy.discardWorkingCopy(); |
1290 |
|
1291 |
deleteProject("P"); |
1292 |
} |
1293 |
} |
1294 |
|
1295 |
/* |
1296 |
* Ensures that working copies with different owner than that of the |
1297 |
* type hierarchy listener are ignored. |
1298 |
* See https://bugs.eclipse.org/bugs/show_bug.cgi?id=275805 |
1299 |
*/ |
1300 |
public void testOwner() throws CoreException { |
1301 |
ITypeHierarchy h = null; |
1302 |
ICompilationUnit aWorkingCopy = null; |
1303 |
ICompilationUnit anotherWorkingCopy = null; |
1304 |
try { |
1305 |
createJavaProject("P"); |
1306 |
createFolder("/P/p"); |
1307 |
createFile( |
1308 |
"/P/p/X.java", |
1309 |
"package p;\n" + |
1310 |
"public class X {\n" + |
1311 |
"}" |
1312 |
); |
1313 |
|
1314 |
aWorkingCopy = getCompilationUnit("/P/p/X.java").getWorkingCopy(null); |
1315 |
h = aWorkingCopy.getType("X").newTypeHierarchy(null); |
1316 |
h.addTypeHierarchyChangedListener(this); |
1317 |
|
1318 |
anotherWorkingCopy = getCompilationUnit("/P/p/X.java").getWorkingCopy(null); |
1319 |
anotherWorkingCopy.getBuffer().setContents( |
1320 |
"package p;\n" + |
1321 |
"public class X extends Throwable {\n" + |
1322 |
"}" |
1323 |
); |
1324 |
anotherWorkingCopy.commitWorkingCopy(false/*don't force*/, null/*no progress*/); |
1325 |
assertTrue("Should receive NO change", !this.changeReceived); |
1326 |
} finally { |
1327 |
if (h != null) |
1328 |
h.removeTypeHierarchyChangedListener(this); |
1329 |
if (aWorkingCopy != null) |
1330 |
aWorkingCopy.discardWorkingCopy(); |
1331 |
if (anotherWorkingCopy != null) |
1332 |
anotherWorkingCopy.discardWorkingCopy(); |
1333 |
deleteProject("P"); |
1334 |
} |
1335 |
} |
1247 |
/** |
1336 |
/** |
1248 |
* Make a note of the change |
1337 |
* Make a note of the change |
1249 |
*/ |
1338 |
*/ |