View | Details | Raw Unified | Return to bug 177819
Collapse All | Expand All

(-)src/org/eclipse/jdt/core/tests/model/JavaElementDeltaTests.java (+32 lines)
Lines 356-361 Link Here
356
}
356
}
357
357
358
/*
358
/*
359
 * Ensures that adding a folder and a jar file (on the classpath) in this folder 
360
 * inside an IWorkspaceRunnable reports the correct delta
361
 * (the folder and jar file being in a source folder)
362
 * (regression test for bug 177819 Jar files added to a plugin are ignored)
363
 */
364
public void testAddJarAndFolderInSource() throws CoreException {
365
	try {
366
		createJavaProject("P", new String[] {""}, new String[] {"/P/lib-1/test.jar"}, "");
367
368
		startDeltas();
369
		ResourcesPlugin.getWorkspace().run(
370
			new IWorkspaceRunnable() {
371
				public void run(IProgressMonitor monitor) throws CoreException {
372
					createFolder("/P/lib-1");
373
					createFile("/P/lib-1/test.jar", "");
374
				}
375
			},
376
			null
377
		);
378
		assertDeltas(
379
			"Unexpected delta", 
380
			"P[*]: {CHILDREN | CONTENT}\n" + 
381
			"	lib-1/test.jar[+]: {}\n" + 
382
			"	ResourceDelta(/P/lib-1)[+]"
383
		);
384
	} finally {
385
		stopDeltas();
386
		deleteProject("P");
387
	}
388
}
389
390
/*
359
 * Add the java nature to an existing project and set the classpath in an IWorkspaceRunnable.
391
 * Add the java nature to an existing project and set the classpath in an IWorkspaceRunnable.
360
 * Ensures that adding a non-java resource reports the correct delta.
392
 * Ensures that adding a non-java resource reports the correct delta.
361
 * (regression test for bug 44066 Package Explorer doesn't show new file)
393
 * (regression test for bug 44066 Package Explorer doesn't show new file)
(-)model/org/eclipse/jdt/internal/core/DeltaProcessingState.java (-3 / +7 lines)
Lines 485-500 Link Here
485
			updatedRoots = this.roots;
485
			updatedRoots = this.roots;
486
			otherUpdatedRoots = this.otherRoots;
486
			otherUpdatedRoots = this.otherRoots;
487
		}
487
		}
488
		int containerSegmentCount = containerPath.segmentCount();
489
		boolean containerIsProject = containerSegmentCount == 1;
488
		Iterator iterator = updatedRoots.entrySet().iterator();
490
		Iterator iterator = updatedRoots.entrySet().iterator();
489
		while (iterator.hasNext()) {
491
		while (iterator.hasNext()) {
490
			Map.Entry entry = (Map.Entry) iterator.next();
492
			Map.Entry entry = (Map.Entry) iterator.next();
491
			IPath path = (IPath) entry.getKey();
493
			IPath path = (IPath) entry.getKey();
492
			if (containerPath.isPrefixOf(path) && !containerPath.equals(path)) {
494
			if (containerPath.isPrefixOf(path) && !containerPath.equals(path)) {
493
				IResourceDelta rootDelta = containerDelta.findMember(path.removeFirstSegments(1));
495
				IResourceDelta rootDelta = containerDelta.findMember(path.removeFirstSegments(containerSegmentCount));
494
				if (rootDelta == null) continue;
496
				if (rootDelta == null) continue;
495
				DeltaProcessor.RootInfo rootInfo = (DeltaProcessor.RootInfo) entry.getValue();
497
				DeltaProcessor.RootInfo rootInfo = (DeltaProcessor.RootInfo) entry.getValue();
496
	
498
	
497
				if (!rootInfo.project.getPath().isPrefixOf(path)) { // only consider roots that are not included in the container
499
				if (!containerIsProject 
500
						|| !rootInfo.project.getPath().isPrefixOf(path)) { // only consider folder roots that are not included in the container
498
					deltaProcessor.updateCurrentDeltaAndIndex(rootDelta, IJavaElement.PACKAGE_FRAGMENT_ROOT, rootInfo);
501
					deltaProcessor.updateCurrentDeltaAndIndex(rootDelta, IJavaElement.PACKAGE_FRAGMENT_ROOT, rootInfo);
499
				}
502
				}
500
				
503
				
Lines 503-509 Link Here
503
					Iterator otherProjects = rootList.iterator();
506
					Iterator otherProjects = rootList.iterator();
504
					while (otherProjects.hasNext()) {
507
					while (otherProjects.hasNext()) {
505
						rootInfo = (DeltaProcessor.RootInfo)otherProjects.next();
508
						rootInfo = (DeltaProcessor.RootInfo)otherProjects.next();
506
						if (!rootInfo.project.getPath().isPrefixOf(path)) { // only consider roots that are not included in the container
509
						if (!containerIsProject 
510
								|| !rootInfo.project.getPath().isPrefixOf(path)) { // only consider folder roots that are not included in the container
507
							deltaProcessor.updateCurrentDeltaAndIndex(rootDelta, IJavaElement.PACKAGE_FRAGMENT_ROOT, rootInfo);
511
							deltaProcessor.updateCurrentDeltaAndIndex(rootDelta, IJavaElement.PACKAGE_FRAGMENT_ROOT, rootInfo);
508
						}
512
						}
509
					}
513
					}

Return to bug 177819