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

Collapse All | Expand All

(-)src/org/eclipse/jdt/core/tests/model/ReconcilerTests.java (+79 lines)
Lines 16-21 Link Here
16
16
17
import junit.framework.Test;
17
import junit.framework.Test;
18
18
19
import org.eclipse.core.resources.IResource;
19
import org.eclipse.core.resources.IWorkspaceRunnable;
20
import org.eclipse.core.resources.IWorkspaceRunnable;
20
import org.eclipse.core.runtime.CoreException;
21
import org.eclipse.core.runtime.CoreException;
21
import org.eclipse.core.runtime.ILogListener;
22
import org.eclipse.core.runtime.ILogListener;
Lines 870-875 Link Here
870
	}
871
	}
871
}
872
}
872
/**
873
/**
874
 * @bug 162621: [model][delta] Validation errors do not clear after replacing jar file
875
 * @test Ensures that changing an internal jar and refreshing takes the change into account
876
 * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=162621"
877
 */
878
public void testChangeInternalJar() throws CoreException, IOException {
879
	IJavaProject project = getJavaProject("Reconciler");
880
	String jarName = "b162621.jar";
881
	try {
882
		String[] pathAndContents = new String[] {
883
			"test/before/Foo.java",
884
			"package test.before;\n" + 
885
			"public class Foo {\n" + 
886
			"}\n"
887
		};
888
		addLibrary(project, jarName, "b162621_src.zip", pathAndContents, JavaCore.VERSION_1_4);
889
890
		// Set working copy content with no error
891
		setUpWorkingCopy("/Reconciler/src/test/Test.java",
892
			"package test;\n" + 
893
			"import test.before.Foo;\n" + 
894
			"public class Test {\n" + 
895
			"	Foo f;\n" + 
896
			"}\n"
897
		);
898
		assertProblems(
899
			"Unexpected problems", 
900
			"----------\n" + 
901
			"----------\n"
902
		);
903
904
		// Update working copy with Jar expected changes
905
		String contents = "package test;\n" + 
906
			"import test.after.Foo;\n" + 
907
			"public class Test {\n" + 
908
			"	Foo f;\n" + 
909
			"}\n";
910
		setWorkingCopyContents(contents);
911
		this.workingCopy.reconcile(ICompilationUnit.NO_AST, true, null, null);
912
		assertProblems(
913
			"Wrong expected problems", 
914
			"----------\n" + 
915
			"1. ERROR in /Reconciler/src/test/Test.java (at line 2)\n" + 
916
			"	import test.after.Foo;\n" + 
917
			"	       ^^^^^^^^^^\n" + 
918
			"The import test.after cannot be resolved\n" + 
919
			"----------\n" + 
920
			"2. ERROR in /Reconciler/src/test/Test.java (at line 4)\n" + 
921
			"	Foo f;\n" + 
922
			"	^^^\n" + 
923
			"Foo cannot be resolved to a type\n" + 
924
			"----------\n"
925
		);
926
		
927
		// change jar and refresh
928
		String projectLocation = project.getProject().getLocation().toOSString();
929
		String jarPath = projectLocation + File.separator + jarName;
930
		org.eclipse.jdt.core.tests.util.Util.createJar(new String[] {
931
			"test/after/Foo.java",
932
			"package test.after;\n" + 
933
			"public class Foo {\n" + 
934
			"}\n"
935
		}, jarPath, "1.4");
936
		project.getProject().refreshLocal(IResource.DEPTH_INFINITE, null);
937
938
		// Verify that error is gone
939
		this.problemRequestor.initialize(contents.toCharArray());
940
		this.workingCopy.reconcile(ICompilationUnit.NO_AST, true, null, null);
941
		assertProblems(
942
			"Unexpected problems", 
943
			"----------\n" + 
944
			"----------\n"
945
		);
946
	} finally {
947
		removeLibraryEntry(project, new Path(jarName));
948
		deleteFile(new File(jarName));
949
	}
950
}
951
/**
873
 * Ensures that the reconciler reconciles the new contents with the current
952
 * Ensures that the reconciler reconciles the new contents with the current
874
 * contents,updating the structure of this reconciler's compilation
953
 * contents,updating the structure of this reconciler's compilation
875
 * unit, and fires the Java element deltas for the structural changes
954
 * unit, and fires the Java element deltas for the structural changes
(-)model/org/eclipse/jdt/internal/core/DeltaProcessor.java (+3 lines)
Lines 624-629 Link Here
624
			int flags = IJavaElementDelta.F_CONTENT;
624
			int flags = IJavaElementDelta.F_CONTENT;
625
			if (element instanceof JarPackageFragmentRoot){
625
			if (element instanceof JarPackageFragmentRoot){
626
				flags |= IJavaElementDelta.F_ARCHIVE_CONTENT_CHANGED;
626
				flags |= IJavaElementDelta.F_ARCHIVE_CONTENT_CHANGED;
627
				// need also to reset project cache otherwise it will be out-of-date
628
				// see bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=162621
629
				this.projectCachesToReset.add(element.getJavaProject());
627
			}
630
			}
628
			if (isPrimary) {
631
			if (isPrimary) {
629
				flags |= IJavaElementDelta.F_PRIMARY_RESOURCE;
632
				flags |= IJavaElementDelta.F_PRIMARY_RESOURCE;

Return to bug 162621