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

Collapse All | Expand All

(-)model/org/eclipse/jdt/internal/core/ChangeClasspathOperation.java (+4 lines)
Lines 40-45 Link Here
40
	 * - create resolved classpath markers
40
	 * - create resolved classpath markers
41
	 */
41
	 */
42
	protected void classpathChanged(JavaProject project) throws JavaModelException {
42
	protected void classpathChanged(JavaProject project) throws JavaModelException {
43
		// reset the project's caches early since some clients rely on the project's caches being up-to-date when run inside an IWorkspaceRunnable
44
		// (see https://bugs.eclipse.org/bugs/show_bug.cgi?id=212769#c5 )
45
		project.resetCaches();
46
		
43
		DeltaProcessingState state = JavaModelManager.getJavaModelManager().deltaState;
47
		DeltaProcessingState state = JavaModelManager.getJavaModelManager().deltaState;
44
		DeltaProcessor deltaProcessor = state.getDeltaProcessor();
48
		DeltaProcessor deltaProcessor = state.getDeltaProcessor();
45
		ClasspathChange change = (ClasspathChange) deltaProcessor.classpathChanges.get(project.getProject());
49
		ClasspathChange change = (ClasspathChange) deltaProcessor.classpathChanges.get(project.getProject());
(-)src/org/eclipse/jdt/core/tests/model/ExternalJarDeltaTests.java (+36 lines)
Lines 293-298 Link Here
293
		this.stopDeltas();
293
		this.stopDeltas();
294
	}
294
	}
295
}
295
}
296
/*
297
 * Ensures that the correct delta is reported after a setRawClasspath and after a modification of an external jar.
298
 * (regression test for https://bugs.eclipse.org/bugs/show_bug.cgi?id=212769 )
299
 */
300
public void testExternalJarChanged7() throws CoreException, IOException {
301
	File f = null;
302
	try {
303
		IJavaProject project = this.createJavaProject("P", new String[] {""}, "");
304
		
305
		String pPath = getExternalPath() + "p.jar";
306
		setClasspath(project, new IClasspathEntry[]{JavaCore.newLibraryEntry(new Path(pPath), null, null)});
307
		
308
		f = new File(pPath);
309
		f.createNewFile();
310
		getJavaModel().refreshExternalArchives(null,null);
311
		waitUntilIndexesReady();
312
		startDeltas();
313
		
314
		touch(f);
315
		setClasspath(project, new IClasspathEntry[]{JavaCore.newLibraryEntry(new Path(pPath), null, null), JavaCore.newSourceEntry(new Path("/P"))});
316
		
317
		assertDeltas(
318
			"Unexpected delta", 
319
			"P[*]: {CHILDREN | CONTENT | CLASSPATH CHANGED}\n" + 
320
			"	<project root>[*]: {ADDED TO CLASSPATH}\n" + 
321
			"	"+f.getCanonicalPath()+"[*]: {CONTENT | ARCHIVE CONTENT CHANGED}\n" + 
322
			"	ResourceDelta(/P/.classpath)[*]"
323
		);
324
	} finally {
325
		if(f != null) {
326
			deleteFile(f);
327
		}
328
		this.deleteProject("P");
329
		this.stopDeltas();
330
	}
331
}
296
/**
332
/**
297
 * Refresh the JavaModel after an addition of an external jar.
333
 * Refresh the JavaModel after an addition of an external jar.
298
 */
334
 */
(-)src/org/eclipse/jdt/core/tests/model/JavaProjectTests.java (+27 lines)
Lines 391-396 Link Here
391
	assertEquals("Unexpected number of roots for non existing entry", 0, roots.length);
391
	assertEquals("Unexpected number of roots for non existing entry", 0, roots.length);
392
392
393
}
393
}
394
/*
395
 * Ensures that a type can be found if run after setting the classpath in a runnable
396
 * (regression test for https://bugs.eclipse.org/bugs/show_bug.cgi?id=212769 )
397
 */
398
public void testFindTypeAfterSetClasspath() throws CoreException {
399
	try {
400
		final IJavaProject project = createJavaProject("P", new String[] {"src1"}, "bin");
401
		createFolder("/P/src2/p");
402
		createFile("/P/src2/p/X.java", "package p; public class X {}");
403
		project.findType("p.X"); // populate project's cache
404
		final IType[] result = new IType[1];
405
		ResourcesPlugin.getWorkspace().run(
406
			new IWorkspaceRunnable() {
407
				public void run(IProgressMonitor monitor) throws CoreException {
408
					addClasspathEntry(project, JavaCore.newSourceEntry(new Path("/P/src2")));
409
					result[0] = project.findType("p.X");
410
				}
411
			},
412
			null);
413
		assertElementsEqual(
414
			"Unexpected type found",
415
			"X [in X.java [in p [in src2 [in P]]]]",
416
			result);
417
	} finally {
418
		deleteProject("P");
419
	}
420
}
394
/**
421
/**
395
 * Test that a folder with a dot name does not relate to a package fragment
422
 * Test that a folder with a dot name does not relate to a package fragment
396
 */
423
 */
(-)src/org/eclipse/jdt/core/tests/model/AbstractJavaModelTests.java (+7 lines)
Lines 233-238 Link Here
233
		return suite;
233
		return suite;
234
	}
234
	}
235
235
236
	protected void addClasspathEntry(IJavaProject project, IClasspathEntry entry) throws JavaModelException{
237
		IClasspathEntry[] entries = project.getRawClasspath();
238
		int length = entries.length;
239
		System.arraycopy(entries, 0, entries = new IClasspathEntry[length + 1], 0, length);
240
		entries[length] = entry;
241
		project.setRawClasspath(entries, null);
242
	}
236
	protected void addJavaNature(String projectName) throws CoreException {
243
	protected void addJavaNature(String projectName) throws CoreException {
237
		IProject project = getWorkspaceRoot().getProject(projectName);
244
		IProject project = getWorkspaceRoot().getProject(projectName);
238
		IProjectDescription description = project.getDescription();
245
		IProjectDescription description = project.getDescription();

Return to bug 212769