### Eclipse Workspace Patch 1.0 #P org.eclipse.jdt.core.tests.model Index: src/org/eclipse/jdt/core/tests/model/ReconcilerStatementsRecoveryTests.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ReconcilerStatementsRecoveryTests.java,v retrieving revision 1.4 diff -u -r1.4 ReconcilerStatementsRecoveryTests.java --- src/org/eclipse/jdt/core/tests/model/ReconcilerStatementsRecoveryTests.java 29 Mar 2006 04:03:08 -0000 1.4 +++ src/org/eclipse/jdt/core/tests/model/ReconcilerStatementsRecoveryTests.java 13 Mar 2007 16:19:27 -0000 @@ -46,7 +46,7 @@ boolean isCanceling = false; public void acceptProblem(IProblem problem) { - if (isCanceling) this.progressMonitor.setCanceled(true); // auto-cancel on first problem + if (this.isCanceling) this.progressMonitor.setCanceled(true); // auto-cancel on first problem super.acceptProblem(problem); } } @@ -121,7 +121,7 @@ public void setUp() throws Exception { super.setUp(); this.problemRequestor = new ProblemRequestor(); - this.workingCopy = getCompilationUnit("Reconciler/src/p1/X.java").getWorkingCopy(new WorkingCopyOwner() {}, this.problemRequestor, null); + this.workingCopy = getCompilationUnit("Reconciler/src/p1/X.java").getWorkingCopy(newWorkingCopyOwner(this.problemRequestor), null); this.problemRequestor.initialize(this.workingCopy.getSource().toCharArray()); startDeltas(); } Index: src/org/eclipse/jdt/core/tests/model/InclusionPatternsTests.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/InclusionPatternsTests.java,v retrieving revision 1.17 diff -u -r1.17 InclusionPatternsTests.java --- src/org/eclipse/jdt/core/tests/model/InclusionPatternsTests.java 27 Jun 2006 09:53:21 -0000 1.17 +++ src/org/eclipse/jdt/core/tests/model/InclusionPatternsTests.java 13 Mar 2007 16:19:25 -0000 @@ -386,9 +386,10 @@ " class A", root); } -/* +/** * Ensure that a type can be resolved if it is included but not its super packages. * (regression test for bug 119161 classes in "deep" packages not fully recognized when using tight inclusion filters) + * @deprecated */ public void testIncludeCUOnly01() throws CoreException { setClasspath(new String[] {"/P/src", "p1/p2/*.java|q/*.java"}); @@ -409,7 +410,38 @@ "public class Y extends X {\n" + "}", null/*primary owner*/, + problemRequestor + ); + assertProblems( + "Unepected problems", + "----------\n" + + "----------\n", problemRequestor); + } finally { + if (workingCopy != null) + workingCopy.discardWorkingCopy(); + } +} +public void testIncludeCUOnly01_new() throws CoreException { + setClasspath(new String[] {"/P/src", "p1/p2/*.java|q/*.java"}); + addLibraryEntry(getJavaProject("P"), getExternalJCLPathString(), false); + createFolder("/P/src/p1/p2"); + createFile( + "/P/src/p1/p2/X.java", + "package p1.p2;\n" + + "public class X {\n" + + "}" + ); + ICompilationUnit workingCopy = null; + try { + ProblemRequestor problemRequestor = new ProblemRequestor(); + workingCopy = getWorkingCopy( + "/P/src/Y.java", + "import p1.p2.X;\n" + + "public class Y extends X {\n" + + "}", + newWorkingCopyOwner(problemRequestor) + ); assertProblems( "Unepected problems", "----------\n" + @@ -420,9 +452,10 @@ workingCopy.discardWorkingCopy(); } } -/* +/** * Ensure that a type can be resolved if it is included but not its super packages. * (regression test for bug 119161 classes in "deep" packages not fully recognized when using tight inclusion filters) + * @deprecated */ public void testIncludeCUOnly02() throws CoreException { setClasspath(new String[] {"/P/src", "p1/p2/p3/*.java|q/*.java"}); @@ -443,7 +476,38 @@ "public class Y extends X {\n" + "}", null/*primary owner*/, + problemRequestor + ); + assertProblems( + "Unepected problems", + "----------\n" + + "----------\n", problemRequestor); + } finally { + if (workingCopy != null) + workingCopy.discardWorkingCopy(); + } +} +public void testIncludeCUOnly02_new() throws CoreException { + setClasspath(new String[] {"/P/src", "p1/p2/p3/*.java|q/*.java"}); + addLibraryEntry(getJavaProject("P"), getExternalJCLPathString(), false); + createFolder("/P/src/p1/p2/p3"); + createFile( + "/P/src/p1/p2/p3/X.java", + "package p1.p2.p3;\n" + + "public class X {\n" + + "}" + ); + ICompilationUnit workingCopy = null; + try { + ProblemRequestor problemRequestor = new ProblemRequestor(); + workingCopy = getWorkingCopy( + "/P/src/Y.java", + "import p1.p2.p3.X;\n" + + "public class Y extends X {\n" + + "}", + newWorkingCopyOwner(problemRequestor) + ); assertProblems( "Unepected problems", "----------\n" + @@ -466,10 +530,10 @@ "public class A {\n" + "}" ); - assertTrue("Resource should not be on classpath", !project.isOnClasspath(file)); + assertTrue("Resource should not be on classpath", !this.project.isOnClasspath(file)); ICompilationUnit cu = getCompilationUnit("/P/src/p/A.java"); - assertTrue("CU should not be on classpath", !project.isOnClasspath(cu)); + assertTrue("CU should not be on classpath", !this.project.isOnClasspath(cu)); } /* * Ensures that a cu that is included is on the classpath of the project. @@ -483,10 +547,10 @@ "public class A {\n" + "}" ); - assertTrue("Resource should be on classpath", project.isOnClasspath(file)); + assertTrue("Resource should be on classpath", this.project.isOnClasspath(file)); ICompilationUnit cu = getCompilationUnit("/P/src/p/A.java"); - assertTrue("CU should be on classpath", project.isOnClasspath(cu)); + assertTrue("CU should be on classpath", this.project.isOnClasspath(cu)); } /* * Ensures that a non-java resource that is not included is not on the classpath of the project. @@ -495,7 +559,7 @@ setClasspath(new String[] {"/P/src", "**/X.java"}); createFolder("/P/src/p"); IFile file = createFile("/P/src/p/readme.txt", ""); - assertTrue("Resource should not be on classpath", !project.isOnClasspath(file)); + assertTrue("Resource should not be on classpath", !this.project.isOnClasspath(file)); } /* * Ensures that a non-java resource that is included is on the classpath of the project. @@ -504,7 +568,7 @@ setClasspath(new String[] {"/P/src", "p/**"}); createFolder("/P/src/p"); IFile file = createFile("/P/src/p/readme.txt", ""); - assertTrue("Resource should be on classpath", project.isOnClasspath(file)); + assertTrue("Resource should be on classpath", this.project.isOnClasspath(file)); } /* * Ensures that moving a folder that contains an included package reports the correct delta. Index: src/org/eclipse/jdt/core/tests/model/TypeHierarchyNotificationTests.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/TypeHierarchyNotificationTests.java,v retrieving revision 1.27 diff -u -r1.27 TypeHierarchyNotificationTests.java --- src/org/eclipse/jdt/core/tests/model/TypeHierarchyNotificationTests.java 6 Mar 2007 04:43:19 -0000 1.27 +++ src/org/eclipse/jdt/core/tests/model/TypeHierarchyNotificationTests.java 13 Mar 2007 16:19:31 -0000 @@ -122,7 +122,7 @@ ICompilationUnit copy = null; try { copy = getCompilationUnit("TypeHierarchyNotification", "src", "p3", "A.java"); - copy.becomeWorkingCopy(null, null); + copy.becomeWorkingCopy(null); IRegion region = JavaCore.newRegion(); region.add(copy.getParent()); @@ -599,7 +599,7 @@ "}" ); workingCopy = getCompilationUnit("/P1/p/X.java"); - workingCopy.becomeWorkingCopy(null/*no pb requestor*/, null/*no progress*/); + workingCopy.becomeWorkingCopy(null/*no progress*/); h = workingCopy.getType("X").newTypeHierarchy(null); h.addTypeHierarchyChangedListener(this); @@ -713,7 +713,7 @@ ICompilationUnit copy = null; try { copy = getCompilationUnit("TypeHierarchyNotification", "src", "p2", "A.java"); - copy.becomeWorkingCopy(null, null); + copy.becomeWorkingCopy(null); IRegion region = JavaCore.newRegion(); region.add(copy.getParent()); @@ -754,7 +754,7 @@ ICompilationUnit copy = getCompilationUnit("TypeHierarchyNotification", "src", "p2", "B.java"); ITypeHierarchy h = null; try { - copy.becomeWorkingCopy(null, null); + copy.becomeWorkingCopy(null); h = getCompilationUnit("TypeHierarchyNotification", "src", "p2", "A.java").getType("A").newTypeHierarchy(javaProject, null); h.addTypeHierarchyChangedListener(this); Index: src/org/eclipse/jdt/core/tests/model/TypeHierarchyTests.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/TypeHierarchyTests.java,v retrieving revision 1.69 diff -u -r1.69 TypeHierarchyTests.java --- src/org/eclipse/jdt/core/tests/model/TypeHierarchyTests.java 6 Mar 2007 04:43:20 -0000 1.69 +++ src/org/eclipse/jdt/core/tests/model/TypeHierarchyTests.java 13 Mar 2007 16:19:32 -0000 @@ -643,7 +643,7 @@ ICompilationUnit workingCopy = null; try { workingCopy = getCompilationUnit("/TypeHierarchy/src/q4/Y.java"); - workingCopy.becomeWorkingCopy(null, null); + workingCopy.becomeWorkingCopy(null); workingCopy.getBuffer().setContents(""); workingCopy.makeConsistent(null); Index: src/org/eclipse/jdt/core/tests/model/ResolveTests.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ResolveTests.java,v retrieving revision 1.71 diff -u -r1.71 ResolveTests.java --- src/org/eclipse/jdt/core/tests/model/ResolveTests.java 7 Dec 2006 14:49:46 -0000 1.71 +++ src/org/eclipse/jdt/core/tests/model/ResolveTests.java 13 Mar 2007 16:19:29 -0000 @@ -19,7 +19,6 @@ public class ResolveTests extends AbstractJavaModelTests { ICompilationUnit wc = null; - WorkingCopyOwner owner = null; static { // TESTS_NAMES = new String[] { "testSecondaryTypes" }; @@ -32,14 +31,14 @@ super(name); } public ICompilationUnit getWorkingCopy(String path, String source) throws JavaModelException { - return super.getWorkingCopy(path, source, this.owner, null); + return super.getWorkingCopy(path, source, this.wcOwner); } private IJavaElement[] select(String path, String source, String selection) throws JavaModelException { this.wc = getWorkingCopy(path, source); - String str = wc.getSource(); + String str = this.wc.getSource(); int start = str.lastIndexOf(selection); int length = selection.length(); - return wc.codeSelect(start, length, this.owner); + return this.wc.codeSelect(start, length, this.wcOwner); } public void setUpSuite() throws Exception { super.setUpSuite(); @@ -48,8 +47,7 @@ } protected void setUp() throws Exception { super.setUp(); - - this.owner = new WorkingCopyOwner(){}; + this.wcOwner = new WorkingCopyOwner(){}; } public void tearDownSuite() throws Exception { @@ -92,7 +90,8 @@ "class Test1 {\n" + "}\n" + "class Test2 {\n" + - "}"); + "}" + ); String str = this.workingCopies[0].getSource(); int start = str.lastIndexOf("foo(o)"); Index: src/org/eclipse/jdt/core/tests/model/AttachedJavadocTests.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/AttachedJavadocTests.java,v retrieving revision 1.28 diff -u -r1.28 AttachedJavadocTests.java --- src/org/eclipse/jdt/core/tests/model/AttachedJavadocTests.java 6 Mar 2007 04:43:19 -0000 1.28 +++ src/org/eclipse/jdt/core/tests/model/AttachedJavadocTests.java 13 Mar 2007 16:19:23 -0000 @@ -33,7 +33,6 @@ import org.eclipse.jdt.core.IType; import org.eclipse.jdt.core.JavaCore; import org.eclipse.jdt.core.JavaModelException; -import org.eclipse.jdt.core.WorkingCopyOwner; public class AttachedJavadocTests extends ModifyingResourceTests { static { @@ -85,7 +84,7 @@ entries[i] = JavaCore.newLibraryEntry(entry.getPath(), entry.getSourceAttachmentPath(), entry.getSourceAttachmentRootPath(), entry.getAccessRules(), new IClasspathAttribute[] { attribute}, entry.isExported()); } } - project.setRawClasspath(entries, null); + this.project.setRawClasspath(entries, null); IPackageFragmentRoot[] roots = this.project.getAllPackageFragmentRoots(); int count = 0; @@ -95,14 +94,14 @@ case IPackageFragmentRoot.K_BINARY : if (!packageFragmentRoot.isExternal()) { count++; - if (root == null) { - root = packageFragmentRoot; + if (this.root == null) { + this.root = packageFragmentRoot; } } } } assertEquals("Wrong value", 1, count); //$NON-NLS-1$ - assertNotNull("Should not be null", root); //$NON-NLS-1$ + assertNotNull("Should not be null", this.root); //$NON-NLS-1$ } /** @@ -469,8 +468,7 @@ "/AttachedJavadocProject/src/Test.java", "import p2.Y;\n" + "public class Test extends Y { }", - new WorkingCopyOwner() {}, - problemRequestor + newWorkingCopyOwner(problemRequestor) ); assertProblems( "Unexpected problems", Index: src/org/eclipse/jdt/core/tests/model/CreateImportsTests.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CreateImportsTests.java,v retrieving revision 1.1 diff -u -r1.1 CreateImportsTests.java --- src/org/eclipse/jdt/core/tests/model/CreateImportsTests.java 20 Jun 2006 11:33:01 -0000 1.1 +++ src/org/eclipse/jdt/core/tests/model/CreateImportsTests.java 13 Mar 2007 16:19:24 -0000 @@ -37,7 +37,7 @@ protected void setUp() throws Exception { super.setUp(); ICompilationUnit workingCopy = getCompilationUnit("P/X.java"); - workingCopy.becomeWorkingCopy(null/*no problem requested*/, null/*no progress*/); + workingCopy.becomeWorkingCopy(null/*no progress*/); this.workingCopies = new ICompilationUnit[] {workingCopy}; setContents( "public class X {\n" + Index: src/org/eclipse/jdt/core/tests/model/SortCompilationUnitElementsTests.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/SortCompilationUnitElementsTests.java,v retrieving revision 1.39 diff -u -r1.39 SortCompilationUnitElementsTests.java --- src/org/eclipse/jdt/core/tests/model/SortCompilationUnitElementsTests.java 31 Jan 2007 20:18:08 -0000 1.39 +++ src/org/eclipse/jdt/core/tests/model/SortCompilationUnitElementsTests.java 13 Mar 2007 16:19:31 -0000 @@ -2005,7 +2005,7 @@ " A, B, C, Z;\n" + "}"; unit = this.getCompilationUnit("/P/src/X.java"); - unit.becomeWorkingCopy(null, null); + unit.becomeWorkingCopy(null); String source = unit.getSource(); Document document = new Document(source); CompilerOptions options = new CompilerOptions(unit.getJavaProject().getOptions(true)); @@ -2058,7 +2058,7 @@ "}" ); unit = this.getCompilationUnit("/P/src/X.java"); - unit.becomeWorkingCopy(null, null); + unit.becomeWorkingCopy(null); CompilerOptions options = new CompilerOptions(unit.getJavaProject().getOptions(true)); ASTParser parser = ASTParser.newParser(AST.JLS3); parser.setCompilerOptions(options.getMap()); Index: src/org/eclipse/jdt/core/tests/model/WorkingCopyOwnerTests.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/WorkingCopyOwnerTests.java,v retrieving revision 1.59 diff -u -r1.59 WorkingCopyOwnerTests.java --- src/org/eclipse/jdt/core/tests/model/WorkingCopyOwnerTests.java 28 Jun 2006 16:12:16 -0000 1.59 +++ src/org/eclipse/jdt/core/tests/model/WorkingCopyOwnerTests.java 13 Mar 2007 16:19:33 -0000 @@ -41,14 +41,12 @@ public static Test suite() { return buildModelTestSuite(WorkingCopyOwnerTests.class); } + // Use this static initializer to specify subset for tests // All specified tests which do not belong to the class are skipped... static { - // Names of tests to run: can be "testBugXXXX" or "BugXXXX") // TESTS_NAMES = new String[] { "testNewWorkingCopy03" }; - // Numbers of tests to run: "test" will be run for each number of this array // TESTS_NUMBERS = new int[] { 2, 12 }; - // Range numbers of tests to run: all tests between "test" and "test" will be run for { first, last } // TESTS_RANGE = new int[] { 16, -1 }; } @@ -110,7 +108,7 @@ this.workingCopy = getCompilationUnit("P/X.java"); assertTrue("should not be in working copy mode", !this.workingCopy.isWorkingCopy()); - this.workingCopy.becomeWorkingCopy(null, null); + this.workingCopy.becomeWorkingCopy(null); assertTrue("should be in working copy mode", this.workingCopy.isWorkingCopy()); } @@ -118,10 +116,10 @@ * Tests that a working copy remains a working copy when becomeWorkingCopy() is called. */ public void testBecomeWorkingCopy2() throws CoreException { - this.workingCopy = getCompilationUnit("P/X.java").getWorkingCopy(new TestWorkingCopyOwner(), null, null); + this.workingCopy = getCompilationUnit("P/X.java").getWorkingCopy(new TestWorkingCopyOwner(), null); assertTrue("should be in working copy mode", this.workingCopy.isWorkingCopy()); - this.workingCopy.becomeWorkingCopy(null, null); + this.workingCopy.becomeWorkingCopy(null); assertTrue("should still be in working copy mode", this.workingCopy.isWorkingCopy()); } @@ -132,7 +130,7 @@ public void testBecomeWorkingCopy3() throws CoreException { this.workingCopy = getCompilationUnit("P/Y.java"); - this.workingCopy.becomeWorkingCopy(null, null); + this.workingCopy.becomeWorkingCopy(null); assertSortedElementsEqual( "Unexpected children of default package", "X.java [in [in [in P]]]\n" + @@ -148,14 +146,14 @@ // count the number of time isCanceled() is called when converting this source unit CancelCounter counter = new CancelCounter(); - this.workingCopy.becomeWorkingCopy(null, counter); + this.workingCopy.becomeWorkingCopy(counter); this.workingCopy.discardWorkingCopy(); // throw an OperatonCanceledException at each point isCanceled() is called for (int i = 0; i < counter.count; i++) { boolean gotException = false; try { - this.workingCopy.becomeWorkingCopy(null, new Canceler(i)); + this.workingCopy.becomeWorkingCopy(new Canceler(i)); } catch (OperationCanceledException e) { gotException = true; } @@ -164,7 +162,7 @@ } // last should not throw an OperationCanceledException - this.workingCopy.becomeWorkingCopy(null, new Canceler(counter.count)); + this.workingCopy.becomeWorkingCopy(new Canceler(counter.count)); } /* @@ -178,7 +176,7 @@ "}" ); this.workingCopy = getCompilationUnit("P/Y.java"); - this.workingCopy.becomeWorkingCopy(null, null); + this.workingCopy.becomeWorkingCopy(null); String newContents = "public class Y {\n" + " void foo() {\n" + @@ -207,7 +205,7 @@ "}" ); this.workingCopy = getCompilationUnit("P/Y.java"); - this.workingCopy.becomeWorkingCopy(null, null); + this.workingCopy.becomeWorkingCopy(null); this.workingCopy.getBuffer().setContents( "public class Y {\n" + " void foo() {\n" + @@ -242,7 +240,7 @@ "}" ); this.workingCopy = getCompilationUnit("P/Y.java"); - this.workingCopy.becomeWorkingCopy(null, null); + this.workingCopy.becomeWorkingCopy(null); this.workingCopy.getBuffer().setContents( "public class Y {\n" + " void foo() {\n" + @@ -306,7 +304,7 @@ ); this.workingCopy = getCompilationUnit("P/Y.java"); startDeltas(); - this.workingCopy.becomeWorkingCopy(null, null); + this.workingCopy.becomeWorkingCopy(null); assertDeltas( "Unexpected delta", "P[*]: {CHILDREN}\n" + @@ -330,7 +328,7 @@ try { this.workingCopy = getCompilationUnit("P/Y.java"); startDeltas(); - this.workingCopy.becomeWorkingCopy(null, null); + this.workingCopy.becomeWorkingCopy(null); assertDeltas( "Unexpected delta", "P[*]: {CHILDREN}\n" + @@ -384,7 +382,7 @@ "}" ); this.workingCopy = getCompilationUnit("P/Y.java"); - this.workingCopy.becomeWorkingCopy(null, null); + this.workingCopy.becomeWorkingCopy(null); startDeltas(); this.workingCopy.discardWorkingCopy(); @@ -416,7 +414,7 @@ "}" ); this.workingCopy = getCompilationUnit("P/Y.java"); - this.workingCopy.becomeWorkingCopy(null, null); + this.workingCopy.becomeWorkingCopy(null); this.workingCopy.getType("Y").createField("int x;", null, false, null); startDeltas(); @@ -444,7 +442,7 @@ public void testDeltaDiscardPrimaryWorkingCopy3() throws CoreException { try { this.workingCopy = getCompilationUnit("P/Y.java"); - this.workingCopy.becomeWorkingCopy(null, null); + this.workingCopy.becomeWorkingCopy(null); startDeltas(); this.workingCopy.discardWorkingCopy(); @@ -468,7 +466,7 @@ public void testDeltaDiscardPrimaryWorkingCopy4() throws CoreException { try { this.workingCopy = getCompilationUnit("P/X.java"); - this.workingCopy.becomeWorkingCopy(null, null); + this.workingCopy.becomeWorkingCopy(null); this.workingCopy.getBuffer().setContents("/*annotation*/public class X {}"); startDeltas(); @@ -492,7 +490,7 @@ ICompilationUnit cu = null; try { cu = getCompilationUnit("P/X.java"); - cu.becomeWorkingCopy(null, null); + cu.becomeWorkingCopy(null); assertTrue("should be in working copy mode", cu.isWorkingCopy()); cu.discardWorkingCopy(); @@ -512,9 +510,9 @@ ICompilationUnit cu = null; try { cu = getCompilationUnit("P/X.java"); - cu.becomeWorkingCopy(null, null); - cu.becomeWorkingCopy(null, null); - cu.becomeWorkingCopy(null, null); + cu.becomeWorkingCopy(null); + cu.becomeWorkingCopy(null); + cu.becomeWorkingCopy(null); assertTrue("should be in working copy mode", cu.isWorkingCopy()); cu.discardWorkingCopy(); @@ -541,9 +539,9 @@ try { ICompilationUnit cu = getCompilationUnit("P/X.java"); TestWorkingCopyOwner owner = new TestWorkingCopyOwner(); - this.workingCopy = cu.getWorkingCopy(owner, null, null); - this.workingCopy = cu.getWorkingCopy(owner, null, null); - this.workingCopy = cu.getWorkingCopy(owner, null, null); + this.workingCopy = cu.getWorkingCopy(owner, null); + this.workingCopy = cu.getWorkingCopy(owner, null); + this.workingCopy = cu.getWorkingCopy(owner, null); assertTrue("should be in working copy mode", this.workingCopy.isWorkingCopy()); assertTrue("should be opened", this.workingCopy.isOpen()); assertTrue("should exist", this.workingCopy.exists()); @@ -575,7 +573,7 @@ public void testDiscardWorkingCopy4() throws CoreException { ICompilationUnit cu = getCompilationUnit("P/X.java"); TestWorkingCopyOwner owner = new TestWorkingCopyOwner(); - this.workingCopy = cu.getWorkingCopy(owner, null, null); + this.workingCopy = cu.getWorkingCopy(owner, null); boolean gotException = false; try { @@ -604,7 +602,7 @@ ICompilationUnit cu = null; try { cu = getCompilationUnit("P/Y.java"); - cu.becomeWorkingCopy(null, null); + cu.becomeWorkingCopy(null); cu.discardWorkingCopy(); assertElementsEqual( @@ -626,7 +624,7 @@ ICompilationUnit cu = null; try { cu = getCompilationUnit("P/X.java"); - cu.becomeWorkingCopy(null, null); + cu.becomeWorkingCopy(null); assertResourceNamesEqual( "Unexpected resource", "X.java", @@ -644,7 +642,7 @@ public void testGetOwner1() throws CoreException { ICompilationUnit cu = getCompilationUnit("P/X.java"); TestWorkingCopyOwner owner = new TestWorkingCopyOwner(); - this.workingCopy = cu.getWorkingCopy(owner, null, null); + this.workingCopy = cu.getWorkingCopy(owner, null); assertEquals("Unexpected owner", owner, this.workingCopy.getOwner()); } @@ -663,7 +661,7 @@ public void testGetPrimary1() throws CoreException { ICompilationUnit cu = getCompilationUnit("P/X.java"); TestWorkingCopyOwner owner = new TestWorkingCopyOwner(); - this.workingCopy = cu.getWorkingCopy(owner, null, null); + this.workingCopy = cu.getWorkingCopy(owner, null); assertEquals("Unexpected compilation unit", cu, this.workingCopy.getPrimary()); } @@ -673,7 +671,7 @@ */ public void testGetPrimary2() throws CoreException { this.workingCopy = getCompilationUnit("P/X.java"); - this.workingCopy.becomeWorkingCopy(null, null); + this.workingCopy.becomeWorkingCopy(null); assertEquals("Unexpected compilation unit", this.workingCopy, this.workingCopy.getPrimary()); } @@ -685,7 +683,7 @@ public void testGetPrimaryElement1() throws CoreException { ICompilationUnit cu = getCompilationUnit("P/X.java"); TestWorkingCopyOwner owner = new TestWorkingCopyOwner(); - this.workingCopy = cu.getWorkingCopy(owner, null, null); + this.workingCopy = cu.getWorkingCopy(owner, null); IJavaElement element = this.workingCopy.getType("X"); assertEquals("Unexpected element", cu.getType("X"), element.getPrimaryElement()); @@ -696,7 +694,7 @@ */ public void testGetPrimaryElement2() throws CoreException { this.workingCopy = getCompilationUnit("P/X.java"); - this.workingCopy.becomeWorkingCopy(null, null); + this.workingCopy.becomeWorkingCopy(null); IJavaElement element = this.workingCopy.getType("X"); assertEquals("Unexpected element", element, element.getPrimaryElement()); @@ -736,7 +734,7 @@ // create working copy on existing cu ICompilationUnit cu1 = getCompilationUnit("P/X.java"); - workingCopy11 = cu1.getWorkingCopy(owner1, null, null); + workingCopy11 = cu1.getWorkingCopy(owner1, null); assertSortedElementsEqual( "Unexpected working copies (2)", "[Working copy] X.java [in [in [in P]]]", @@ -745,7 +743,7 @@ // create working copy on non-existing cu ICompilationUnit cu2 = getCompilationUnit("P/Y.java"); - workingCopy12 = cu2.getWorkingCopy(owner1, null, null); + workingCopy12 = cu2.getWorkingCopy(owner1, null); assertSortedElementsEqual( "Unexpected working copies (3)", "[Working copy] X.java [in [in [in P]]]\n" + @@ -755,7 +753,7 @@ // create working copy for another owner TestWorkingCopyOwner owner2 = new TestWorkingCopyOwner(); - workingCopy21 = cu1.getWorkingCopy(owner2, null, null); + workingCopy21 = cu1.getWorkingCopy(owner2, null); // owner2 should have the new working copy assertSortedElementsEqual( @@ -800,9 +798,9 @@ try { ICompilationUnit cu = getCompilationUnit("P/X.java"); TestWorkingCopyOwner owner = new TestWorkingCopyOwner(); - this.workingCopy = cu.getWorkingCopy(owner, null, null); + this.workingCopy = cu.getWorkingCopy(owner, null); - assertEquals("Unexpected working copy", this.workingCopy, cu.getWorkingCopy(owner, null, null)); + assertEquals("Unexpected working copy", this.workingCopy, cu.getWorkingCopy(owner, null)); } finally { if (this.workingCopy != null) { int max = 2; @@ -823,9 +821,9 @@ try { ICompilationUnit cu = getCompilationUnit("P/X.java"); TestWorkingCopyOwner owner1 = new TestWorkingCopyOwner(); - workingCopy1 = cu.getWorkingCopy(owner1, null, null); + workingCopy1 = cu.getWorkingCopy(owner1, null); TestWorkingCopyOwner owner2 = new TestWorkingCopyOwner(); - workingCopy2 = cu.getWorkingCopy(owner2, null, null); + workingCopy2 = cu.getWorkingCopy(owner2, null); assertTrue("working copies should be different", !workingCopy1.equals(workingCopy2)); } finally { @@ -851,7 +849,7 @@ "}" ); WorkingCopyOwner owner = new TestWorkingCopyOwner(); - this.workingCopy = getCompilationUnit("/P/Y.java").getWorkingCopy(owner, null/*no problem requestor*/, null/*no progress*/); + this.workingCopy = getCompilationUnit("/P/Y.java").getWorkingCopy(owner, null/*no progress*/); IType focus = getCompilationUnit("/P/X.java").getType("X"); ITypeHierarchy hierarchy = focus.newTypeHierarchy(owner, null/*no progress*/); IType[] subtypes = hierarchy.getSubtypes(focus); @@ -880,7 +878,7 @@ ); createFolder("/P/p2"); this.workingCopy = getCompilationUnit("P/p1/Y.java"); - this.workingCopy.becomeWorkingCopy(null, null); + this.workingCopy.becomeWorkingCopy(null); // ensure the package is open getPackage("/P/p1").open(null); @@ -1031,7 +1029,7 @@ return buffer; } }; - this.workingCopy = owner.newWorkingCopy("X.java", null/*no classpath*/, null/*no problem requestor*/, null/*no progress monitor*/); + this.workingCopy = owner.newWorkingCopy("X.java", null/*no classpath*/, null/*no progress monitor*/); this.workingCopy.commitWorkingCopy(true, null); assertFalse("Should not have unsaved changes", this.workingCopy.hasUnsavedChanges()); } @@ -1059,14 +1057,14 @@ ICompilationUnit workingCopy2 = null; try { TestWorkingCopyOwner owner = new TestWorkingCopyOwner(); - workingCopy1 = getCompilationUnit("P/X.java").getWorkingCopy(owner, null, null); + workingCopy1 = getCompilationUnit("P/X.java").getWorkingCopy(owner, null); workingCopy1.getBuffer().setContents( "public class X implements I {\n" + "}" ); workingCopy1.makeConsistent(null); - workingCopy2 = getCompilationUnit("P/I.java").getWorkingCopy(owner, null, null); + workingCopy2 = getCompilationUnit("P/I.java").getWorkingCopy(owner, null); workingCopy2.getBuffer().setContents( "public interface I {\n" + "}" @@ -1102,7 +1100,7 @@ */ public void testParseCompilationUnit2() throws CoreException { TestWorkingCopyOwner owner = new TestWorkingCopyOwner(); - this.workingCopy = getCompilationUnit("P/Y.java").getWorkingCopy(owner, null, null); + this.workingCopy = getCompilationUnit("P/Y.java").getWorkingCopy(owner, null); this.workingCopy.getBuffer().setContents( "public class Y {\n" + "}" @@ -1168,7 +1166,7 @@ // create working copy on Y.java TestWorkingCopyOwner owner = new TestWorkingCopyOwner(); - this.workingCopy = getCompilationUnit("P1/src/Y.java").getWorkingCopy(owner, null, null); + this.workingCopy = getCompilationUnit("P1/src/Y.java").getWorkingCopy(owner, null); this.workingCopy.getBuffer().setContents( "public class Y {\n" + "}" @@ -1202,7 +1200,7 @@ public void testSearch1() throws CoreException { ICompilationUnit cu = getCompilationUnit("P/Y.java"); TestWorkingCopyOwner owner = new TestWorkingCopyOwner(); - this.workingCopy = cu.getWorkingCopy(owner, null, null); + this.workingCopy = cu.getWorkingCopy(owner, null); this.workingCopy.getBuffer().setContents( "public class Y {\n" + " X field;\n" + @@ -1233,7 +1231,7 @@ public void testSearch2() throws CoreException { ICompilationUnit cu = getCompilationUnit("P/X.java"); TestWorkingCopyOwner owner = new TestWorkingCopyOwner(); - this.workingCopy = cu.getWorkingCopy(owner, null, null); + this.workingCopy = cu.getWorkingCopy(owner, null); // remove type X this.workingCopy.getBuffer().setContents(""); @@ -1264,7 +1262,7 @@ try { createFile("/P/Y.java", ""); this.workingCopy = getCompilationUnit("P/Y.java"); - this.workingCopy.becomeWorkingCopy(null, null); + this.workingCopy.becomeWorkingCopy(null); // create type Y in working copy this.workingCopy.getBuffer().setContents("public class Y {}"); @@ -1308,7 +1306,7 @@ createFolder("P/p"); createFile("/P/p/Y.java", ""); primaryWorkingCopy = getCompilationUnit("P/p/Y.java"); - primaryWorkingCopy.becomeWorkingCopy(null, null); + primaryWorkingCopy.becomeWorkingCopy(null); // create type Y in working copy primaryWorkingCopy.getBuffer().setContents( Index: src/org/eclipse/jdt/core/tests/model/CompilationUnitTests.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CompilationUnitTests.java,v retrieving revision 1.50 diff -u -r1.50 CompilationUnitTests.java --- src/org/eclipse/jdt/core/tests/model/CompilationUnitTests.java 28 Jun 2006 08:51:55 -0000 1.50 +++ src/org/eclipse/jdt/core/tests/model/CompilationUnitTests.java 13 Mar 2007 16:19:24 -0000 @@ -111,10 +111,10 @@ } private ICompilationUnit createWorkingCopy(String source) throws JavaModelException { - this.workingCopy = getCompilationUnit("/P/src/p/Y.java").getWorkingCopy(new WorkingCopyOwner(){}, null, null); + this.workingCopy = getCompilationUnit("/P/src/p/Y.java").getWorkingCopy(new WorkingCopyOwner(){}, null); this.workingCopy.getBuffer().setContents(source); this.workingCopy.makeConsistent(null); - return workingCopy; + return this.workingCopy; } /** * Create working copy and compute problems. @@ -283,7 +283,7 @@ "public interface Y {\n" + "}" ); - String[] categories = workingCopy.getType("Y").getCategories(); + String[] categories = this.workingCopy.getType("Y").getCategories(); assertStringsEqual( "Unexpected categories", "test\n", @@ -302,7 +302,7 @@ "public enum Y {\n" + "}" ); - String[] categories = workingCopy.getType("Y").getCategories(); + String[] categories = this.workingCopy.getType("Y").getCategories(); assertStringsEqual( "Unexpected categories", "test\n", @@ -321,7 +321,7 @@ "public @interface Y {\n" + "}" ); - String[] categories = workingCopy.getType("Y").getCategories(); + String[] categories = this.workingCopy.getType("Y").getCategories(); assertStringsEqual( "Unexpected categories", "test\n", @@ -341,7 +341,7 @@ " void foo() {}\n" + "}" ); - String[] categories = workingCopy.getType("Y").getMethod("foo", new String[0]).getCategories(); + String[] categories = this.workingCopy.getType("Y").getMethod("foo", new String[0]).getCategories(); assertStringsEqual( "Unexpected categories", "test\n", @@ -361,7 +361,7 @@ " public Y() {}\n" + "}" ); - String[] categories = workingCopy.getType("Y").getMethod("Y", new String[0]).getCategories(); + String[] categories = this.workingCopy.getType("Y").getMethod("Y", new String[0]).getCategories(); assertStringsEqual( "Unexpected categories", "test\n", @@ -381,7 +381,7 @@ " int field;\n" + "}" ); - String[] categories = workingCopy.getType("Y").getField("field").getCategories(); + String[] categories = this.workingCopy.getType("Y").getField("field").getCategories(); assertStringsEqual( "Unexpected categories", "test\n", @@ -401,7 +401,7 @@ " class Member {}\n" + "}" ); - String[] categories = workingCopy.getType("Y").getType("Member").getCategories(); + String[] categories = this.workingCopy.getType("Y").getType("Member").getCategories(); assertStringsEqual( "Unexpected categories", "test\n", @@ -420,7 +420,7 @@ " void foo() {}\n" + "}" ); - String[] categories = workingCopy.getType("Y").getMethod("foo", new String[0]).getCategories(); + String[] categories = this.workingCopy.getType("Y").getMethod("foo", new String[0]).getCategories(); assertStringsEqual( "Unexpected categories", "", @@ -441,7 +441,7 @@ " void foo() {}\n" + "}" ); - String[] categories = workingCopy.getType("Y").getMethod("foo", new String[0]).getCategories(); + String[] categories = this.workingCopy.getType("Y").getMethod("foo", new String[0]).getCategories(); assertStringsEqual( "Unexpected categories", "test1\n" + @@ -462,7 +462,7 @@ " void foo() {}\n" + "}" ); - String[] categories = workingCopy.getType("Y").getMethod("foo", new String[0]).getCategories(); + String[] categories = this.workingCopy.getType("Y").getMethod("foo", new String[0]).getCategories(); assertStringsEqual( "Unexpected categories", "test1\n" + @@ -564,7 +564,7 @@ " void foo3() {}\n" + "}" ); - IJavaElement[] children = workingCopy.getType("Y").getChildrenForCategory("test"); + IJavaElement[] children = this.workingCopy.getType("Y").getChildrenForCategory("test"); assertElementsEqual( "Unexpected children", "field [in Y [in [Working copy] Y.java [in p [in src [in P]]]]]\n" + @@ -594,7 +594,7 @@ " void foo2() {}\n" + "}" ); - IJavaElement[] children = workingCopy.getType("Y").getChildrenForCategory("test1"); + IJavaElement[] children = this.workingCopy.getType("Y").getChildrenForCategory("test1"); assertElementsEqual( "Unexpected children", "Member [in Y [in [Working copy] Y.java [in p [in src [in P]]]]]\n" + @@ -829,7 +829,7 @@ * compilation unit for an inner type. */ public void testGetInnerTypes() throws JavaModelException { - IType type1 = cu.getType("X"); + IType type1 = this.cu.getType("X"); assertTrue("X type should have children", type1.hasChildren()); assertTrue("X type superclass name should be null", type1.getSuperclassName() == null); String[] superinterfaceNames= type1.getSuperInterfaceNames(); @@ -1210,7 +1210,7 @@ "public class Y {\n" + "}" ); - ITypeParameter[] typeParameters = workingCopy.getType("Y").getTypeParameters(); + ITypeParameter[] typeParameters = this.workingCopy.getType("Y").getTypeParameters(); assertTypeParametersEqual( "T\n", typeParameters); @@ -1225,7 +1225,7 @@ "public class Y {\n" + "}" ); - ITypeParameter[] typeParameters = workingCopy.getType("Y").getTypeParameters(); + ITypeParameter[] typeParameters = this.workingCopy.getType("Y").getTypeParameters(); assertTypeParametersEqual( "T\n" + "U\n", @@ -1241,7 +1241,7 @@ "public class Y {\n" + "}" ); - ITypeParameter[] typeParameters = workingCopy.getType("Y").getTypeParameters(); + ITypeParameter[] typeParameters = this.workingCopy.getType("Y").getTypeParameters(); assertTypeParametersEqual( "T extends List\n", typeParameters); @@ -1256,7 +1256,7 @@ "public class Y {\n" + "}" ); - ITypeParameter[] typeParameters = workingCopy.getType("Y").getTypeParameters(); + ITypeParameter[] typeParameters = this.workingCopy.getType("Y").getTypeParameters(); assertTypeParametersEqual( "T extends List & Runnable & Comparable\n", typeParameters); @@ -1274,7 +1274,7 @@ " }\n" + "}" ); - ITypeParameter[] typeParameters = workingCopy.getType("Y").getMethod("foo", new String[]{}).getTypeParameters(); + ITypeParameter[] typeParameters = this.workingCopy.getType("Y").getMethod("foo", new String[]{}).getTypeParameters(); assertTypeParametersEqual( "T extends List\n" + "U extends X & Runnable\n", Index: src/org/eclipse/jdt/core/tests/model/ResolveTests_1_5.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ResolveTests_1_5.java,v retrieving revision 1.53 diff -u -r1.53 ResolveTests_1_5.java --- src/org/eclipse/jdt/core/tests/model/ResolveTests_1_5.java 7 Dec 2006 14:49:46 -0000 1.53 +++ src/org/eclipse/jdt/core/tests/model/ResolveTests_1_5.java 13 Mar 2007 16:19:30 -0000 @@ -19,7 +19,6 @@ public class ResolveTests_1_5 extends AbstractJavaModelTests { ICompilationUnit wc = null; - WorkingCopyOwner owner = null; static { // Names of tests to run: can be "testBugXXXX" or "BugXXXX") @@ -36,20 +35,20 @@ super(name); } public ICompilationUnit getWorkingCopy(String path, String source) throws JavaModelException { - return super.getWorkingCopy(path, source, this.owner, null); + return super.getWorkingCopy(path, source, this.wcOwner); } private IJavaElement[] select(String path, String source, String selection) throws JavaModelException { this.wc = getWorkingCopy(path, source); - String str = wc.getSource(); + String str = this.wc.getSource(); int start = str.lastIndexOf(selection); int length = selection.length(); - return wc.codeSelect(start, length, this.owner); + return this.wc.codeSelect(start, length, this.wcOwner); } private IJavaElement[] selectAfter(String path, String source, String selection) throws JavaModelException { this.wc = getWorkingCopy(path, source); - String str = wc.getSource(); + String str = this.wc.getSource(); int start = str.lastIndexOf(selection) + selection.length(); - return wc.codeSelect(start, 0, this.owner); + return this.wc.codeSelect(start, 0, this.wcOwner); } public void setUpSuite() throws Exception { super.setUpSuite(); @@ -60,8 +59,7 @@ } protected void setUp() throws Exception { super.setUp(); - - this.owner = new WorkingCopyOwner(){}; + this.wcOwner = new WorkingCopyOwner(){}; } public void tearDownSuite() throws Exception { deleteProject("Resolve"); @@ -70,7 +68,7 @@ } protected void tearDown() throws Exception { - if(this.wc != null) { + if (this.wc != null) { this.wc.discardWorkingCopy(); } super.tearDown(); @@ -132,12 +130,12 @@ " }\n" + "}"); - String str = wc.getSource(); + String str = this.wc.getSource(); String selection = "Test"; int start = str.lastIndexOf(selection); int length = selection.length(); - IJavaElement[] elements = wc.codeSelect(start, length); + IJavaElement[] elements = this.wc.codeSelect(start, length); assertElementsEqual( "Unexpected elements", "Test [in [Working copy] Test.java [in test0004 [in src2 [in Resolve]]]]", @@ -523,11 +521,11 @@ " Test.Inner x;\n" + "}"); - String str = wc.getSource(); + String str = this.wc.getSource(); String selection = "Inn"; int start = str.lastIndexOf(selection); - IJavaElement[] elements = wc.codeSelect(start, 0); + IJavaElement[] elements = this.wc.codeSelect(start, 0); assertElementsEqual( "Unexpected elements", "Inner [in Test [in [Working copy] Test.java [in test0027 [in src2 [in Resolve]]]]]", @@ -544,11 +542,11 @@ " Test.Inner x;\n" + "}"); - String str = wc.getSource(); + String str = this.wc.getSource(); String selection = "Inn"; int start = str.lastIndexOf(selection); - IJavaElement[] elements = wc.codeSelect(start, 0); + IJavaElement[] elements = this.wc.codeSelect(start, 0); assertElementsEqual( "Unexpected elements", "Inner [in Test [in [Working copy] Test.java [in test0028 [in src2 [in Resolve]]]]]", @@ -565,11 +563,11 @@ " Test.Inner x;\n" + "}"); - String str = wc.getSource(); + String str = this.wc.getSource(); String selection = "Inn"; int start = str.lastIndexOf(selection); - IJavaElement[] elements = wc.codeSelect(start, 0); + IJavaElement[] elements = this.wc.codeSelect(start, 0); assertElementsEqual( "Unexpected elements", "Inner [in Test [in [Working copy] Test.java [in test0029 [in src2 [in Resolve]]]]]", @@ -586,12 +584,12 @@ " Test.Inner x;\n" + "}"); - String str = wc.getSource(); + String str = this.wc.getSource(); String selection = "Inner"; int start = str.lastIndexOf(selection); int length = selection.length(); - IJavaElement[] elements = wc.codeSelect(start, length); + IJavaElement[] elements = this.wc.codeSelect(start, length); assertElementsEqual( "Unexpected elements", "Inner [in Test [in [Working copy] Test.java [in test0030 [in src2 [in Resolve]]]]]", @@ -608,12 +606,12 @@ " Test.Inner x;\n" + "}"); - String str = wc.getSource(); + String str = this.wc.getSource(); String selection = "Inner"; int start = str.lastIndexOf(selection); int length = selection.length(); - IJavaElement[] elements = wc.codeSelect(start, length); + IJavaElement[] elements = this.wc.codeSelect(start, length); assertElementsEqual( "Unexpected elements", "Inner [in Test [in [Working copy] Test.java [in test0031 [in src2 [in Resolve]]]]]", @@ -630,12 +628,12 @@ " Test.Inner x;\n" + "}"); - String str = wc.getSource(); + String str = this.wc.getSource(); String selection = "Inner"; int start = str.lastIndexOf(selection); int length = selection.length(); - IJavaElement[] elements = wc.codeSelect(start, length); + IJavaElement[] elements = this.wc.codeSelect(start, length); assertElementsEqual( "Unexpected elements", "Inner [in Test [in [Working copy] Test.java [in test0032 [in src2 [in Resolve]]]]]", @@ -652,12 +650,12 @@ " Test.Inner x;\n" + "}"); - String str = wc.getSource(); + String str = this.wc.getSource(); String selection = "Inner"; int start = str.lastIndexOf(selection); int length = selection.length(); - IJavaElement[] elements = wc.codeSelect(start, length); + IJavaElement[] elements = this.wc.codeSelect(start, length); assertElementsEqual( "Unexpected elements", "Inner [in Test [in [Working copy] Test.java [in test0033 [in src2 [in Resolve]]]]]", @@ -674,12 +672,12 @@ " Test.Inner x;\n" + "}"); - String str = wc.getSource(); + String str = this.wc.getSource(); String selection = "Test.Inner"; int start = str.lastIndexOf(selection); int length = selection.length(); - IJavaElement[] elements = wc.codeSelect(start, length); + IJavaElement[] elements = this.wc.codeSelect(start, length); assertElementsEqual( "Unexpected elements", "Inner [in Test [in [Working copy] Test.java [in test0034 [in src2 [in Resolve]]]]]", @@ -696,12 +694,12 @@ " Test.Inner x;\n" + "}"); - String str = wc.getSource(); + String str = this.wc.getSource(); String selection = "Test.Inner"; int start = str.lastIndexOf(selection); int length = selection.length(); - IJavaElement[] elements = wc.codeSelect(start, length); + IJavaElement[] elements = this.wc.codeSelect(start, length); assertElementsEqual( "Unexpected elements", "Inner [in Test [in [Working copy] Test.java [in test0035 [in src2 [in Resolve]]]]]", @@ -718,12 +716,12 @@ " Test.Inner x;\n" + "}"); - String str = wc.getSource(); + String str = this.wc.getSource(); String selection = "Test.Inner"; int start = str.lastIndexOf(selection); int length = selection.length(); - IJavaElement[] elements = wc.codeSelect(start, length); + IJavaElement[] elements = this.wc.codeSelect(start, length); assertElementsEqual( "Unexpected elements", "Inner [in Test [in [Working copy] Test.java [in test0036 [in src2 [in Resolve]]]]]", @@ -740,12 +738,12 @@ " Test.Inner x;\n" + "}"); - String str = wc.getSource(); + String str = this.wc.getSource(); String selection = "Test.Inner"; int start = str.lastIndexOf(selection); int length = selection.length(); - IJavaElement[] elements = wc.codeSelect(start, length); + IJavaElement[] elements = this.wc.codeSelect(start, length); assertElementsEqual( "Unexpected elements", "Inner [in Test [in [Working copy] Test.java [in test0037 [in src2 [in Resolve]]]]]", @@ -762,12 +760,12 @@ " Test.Inner x;\n" + "}"); - String str = wc.getSource(); + String str = this.wc.getSource(); String selection = "Test.Inner"; int start = str.lastIndexOf(selection); int length = selection.length(); - IJavaElement[] elements = wc.codeSelect(start, length); + IJavaElement[] elements = this.wc.codeSelect(start, length); assertElementsEqual( "Unexpected elements", "Inner [in Test [in [Working copy] Test.java [in test0038 [in src2 [in Resolve]]]]]", @@ -784,12 +782,12 @@ " Test.Inner x;\n" + "}"); - String str = wc.getSource(); + String str = this.wc.getSource(); String selection = "Test.Inner"; int start = str.lastIndexOf(selection); int length = selection.length(); - IJavaElement[] elements = wc.codeSelect(start, length); + IJavaElement[] elements = this.wc.codeSelect(start, length); assertElementsEqual( "Unexpected elements", "Inner [in Test [in [Working copy] Test.java [in test0039 [in src2 [in Resolve]]]]]", @@ -806,12 +804,12 @@ " Test.Inner x;\n" + "}"); - String str = wc.getSource(); + String str = this.wc.getSource(); String selection = "Inner"; int start = str.lastIndexOf(selection); int length = selection.length(); - IJavaElement[] elements = wc.codeSelect(start, length); + IJavaElement[] elements = this.wc.codeSelect(start, length); assertElementsEqual( "Unexpected elements", "Inner [in Test [in [Working copy] Test.java [in test0040 [in src2 [in Resolve]]]]]", @@ -834,12 +832,12 @@ " }\n" + "}"); - String str = wc.getSource(); + String str = this.wc.getSource(); String selection = "Local1>.Local2>"; int start = str.lastIndexOf(selection); int length = selection.length(); - IJavaElement[] elements = wc.codeSelect(start, length); + IJavaElement[] elements = this.wc.codeSelect(start, length); assertElementsEqual( "Unexpected elements", "Local2 [in Local1 [in foo() [in Test [in [Working copy] Test.java [in test0041 [in src2 [in Resolve]]]]]]]", @@ -856,12 +854,12 @@ " Test.Inner v;\n" + "}"); - String str = wc.getSource(); + String str = this.wc.getSource(); String selection = "Test.Inner"; int start = str.lastIndexOf(selection); int length = selection.length(); - IJavaElement[] elements = wc.codeSelect(start, length); + IJavaElement[] elements = this.wc.codeSelect(start, length); assertElementsEqual( "Unexpected elements", "Inner [in Test [in [Working copy] Test.java [in test0042 [in src2 [in Resolve]]]]]", @@ -876,12 +874,12 @@ " Test var;\n" + "}"); - String str = wc.getSource(); + String str = this.wc.getSource(); String selection = "Test"; int start = str.lastIndexOf(selection); int length = selection.length(); - IJavaElement[] elements = wc.codeSelect(start, length); + IJavaElement[] elements = this.wc.codeSelect(start, length); assertElementsEqual( "Unexpected elements", "Test [in [Working copy] Test.java [in test0043 [in src2 [in Resolve]]]]", @@ -898,12 +896,12 @@ " Test var;\n" + "}"); - String str = wc.getSource(); + String str = this.wc.getSource(); String selection = "Test"; int start = str.lastIndexOf(selection); int length = selection.length(); - IJavaElement[] elements = wc.codeSelect(start, length); + IJavaElement[] elements = this.wc.codeSelect(start, length); assertElementsEqual( "Unexpected elements", "Test [in [Working copy] Test.java [in test0044 [in src2 [in Resolve]]]]", @@ -918,12 +916,12 @@ " String var;\n" + "}"); - String str = wc.getSource(); + String str = this.wc.getSource(); String selection = "var"; int start = str.lastIndexOf(selection); int length = selection.length(); - IJavaElement[] elements = wc.codeSelect(start, length); + IJavaElement[] elements = this.wc.codeSelect(start, length); assertElementsEqual( "Unexpected elements", "var [in Test [in [Working copy] Test.java [in test0045 [in src2 [in Resolve]]]]]", @@ -941,12 +939,12 @@ " }\n" + "}"); - String str = wc.getSource(); + String str = this.wc.getSource(); String selection = "var"; int start = str.lastIndexOf(selection); int length = selection.length(); - IJavaElement[] elements = wc.codeSelect(start, length); + IJavaElement[] elements = this.wc.codeSelect(start, length); assertElementsEqual( "Unexpected elements", "var [in Test [in [Working copy] Test.java [in test0046 [in src2 [in Resolve]]]]]", @@ -965,12 +963,12 @@ " }\n" + "}"); - String str = wc.getSource(); + String str = this.wc.getSource(); String selection = "var"; int start = str.lastIndexOf(selection); int length = selection.length(); - IJavaElement[] elements = wc.codeSelect(start, length); + IJavaElement[] elements = this.wc.codeSelect(start, length); assertElementsEqual( "Unexpected elements", "var [in Test [in [Working copy] Test.java [in test0047 [in src2 [in Resolve]]]]]", @@ -989,12 +987,12 @@ " }\n" + "}"); - String str = wc.getSource(); + String str = this.wc.getSource(); String selection = "var"; int start = str.lastIndexOf(selection); int length = selection.length(); - IJavaElement[] elements = wc.codeSelect(start, length); + IJavaElement[] elements = this.wc.codeSelect(start, length); assertElementsEqual( "Unexpected elements", "var [in Test [in [Working copy] Test.java [in test0048 [in src2 [in Resolve]]]]]", @@ -1013,12 +1011,12 @@ " }\n" + "}"); - String str = wc.getSource(); + String str = this.wc.getSource(); String selection = "var"; int start = str.lastIndexOf(selection); int length = selection.length(); - IJavaElement[] elements = wc.codeSelect(start, length); + IJavaElement[] elements = this.wc.codeSelect(start, length); assertElementsEqual( "Unexpected elements", "var [in Test [in [Working copy] Test.java [in test0049 [in src2 [in Resolve]]]]]", @@ -1037,12 +1035,12 @@ " }\n" + "}"); - String str = wc.getSource(); + String str = this.wc.getSource(); String selection = "var"; int start = str.lastIndexOf(selection); int length = selection.length(); - IJavaElement[] elements = wc.codeSelect(start, length); + IJavaElement[] elements = this.wc.codeSelect(start, length); assertElementsEqual( "Unexpected elements", "var [in Test [in [Working copy] Test.java [in test0050 [in src2 [in Resolve]]]]]", @@ -1063,12 +1061,12 @@ " }\n" + "}"); - String str = wc.getSource(); + String str = this.wc.getSource(); String selection = "var"; int start = str.lastIndexOf(selection); int length = selection.length(); - IJavaElement[] elements = wc.codeSelect(start, length); + IJavaElement[] elements = this.wc.codeSelect(start, length); assertElementsEqual( "Unexpected elements", "var [in Inner [in foo() [in Test [in [Working copy] Test.java [in test0051 [in src2 [in Resolve]]]]]]]", @@ -1089,12 +1087,12 @@ " }\n" + "}"); - String str = wc.getSource(); + String str = this.wc.getSource(); String selection = "var"; int start = str.lastIndexOf(selection); int length = selection.length(); - IJavaElement[] elements = wc.codeSelect(start, length); + IJavaElement[] elements = this.wc.codeSelect(start, length); assertElementsEqual( "Unexpected elements", "var [in Inner [in foo() [in Test [in [Working copy] Test.java [in test0052 [in src2 [in Resolve]]]]]]]", @@ -1116,12 +1114,12 @@ " }\n" + "}"); - String str = wc.getSource(); + String str = this.wc.getSource(); String selection = "foo"; int start = str.lastIndexOf(selection); int length = selection.length(); - IJavaElement[] elements = wc.codeSelect(start, length); + IJavaElement[] elements = this.wc.codeSelect(start, length); assertElementsEqual( "Unexpected elements", "foo() [in Test [in [Working copy] Test.java [in test0053 [in src2 [in Resolve]]]]]", @@ -1143,12 +1141,12 @@ " }\n" + "}"); - String str = wc.getSource(); + String str = this.wc.getSource(); String selection = "foo"; int start = str.lastIndexOf(selection); int length = selection.length(); - IJavaElement[] elements = wc.codeSelect(start, length); + IJavaElement[] elements = this.wc.codeSelect(start, length); assertElementsEqual( "Unexpected elements", "foo() [in Test [in [Working copy] Test.java [in test0054 [in src2 [in Resolve]]]]]", @@ -1170,12 +1168,12 @@ " }\n" + "}"); - String str = wc.getSource(); + String str = this.wc.getSource(); String selection = "foo"; int start = str.lastIndexOf(selection); int length = selection.length(); - IJavaElement[] elements = wc.codeSelect(start, length); + IJavaElement[] elements = this.wc.codeSelect(start, length); assertElementsEqual( "Unexpected elements", "foo() [in Test [in [Working copy] Test.java [in test0055 [in src2 [in Resolve]]]]]", @@ -1195,12 +1193,12 @@ " }\n" + "}"); - String str = wc.getSource(); + String str = this.wc.getSource(); String selection = "foo"; int start = str.lastIndexOf(selection); int length = selection.length(); - IJavaElement[] elements = wc.codeSelect(start, length); + IJavaElement[] elements = this.wc.codeSelect(start, length); assertElementsEqual( "Unexpected elements", "foo() [in Test [in [Working copy] Test.java [in test0056 [in src2 [in Resolve]]]]]", @@ -1222,12 +1220,12 @@ " }\n" + "}"); - String str = wc.getSource(); + String str = this.wc.getSource(); String selection = "foo"; int start = str.lastIndexOf(selection); int length = selection.length(); - IJavaElement[] elements = wc.codeSelect(start, length); + IJavaElement[] elements = this.wc.codeSelect(start, length); assertElementsEqual( "Unexpected elements", "foo() [in Test [in [Working copy] Test.java [in test0057 [in src2 [in Resolve]]]]]", @@ -1249,12 +1247,12 @@ " }\n" + "}"); - String str = wc.getSource(); + String str = this.wc.getSource(); String selection = "foo"; int start = str.lastIndexOf(selection); int length = selection.length(); - IJavaElement[] elements = wc.codeSelect(start, length); + IJavaElement[] elements = this.wc.codeSelect(start, length); assertElementsEqual( "Unexpected elements", "foo() [in Test [in [Working copy] Test.java [in test0058 [in src2 [in Resolve]]]]]", @@ -1276,12 +1274,12 @@ " }\n" + "}"); - String str = wc.getSource(); + String str = this.wc.getSource(); String selection = "foo"; int start = str.lastIndexOf(selection); int length = selection.length(); - IJavaElement[] elements = wc.codeSelect(start, length); + IJavaElement[] elements = this.wc.codeSelect(start, length); assertElementsEqual( "Unexpected elements", "foo() [in Test [in [Working copy] Test.java [in test0059 [in src2 [in Resolve]]]]]", @@ -1303,12 +1301,12 @@ " }\n" + "}"); - String str = wc.getSource(); + String str = this.wc.getSource(); String selection = "foo"; int start = str.lastIndexOf(selection); int length = selection.length(); - IJavaElement[] elements = wc.codeSelect(start, length); + IJavaElement[] elements = this.wc.codeSelect(start, length); assertElementsEqual( "Unexpected elements", "foo() [in Test [in [Working copy] Test.java [in test0060 [in src2 [in Resolve]]]]]", @@ -1326,12 +1324,12 @@ " }\n" + "}"); - String str = wc.getSource(); + String str = this.wc.getSource(); String selection = "foo"; int start = str.lastIndexOf(selection); int length = selection.length(); - IJavaElement[] elements = wc.codeSelect(start, length); + IJavaElement[] elements = this.wc.codeSelect(start, length); assertElementsEqual( "Unexpected elements", "foo() [in Test [in [Working copy] Test.java [in test0061 [in src2 [in Resolve]]]]]", @@ -1349,12 +1347,12 @@ " }\n" + "}"); - String str = wc.getSource(); + String str = this.wc.getSource(); String selection = "foo"; int start = str.lastIndexOf(selection); int length = selection.length(); - IJavaElement[] elements = wc.codeSelect(start, length); + IJavaElement[] elements = this.wc.codeSelect(start, length); assertElementsEqual( "Unexpected elements", "foo() [in Test [in [Working copy] Test.java [in test0062 [in src2 [in Resolve]]]]]", @@ -1376,12 +1374,12 @@ " }\n" + "}"); - String str = wc.getSource(); + String str = this.wc.getSource(); String selection = "foo"; int start = str.lastIndexOf(selection); int length = selection.length(); - IJavaElement[] elements = wc.codeSelect(start, length); + IJavaElement[] elements = this.wc.codeSelect(start, length); assertElementsEqual( "Unexpected elements", "foo() [in Test [in [Working copy] Test.java [in test0063 [in src2 [in Resolve]]]]]", @@ -1400,12 +1398,12 @@ " }\n" + "}"); - String str = wc.getSource(); + String str = this.wc.getSource(); String selection = "Test"; int start = str.lastIndexOf(selection); int length = selection.length(); - IJavaElement[] elements = wc.codeSelect(start, length); + IJavaElement[] elements = this.wc.codeSelect(start, length); assertElementsEqual( "Unexpected elements", "Test(U) [in Test [in [Working copy] Test.java [in test0064 [in src2 [in Resolve]]]]]", @@ -1424,12 +1422,12 @@ " }\n" + "}"); - String str = wc.getSource(); + String str = this.wc.getSource(); String selection = "Test"; int start = str.lastIndexOf(selection); int length = selection.length(); - IJavaElement[] elements = wc.codeSelect(start, length); + IJavaElement[] elements = this.wc.codeSelect(start, length); assertElementsEqual( "Unexpected elements", "Test(U) [in Test [in [Working copy] Test.java [in test0065 [in src2 [in Resolve]]]]]", @@ -1448,12 +1446,12 @@ " }\n" + "}"); - String str = wc.getSource(); + String str = this.wc.getSource(); String selection = "Test"; int start = str.lastIndexOf(selection); int length = selection.length(); - IJavaElement[] elements = wc.codeSelect(start, length); + IJavaElement[] elements = this.wc.codeSelect(start, length); assertElementsEqual( "Unexpected elements", "Test(U) [in Test [in [Working copy] Test.java [in test0066 [in src2 [in Resolve]]]]]", @@ -1472,12 +1470,12 @@ " }\n" + "}"); - String str = wc.getSource(); + String str = this.wc.getSource(); String selection = "Test"; int start = str.lastIndexOf(selection); int length = selection.length(); - IJavaElement[] elements = wc.codeSelect(start, length); + IJavaElement[] elements = this.wc.codeSelect(start, length); assertElementsEqual( "Unexpected elements", "Test(U) [in Test [in [Working copy] Test.java [in test0067 [in src2 [in Resolve]]]]]", @@ -1496,12 +1494,12 @@ " }\n" + "}"); - String str = wc.getSource(); + String str = this.wc.getSource(); String selection = "Test"; int start = str.lastIndexOf(selection); int length = selection.length(); - IJavaElement[] elements = wc.codeSelect(start, length); + IJavaElement[] elements = this.wc.codeSelect(start, length); assertElementsEqual( "Unexpected elements", "Test(U) [in Test [in [Working copy] Test.java [in test0068 [in src2 [in Resolve]]]]]", @@ -1524,12 +1522,12 @@ " }\n" + "}"); - String str = wc.getSource(); + String str = this.wc.getSource(); String selection = "Inner"; int start = str.lastIndexOf(selection); int length = selection.length(); - IJavaElement[] elements = wc.codeSelect(start, length); + IJavaElement[] elements = this.wc.codeSelect(start, length); assertElementsEqual( "Unexpected elements", "Inner(W) [in Inner [in Test [in [Working copy] Test.java [in test0069 [in src2 [in Resolve]]]]]]", @@ -1548,12 +1546,12 @@ " }\n" + "}"); - String str = wc.getSource(); + String str = this.wc.getSource(); String selection = "Test"; int start = str.lastIndexOf(selection); int length = selection.length(); - IJavaElement[] elements = wc.codeSelect(start, length); + IJavaElement[] elements = this.wc.codeSelect(start, length); assertElementsEqual( "Unexpected elements", "Test(U) [in Test [in [Working copy] Test.java [in test0070 [in src2 [in Resolve]]]]]", @@ -1572,12 +1570,12 @@ " }\n" + "}"); - String str = wc.getSource(); + String str = this.wc.getSource(); String selection = "Test"; int start = str.lastIndexOf(selection); int length = selection.length(); - IJavaElement[] elements = wc.codeSelect(start, length); + IJavaElement[] elements = this.wc.codeSelect(start, length); assertElementsEqual( "Unexpected elements", "Test(U) [in Test [in [Working copy] Test.java [in test0071 [in src2 [in Resolve]]]]]", @@ -1596,12 +1594,12 @@ " }\n" + "}"); - String str = wc.getSource(); + String str = this.wc.getSource(); String selection = "Test"; int start = str.lastIndexOf(selection); int length = selection.length(); - IJavaElement[] elements = wc.codeSelect(start, length); + IJavaElement[] elements = this.wc.codeSelect(start, length); assertElementsEqual( "Unexpected elements", "Test(U) [in Test [in [Working copy] Test.java [in test0072 [in src2 [in Resolve]]]]]", @@ -1620,12 +1618,12 @@ " }\n" + "}"); - String str = wc.getSource(); + String str = this.wc.getSource(); String selection = "Test"; int start = str.lastIndexOf(selection); int length = selection.length(); - IJavaElement[] elements = wc.codeSelect(start, length); + IJavaElement[] elements = this.wc.codeSelect(start, length); assertElementsEqual( "Unexpected elements", "Test(U) [in Test [in [Working copy] Test.java [in test0073 [in src2 [in Resolve]]]]]", @@ -1644,12 +1642,12 @@ " }\n" + "}"); - String str = wc.getSource(); + String str = this.wc.getSource(); String selection = "Test"; int start = str.lastIndexOf(selection); int length = selection.length(); - IJavaElement[] elements = wc.codeSelect(start, length); + IJavaElement[] elements = this.wc.codeSelect(start, length); assertElementsEqual( "Unexpected elements", "Test(U) [in Test [in [Working copy] Test.java [in test0074 [in src2 [in Resolve]]]]]", @@ -1672,12 +1670,12 @@ " }\n" + "}"); - String str = wc.getSource(); + String str = this.wc.getSource(); String selection = "Inner"; int start = str.lastIndexOf(selection); int length = selection.length(); - IJavaElement[] elements = wc.codeSelect(start, length); + IJavaElement[] elements = this.wc.codeSelect(start, length); assertElementsEqual( "Unexpected elements", "Inner(W) [in Inner [in Test [in [Working copy] Test.java [in test0075 [in src2 [in Resolve]]]]]]", @@ -1694,12 +1692,12 @@ " Test.Inner> var;\n" + "}"); - String str = wc.getSource(); + String str = this.wc.getSource(); String selection = "Inner"; int start = str.lastIndexOf(selection); int length = selection.length(); - IJavaElement[] elements = wc.codeSelect(start, length); + IJavaElement[] elements = this.wc.codeSelect(start, length); assertElementsEqual( "Unexpected elements", "Inner [in Test [in [Working copy] Test.java [in test0076 [in src2 [in Resolve]]]]]", @@ -1715,12 +1713,12 @@ "public @MyAnn class Test {\n" + "}"); - String str = wc.getSource(); + String str = this.wc.getSource(); String selection = "MyAnn"; int start = str.lastIndexOf(selection); int length = selection.length(); - IJavaElement[] elements = wc.codeSelect(start, length); + IJavaElement[] elements = this.wc.codeSelect(start, length); assertElementsEqual( "Unexpected elements", "MyAnn [in [Working copy] Test.java [in test0077 [in src2 [in Resolve]]]]", @@ -1737,12 +1735,12 @@ "public @MyAnn(\"\") class Test {\n" + "}"); - String str = wc.getSource(); + String str = this.wc.getSource(); String selection = "MyAnn"; int start = str.lastIndexOf(selection); int length = selection.length(); - IJavaElement[] elements = wc.codeSelect(start, length); + IJavaElement[] elements = this.wc.codeSelect(start, length); assertElementsEqual( "Unexpected elements", "MyAnn [in [Working copy] Test.java [in test0078 [in src2 [in Resolve]]]]", @@ -1759,12 +1757,12 @@ "public @MyAnn class Test {\n" + "}"); - String str = wc.getSource(); + String str = this.wc.getSource(); String selection = "MyAnn"; int start = str.lastIndexOf(selection); int length = selection.length(); - IJavaElement[] elements = wc.codeSelect(start, length); + IJavaElement[] elements = this.wc.codeSelect(start, length); assertElementsEqual( "Unexpected elements", "MyAnn [in [Working copy] Test.java [in test0079 [in src2 [in Resolve]]]]", @@ -1782,12 +1780,12 @@ "public @MyAnn(value1 = \"\", value2 = \"\") class Test {\n" + "}"); - String str = wc.getSource(); + String str = this.wc.getSource(); String selection = "MyAnn"; int start = str.lastIndexOf(selection); int length = selection.length(); - IJavaElement[] elements = wc.codeSelect(start, length); + IJavaElement[] elements = this.wc.codeSelect(start, length); assertElementsEqual( "Unexpected elements", "MyAnn [in [Working copy] Test.java [in test0080 [in src2 [in Resolve]]]]", @@ -1805,12 +1803,12 @@ "public @MyAnn(value1 = \"\", value2 = \"\") class Test {\n" + "}"); - String str = wc.getSource(); + String str = this.wc.getSource(); String selection = "value1"; int start = str.lastIndexOf(selection); int length = selection.length(); - IJavaElement[] elements = wc.codeSelect(start, length); + IJavaElement[] elements = this.wc.codeSelect(start, length); assertElementsEqual( "Unexpected elements", "value1() [in MyAnn [in [Working copy] Test.java [in test0081 [in src2 [in Resolve]]]]]", @@ -1866,12 +1864,12 @@ " List list;\n" + "}"); - String str = wc.getSource(); + String str = this.wc.getSource(); String selection = "List"; int start = str.lastIndexOf(selection); int length = selection.length(); - IJavaElement[] elements = wc.codeSelect(start, length); + IJavaElement[] elements = this.wc.codeSelect(start, length); assertElementsEqual( "Unexpected elements", "", Index: src/org/eclipse/jdt/core/tests/model/WorkingCopyNotInClasspathTests.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/WorkingCopyNotInClasspathTests.java,v retrieving revision 1.43 diff -u -r1.43 WorkingCopyNotInClasspathTests.java --- src/org/eclipse/jdt/core/tests/model/WorkingCopyNotInClasspathTests.java 29 Mar 2006 04:03:06 -0000 1.43 +++ src/org/eclipse/jdt/core/tests/model/WorkingCopyNotInClasspathTests.java 13 Mar 2007 16:19:32 -0000 @@ -13,15 +13,8 @@ import junit.framework.Test; import org.eclipse.core.resources.*; -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IWorkspaceRoot; -import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.runtime.CoreException; import org.eclipse.jdt.core.*; -import org.eclipse.jdt.core.IBuffer; -import org.eclipse.jdt.core.ICompilationUnit; -import org.eclipse.jdt.core.JavaCore; -import org.eclipse.jdt.core.JavaModelException; import org.eclipse.jdt.internal.core.util.Util; public class WorkingCopyNotInClasspathTests extends ModifyingResourceTests { @@ -165,9 +158,10 @@ IFile file = project.getFile("A.java"); wc = JavaCore.createCompilationUnitFrom(file); ReconcilerTests.ProblemRequestor pbRequestor = new ReconcilerTests.ProblemRequestor(); - wc.becomeWorkingCopy(pbRequestor, null); + wc.becomeWorkingCopy(null); wc.getBuffer().setContents("public class A {}"); - wc.reconcile(ICompilationUnit.NO_AST, true/*force problem detection*/, null, null); + WorkingCopyOwner owner = newWorkingCopyOwner(pbRequestor); + wc.reconcile(ICompilationUnit.NO_AST, true/*force problem detection*/, owner, null); } finally { if (wc != null) { wc.discardWorkingCopy(); @@ -187,8 +181,8 @@ IFile file = project.getFile("A.java"); wc = JavaCore.createCompilationUnitFrom(file); ReconcilerTests.ProblemRequestor pbRequestor = new ReconcilerTests.ProblemRequestor(); - wc.becomeWorkingCopy(pbRequestor, null); - wc.reconcile(ICompilationUnit.NO_AST, true/*force problem detection*/, null, null); + wc.becomeWorkingCopy(null); + wc.reconcile(ICompilationUnit.NO_AST, true/*force problem detection*/, newWorkingCopyOwner(pbRequestor), null); } finally { if (wc != null) { wc.discardWorkingCopy(); @@ -359,7 +353,7 @@ "class X {}"; IFile file = this.createFile("/SimpleProject/src/native.1/X.java", source); primary = JavaCore.createCompilationUnitFrom(file); - primary.becomeWorkingCopy(null, null); + primary.becomeWorkingCopy(null); IBuffer workingCopyBuffer = primary.getBuffer(); assertTrue("Working copy buffer should not be null", workingCopyBuffer != null); @@ -397,7 +391,7 @@ "class X {}"; IFile file = this.createFile("/SimpleProject/src/native.1/some invalid name.java", source); primary = JavaCore.createCompilationUnitFrom(file); - primary.becomeWorkingCopy(null, null); + primary.becomeWorkingCopy(null); IBuffer workingCopyBuffer = primary.getBuffer(); assertTrue("Working copy buffer should not be null", workingCopyBuffer != null); Index: src/org/eclipse/jdt/core/tests/model/JavaElementDeltaTests.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/JavaElementDeltaTests.java,v retrieving revision 1.71 diff -u -r1.71 JavaElementDeltaTests.java --- src/org/eclipse/jdt/core/tests/model/JavaElementDeltaTests.java 20 Oct 2006 01:45:46 -0000 1.71 +++ src/org/eclipse/jdt/core/tests/model/JavaElementDeltaTests.java 13 Mar 2007 16:19:25 -0000 @@ -785,7 +785,7 @@ "}"); ICompilationUnit unit = getCompilationUnit("P", "", "", "X.java"); startDeltas(); - copy = unit.getWorkingCopy(new WorkingCopyOwner() {}, null, null); + copy = unit.getWorkingCopy(new WorkingCopyOwner() {}, null); assertDeltas( "Unexpected delta", "P[*]: {CHILDREN}\n" + @@ -1031,7 +1031,7 @@ "public class X {\n" + "}"); ICompilationUnit unit = getCompilationUnit("P", "", "", "X.java"); - copy = unit.getWorkingCopy(new WorkingCopyOwner() {}, null, null); + copy = unit.getWorkingCopy(new WorkingCopyOwner() {}, null); startDeltas(); copy.discardWorkingCopy(); assertDeltas( @@ -1103,7 +1103,7 @@ listener.flush(); // shared working copy creation - wc = cu.getWorkingCopy(new WorkingCopyOwner() {}, null, null); + wc = cu.getWorkingCopy(new WorkingCopyOwner() {}, null); assertEquals( "Unexpected delta after creating shared working copy", "P[*]: {CHILDREN}\n" + @@ -1206,7 +1206,7 @@ listener.flush(); // shared working copy creation - wc = cu.getWorkingCopy(new WorkingCopyOwner() {}, null, null); + wc = cu.getWorkingCopy(new WorkingCopyOwner() {}, null); assertEquals( "Unexpected delta after creating shared working copy", "", Index: src/org/eclipse/jdt/core/tests/model/AbstractJavaModelTests.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/AbstractJavaModelTests.java,v retrieving revision 1.181 diff -u -r1.181 AbstractJavaModelTests.java --- src/org/eclipse/jdt/core/tests/model/AbstractJavaModelTests.java 8 Mar 2007 14:58:03 -0000 1.181 +++ src/org/eclipse/jdt/core/tests/model/AbstractJavaModelTests.java 13 Mar 2007 16:19:23 -0000 @@ -57,6 +57,15 @@ protected boolean displayName = false; protected String endChar = ","; + public static class BasicProblemRequestor implements IProblemRequestor { + public void acceptProblem(IProblem problem) {} + public void beginReporting() {} + public void endReporting() {} + public boolean isActive() { + return true; + } + } + public static class ProblemRequestor implements IProblemRequestor { public StringBuffer problems; public int problemCount; @@ -99,10 +108,10 @@ public ByteArrayOutputStream stackTraces; public void elementChanged(ElementChangedEvent ev) { - IJavaElementDelta[] copy= new IJavaElementDelta[deltas.length + 1]; - System.arraycopy(deltas, 0, copy, 0, deltas.length); - copy[deltas.length]= ev.getDelta(); - deltas= copy; + IJavaElementDelta[] copy= new IJavaElementDelta[this.deltas.length + 1]; + System.arraycopy(this.deltas, 0, copy, 0, this.deltas.length); + copy[this.deltas.length]= ev.getDelta(); + this.deltas= copy; new Throwable("Caller of IElementChangedListener#elementChanged").printStackTrace(new PrintStream(this.stackTraces)); } @@ -1589,24 +1598,40 @@ } public ICompilationUnit getWorkingCopy(String path, String source) throws JavaModelException { return getWorkingCopy(path, source, false); - } + } public ICompilationUnit getWorkingCopy(String path, String source, boolean computeProblems) throws JavaModelException { - if (this.wcOwner == null) this.wcOwner = new WorkingCopyOwner() {}; - return getWorkingCopy(path, source, this.wcOwner, computeProblems); + if (this.wcOwner == null) { + this.wcOwner = newWorkingCopyOwner(computeProblems ? new BasicProblemRequestor() : null); + return getWorkingCopy(path, source, this.wcOwner); + } + ICompilationUnit wc = getWorkingCopy(path, source, this.wcOwner); + // Verify that compute problem parameter is compatible with working copy problem requestor + if (computeProblems) { + assertNotNull("Cannot compute problems if working copy owner is set to null!", this.wcOwner.getProblemRequestor(wc)); + } else { + assertNull("Cannot ignore problems if working copy owner is not set to null!", this.wcOwner.getProblemRequestor(wc)); + } + return wc; } - public ICompilationUnit getWorkingCopy(String path, String source, WorkingCopyOwner owner, boolean computeProblems) throws JavaModelException { - IProblemRequestor problemRequestor = computeProblems - ? new IProblemRequestor() { - public void acceptProblem(IProblem problem) {} - public void beginReporting() {} - public void endReporting() {} - public boolean isActive() { - return true; - } - } - : null; - return getWorkingCopy(path, source, owner, problemRequestor); + public ICompilationUnit getWorkingCopy(String path, String source, WorkingCopyOwner owner) throws JavaModelException { + ICompilationUnit workingCopy = getCompilationUnit(path); + if (owner != null) + workingCopy = workingCopy.getWorkingCopy(owner, null/*no progress monitor*/); + else + workingCopy.becomeWorkingCopy(null/*no progress monitor*/); + workingCopy.getBuffer().setContents(source); + IProblemRequestor problemRequestor = owner.getProblemRequestor(workingCopy); + if (problemRequestor instanceof ProblemRequestor) { + ((ProblemRequestor) problemRequestor).initialize(source.toCharArray()); + } + workingCopy.makeConsistent(null/*no progress monitor*/); + return workingCopy; } + /** + * This method is still necessary when we need to use an owner and a specific problem requestor + * (typically while using primary owner). + * @deprecated + */ public ICompilationUnit getWorkingCopy(String path, String source, WorkingCopyOwner owner, IProblemRequestor problemRequestor) throws JavaModelException { ICompilationUnit workingCopy = getCompilationUnit(path); if (owner != null) @@ -1683,15 +1708,33 @@ protected ICompilationUnit newExternalWorkingCopy(String name, final String contents) throws JavaModelException { return newExternalWorkingCopy(name, null/*no classpath*/, null/*no problem requestor*/, contents); } - protected ICompilationUnit newExternalWorkingCopy(String name, IClasspathEntry[] classpath, IProblemRequestor problemRequestor, final String contents) throws JavaModelException { + protected ICompilationUnit newExternalWorkingCopy(String name, IClasspathEntry[] classpath, final IProblemRequestor problemRequestor, final String contents) throws JavaModelException { WorkingCopyOwner owner = new WorkingCopyOwner() { public IBuffer createBuffer(ICompilationUnit wc) { IBuffer buffer = super.createBuffer(wc); buffer.setContents(contents); return buffer; } + public IProblemRequestor getProblemRequestor(ICompilationUnit workingCopy) { + return problemRequestor; + } + }; + return owner.newWorkingCopy(name, classpath, null/*no progress monitor*/); + } + + /** + * Create a new working copy owner using given problem requestor + * to report problem. + * + * @param problemRequestor The requestor used to report problems + * @return The created working copy owner + */ + protected WorkingCopyOwner newWorkingCopyOwner(final IProblemRequestor problemRequestor) { + return new WorkingCopyOwner() { + public IProblemRequestor getProblemRequestor(ICompilationUnit unit) { + return problemRequestor; + } }; - return owner.newWorkingCopy(name, classpath, problemRequestor, null/*no progress monitor*/); } public byte[] read(java.io.File file) throws java.io.IOException { @@ -2015,10 +2058,10 @@ IJavaElement selectJavaElement(ICompilationUnit unit, String selection, int occurences, int elementType) throws JavaModelException { int[] selectionPositions = selectionInfo(unit, selection, occurences); IJavaElement[] elements = null; - if (wcOwner == null) { + if (this.wcOwner == null) { elements = unit.codeSelect(selectionPositions[0], selectionPositions[1]); } else { - elements = unit.codeSelect(selectionPositions[0], selectionPositions[1], wcOwner); + elements = unit.codeSelect(selectionPositions[0], selectionPositions[1], this.wcOwner); } assertEquals("Invalid selection number", 1, elements.length); assertEquals("Invalid java element type: "+elements[0].getElementName(), elements[0].getElementType(), elementType); Index: src/org/eclipse/jdt/core/tests/model/ExclusionPatternsTests.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ExclusionPatternsTests.java,v retrieving revision 1.34 diff -u -r1.34 ExclusionPatternsTests.java --- src/org/eclipse/jdt/core/tests/model/ExclusionPatternsTests.java 13 Jun 2006 13:01:06 -0000 1.34 +++ src/org/eclipse/jdt/core/tests/model/ExclusionPatternsTests.java 13 Mar 2007 16:19:24 -0000 @@ -168,7 +168,7 @@ ICompilationUnit workingCopy = null; try { workingCopy = getCompilationUnit("/P/src/p/A.java"); - workingCopy.becomeWorkingCopy(null, null); + workingCopy.becomeWorkingCopy(null); clearDeltas(); setClasspath(new String[] {"/P/src", "**/A.java"}); Index: src/org/eclipse/jdt/core/tests/model/ClasspathInitializerTests.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ClasspathInitializerTests.java,v retrieving revision 1.47 diff -u -r1.47 ClasspathInitializerTests.java --- src/org/eclipse/jdt/core/tests/model/ClasspathInitializerTests.java 2 Mar 2007 09:36:14 -0000 1.47 +++ src/org/eclipse/jdt/core/tests/model/ClasspathInitializerTests.java 13 Mar 2007 16:19:24 -0000 @@ -356,7 +356,7 @@ startDeltas(); workingCopy = getCompilationUnit("/P2/src/X.java"); - workingCopy.becomeWorkingCopy(null, null); + workingCopy.becomeWorkingCopy(null); assertDeltas( "Unexpected delta on startup", Index: src/org/eclipse/jdt/core/tests/model/SelectionJavadocModelTests.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/SelectionJavadocModelTests.java,v retrieving revision 1.12 diff -u -r1.12 SelectionJavadocModelTests.java --- src/org/eclipse/jdt/core/tests/model/SelectionJavadocModelTests.java 6 Mar 2007 04:43:20 -0000 1.12 +++ src/org/eclipse/jdt/core/tests/model/SelectionJavadocModelTests.java 13 Mar 2007 16:19:30 -0000 @@ -837,8 +837,8 @@ */ public void testBug86380() throws CoreException { this.wcOwner = new WorkingCopyOwner() {}; - workingCopies = new ICompilationUnit[2]; - workingCopies[0] = getWorkingCopy("/Tests/b86380/package-info.java", + this.workingCopies = new ICompilationUnit[2]; + this.workingCopies[0] = getWorkingCopy("/Tests/b86380/package-info.java", "/**\n" + " * Valid javadoc.\n" + " * @see Test\n" + @@ -851,11 +851,9 @@ " * @throws unexpected\n" + " * @return unexpected \n" + " */\n" + - "package b86380;\n", - wcOwner, - null/*don't compute problems*/ + "package b86380;\n" ); - workingCopies[1] = getWorkingCopy("/Tests/b86380/Test.java", + this.workingCopies[1] = getWorkingCopy("/Tests/b86380/Test.java", "/**\n" + " * Invalid javadoc\n" + " */\n" + @@ -863,9 +861,7 @@ "public class Test {\n" + " public int field;\n" + " public void foo() {}\n" + - "}\n", - wcOwner, - null/*don't compute problems*/ + "}\n" ); IJavaElement[] elements = new IJavaElement[3]; elements[0] = selectType(this.workingCopies[0], "Test"); @@ -894,8 +890,8 @@ " }\n" + "}\n" ); - int[] selectionPositions = selectionInfo(workingCopies[0], "field", 2); - IJavaElement[] elements = workingCopies[0].codeSelect(selectionPositions[0], 0); + int[] selectionPositions = selectionInfo(this.workingCopies[0], "field", 2); + IJavaElement[] elements = this.workingCopies[0].codeSelect(selectionPositions[0], 0); assertElementsEqual("Invalid selection(s)", "field [in Test [in [Working copy] Test.java [in b90266 [in [in Tests]]]]]", elements @@ -912,8 +908,8 @@ " }\n" + "}\n" ); - int[] selectionPositions = selectionInfo(workingCopies[0], "field", 2); - IJavaElement[] elements = workingCopies[0].codeSelect(selectionPositions[0], 0); + int[] selectionPositions = selectionInfo(this.workingCopies[0], "field", 2); + IJavaElement[] elements = this.workingCopies[0].codeSelect(selectionPositions[0], 0); assertElementsEqual("Invalid selection(s)", "field [in Test [in [Working copy] Test.java [in b90266 [in [in Tests]]]]]", elements @@ -935,8 +931,8 @@ " public void foo() {}\n" + "}\n" ); - int[] selectionPositions = selectionInfo(workingCopies[0], "fooo", 1); - IJavaElement[] elements = workingCopies[0].codeSelect(selectionPositions[0], 0); + int[] selectionPositions = selectionInfo(this.workingCopies[0], "fooo", 1); + IJavaElement[] elements = this.workingCopies[0].codeSelect(selectionPositions[0], 0); assertElementsEqual("Invalid selection(s)", "Test [in [Working copy] Test.java [in b165701 [in [in Tests]]]]", elements @@ -977,8 +973,8 @@ "class Y {}\n" + "class Z {}" ); - int[] selectionPositions = selectionInfo(workingCopies[0], "getMax", 1); - IJavaElement[] elements = workingCopies[0].codeSelect(selectionPositions[0], 0); + int[] selectionPositions = selectionInfo(this.workingCopies[0], "getMax", 1); + IJavaElement[] elements = this.workingCopies[0].codeSelect(selectionPositions[0], 0); assertElementsEqual("Invalid selection(s)", "getMax(A) [in X [in [Working copy] Test.java [in b165794 [in [in Tests]]]]]", elements @@ -991,8 +987,8 @@ */ public void testBug171802() throws CoreException { this.wcOwner = new WorkingCopyOwner() {}; - workingCopies = new ICompilationUnit[2]; - workingCopies[0] = getWorkingCopy("/Tests/b171802/Y.java", + this.workingCopies = new ICompilationUnit[2]; + this.workingCopies[0] = getWorkingCopy("/Tests/b171802/Y.java", "package b171802;\n" + "\n" + "/**\n" + @@ -1000,11 +996,9 @@ " */\n" + "public class Y {\n" + "\n" + - "}\n", - wcOwner, - null/*don't compute problems*/ + "}\n" ); - workingCopies[1] = getWorkingCopy("/Tests/b171802/X.java", + this.workingCopies[1] = getWorkingCopy("/Tests/b171802/X.java", "package b171802;\n" + "\n" + "public class X {\n" + @@ -1019,9 +1013,7 @@ " */\n" + " void bar(char[] param1, Y param2) {}\n" + "\n" + - "}\n", - wcOwner, - null/*don't compute problems*/ + "}\n" ); IJavaElement[] elements = new IJavaElement[1]; elements[0] = selectMethod(this.workingCopies[1], "bar"); Index: src/org/eclipse/jdt/core/tests/model/AbstractJavaModelCompletionTests.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/AbstractJavaModelCompletionTests.java,v retrieving revision 1.8 diff -u -r1.8 AbstractJavaModelCompletionTests.java --- src/org/eclipse/jdt/core/tests/model/AbstractJavaModelCompletionTests.java 29 Mar 2006 04:03:07 -0000 1.8 +++ src/org/eclipse/jdt/core/tests/model/AbstractJavaModelCompletionTests.java 13 Mar 2007 16:19:22 -0000 @@ -70,7 +70,7 @@ removeLibraryEntry(javaProject, new Path(projectPath + jarName)); } public ICompilationUnit getWorkingCopy(String path, String source) throws JavaModelException { - return super.getWorkingCopy(path, source, this.wcOwner, null); + return super.getWorkingCopy(path, source, this.wcOwner); } protected CompletionResult complete(String path, String source, String completeBehind) throws JavaModelException { return this.complete(path, source, false, completeBehind); Index: src/org/eclipse/jdt/core/tests/model/JavaSearchBugsTests.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/JavaSearchBugsTests.java,v retrieving revision 1.102 diff -u -r1.102 JavaSearchBugsTests.java --- src/org/eclipse/jdt/core/tests/model/JavaSearchBugsTests.java 5 Mar 2007 15:43:04 -0000 1.102 +++ src/org/eclipse/jdt/core/tests/model/JavaSearchBugsTests.java 13 Mar 2007 16:19:27 -0000 @@ -95,7 +95,7 @@ if (this.wcOwner == null) { this.wcOwner = new WorkingCopyOwner() {}; } - return getWorkingCopy(path, source, this.wcOwner, null/*don't compute problems*/); + return getWorkingCopy(path, source, this.wcOwner); } protected void search(IJavaElement element, int limitTo) throws CoreException { search(element, limitTo, EXACT_RULE, getJavaSearchScopeBugs(), resultCollector); @@ -231,9 +231,8 @@ "public abstract class A {\n" + " public abstract void foo(V v);\n" + "}\n", - owner, - true - ); + owner + ); workingCopies[1] = getWorkingCopy("/JavaSearchBugs/src/b72866/SX.java", "package b72866;\n" + "public class SX extends A {\n" + @@ -241,8 +240,8 @@ " v.bar(this);\n" + " }\n" + "}\n" , - owner, - true); + owner + ); workingCopies[2] = getWorkingCopy("/JavaSearchBugs/src/b72866/V.java", "package b72866;\n" + "public class V {\n" + @@ -250,8 +249,8 @@ " void bar(X x) {}\n" + " void bar(SX s) {}\n" + "}\n" , - owner, - true); + owner + ); workingCopies[3] = getWorkingCopy("/JavaSearchBugs/src/b72866/X.java", "package b72866;\n" + "public class X extends A {\n" + @@ -259,8 +258,8 @@ " v.bar(this);\n" + " }\n" + "}\n" , - owner, - true ); + owner + ); IType type = workingCopies[2].getType("V"); IMethod method = type.getMethod("bar", new String[] {"QX;"}); search(method, REFERENCES); @@ -329,20 +328,20 @@ workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b73336/A.java", "package b73336;\n" + "public class A {}\n", - owner, - true); + owner + ); workingCopies[1] = getWorkingCopy("/JavaSearchBugs/src/b73336/AA.java", "package b73336;\n" + "public class AA extends A {}\n", - owner, - true); + owner + ); workingCopies[2] = getWorkingCopy("/JavaSearchBugs/src/b73336/B.java", "package b73336;\n" + "public class B extends X {\n" + " void foo(T t) {}\n" + "}\n", - owner, - true); + owner + ); workingCopies[3] = getWorkingCopy("/JavaSearchBugs/src/b73336/C.java", "package b73336;\n" + "public class C implements I {\n" + @@ -351,15 +350,15 @@ " b.foo(new A());\n" + " }\n" + "}\n", - owner, - true ); + owner + ); workingCopies[4] = getWorkingCopy("/JavaSearchBugs/src/b73336/I.java", "package b73336;\n" + "public interface I {\n" + " public void foo();\n" + "}\n", - owner, - true ); + owner + ); workingCopies[5] = getWorkingCopy("/JavaSearchBugs/src/b73336/X.java", "package b73336;\n" + "public class X {\n" + @@ -368,8 +367,8 @@ " void foo() {}\n" + " }\n" + "}\n", - owner, - true ); + owner + ); // search for first and second method should both return 2 inaccurate matches IType type = workingCopies[0].getType("A"); search(type, REFERENCES); //, getJavaSearchScopeBugs("b73336", false)); @@ -388,14 +387,14 @@ workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b73336b/A.java", "package b73336b;\n" + "public class A {}\n", - owner, - true); + owner + ); workingCopies[1] = getWorkingCopy("/JavaSearchBugs/src/b73336b/B.java", "package b73336b;\n" + "public class B extends X {\n" + "}\n", - owner, - true); + owner + ); workingCopies[2] = getWorkingCopy("/JavaSearchBugs/src/b73336b/C.java", "package b73336b;\n" + "public class C extends X.Member {\n" + @@ -403,8 +402,8 @@ " new X().super();\n" + " }\n" + "}\n", - owner, - true); + owner + ); workingCopies[3] = getWorkingCopy("/JavaSearchBugs/src/b73336b/X.java", "package b73336b;\n" + "public class X {\n" + @@ -413,8 +412,8 @@ " void foo() {}\n" + " }\n" + "}\n", - owner, - true ); + owner + ); // search for first and second method should both return 2 inaccurate matches IType type = workingCopies[0].getType("A"); // search(type, REFERENCES, getJavaSearchScopeBugs("b73336b", false)); @@ -436,21 +435,21 @@ workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b73336c/A.java", "package b73336c;\n" + "public class A {}\n", - owner, - true); + owner + ); workingCopies[1] = getWorkingCopy("/JavaSearchBugs/src/b73336c/B.java", "package b73336c;\n" + "public class B extends X {\n" + "}\n", - owner, - true); + owner + ); workingCopies[2] = getWorkingCopy("/JavaSearchBugs/src/b73336c/C.java", "package b73336c;\n" + "public class C implements X.Interface {\n" + " void bar() {}\n" + "}\n", - owner, - true); + owner + ); workingCopies[3] = getWorkingCopy("/JavaSearchBugs/src/b73336c/X.java", "package b73336c;\n" + "public class X {\n" + @@ -458,8 +457,8 @@ " void bar();\n" + " }\n" + "}\n", - owner, - true ); + owner + ); // search for first and second method should both return 2 inaccurate matches IType type = workingCopies[0].getType("A"); // search(type, REFERENCES, getJavaSearchScopeBugs("b73336c", false)); @@ -484,13 +483,13 @@ "package b73696;\n" + "public class C implements I {\n" + "}", - owner, - true); + owner + ); workingCopies[1] = getWorkingCopy("/JavaSearchBugs/src/b73696/I.java", "package b73696;\n" + "public interface I {}\n", - owner, - true); + owner + ); IJavaSearchScope scope = SearchEngine.createJavaSearchScope(workingCopies); // Interface declaration @@ -547,21 +546,21 @@ " void foo(IRegion r) {\n" + " }\n" + "}\n", - owner, - true); + owner + ); workingCopies[1] = getWorkingCopy("/JavaSearchBugs/src/b74776/IRegion.java", "package b74776;\n" + "public interface IRegion {\n" + "}\n", - owner, - true); + owner + ); workingCopies[2] = getWorkingCopy("/JavaSearchBugs/src/b74776/Region.java", "package b74776;\n" + "public class Region implements IRegion {\n" + "\n" + "}\n", - owner, - true); + owner + ); // search method references IType type = workingCopies[0].getType("A"); IMethod method = type.getMethod("foo", new String[] { "QRegion;" }); @@ -681,8 +680,8 @@ "public class M {\n" + " static int VAL=78082;\n" + "}\n", - owner, - true); + owner + ); workingCopies[1] = getWorkingCopy("/JavaSearchBugs/src/b78082/XY.java", "package b78082;\n" + "import static b78082.M.VAL;\n" + @@ -690,8 +689,8 @@ " double val = VAL;\n" + " double val2= b78082.M.VAL;\n" + "}\n", - owner, - true); + owner + ); // search field references IType type = workingCopies[0].getType("M"); IField field = type.getField("VAL"); @@ -842,8 +841,8 @@ "package b79860;\n" + "public class X { }\n" + "class A { }", - owner, - true); + owner + ); workingCopies[1] = getWorkingCopy("/JavaSearchBugs/src/b79860/Y.java", "package b79860;\n" + "public class Y { }\n" + @@ -851,8 +850,8 @@ "interface I1 {}\n" + "interface I2 {}\n" + "interface I3 {}\n", - owner, - true); + owner + ); IType type = workingCopies[0].getType("A"); search(type, REFERENCES); assertSearchResults( @@ -866,8 +865,8 @@ "package b79860;\n" + "public class X { }\n" + "class A { }", - owner, - true); + owner + ); workingCopies[1] = getWorkingCopy("/JavaSearchBugs/src/b79860/Y.java", "package b79860;\n" + "public class Y { }\n" + @@ -875,8 +874,8 @@ "interface I1 {}\n" + "interface I2 {}\n" + "interface I3 {}\n", - owner, - true); + owner + ); search("I?", TYPE, REFERENCES); assertSearchResults( "src/b79860/Y.java b79860.Y [I1] EXACT_MATCH\n" + @@ -1053,15 +1052,15 @@ "public class A {\n" + " void m() {}\n" + "}", - owner, - true); + owner + ); workingCopies[1] = getWorkingCopy("/JavaSearchBugs/src/b80223/b/B.java", "package b80223.b;\n" + "public class B extends b80223.a.A {\n" + " void m() {}\n" + "}", - owner, - true); + owner + ); // search for method declaration should find only A match IType type = workingCopies[0].getType("A"); IMethod method = type.getMethod("m", new String[0]); @@ -6308,8 +6307,7 @@ " new Test().foo(100);\n" + " }\n" + "}\n", - new WorkingCopyOwner() {}, - problemRequestor + newWorkingCopyOwner(problemRequestor) ); assertEquals("CU Should not have any problem!", "----------\n" + Index: src/org/eclipse/jdt/core/tests/model/AccessRestrictionsTests.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/AccessRestrictionsTests.java,v retrieving revision 1.9 diff -u -r1.9 AccessRestrictionsTests.java --- src/org/eclipse/jdt/core/tests/model/AccessRestrictionsTests.java 6 Mar 2007 04:43:19 -0000 1.9 +++ src/org/eclipse/jdt/core/tests/model/AccessRestrictionsTests.java 13 Mar 2007 16:19:23 -0000 @@ -21,7 +21,7 @@ static class ProblemRequestor extends AbstractJavaModelTests.ProblemRequestor { ProblemRequestor (String source) { if (source != null) - unitSource = source.toCharArray(); + this.unitSource = source.toCharArray(); } ProblemRequestor() { } @@ -54,6 +54,19 @@ protected void assertProblems(String message, String expected) { assertProblems(message, expected, this.problemRequestor); } + + public ICompilationUnit getWorkingCopy(String path, String source) throws JavaModelException { + return getWorkingCopy(path, source, this.wcOwner); + } + + protected void setUp() throws Exception { + super.setUp(); + this.wcOwner = new WorkingCopyOwner() { + public IProblemRequestor getProblemRequestor(ICompilationUnit unit) { + return AccessRestrictionsTests.this.problemRequestor; + } + }; + } /* * https://bugs.eclipse.org/bugs/show_bug.cgi?id=76266 @@ -64,7 +77,6 @@ public void test001() throws CoreException { ICompilationUnit x1 = null, x2 = null, y = null, z = null; try { - WorkingCopyOwner owner = new WorkingCopyOwner(){}; createJavaProject( "P1", new String[] {"src"}, @@ -77,9 +89,8 @@ "public class X1 {\n" + " void foo() {\n" + " }\n" + - "}", - owner, - this.problemRequestor); + "}" + ); assertProblems( "Unexpected problems", "----------\n" + @@ -91,8 +102,8 @@ "public class X2 extends X1 {\n" + " void bar() {\n" + " }\n" + - "}", owner, - this.problemRequestor); + "}" + ); assertProblems( "Unexpected problems", "----------\n" + @@ -113,9 +124,8 @@ this.problemRequestor = new ProblemRequestor(src); z = getWorkingCopy( "/P2/src/p/Z.java", - src, - owner, - this.problemRequestor); + src + ); assertProblems( "Unexpected problems value", "----------\n" + @@ -137,9 +147,8 @@ this.problemRequestor = new ProblemRequestor(src); y = getWorkingCopy( "/P2/src/p/Y.java", - src, - owner, - this.problemRequestor); + src + ); assertProblems( "Unexpected problems value", "----------\n" + @@ -171,7 +180,6 @@ public void test002() throws CoreException { ICompilationUnit x1 = null, x2 = null, y = null; try { - WorkingCopyOwner owner = new WorkingCopyOwner(){}; createJavaProject( "P1", new String[] {"src"}, @@ -183,9 +191,8 @@ "package p;\n" + "public class X1 {\n" + " int m1;\n" + - "}", - owner, - this.problemRequestor); + "}" + ); assertProblems( "Unexpected problems", "----------\n" + @@ -196,9 +203,8 @@ "package p;\n" + "public class X2 extends X1 {\n" + " char m2;\n" + - "}", - owner, - this.problemRequestor); + "}" + ); assertProblems( "Unexpected problems", "----------\n" + @@ -222,9 +228,8 @@ this.problemRequestor = new ProblemRequestor(src); y = getWorkingCopy( "/P2/src/p/Y.java", - src, - owner, - this.problemRequestor); + src + ); assertProblems( "Unexpected problems value", "----------\n" + @@ -254,7 +259,6 @@ public void test003() throws CoreException { ICompilationUnit x1 = null, x2 = null, y = null; try { - WorkingCopyOwner owner = new WorkingCopyOwner(){}; createJavaProject( "P1", new String[] {"src"}, @@ -270,9 +274,8 @@ " protected void foo() {}\n" + " }\n" + " interface I1 {}\n" + - "}", - owner, - this.problemRequestor); + "}" + ); assertProblems( "Unexpected problems", "----------\n" + @@ -284,9 +287,8 @@ "public class X2 extends X1 {\n" + " class C2 {}\n" + " interface I2 {}\n" + - "}", - owner, - this.problemRequestor); + "}" + ); assertProblems( "Unexpected problems", "----------\n" + @@ -318,9 +320,8 @@ this.problemRequestor = new ProblemRequestor(src); y = getWorkingCopy( "/P2/src/p/Y.java", - src, - owner, - this.problemRequestor); + src + ); assertProblems( "Unexpected problems value", "----------\n" + @@ -372,7 +373,6 @@ public void test004() throws CoreException { ICompilationUnit x1 = null, z = null; try { - WorkingCopyOwner owner = new WorkingCopyOwner(){}; createJavaProject( "P1", new String[] {"src"}, @@ -385,9 +385,8 @@ "public class X1 {\n" + " class C1 {}\n" + " interface I1 {}\n" + - "}", - owner, - this.problemRequestor); + "}" + ); assertProblems( "Unexpected problems", "----------\n" + @@ -407,9 +406,8 @@ this.problemRequestor = new ProblemRequestor(src); z = getWorkingCopy( "/P2/src/p/Z.java", - src, - owner, - this.problemRequestor); + src + ); assertProblems( "Unexpected problems value", "----------\n" + @@ -444,7 +442,6 @@ public void test005() throws CoreException { ICompilationUnit x1 = null, i1 = null, x2 = null, y = null; try { - WorkingCopyOwner owner = new WorkingCopyOwner(){}; createJavaProject( "P1", new String[] {"src"}, @@ -457,9 +454,8 @@ "public class X1 {\n" + " public void foo() {\n" + " }\n" + - "}", - owner, - this.problemRequestor); + "}" + ); assertProblems( "Unexpected problems", "----------\n" + @@ -470,9 +466,8 @@ "package q;\n" + "interface I1 {\n" + " void foo();\n" + - "}", - owner, - this.problemRequestor); + "}" + ); assertProblems( "Unexpected problems", "----------\n" + @@ -485,9 +480,8 @@ " public void bar() {\n" + " foo();\n" + " }\n" + - "}", - owner, - this.problemRequestor); + "}" + ); assertProblems( "Unexpected problems", "----------\n" + @@ -515,9 +509,8 @@ this.problemRequestor = new ProblemRequestor(src); y = getWorkingCopy( "/P2/src/r/Y.java", - src, - owner, - this.problemRequestor); + src + ); assertProblems( "Unexpected problems value", "----------\n" + @@ -547,7 +540,6 @@ public void test006() throws CoreException { ICompilationUnit x = null, y = null; try { - WorkingCopyOwner owner = new WorkingCopyOwner(){}; IJavaProject p1 = createJavaProject( "P1", new String[] {"src"}, @@ -563,9 +555,8 @@ "package p;\n" + "public class X {\n" + " T m;\n" + - "}", - owner, - this.problemRequestor); + "}" + ); assertProblems( "Unexpected problems", "----------\n" + @@ -594,9 +585,8 @@ this.problemRequestor = new ProblemRequestor(src); y = getWorkingCopy( "/P2/src/p/Y.java", - src, - owner, - this.problemRequestor); + src + ); assertProblems( "Unexpected problems value", "----------\n" + @@ -639,7 +629,6 @@ public void test007() throws CoreException { ICompilationUnit x = null, y = null; try { - WorkingCopyOwner owner = new WorkingCopyOwner(){}; IJavaProject p1 = createJavaProject( "P1", new String[] {"src"}, @@ -658,9 +647,8 @@ " public X (T t) {\n" + " this.m = t;\n" + " }\n" + - "}", - owner, - this.problemRequestor); + "}" + ); assertProblems( "Unexpected problems", "----------\n" + @@ -689,9 +677,8 @@ this.problemRequestor = new ProblemRequestor(src); y = getWorkingCopy( "/P2/src/p/Y.java", - src, - owner, - this.problemRequestor); + src + ); assertProblems( "Unexpected problems value", "----------\n" + @@ -734,7 +721,6 @@ public void test008() throws CoreException { ICompilationUnit x1 = null, x2 = null, y = null; try { - WorkingCopyOwner owner = new WorkingCopyOwner(){}; IJavaProject p1 = createJavaProject( "P1", new String[] {"src"}, @@ -751,9 +737,8 @@ "public class X1 {\n" + " void foo() {\n" + " }\n" + - "}", - owner, - this.problemRequestor); + "}" + ); assertProblems( "Unexpected problems", "----------\n" + @@ -765,8 +750,8 @@ "public class X2 extends X1 {\n" + " void bar() {\n" + " }\n" + - "}", owner, - this.problemRequestor); + "}" + ); assertProblems( "Unexpected problems", "----------\n" + @@ -793,9 +778,8 @@ this.problemRequestor = new ProblemRequestor(src); y = getWorkingCopy( "/P2/src/p/Y.java", - src, - owner, - this.problemRequestor); + src + ); assertProblems( "Unexpected problems value", "----------\n" + @@ -824,7 +808,6 @@ public void test009() throws CoreException { ICompilationUnit x1 = null, x2 = null, y = null; try { - WorkingCopyOwner owner = new WorkingCopyOwner(){}; IJavaProject p1 = createJavaProject( "P1", new String[] {"src"}, @@ -840,9 +823,8 @@ "package p;\n" + "public class X1 {\n" + " int m1;\n" + - "}", - owner, - this.problemRequestor); + "}" + ); assertProblems( "Unexpected problems", "----------\n" + @@ -853,9 +835,8 @@ "package p;\n" + "public class X2 extends X1 {\n" + " char m2;\n" + - "}", - owner, - this.problemRequestor); + "}" + ); assertProblems( "Unexpected problems", "----------\n" + @@ -882,9 +863,8 @@ this.problemRequestor = new ProblemRequestor(src); y = getWorkingCopy( "/P2/src/p/Y.java", - src, - owner, - this.problemRequestor); + src + ); assertProblems( "Unexpected problems value", "----------\n" + @@ -913,7 +893,6 @@ public void test010() throws CoreException { ICompilationUnit x1 = null, x2 = null, y = null; try { - WorkingCopyOwner owner = new WorkingCopyOwner(){}; IJavaProject p1 = createJavaProject( "P1", new String[] {"src"}, @@ -933,9 +912,8 @@ " protected void foo() {}\n" + " }\n" + " interface I1 {}\n" + - "}", - owner, - this.problemRequestor); + "}" + ); assertProblems( "Unexpected problems", "----------\n" + @@ -947,9 +925,8 @@ "public class X2 extends X1 {\n" + " class C2 {}\n" + " interface I2 {}\n" + - "}", - owner, - this.problemRequestor); + "}" + ); assertProblems( "Unexpected problems", "----------\n" + @@ -985,9 +962,8 @@ this.problemRequestor = new ProblemRequestor(src); y = getWorkingCopy( "/P2/src/p/Y.java", - src, - owner, - this.problemRequestor); + src + ); assertProblems( "Unexpected problems value", "----------\n" + Index: src/org/eclipse/jdt/core/tests/model/JavaSearchMultipleProjectsTests.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/JavaSearchMultipleProjectsTests.java,v retrieving revision 1.40 diff -u -r1.40 JavaSearchMultipleProjectsTests.java --- src/org/eclipse/jdt/core/tests/model/JavaSearchMultipleProjectsTests.java 17 Dec 2006 17:18:45 -0000 1.40 +++ src/org/eclipse/jdt/core/tests/model/JavaSearchMultipleProjectsTests.java 13 Mar 2007 16:19:27 -0000 @@ -582,7 +582,7 @@ // create working copies WorkingCopyOwner owner = new WorkingCopyOwner() {}; - workingCopy1 = getCompilationUnit("/P1/p1/X.java").getWorkingCopy(owner, null/*no problem requestor*/, null/*no progress monitor*/); + workingCopy1 = getCompilationUnit("/P1/p1/X.java").getWorkingCopy(owner, null/*no progress monitor*/); workingCopy1.getBuffer().setContents( "package p1;\n" + "public class X {\n" + @@ -591,7 +591,7 @@ "}" ); workingCopy1.makeConsistent(null); - workingCopy2 = getCompilationUnit("/P2/p2/Y.java").getWorkingCopy(owner, null/*no problem requestor*/, null/*no progress monitor*/); + workingCopy2 = getCompilationUnit("/P2/p2/Y.java").getWorkingCopy(owner, null/*no progress monitor*/); workingCopy2.getBuffer().setContents( "package p2;\n" + "import p1.X;\n" + Index: src/org/eclipse/jdt/core/tests/model/ReconcilerTests.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ReconcilerTests.java,v retrieving revision 1.113 diff -u -r1.113 ReconcilerTests.java --- src/org/eclipse/jdt/core/tests/model/ReconcilerTests.java 6 Mar 2007 04:43:20 -0000 1.113 +++ src/org/eclipse/jdt/core/tests/model/ReconcilerTests.java 13 Mar 2007 16:19:29 -0000 @@ -37,10 +37,10 @@ import org.eclipse.jdt.internal.core.search.indexing.IndexManager; public class ReconcilerTests extends ModifyingResourceTests { - + protected ICompilationUnit workingCopy; protected ProblemRequestor problemRequestor; - + /* A problem requestor that auto-cancels on first problem */ class CancelingProblemRequestor extends ProblemRequestor { IProgressMonitor progressMonitor = new IProgressMonitor() { @@ -58,14 +58,14 @@ public void subTask(String name) {} public void worked(int work) {} }; - + boolean isCanceling = false; public void acceptProblem(IProblem problem) { - if (isCanceling) this.progressMonitor.setCanceled(true); // auto-cancel on first problem + if (this.isCanceling) this.progressMonitor.setCanceled(true); // auto-cancel on first problem super.acceptProblem(problem); - } + } } - + class ReconcileParticipant extends CompilationParticipant { IJavaElementDelta delta; org.eclipse.jdt.core.dom.CompilationUnit ast; @@ -134,7 +134,7 @@ System.arraycopy(oldClasspath, 0, newClasspath, 0, oldLength); System.arraycopy(entries, 0, newClasspath, oldLength, length); project.setRawClasspath(newClasspath, null); - + if (enableForbiddenReferences) { project.setOption(JavaCore.COMPILER_PB_FORBIDDEN_REFERENCE, JavaCore.ERROR); } @@ -154,7 +154,12 @@ public void setUp() throws Exception { super.setUp(); this.problemRequestor = new ProblemRequestor(); - this.workingCopy = getCompilationUnit("Reconciler/src/p1/X.java").getWorkingCopy(new WorkingCopyOwner() {}, this.problemRequestor, null); + this.wcOwner = new WorkingCopyOwner() { + public IProblemRequestor getProblemRequestor(ICompilationUnit unit) { + return ReconcilerTests.this.problemRequestor; + } + }; + this.workingCopy = getCompilationUnit("Reconciler/src/p1/X.java").getWorkingCopy(this.wcOwner, null); this.problemRequestor.initialize(this.workingCopy.getSource().toCharArray()); startDeltas(); } @@ -166,7 +171,7 @@ createFolder("/Reconciler/src/p1"); createFolder("/Reconciler/src/p2"); createFile( - "/Reconciler/src/p1/X.java", + "/Reconciler/src/p1/X.java", "package p1;\n" + "import p2.*;\n" + "public class X {\n" + @@ -181,9 +186,9 @@ // Create project with 1.5 compliance IJavaProject project15 = createJavaProject("Reconciler15", new String[] {"src"}, new String[] {"JCL15_LIB"}, "bin", "1.5"); addLibrary( - project15, - "lib15.jar", - "lib15src.zip", + project15, + "lib15.jar", + "lib15src.zip", new String[] { "java/util/List.java", "package java.util;\n" + @@ -210,25 +215,26 @@ "public @interface SuppressWarnings {\n" + " String[] value();\n" + "}" - }, + }, JavaCore.VERSION_1_5 ); project15.setOption(JavaCore.COMPILER_PB_UNUSED_LOCAL, JavaCore.IGNORE); project15.setOption(JavaCore.COMPILER_PB_RAW_TYPE_REFERENCE, JavaCore.IGNORE); } private void setUp15WorkingCopy() throws JavaModelException { - setUp15WorkingCopy("Reconciler15/src/p1/X.java", new WorkingCopyOwner() {}); + setUp15WorkingCopy("Reconciler15/src/p1/X.java", this.wcOwner); } private void setUp15WorkingCopy(String path, WorkingCopyOwner owner) throws JavaModelException { String contents = this.workingCopy.getSource(); setUpWorkingCopy(path, contents, owner); } private void setUpWorkingCopy(String path, String contents) throws JavaModelException { - setUpWorkingCopy(path, contents, new WorkingCopyOwner() {}); + setUpWorkingCopy(path, contents, this.wcOwner); } private void setUpWorkingCopy(String path, String contents, WorkingCopyOwner owner) throws JavaModelException { this.workingCopy.discardWorkingCopy(); - this.workingCopy = getCompilationUnit(path).getWorkingCopy(owner, this.problemRequestor, null); + this.workingCopy = getCompilationUnit(path).getWorkingCopy(owner, null); + assertEquals("Invalid problem requestor!", this.problemRequestor, this.wcOwner.getProblemRequestor(this.workingCopy)); setWorkingCopyContents(contents); this.workingCopy.makeConsistent(null); } @@ -260,12 +266,12 @@ createJavaProject("P1", new String[] {"src"}, new String[] {"JCL_LIB"}, null, null, new String[0], null, null, new boolean[0], "bin", null, new String[][] {{"**/X.java"}}, null, "1.4"); createFolder("/P1/src/p"); createFile("/P1/src/p/X.java", "package p; public class X {}"); - + createJavaProject("P2", new String[] {"src"}, new String[] {"JCL_LIB"}, new String[] {"/P1"}, "bin"); setUpWorkingCopy("/P2/src/Y.java", "public class Y extends p.X {}"); assertProblems( - "Unexpected problems", - "----------\n" + + "Unexpected problems", + "----------\n" + "----------\n" ); } finally { @@ -299,8 +305,8 @@ createJavaProject("P2", new String[] {"src"}, new String[] {"JCL_LIB"}, new String[] {"/P1"}, "bin"); setUpWorkingCopy("/P2/src/Y.java", "public class Y extends p.X {}"); assertProblems( - "Unexpected problems", - "----------\n" + + "Unexpected problems", + "----------\n" + "----------\n" ); } finally { @@ -317,14 +323,14 @@ createJavaProject("P1"); createFolder("/P1/p"); createFile("/P1/p/X.java", "package p; public class X {}"); - + createJavaProject("P2", new String[] {}, new String[] {}, null, null, new String[] {"/P1"}, null, null, new boolean[] {true}, "", null, null, null, "1.4"); - + createJavaProject("P3", new String[] {"src"}, new String[] {"JCL_LIB"}, null, null, new String[] {"/P2"}, null, new String[][] {new String[] {"**/X"}}, false/*don't combine access restrictions*/, new boolean[] {true}, "bin", null, null, null, "1.4"); setUpWorkingCopy("/P3/src/Y.java", "public class Y extends p.X {}"); assertProblems( - "Unexpected problems", - "----------\n" + + "Unexpected problems", + "----------\n" + "----------\n" ); } finally { @@ -340,18 +346,18 @@ createJavaProject("P1"); createFolder("/P1/p"); createFile("/P1/p/X.java", "package p; public class X {}"); - + createJavaProject("P2", new String[] {}, new String[] {}, null, null, new String[] {"/P1"}, null, null, new boolean[] {true}, "", null, null, null, "1.4"); - + createJavaProject("P3", new String[] {"src"}, new String[] {"JCL_LIB"}, null, null, new String[] {"/P2"}, null, new String[][] {new String[] {"**/X"}}, true/*combine access restrictions*/, new boolean[] {true}, "bin", null, null, null, "1.4"); setUpWorkingCopy("/P3/src/Y.java", "public class Y extends p.X {}"); assertProblems( - "Unexpected problems", - "----------\n" + - "1. ERROR in /P3/src/Y.java (at line 1)\n" + - " public class Y extends p.X {}\n" + - " ^^^\n" + - "Access restriction: The type X is not accessible due to restriction on required project P1\n" + + "Unexpected problems", + "----------\n" + + "1. ERROR in /P3/src/Y.java (at line 1)\n" + + " public class Y extends p.X {}\n" + + " ^^^\n" + + "Access restriction: The type X is not accessible due to restriction on required project P1\n" + "----------\n" ); } finally { @@ -366,7 +372,7 @@ try { createJavaProject("P1"); createFolder("/P1/p"); - createFile("/P1/p/X.java", "package p; public class X {}"); + createFile("/P1/p/X.java", "package p; public class X {}"); IJavaProject p2 = createJavaProject("P2", new String[] {"src"}, new String[] {"JCL_LIB"}, "bin"); IClasspathEntry[] classpath = p2.getRawClasspath(); int length = classpath.length; @@ -375,11 +381,11 @@ p2.setRawClasspath(classpath, null); setUpWorkingCopy("/P2/src/Y.java", "public class Y extends p.X {}"); assertProblems( - "Unexpected problems", - "----------\n" + + "Unexpected problems", + "----------\n" + "----------\n" ); - + // remove accessible rule System.arraycopy(classpath, 0, classpath = new IClasspathEntry[length+1], 0, length); classpath[length] = createSourceEntry("P2", "/P1", "-**/*"); @@ -387,12 +393,12 @@ this.problemRequestor.initialize(this.workingCopy.getSource().toCharArray()); this.workingCopy.reconcile(ICompilationUnit.NO_AST, true/*force problem detection*/, null, null); assertProblems( - "Unexpected problems", - "----------\n" + - "1. ERROR in /P2/src/Y.java (at line 1)\n" + - " public class Y extends p.X {}\n" + - " ^^^\n" + - "Access restriction: The type X is not accessible due to restriction on required project P1\n" + + "Unexpected problems", + "----------\n" + + "1. ERROR in /P2/src/Y.java (at line 1)\n" + + " public class Y extends p.X {}\n" + + " ^^^\n" + + "Access restriction: The type X is not accessible due to restriction on required project P1\n" + "----------\n" ); @@ -415,8 +421,8 @@ "}"); this.workingCopy.reconcile(ICompilationUnit.NO_AST, false, null, null); assertDeltas( - "Unexpected delta", - "X[*]: {CHILDREN | FINE GRAINED}\n" + + "Unexpected delta", + "X[*]: {CHILDREN | FINE GRAINED}\n" + " foo()#2[+]: {}" ); } @@ -440,9 +446,9 @@ "}"); this.workingCopy.reconcile(ICompilationUnit.NO_AST, false, null, null); assertDeltas( - "Unexpected delta", - "X[*]: {CHILDREN | FINE GRAINED}\n" + - " X(int)[+]: {}\n" + + "Unexpected delta", + "X[*]: {CHILDREN | FINE GRAINED}\n" + + " X(int)[+]: {}\n" + " i[+]: {}" ); } @@ -464,7 +470,7 @@ "}"); this.workingCopy.reconcile(ICompilationUnit.NO_AST, false, null, null); assertDeltas( - "Unexpected delta", + "Unexpected delta", "[*]: {CHILDREN | FINE GRAINED}\n" + " import java.lang.reflect.*[+]: {}\n" + " import java.util.Vector[+]: {}" @@ -488,7 +494,7 @@ "}"); this.workingCopy.reconcile(ICompilationUnit.NO_AST, false, null, null); assertDeltas( - "Unexpected delta", + "Unexpected delta", "X[*]: {CHILDREN | FINE GRAINED}\n" + " bar()[+]: {}" ); @@ -510,8 +516,8 @@ "}"); this.workingCopy.reconcile(ICompilationUnit.NO_AST, false, null, null); assertDeltas( - "Unexpected delta", - "X[*]: {CHILDREN | FINE GRAINED}\n" + + "Unexpected delta", + "X[*]: {CHILDREN | FINE GRAINED}\n" + " some()[+]: {}" ); } @@ -533,7 +539,7 @@ " }\n" + "}"); this.workingCopy.reconcile(ICompilationUnit.NO_AST, false, null, null); - + // Add { on partial method clearDeltas(); setWorkingCopyContents( @@ -546,7 +552,7 @@ "}"); this.workingCopy.reconcile(ICompilationUnit.NO_AST, false, null, null); assertDeltas( - "Unexpected delta", + "Unexpected delta", "[Working copy] X.java[*]: {CONTENT | FINE GRAINED}" ); } @@ -562,10 +568,10 @@ "}"); this.workingCopy.reconcile(AST.JLS3, false/*don't force problem detection*/, null/*primary owner*/, null/*no progress*/); assertASTNodeEquals( - "Unexpected ast", - "package p1;\n" + - "import p2.*;\n" + - "public class X {\n" + + "Unexpected ast", + "package p1;\n" + + "import p2.*;\n" + + "public class X {\n" + "}\n", this.deltaListener.getCompilationUnitAST(this.workingCopy)); } @@ -576,12 +582,12 @@ public void testBroadcastAST2() throws JavaModelException { this.workingCopy.reconcile(AST.JLS3, true/*force problem detection*/, null/*primary owner*/, null/*no progress*/); assertASTNodeEquals( - "Unexpected ast", - "package p1;\n" + - "import p2.*;\n" + - "public class X {\n" + - " public void foo(){\n" + - " }\n" + + "Unexpected ast", + "package p1;\n" + + "import p2.*;\n" + + "public class X {\n" + + " public void foo(){\n" + + " }\n" + "}\n", this.deltaListener.getCompilationUnitAST(this.workingCopy)); } @@ -592,12 +598,12 @@ public void testBroadcastAST3() throws JavaModelException { this.workingCopy.reconcile(AST.JLS3, false/*don't force problem detection*/, null/*primary owner*/, null/*no progress*/); assertASTNodeEquals( - "Unexpected ast", - "package p1;\n" + - "import p2.*;\n" + - "public class X {\n" + - " public void foo(){\n" + - " }\n" + + "Unexpected ast", + "package p1;\n" + + "import p2.*;\n" + + "public class X {\n" + + " public void foo(){\n" + + " }\n" + "}\n", this.deltaListener.getCompilationUnitAST(this.workingCopy)); } @@ -615,15 +621,15 @@ "import p2.*;\n" + "public class X {\n" + "}"); - ReconcilerTests.this.workingCopy.reconcile(AST.JLS3, false/*don't force problem detection*/, null/*primary owner*/, monitor); + ReconcilerTests.this.workingCopy.reconcile(AST.JLS3, false/*don't force problem detection*/, null/*primary owner*/, monitor); } }, null/*no progress*/); assertASTNodeEquals( - "Unexpected ast", - "package p1;\n" + - "import p2.*;\n" + - "public class X {\n" + + "Unexpected ast", + "package p1;\n" + + "import p2.*;\n" + + "public class X {\n" + "}\n", this.deltaListener.getCompilationUnitAST(this.workingCopy)); } @@ -666,11 +672,11 @@ "}" ); this.workingCopy.makeConsistent(null); - + // count the number of time isCanceled() is called when converting this source unit CancelCounter counter = new CancelCounter(); this.workingCopy.reconcile(AST.JLS2, true, null, counter); - + // throw an OperatonCanceledException at each point isCanceled() is called for (int i = 0; i < counter.count; i++) { boolean gotException = false; @@ -681,7 +687,7 @@ } assertTrue("Should get an OperationCanceledException (" + i + ")", gotException); } - + // last should not throw an OperationCanceledException this.workingCopy.reconcile(AST.JLS2, true, null, new Canceler(counter.count)); } @@ -702,8 +708,8 @@ ); this.workingCopy.reconcile(ICompilationUnit.NO_AST, false, null, null); assertDeltas( - "Unexpected delta", - "X[*]: {CHILDREN | FINE GRAINED}\n" + + "Unexpected delta", + "X[*]: {CHILDREN | FINE GRAINED}\n" + " foo()[*]: {CATEGORIES}" ); } @@ -723,7 +729,7 @@ "}" ); this.workingCopy.makeConsistent(null); - + setWorkingCopyContents( "package p1;\n" + "import p2.*;\n" + @@ -734,8 +740,8 @@ ); this.workingCopy.reconcile(ICompilationUnit.NO_AST, false, null, null); assertDeltas( - "Unexpected delta", - "X[*]: {CHILDREN | FINE GRAINED}\n" + + "Unexpected delta", + "X[*]: {CHILDREN | FINE GRAINED}\n" + " foo()[*]: {CATEGORIES}" ); } @@ -755,7 +761,7 @@ "}" ); this.workingCopy.makeConsistent(null); - + setWorkingCopyContents( "package p1;\n" + "import p2.*;\n" + @@ -769,8 +775,8 @@ ); this.workingCopy.reconcile(ICompilationUnit.NO_AST, false, null, null); assertDeltas( - "Unexpected delta", - "X[*]: {CHILDREN | FINE GRAINED}\n" + + "Unexpected delta", + "X[*]: {CHILDREN | FINE GRAINED}\n" + " foo()[*]: {CATEGORIES}" ); } @@ -791,7 +797,7 @@ "}" ); this.workingCopy.makeConsistent(null); - + setWorkingCopyContents( "package p1;\n" + "import p2.*;\n" + @@ -805,11 +811,11 @@ " */\n" + " int f2;\n" + "}" - ); + ); this.workingCopy.reconcile(ICompilationUnit.NO_AST, false, null, null); assertDeltas( - "Unexpected delta", - "X[*]: {CHILDREN | FINE GRAINED}\n" + + "Unexpected delta", + "X[*]: {CHILDREN | FINE GRAINED}\n" + " f2[*]: {CATEGORIES}" ); } @@ -830,7 +836,7 @@ "}" }, jarPath, "1.4"); addLibraryEntry(project, jarPath, false); - + // force Y.class file to be cached during resolution setWorkingCopyContents( "package p1;\n" + @@ -840,7 +846,7 @@ " }\n" + "}"); this.workingCopy.reconcile(ICompilationUnit.NO_AST, false, null, null); - + // change jar and refresh org.eclipse.jdt.core.tests.util.Util.createJar(new String[] { "p/Y.java", @@ -851,7 +857,7 @@ "}" }, jarPath, "1.4"); getJavaModel().refreshExternalArchives(null,null); - + setWorkingCopyContents( "package p1;\n" + "public class X extends p.Y {\n" + @@ -861,8 +867,8 @@ "}"); this.workingCopy.reconcile(ICompilationUnit.NO_AST, false, null, null); assertProblems( - "Unexpected problems", - "----------\n" + + "Unexpected problems", + "----------\n" + "----------\n" ); } finally { @@ -881,8 +887,8 @@ try { String[] pathAndContents = new String[] { "test/before/Foo.java", - "package test.before;\n" + - "public class Foo {\n" + + "package test.before;\n" + + "public class Foo {\n" + "}\n" }; addLibrary(project, jarName, "b162621_src.zip", pathAndContents, JavaCore.VERSION_1_4); @@ -897,48 +903,48 @@ // Set working copy content with no error setUpWorkingCopy("/Reconciler/src/test/Test.java", - "package test;\n" + - "import test.before.Foo;\n" + - "public class Test {\n" + - " Foo f;\n" + + "package test;\n" + + "import test.before.Foo;\n" + + "public class Test {\n" + + " Foo f;\n" + "}\n" ); assertProblems( - "Unexpected problems", - "----------\n" + + "Unexpected problems", + "----------\n" + "----------\n" ); // Update working copy with Jar expected changes - String contents = "package test;\n" + - "import test.after.Foo;\n" + - "public class Test {\n" + - " Foo f;\n" + + String contents = "package test;\n" + + "import test.after.Foo;\n" + + "public class Test {\n" + + " Foo f;\n" + "}\n"; setWorkingCopyContents(contents); this.workingCopy.reconcile(ICompilationUnit.NO_AST, true, null, null); assertProblems( - "Wrong expected problems", - "----------\n" + - "1. ERROR in /Reconciler/src/test/Test.java (at line 2)\n" + - " import test.after.Foo;\n" + - " ^^^^^^^^^^\n" + - "The import test.after cannot be resolved\n" + - "----------\n" + - "2. ERROR in /Reconciler/src/test/Test.java (at line 4)\n" + - " Foo f;\n" + - " ^^^\n" + - "Foo cannot be resolved to a type\n" + + "Wrong expected problems", + "----------\n" + + "1. ERROR in /Reconciler/src/test/Test.java (at line 2)\n" + + " import test.after.Foo;\n" + + " ^^^^^^^^^^\n" + + "The import test.after cannot be resolved\n" + + "----------\n" + + "2. ERROR in /Reconciler/src/test/Test.java (at line 4)\n" + + " Foo f;\n" + + " ^^^\n" + + "Foo cannot be resolved to a type\n" + "----------\n" ); - + // change jar and refresh String projectLocation = project.getProject().getLocation().toOSString(); String jarPath = projectLocation + File.separator + jarName; org.eclipse.jdt.core.tests.util.Util.createJar(new String[] { "test/after/Foo.java", - "package test.after;\n" + - "public class Foo {\n" + + "package test.after;\n" + + "public class Foo {\n" + "}\n" }, jarPath, "1.4"); project.getProject().refreshLocal(IResource.DEPTH_INFINITE, null); @@ -954,8 +960,8 @@ this.problemRequestor.initialize(contents.toCharArray()); this.workingCopy.reconcile(ICompilationUnit.NO_AST, true, null, null); assertProblems( - "Unexpected problems", - "----------\n" + + "Unexpected problems", + "----------\n" + "----------\n" ); } finally { @@ -981,7 +987,7 @@ "}"); this.workingCopy.reconcile(ICompilationUnit.NO_AST, false, null, null); assertDeltas( - "Unexpected delta", + "Unexpected delta", "X[*]: {CHILDREN | FINE GRAINED}\n" + " foo()[*]: {CONTENT}" ); @@ -1004,7 +1010,7 @@ "}"); this.workingCopy.reconcile(ICompilationUnit.NO_AST, false, null, null); assertDeltas( - "Unexpected delta", + "Unexpected delta", "X[*]: {CONTENT}" ); } @@ -1024,7 +1030,7 @@ "}"); this.workingCopy.reconcile(ICompilationUnit.NO_AST, false, null, null); assertDeltas( - "Unexpected delta", + "Unexpected delta", "X[*]: {CHILDREN | FINE GRAINED}\n" + " foo()[*]: {MODIFIERS CHANGED}" ); @@ -1046,7 +1052,7 @@ "}"); this.workingCopy.reconcile(ICompilationUnit.NO_AST, false, null, null); assertDeltas( - "Unexpected delta", + "Unexpected delta", "X[*]: {CHILDREN | FINE GRAINED}\n" + " bar()[+]: {}" ); @@ -1078,7 +1084,7 @@ this.workingCopy.reconcile(ICompilationUnit.NO_AST, false, null, null); assertProblems( "Unexpected problems", - "----------\n" + + "----------\n" + "----------\n" ); } finally { @@ -1092,17 +1098,16 @@ public void testConvertPrimitiveTypeArrayTypeArgument() throws CoreException { ICompilationUnit otherCopy = null; try { - WorkingCopyOwner owner = new WorkingCopyOwner() {}; otherCopy = getWorkingCopy( - "Reconciler15/src/Y.java", + "Reconciler15/src/Y.java", "public class Y {\n" + " void foo(Z z) {}\n" + "}\n" + "class Z {\n" + "}", - owner, - false/*don't compute problems*/); - setUp15WorkingCopy("/Reconciler15/src/X.java", owner); + this.wcOwner + ); + setUp15WorkingCopy("/Reconciler15/src/X.java", this.wcOwner); setWorkingCopyContents( "public class X {\n" + " void bar(Y y) {\n" + @@ -1110,10 +1115,10 @@ " }\n" + "}" ); - this.workingCopy.reconcile(ICompilationUnit.NO_AST, false, owner, null); + this.workingCopy.reconcile(ICompilationUnit.NO_AST, false, this.wcOwner, null); assertProblems( "Unexpected problems", - "----------\n" + + "----------\n" + "----------\n" ); } finally { @@ -1135,7 +1140,7 @@ "}"); this.workingCopy.reconcile(ICompilationUnit.NO_AST, false, null, null); assertDeltas( - "Unexpected delta", + "Unexpected delta", "X[*]: {CHILDREN | FINE GRAINED}\n" + " foo()[-]: {}" ); @@ -1158,7 +1163,7 @@ " }\n" + "}"); this.workingCopy.reconcile(ICompilationUnit.NO_AST, false, null, null); - + // delete the 2 methods clearDeltas(); setWorkingCopyContents( @@ -1168,7 +1173,7 @@ "}"); this.workingCopy.reconcile(ICompilationUnit.NO_AST, false, null, null); assertDeltas( - "Unexpected delta", + "Unexpected delta", "X[*]: {CHILDREN | FINE GRAINED}\n" + " bar()[-]: {}\n" + " foo()[-]: {}" @@ -1197,11 +1202,11 @@ this.workingCopy.reconcile(ICompilationUnit.NO_AST, false, null, null); assertProblems( "Unexpected problems", - "----------\n" + - "1. ERROR in /Reconciler/src/p1/X.java (at line 2)\n" + - " public class X extends p.internal.Y {\n" + - " ^^^^^^^^^^^^\n" + - "Access restriction: The type Y is not accessible due to restriction on required project P\n" + + "----------\n" + + "1. ERROR in /Reconciler/src/p1/X.java (at line 2)\n" + + " public class X extends p.internal.Y {\n" + + " ^^^^^^^^^^^^\n" + + "Access restriction: The type Y is not accessible due to restriction on required project P\n" + "----------\n" ); } finally { @@ -1232,7 +1237,7 @@ this.workingCopy.reconcile(ICompilationUnit.NO_AST, false, null, null); assertProblems( "Unexpected problems", - "----------\n" + + "----------\n" + "----------\n" ); } finally { @@ -1259,7 +1264,7 @@ assertProblems( "Unexpected problems", - "----------\n" + + "----------\n" + "----------\n" ); } @@ -1322,7 +1327,7 @@ this.workingCopy.reconcile(ICompilationUnit.NO_AST, false, null, null); assertProblems( "Unexpected problems", - "----------\n" + + "----------\n" + "----------\n" ); } finally { @@ -1353,11 +1358,11 @@ this.workingCopy.reconcile(ICompilationUnit.NO_AST, false, null, null); assertProblems( "Unexpected problems", - "----------\n" + - "1. ERROR in /Reconciler/src/p1/X.java (at line 2)\n" + - " public class X extends p.internal.Y {\n" + - " ^^^^^^^^^^^^\n" + - "Access restriction: The type Y is not accessible due to restriction on required project P\n" + + "----------\n" + + "1. ERROR in /Reconciler/src/p1/X.java (at line 2)\n" + + " public class X extends p.internal.Y {\n" + + " ^^^^^^^^^^^^\n" + + "Access restriction: The type Y is not accessible due to restriction on required project P\n" + "----------\n" ); } finally { @@ -1375,7 +1380,7 @@ "public class X {\n" + "}"); this.workingCopy.reconcile(ICompilationUnit.NO_AST, false, null, null); - + // add an import clearDeltas(); setWorkingCopyContents( @@ -1385,10 +1390,10 @@ "}"); this.workingCopy.reconcile(ICompilationUnit.NO_AST, false, null, null); assertDeltas( - "Unexpected delta", + "Unexpected delta", "[+]: {}" ); - + // append to import name clearDeltas(); setWorkingCopyContents( @@ -1398,9 +1403,9 @@ "}"); this.workingCopy.reconcile(ICompilationUnit.NO_AST, false, null, null); assertDeltas( - "Unexpected delta", - "[*]: {CHILDREN | FINE GRAINED}\n" + - " import p[-]: {}\n" + + "Unexpected delta", + "[*]: {CHILDREN | FINE GRAINED}\n" + + " import p[-]: {}\n" + " import p2[+]: {}" ); } @@ -1437,7 +1442,7 @@ this.workingCopy.reconcile(ICompilationUnit.NO_AST, false, null, null); assertProblems( "Unexpected problems", - "----------\n" + + "----------\n" + "----------\n" ); } finally { @@ -1478,11 +1483,11 @@ this.workingCopy.reconcile(ICompilationUnit.NO_AST, false, null, null); assertProblems( "Unexpected problems", - "----------\n" + - "1. WARNING in /Reconciler/src/p1/X.java (at line 2)\n" + - " public class X extends p.internal.Y {\n" + - " ^^^^^^^^^^^^\n" + - "Discouraged access: The type Y is not accessible due to restriction on required project P2\n" + + "----------\n" + + "1. WARNING in /Reconciler/src/p1/X.java (at line 2)\n" + + " public class X extends p.internal.Y {\n" + + " ^^^^^^^^^^^^\n" + + "Discouraged access: The type Y is not accessible due to restriction on required project P2\n" + "----------\n" ); } finally { @@ -1523,11 +1528,11 @@ this.workingCopy.reconcile(ICompilationUnit.NO_AST, false, null, null); assertProblems( "Unexpected problems", - "----------\n" + - "1. ERROR in /Reconciler/src/p1/X.java (at line 2)\n" + - " public class X extends p.internal.Y {\n" + - " ^^^^^^^^^^^^\n" + - "Access restriction: The type Y is not accessible due to restriction on required project P1\n" + + "----------\n" + + "1. ERROR in /Reconciler/src/p1/X.java (at line 2)\n" + + " public class X extends p.internal.Y {\n" + + " ^^^^^^^^^^^^\n" + + "Access restriction: The type Y is not accessible due to restriction on required project P1\n" + "----------\n" ); } finally { @@ -1560,11 +1565,11 @@ this.workingCopy.reconcile(ICompilationUnit.NO_AST, false, null, null); assertProblems( "Unexpected problems", - "----------\n" + - "1. ERROR in /Reconciler/src/p1/X.java (at line 2)\n" + - " public class X extends p.internal.Y {\n" + - " ^^^^^^^^^^^^\n" + - "Access restriction: The type Y is not accessible due to restriction on required project P1\n" + + "----------\n" + + "1. ERROR in /Reconciler/src/p1/X.java (at line 2)\n" + + " public class X extends p.internal.Y {\n" + + " ^^^^^^^^^^^^\n" + + "Access restriction: The type Y is not accessible due to restriction on required project P1\n" + "----------\n" ); } finally { @@ -1586,17 +1591,17 @@ "}"); this.workingCopy.reconcile(ICompilationUnit.NO_AST, false, null, null); assertDeltas( - "Unexpected delta after syntax error", + "Unexpected delta after syntax error", "X[*]: {CHILDREN | FINE GRAINED}\n" + " foo()[*]: {MODIFIERS CHANGED}" ); assertProblems( "Unexpected problems", - "----------\n" + - "1. ERROR in /Reconciler/src/p1/X.java (at line 4)\n" + - " public.void foo() {\n" + - " ^\n" + - "Syntax error on token \".\", delete this token\n" + + "----------\n" + + "1. ERROR in /Reconciler/src/p1/X.java (at line 4)\n" + + " public.void foo() {\n" + + " ^\n" + + "Syntax error on token \".\", delete this token\n" + "----------\n" ); @@ -1612,17 +1617,17 @@ setWorkingCopyContents(contents); this.workingCopy.reconcile(ICompilationUnit.NO_AST, false, null, null); assertDeltas( - "Unexpected delta after fixing syntax error", + "Unexpected delta after fixing syntax error", "X[*]: {CHILDREN | FINE GRAINED}\n" + " foo()[*]: {MODIFIERS CHANGED}" ); assertProblems( "Unexpected problems", - "----------\n" + - "1. WARNING in /Reconciler/src/p1/X.java (at line 2)\n" + - " import p2.*;\n" + - " ^^\n" + - "The import p2 is never used\n" + + "----------\n" + + "1. WARNING in /Reconciler/src/p1/X.java (at line 2)\n" + + " import p2.*;\n" + + " ^^\n" + + "The import p2 is never used\n" + "----------\n" ); } @@ -1636,20 +1641,20 @@ "public class X {\n" + " public.void foo() {\n" + " }\n" + - "}"; + "}"; setWorkingCopyContents(contents); this.workingCopy.reconcile(ICompilationUnit.NO_AST, false, null, null); - // use force flag to refresh problems + // use force flag to refresh problems this.problemRequestor.initialize(contents.toCharArray()); this.workingCopy.reconcile(ICompilationUnit.NO_AST, true, null, null); assertProblems( "Unexpected problems", - "----------\n" + - "1. ERROR in /Reconciler/src/p1/X.java (at line 4)\n" + - " public.void foo() {\n" + - " ^\n" + - "Syntax error on token \".\", delete this token\n" + + "----------\n" + + "1. ERROR in /Reconciler/src/p1/X.java (at line 4)\n" + + " public.void foo() {\n" + + " ^\n" + + "Syntax error on token \".\", delete this token\n" + "----------\n" ); } @@ -1682,11 +1687,11 @@ public void testMethodWithError04() throws CoreException { CancelingProblemRequestor myPbRequestor = new CancelingProblemRequestor(); - + this.workingCopy.discardWorkingCopy(); ICompilationUnit x = getCompilationUnit("Reconciler", "src", "p1", "X.java"); this.problemRequestor = myPbRequestor; - this.workingCopy = x.getWorkingCopy(new WorkingCopyOwner() {}, this.problemRequestor, null); + this.workingCopy = x.getWorkingCopy(this.wcOwner, null); String contents = "package p1;\n" + @@ -1699,17 +1704,17 @@ this.workingCopy.reconcile(ICompilationUnit.NO_AST, false, null, null); - // use force flag to refresh problems + // use force flag to refresh problems myPbRequestor.isCanceling = true; myPbRequestor.initialize(contents.toCharArray()); this.workingCopy.reconcile(ICompilationUnit.NO_AST, true, null, myPbRequestor.progressMonitor); assertProblems( "Unexpected problems", - "----------\n" + - "1. ERROR in /Reconciler/src/p1/X.java (at line 3)\n" + - " Zork f; \n" + - " ^^^^\n" + - "Zork cannot be resolved to a type\n" + + "----------\n" + + "1. ERROR in /Reconciler/src/p1/X.java (at line 3)\n" + + " Zork f; \n" + + " ^^^^\n" + + "Zork cannot be resolved to a type\n" + "----------\n" ); } @@ -1729,19 +1734,19 @@ " } \n"+ "} \n"; createFile( - "/Reconciler/src/tests/AbstractSearchableSource.java", + "/Reconciler/src/tests/AbstractSearchableSource.java", contents); - + createFile( - "/Reconciler/src/tests/Source.java", + "/Reconciler/src/tests/Source.java", "package tests; \n"+ "interface Source { \n"+ " long getValue(int index); \n"+ " int size(); \n"+ "} \n"); - + createFile( - "/Reconciler/src/tests/AbstractSource.java", + "/Reconciler/src/tests/AbstractSource.java", "package tests; \n"+ "abstract class AbstractSource implements Source { \n"+ " AbstractSource() { \n"+ @@ -1757,23 +1762,24 @@ " return 0; \n"+ " } \n"+ "} \n"); - + createFile( - "/Reconciler/src/tests/SearchableSource.java", + "/Reconciler/src/tests/SearchableSource.java", "package tests; \n"+ "interface SearchableSource extends Source { \n"+ " int indexOf(long value); \n"+ "} \n"); - + ICompilationUnit compilationUnit = getCompilationUnit("Reconciler", "src", "tests", "AbstractSearchableSource.java"); ProblemRequestor pbReq = new ProblemRequestor(); - ICompilationUnit wc = compilationUnit.getWorkingCopy(new WorkingCopyOwner() {}, pbReq, null); + WorkingCopyOwner owner = newWorkingCopyOwner(pbReq); + ICompilationUnit wc = compilationUnit.getWorkingCopy(owner, null); pbReq.initialize(contents.toCharArray()); startDeltas(); wc.reconcile(ICompilationUnit.NO_AST, true, null, null); String actual = pbReq.problems.toString(); - String expected = - "----------\n" + + String expected = + "----------\n" + "----------\n"; if (!expected.equals(actual)){ System.out.println(Util.displayString(actual, 2)); @@ -1805,19 +1811,19 @@ " }\n" + "}"; createFile( - "/Reconciler/src/p1/Y.java", + "/Reconciler/src/p1/Y.java", contents ); this.problemRequestor = new ProblemRequestor(); this.problemRequestor.initialize(contents.toCharArray()); - this.workingCopy = getCompilationUnit("Reconciler/src/p1/Y.java").getWorkingCopy(new WorkingCopyOwner() {}, this.problemRequestor, null); + this.workingCopy = getCompilationUnit("Reconciler/src/p1/Y.java").getWorkingCopy(this.wcOwner, null); assertProblems( "Unexpected problems", - "----------\n" + - "1. ERROR in /Reconciler/src/p1/Y.java (at line 3)\n" + - " public.void foo() {\n" + - " ^\n" + - "Syntax error on token \".\", delete this token\n" + + "----------\n" + + "1. ERROR in /Reconciler/src/p1/Y.java (at line 3)\n" + + " public.void foo() {\n" + + " ^\n" + + "Syntax error on token \".\", delete this token\n" + "----------\n" ); } finally { @@ -1839,26 +1845,26 @@ " }\n" + "}"; createFile( - "/Reconciler/src/p1/Y.java", + "/Reconciler/src/p1/Y.java", contents ); this.problemRequestor = new ProblemRequestor(); this.problemRequestor.initialize(contents.toCharArray()); - this.workingCopy = getCompilationUnit("Reconciler/src/p1/Y.java").getWorkingCopy(new WorkingCopyOwner() {}, this.problemRequestor, null); + this.workingCopy = getCompilationUnit("Reconciler/src/p1/Y.java").getWorkingCopy(this.wcOwner, null); // Close working copy - JavaModelManager.getJavaModelManager().removeInfoAndChildren((CompilationUnit)workingCopy); // use a back door as working copies cannot be closed - + JavaModelManager.getJavaModelManager().removeInfoAndChildren((CompilationUnit)this.workingCopy); // use a back door as working copies cannot be closed + // Reopen should detect syntax error this.problemRequestor.initialize(contents.toCharArray()); this.workingCopy.open(null); assertProblems( "Unexpected problems", - "----------\n" + - "1. ERROR in /Reconciler/src/p1/Y.java (at line 3)\n" + - " public.void foo() {\n" + - " ^\n" + - "Syntax error on token \".\", delete this token\n" + + "----------\n" + + "1. ERROR in /Reconciler/src/p1/Y.java (at line 3)\n" + + " public.void foo() {\n" + + " ^\n" + + "Syntax error on token \".\", delete this token\n" + "----------\n" ); } finally { @@ -1874,35 +1880,35 @@ this.workingCopy = null; try { createFile( - "/Reconciler/src/p1/X01.java", + "/Reconciler/src/p1/X01.java", "package p1;\n" + "public abstract class X01 {\n" + " public abstract void bar(); \n"+ " public abstract void foo(Zork z); \n"+ "}" ); - String contents = + String contents = "package p2;\n" + "public class X01 extends p1.X01 {\n" + " public void bar(){} \n"+ "}"; createFile( - "/Reconciler/src/p2/X01.java", + "/Reconciler/src/p2/X01.java", contents ); this.problemRequestor = new ProblemRequestor(); this.problemRequestor.initialize(contents.toCharArray()); - this.workingCopy = getCompilationUnit("Reconciler/src/p2/X01.java").getWorkingCopy(new WorkingCopyOwner() {}, this.problemRequestor, null); + this.workingCopy = getCompilationUnit("Reconciler/src/p2/X01.java").getWorkingCopy(this.wcOwner, null); // Close working copy - JavaModelManager.getJavaModelManager().removeInfoAndChildren((CompilationUnit)workingCopy); // use a back door as working copies cannot be closed - + JavaModelManager.getJavaModelManager().removeInfoAndChildren((CompilationUnit)this.workingCopy); // use a back door as working copies cannot be closed + // Reopen should detect syntax error this.problemRequestor.initialize(contents.toCharArray()); this.workingCopy.open(null); assertProblems( "Unexpected problems", - "----------\n" + + "----------\n" + "----------\n" // shouldn't report problem against p2.X01 ); } finally { @@ -1916,10 +1922,9 @@ public void testMethodWithError09() throws CoreException { this.workingCopy.discardWorkingCopy(); // don't use the one created in setUp() this.workingCopy = null; - WorkingCopyOwner owner = new WorkingCopyOwner() {}; ICompilationUnit workingCopy1 = null; try { - workingCopy1 = getCompilationUnit("/Reconciler/src/p1/X1.java").getWorkingCopy(owner, null, null); + workingCopy1 = getCompilationUnit("/Reconciler/src/p1/X1.java").getWorkingCopy(this.wcOwner, null); workingCopy1.getBuffer().setContents( "package p1;\n" + "public abstract class X1 {\n" + @@ -1927,20 +1932,20 @@ "}" ); workingCopy1.makeConsistent(null); - + this.problemRequestor = new ProblemRequestor(); - this.workingCopy = getCompilationUnit("Reconciler/src/p/X.java").getWorkingCopy(owner, this.problemRequestor, null); + this.workingCopy = getCompilationUnit("Reconciler/src/p/X.java").getWorkingCopy(this.wcOwner, null); setWorkingCopyContents( "package p;\n" + "public class X extends p1.X1 {\n" + " public void bar(){} \n"+ "}" ); - this.workingCopy.reconcile(ICompilationUnit.NO_AST, false, owner, null); + this.workingCopy.reconcile(ICompilationUnit.NO_AST, false, this.wcOwner, null); assertProblems( "Unexpected problems", - "----------\n" + + "----------\n" + "----------\n" // shouldn't report problem against p.X ); } finally { @@ -1955,11 +1960,10 @@ public void testMethodWithError10() throws CoreException { this.workingCopy.discardWorkingCopy(); // don't use the one created in setUp() this.workingCopy = null; - WorkingCopyOwner owner = new WorkingCopyOwner() {}; ICompilationUnit workingCopy1 = null; try { createFolder("/Reconciler15/src/test/cheetah"); - workingCopy1 = getCompilationUnit("/Reconciler15/src/test/cheetah/NestedGenerics.java").getWorkingCopy(owner, null, null); + workingCopy1 = getCompilationUnit("/Reconciler15/src/test/cheetah/NestedGenerics.java").getWorkingCopy(this.wcOwner, null); workingCopy1.getBuffer().setContents( "package test.cheetah;\n"+ "import java.util.List;\n"+ @@ -1969,9 +1973,9 @@ "}\n" ); workingCopy1.makeConsistent(null); - + this.problemRequestor = new ProblemRequestor(); - this.workingCopy = getCompilationUnit("Reconciler15/src/test/cheetah/NestedGenericsTest.java").getWorkingCopy(owner, this.problemRequestor, null); + this.workingCopy = getCompilationUnit("Reconciler15/src/test/cheetah/NestedGenericsTest.java").getWorkingCopy(this.wcOwner, null); setWorkingCopyContents( "package test.cheetah;\n"+ "import java.util.Stack;\n"+ @@ -1981,11 +1985,11 @@ " }\n"+ "}\n" ); - this.workingCopy.reconcile(ICompilationUnit.NO_AST, false, owner, null); + this.workingCopy.reconcile(ICompilationUnit.NO_AST, false, this.wcOwner, null); assertProblems( "Unexpected problems", - "----------\n" + + "----------\n" + "----------\n" ); } finally { @@ -2001,11 +2005,10 @@ public void testMethodWithError11() throws CoreException { this.workingCopy.discardWorkingCopy(); // don't use the one created in setUp() this.workingCopy = null; - WorkingCopyOwner owner = new WorkingCopyOwner() {}; ICompilationUnit workingCopy1 = null; try { createFolder("/Reconciler15/src/test/cheetah"); - workingCopy1 = getCompilationUnit("/Reconciler15/src/test/cheetah/NestedGenerics.java").getWorkingCopy(owner, null, null); + workingCopy1 = getCompilationUnit("/Reconciler15/src/test/cheetah/NestedGenerics.java").getWorkingCopy(this.wcOwner, null); workingCopy1.getBuffer().setContents( "package test.cheetah;\n"+ "import java.util.*;\n"+ @@ -2016,9 +2019,9 @@ "}\n" ); workingCopy1.makeConsistent(null); - + this.problemRequestor = new ProblemRequestor(); - this.workingCopy = getCompilationUnit("Reconciler15/src/test/cheetah/NestedGenericsTest.java").getWorkingCopy(owner, this.problemRequestor, null); + this.workingCopy = getCompilationUnit("Reconciler15/src/test/cheetah/NestedGenericsTest.java").getWorkingCopy(this.wcOwner, null); setWorkingCopyContents( "package test.cheetah;\n"+ "import java.util.*;\n"+ @@ -2030,11 +2033,11 @@ " }\n"+ "}\n" ); - this.workingCopy.reconcile(ICompilationUnit.NO_AST, false, owner, null); + this.workingCopy.reconcile(ICompilationUnit.NO_AST, false, this.wcOwner, null); assertProblems( "Unexpected problems", - "----------\n" + + "----------\n" + "----------\n" ); } finally { @@ -2050,11 +2053,10 @@ public void testMethodWithError12() throws CoreException { this.workingCopy.discardWorkingCopy(); // don't use the one created in setUp() this.workingCopy = null; - WorkingCopyOwner owner = new WorkingCopyOwner() {}; ICompilationUnit workingCopy1 = null; try { createFolder("/Reconciler15/src/test/cheetah"); - workingCopy1 = getCompilationUnit("/Reconciler15/src/test/cheetah/NestedGenerics.java").getWorkingCopy(owner, null, null); + workingCopy1 = getCompilationUnit("/Reconciler15/src/test/cheetah/NestedGenerics.java").getWorkingCopy(this.wcOwner, null); workingCopy1.getBuffer().setContents( "package test.cheetah;\n"+ "import java.util.*;\n"+ @@ -2065,9 +2067,9 @@ "}\n" ); workingCopy1.makeConsistent(null); - + this.problemRequestor = new ProblemRequestor(); - this.workingCopy = getCompilationUnit("Reconciler15/src/test/cheetah/NestedGenericsTest.java").getWorkingCopy(owner, this.problemRequestor, null); + this.workingCopy = getCompilationUnit("Reconciler15/src/test/cheetah/NestedGenericsTest.java").getWorkingCopy(this.wcOwner, null); setWorkingCopyContents( "package test.cheetah;\n"+ "import java.util.*;\n"+ @@ -2079,11 +2081,11 @@ " }\n"+ "}\n" ); - this.workingCopy.reconcile(ICompilationUnit.NO_AST, false, owner, null); + this.workingCopy.reconcile(ICompilationUnit.NO_AST, false, this.wcOwner, null); assertProblems( "Unexpected problems", - "----------\n" + + "----------\n" + "----------\n" ); } finally { @@ -2099,10 +2101,10 @@ public void testMethodWithError13() throws CoreException { this.workingCopy.discardWorkingCopy(); // don't use the one created in setUp() this.workingCopy = null; - WorkingCopyOwner owner = new WorkingCopyOwner() {}; ICompilationUnit workingCopy1 = null; + this.problemRequestor = null; try { - workingCopy1 = getCompilationUnit("/Reconciler15/src/test/X.java").getWorkingCopy(owner, null, null); + workingCopy1 = getCompilationUnit("/Reconciler15/src/test/X.java").getWorkingCopy(this.wcOwner, null); createFolder("/Reconciler15/src/test"); workingCopy1.getBuffer().setContents( "package test;\n"+ @@ -2115,9 +2117,9 @@ "}\n" ); workingCopy1.makeConsistent(null); - + this.problemRequestor = new ProblemRequestor(); - this.workingCopy = getCompilationUnit("Reconciler15/src/test/Y.java").getWorkingCopy(owner, this.problemRequestor, null); + this.workingCopy = getCompilationUnit("Reconciler15/src/test/Y.java").getWorkingCopy(this.wcOwner, null); setWorkingCopyContents( "package test;\n"+ "public class Y {\n"+ @@ -2127,15 +2129,15 @@ " }\n"+ "}\n" ); - this.workingCopy.reconcile(ICompilationUnit.NO_AST, false, owner, null); + this.workingCopy.reconcile(ICompilationUnit.NO_AST, false, this.wcOwner, null); assertProblems( "Unexpected problems", - "----------\n" + - "1. WARNING in /Reconciler15/src/test/Y.java (at line 5)\n" + - " someX.bar(null);\n" + - " ^^^^^^^^^^^^^^^\n" + - "Type safety: The method bar(Object[]) belongs to the raw type X. References to generic type X should be parameterized\n" + + "----------\n" + + "1. WARNING in /Reconciler15/src/test/Y.java (at line 5)\n" + + " someX.bar(null);\n" + + " ^^^^^^^^^^^^^^^\n" + + "Type safety: The method bar(Object[]) belongs to the raw type X. References to generic type X should be parameterized\n" + "----------\n" ); } finally { @@ -2151,10 +2153,9 @@ public void testMethodWithError14() throws CoreException { this.workingCopy.discardWorkingCopy(); // don't use the one created in setUp() this.workingCopy = null; - WorkingCopyOwner owner = new WorkingCopyOwner() {}; ICompilationUnit workingCopy1 = null; try { - workingCopy1 = getCompilationUnit("/Reconciler15/src/test/X.java").getWorkingCopy(owner, null, null); + workingCopy1 = getCompilationUnit("/Reconciler15/src/test/X.java").getWorkingCopy(this.wcOwner, null); createFolder("/Reconciler15/src/test"); workingCopy1.getBuffer().setContents( "package test;\n"+ @@ -2163,9 +2164,9 @@ "}\n" ); workingCopy1.makeConsistent(null); - + this.problemRequestor = new ProblemRequestor(); - this.workingCopy = getCompilationUnit("Reconciler15/src/test/Y.java").getWorkingCopy(owner, this.problemRequestor, null); + this.workingCopy = getCompilationUnit("Reconciler15/src/test/Y.java").getWorkingCopy(this.wcOwner, null); setWorkingCopyContents( "package test;\n"+ "public class Y {\n"+ @@ -2175,15 +2176,15 @@ " }\n"+ "}\n" ); - this.workingCopy.reconcile(ICompilationUnit.NO_AST, false, owner, null); + this.workingCopy.reconcile(ICompilationUnit.NO_AST, false, this.wcOwner, null); assertProblems( "Unexpected problems", - "----------\n" + - "1. ERROR in /Reconciler15/src/test/Y.java (at line 5)\n" + - " someX.bar();\n" + - " ^^^\n" + - "The method bar(Object) in the type X is not applicable for the arguments ()\n" + + "----------\n" + + "1. ERROR in /Reconciler15/src/test/Y.java (at line 5)\n" + + " someX.bar();\n" + + " ^^^\n" + + "The method bar(Object) in the type X is not applicable for the arguments ()\n" + "----------\n" ); } finally { @@ -2208,7 +2209,7 @@ "}"); this.workingCopy.reconcile(ICompilationUnit.NO_AST, false, null, null); clearDeltas(); - + setWorkingCopyContents( "package p1;\n" + "import p2.*;\n" + @@ -2220,9 +2221,9 @@ "}"); this.workingCopy.reconcile(ICompilationUnit.NO_AST, false, null, null); assertDeltas( - "Unexpected delta", - "X[*]: {CHILDREN | FINE GRAINED}\n" + - " bar()[*]: {REORDERED}\n" + + "Unexpected delta", + "X[*]: {CHILDREN | FINE GRAINED}\n" + + " bar()[*]: {REORDERED}\n" + " foo()[*]: {REORDERED}" ); } @@ -2265,15 +2266,14 @@ public void testRawUsage() throws CoreException { ICompilationUnit otherCopy = null; try { - WorkingCopyOwner owner = new WorkingCopyOwner() {}; otherCopy = getWorkingCopy( - "Reconciler15/src/Generic105756.java", + "Reconciler15/src/Generic105756.java", "public class Generic105756 {\n" + " void foo() {}\n" + "}", - owner, - false/*don't compute problems*/); - setUp15WorkingCopy("/Reconciler15/src/X.java", owner); + this.wcOwner + ); + setUp15WorkingCopy("/Reconciler15/src/X.java", this.wcOwner); setWorkingCopyContents( "public class X {\n" + " void bar(Generic105756 g) {\n" + @@ -2281,10 +2281,10 @@ " }\n" + "}" ); - this.workingCopy.reconcile(ICompilationUnit.NO_AST, false, owner, null); + this.workingCopy.reconcile(ICompilationUnit.NO_AST, false, this.wcOwner, null); assertProblems( "Unexpected problems", - "----------\n" + + "----------\n" + "----------\n" ); } finally { @@ -2309,9 +2309,9 @@ this.workingCopy.reconcile(ICompilationUnit.NO_AST, false, null, null); assertDeltas( "Unexpected participant delta", - "[Working copy] X.java[*]: {CHILDREN | FINE GRAINED}\n" + - " X[*]: {CHILDREN | FINE GRAINED}\n" + - " bar()[+]: {}\n" + + "[Working copy] X.java[*]: {CHILDREN | FINE GRAINED}\n" + + " X[*]: {CHILDREN | FINE GRAINED}\n" + + " bar()[+]: {}\n" + " foo()[-]: {}", participant.delta ); @@ -2358,11 +2358,11 @@ this.workingCopy.reconcile(ICompilationUnit.NO_AST, false, null, null); assertASTNodeEquals( "Unexpected participant delta", - "package p1;\n" + - "import p2.*;\n" + - "public class X {\n" + - " public void bar(){\n" + - " }\n" + + "package p1;\n" + + "import p2.*;\n" + + "public class X {\n" + + " public void bar(){\n" + + " }\n" + "}\n", participant.ast ); @@ -2419,7 +2419,7 @@ this.workingCopy.reconcile(ICompilationUnit.NO_AST, false, null, null); assertProblems( "Unexpected problems", - "----------\n" + + "----------\n" + "----------\n" ); } @@ -2454,11 +2454,11 @@ this.workingCopy.reconcile(ICompilationUnit.NO_AST, false, null, null); assertProblems( "Unexpected problems", - "----------\n" + - "1. ERROR in /Reconciler/src/p1/X.java (at line 4)\n" + - " toString()\n" + - " ^\n" + - "Syntax error, insert \";\" to complete BlockStatements\n" + + "----------\n" + + "1. ERROR in /Reconciler/src/p1/X.java (at line 4)\n" + + " toString()\n" + + " ^\n" + + "Syntax error, insert \";\" to complete BlockStatements\n" + "----------\n" ); } @@ -2499,7 +2499,7 @@ */ public void testReconcileParticipant08() throws CoreException { // set working copy contents and ensure it is consistent - String contents = + String contents = "package p1;\n" + "public class X {\n" + " public void bar() {\n" + @@ -2508,7 +2508,7 @@ setWorkingCopyContents(contents); this.workingCopy.makeConsistent(null); this.problemRequestor.initialize(contents.toCharArray()); - + // reconcile with a participant adding a list of problems new ReconcileParticipant() { public void reconcile(ReconcileContext context) { @@ -2539,8 +2539,8 @@ this.workingCopy.reconcile(ICompilationUnit.NO_AST, false, null, null); assertDeltas( "Unexpected delta", - "X[*]: {CHILDREN | FINE GRAINED}\n" + - " bar()[+]: {}\n" + + "X[*]: {CHILDREN | FINE GRAINED}\n" + + " bar()[+]: {}\n" + " foo()[-]: {}" ); } @@ -2562,17 +2562,17 @@ this.workingCopy.reconcile(ICompilationUnit.NO_AST, false, null, null); assertDeltas( "Unexpected delta", - "X[*]: {CHILDREN | FINE GRAINED}\n" + - " bar()[+]: {}\n" + + "X[*]: {CHILDREN | FINE GRAINED}\n" + + " bar()[+]: {}\n" + " foo()[-]: {}" ); assertProblems( "Unexpected problems", - "----------\n" + - "1. ERROR in /Reconciler/src/p1/X.java (at line 4)\n" + - " public void bar( {\n" + - " ^\n" + - "Syntax error, insert \")\" to complete MethodDeclaration\n" + + "----------\n" + + "1. ERROR in /Reconciler/src/p1/X.java (at line 4)\n" + + " public void bar( {\n" + + " ^\n" + + "Syntax error, insert \")\" to complete MethodDeclaration\n" + "----------\n" ); } @@ -2583,36 +2583,35 @@ public void testSuppressWarnings1() throws JavaModelException { ICompilationUnit otherCopy = null; try { - WorkingCopyOwner owner = new WorkingCopyOwner() {}; otherCopy = getWorkingCopy( "/Reconciler15/src/X.java", - "@Deprecated\n" + - "public class X {\n" + + "@Deprecated\n" + + "public class X {\n" + " void foo(){}\n" + "}\n", - owner, - false/*don't compute problems*/); - setUp15WorkingCopy("/Reconciler15/src/Y.java", owner); + this.wcOwner + ); + setUp15WorkingCopy("/Reconciler15/src/Y.java", this.wcOwner); setWorkingCopyContents( - "public class Y extends X {\n" + + "public class Y extends X {\n" + " @SuppressWarnings(\"all\")\n" + " void foo(){ super.foo(); }\n" + " Zork z;\n" + "}\n" ); - this.workingCopy.reconcile(ICompilationUnit.NO_AST, false, owner, null); + this.workingCopy.reconcile(ICompilationUnit.NO_AST, false, this.wcOwner, null); assertProblems( "Unexpected problems", - "----------\n" + - "1. WARNING in /Reconciler15/src/Y.java (at line 1)\n" + - " public class Y extends X {\n" + - " ^\n" + - "The type X is deprecated\n" + - "----------\n" + - "2. ERROR in /Reconciler15/src/Y.java (at line 4)\n" + - " Zork z;\n" + - " ^^^^\n" + - "Zork cannot be resolved to a type\n" + + "----------\n" + + "1. WARNING in /Reconciler15/src/Y.java (at line 1)\n" + + " public class Y extends X {\n" + + " ^\n" + + "The type X is deprecated\n" + + "----------\n" + + "2. ERROR in /Reconciler15/src/Y.java (at line 4)\n" + + " Zork z;\n" + + " ^^^^\n" + + "Zork cannot be resolved to a type\n" + "----------\n"); } finally { if (otherCopy != null) @@ -2625,42 +2624,41 @@ public void testSuppressWarnings2() throws JavaModelException { ICompilationUnit otherCopy = null; try { - WorkingCopyOwner owner = new WorkingCopyOwner() {}; otherCopy = getWorkingCopy( "/Reconciler15/src/java/util/List.java", "package java.util;\n" + - "public interface List {\n" + + "public interface List {\n" + "}\n", - owner, - false/*don't compute problems*/); - setUp15WorkingCopy("/Reconciler15/src/X.java", owner); - setWorkingCopyContents( - "import java.util.List;\n" + - "\n" + - "public class X {\n" + - " void foo(List list) {\n" + - " List ls1 = list;\n" + - " }\n" + - " @SuppressWarnings(\"unchecked\")\n" + - " void bar(List list) {\n" + - " List ls2 = list;\n" + - " }\n" + + this.wcOwner + ); + setUp15WorkingCopy("/Reconciler15/src/X.java", this.wcOwner); + setWorkingCopyContents( + "import java.util.List;\n" + + "\n" + + "public class X {\n" + + " void foo(List list) {\n" + + " List ls1 = list;\n" + + " }\n" + + " @SuppressWarnings(\"unchecked\")\n" + + " void bar(List list) {\n" + + " List ls2 = list;\n" + + " }\n" + " Zork z;\n" + "}\n" ); this.workingCopy.reconcile(ICompilationUnit.NO_AST, false, null, null); assertProblems( "Unexpected problems", - "----------\n" + - "1. WARNING in /Reconciler15/src/X.java (at line 5)\n" + - " List ls1 = list;\n" + - " ^^^^\n" + - "Type safety: The expression of type List needs unchecked conversion to conform to List\n" + - "----------\n" + - "2. ERROR in /Reconciler15/src/X.java (at line 11)\n" + - " Zork z;\n" + - " ^^^^\n" + - "Zork cannot be resolved to a type\n" + + "----------\n" + + "1. WARNING in /Reconciler15/src/X.java (at line 5)\n" + + " List ls1 = list;\n" + + " ^^^^\n" + + "Type safety: The expression of type List needs unchecked conversion to conform to List\n" + + "----------\n" + + "2. ERROR in /Reconciler15/src/X.java (at line 11)\n" + + " Zork z;\n" + + " ^^^^\n" + + "Zork cannot be resolved to a type\n" + "----------\n" ); } finally { @@ -2674,33 +2672,32 @@ public void testSuppressWarnings3() throws JavaModelException { ICompilationUnit otherCopy = null; try { - WorkingCopyOwner owner = new WorkingCopyOwner() {}; otherCopy = getWorkingCopy( "/Reconciler15/src/java/util/HashMap.java", "package java.util;\n" + - "public class HashMap implements Map {\n" + + "public class HashMap implements Map {\n" + "}\n", - owner, - false/*don't compute problems*/); - setUp15WorkingCopy("/Reconciler15/src/X.java", owner); - setWorkingCopyContents( - "import java.util.*;\n" + - "@SuppressWarnings(\"unchecked\")\n" + - "public class X {\n" + - " void foo() {\n" + - " Map[] map = new HashMap[10];\n" + - " }\n" + - " Zork z;\n" + + this.wcOwner + ); + setUp15WorkingCopy("/Reconciler15/src/X.java", this.wcOwner); + setWorkingCopyContents( + "import java.util.*;\n" + + "@SuppressWarnings(\"unchecked\")\n" + + "public class X {\n" + + " void foo() {\n" + + " Map[] map = new HashMap[10];\n" + + " }\n" + + " Zork z;\n" + "}\n" ); - this.workingCopy.reconcile(ICompilationUnit.NO_AST, false, owner, null); + this.workingCopy.reconcile(ICompilationUnit.NO_AST, false, this.wcOwner, null); assertProblems( "Unexpected problems", - "----------\n" + - "1. ERROR in /Reconciler15/src/X.java (at line 7)\n" + - " Zork z;\n" + - " ^^^^\n" + - "Zork cannot be resolved to a type\n" + + "----------\n" + + "1. ERROR in /Reconciler15/src/X.java (at line 7)\n" + + " Zork z;\n" + + " ^^^^\n" + + "Zork cannot be resolved to a type\n" + "----------\n" ); } finally { @@ -2714,36 +2711,35 @@ public void testSuppressWarnings4() throws JavaModelException { ICompilationUnit otherCopy = null; try { - WorkingCopyOwner owner = new WorkingCopyOwner() {}; otherCopy = getWorkingCopy( "/Reconciler15/src/X.java", - "/** @deprecated */\n" + - "public class X {\n" + + "/** @deprecated */\n" + + "public class X {\n" + " void foo(){}\n" + "}\n", - owner, - false/*don't compute problems*/); - setUp15WorkingCopy("/Reconciler15/src/Y.java", owner); + this.wcOwner + ); + setUp15WorkingCopy("/Reconciler15/src/Y.java", this.wcOwner); setWorkingCopyContents( - "public class Y extends X {\n" + + "public class Y extends X {\n" + " @SuppressWarnings(\"all\")\n" + " void foo(){ super.foo(); }\n" + " Zork z;\n" + "}\n" ); - this.workingCopy.reconcile(ICompilationUnit.NO_AST, false, owner, null); + this.workingCopy.reconcile(ICompilationUnit.NO_AST, false, this.wcOwner, null); assertProblems( "Unexpected problems", - "----------\n" + - "1. WARNING in /Reconciler15/src/Y.java (at line 1)\n" + - " public class Y extends X {\n" + - " ^\n" + - "The type X is deprecated\n" + - "----------\n" + - "2. ERROR in /Reconciler15/src/Y.java (at line 4)\n" + - " Zork z;\n" + - " ^^^^\n" + - "Zork cannot be resolved to a type\n" + + "----------\n" + + "1. WARNING in /Reconciler15/src/Y.java (at line 1)\n" + + " public class Y extends X {\n" + + " ^\n" + + "The type X is deprecated\n" + + "----------\n" + + "2. ERROR in /Reconciler15/src/Y.java (at line 4)\n" + + " Zork z;\n" + + " ^^^^\n" + + "Zork cannot be resolved to a type\n" + "----------\n"); } finally { if (otherCopy != null) @@ -2765,11 +2761,11 @@ this.workingCopy.reconcile(ICompilationUnit.NO_AST, false, null, null); assertProblems( "Unexpected problems", - "----------\n" + - "1. ERROR in /Reconciler/src/p1/X.java (at line 4)\n" + - " throw new Exception();\n" + - " ^^^^^^^^^^^^^^^^^^^^^^\n" + - "Unhandled exception type Exception\n" + + "----------\n" + + "1. ERROR in /Reconciler/src/p1/X.java (at line 4)\n" + + " throw new Exception();\n" + + " ^^^^^^^^^^^^^^^^^^^^^^\n" + + "Unhandled exception type Exception\n" + "----------\n" ); } @@ -2781,7 +2777,7 @@ this.workingCopy.makeConsistent(null); this.workingCopy.reconcile(ICompilationUnit.NO_AST, false, null, null); assertDeltas( - "Should have got NO delta", + "Should have got NO delta", "" ); } @@ -2826,11 +2822,10 @@ " }\n" + "}" ); - + createJavaProject("P2", new String[] {""}, new String[] {"JCL_LIB"}, new String[] {"/P1"}, "", "1.4"); createFolder("/P2/p"); - WorkingCopyOwner owner = new WorkingCopyOwner() {}; - this.workingCopy = getWorkingCopy("/P2/p/Y.java", "", owner, this.problemRequestor); + this.workingCopy = getWorkingCopy("/P2/p/Y.java", "", this.wcOwner); setWorkingCopyContents( "package p;\n" + "public class Y {\n" + @@ -2839,10 +2834,10 @@ " }\n" + "}" ); - this.workingCopy.reconcile(ICompilationUnit.NO_AST, true/*force pb detection*/, owner, null); + this.workingCopy.reconcile(ICompilationUnit.NO_AST, true/*force pb detection*/, this.wcOwner, null); assertProblems( "Unexpected problems", - "----------\n" + + "----------\n" + "----------\n" ); } finally { @@ -2856,7 +2851,6 @@ public void testTypeParameterWithBound() throws CoreException { this.workingCopy.discardWorkingCopy(); // don't use the one created in setUp() this.workingCopy = null; - WorkingCopyOwner owner = new WorkingCopyOwner() {}; ICompilationUnit workingCopy1 = null; try { workingCopy1 = getWorkingCopy( @@ -2865,12 +2859,11 @@ "public interface I {\n"+ " void foo(T t);\n"+ "}\n", - owner, - null /*no problem requestor*/ + this.wcOwner ); - + this.problemRequestor = new ProblemRequestor(); - this.workingCopy = getWorkingCopy("Reconciler15/src/test/X.java", "", owner, this.problemRequestor); + this.workingCopy = getWorkingCopy("Reconciler15/src/test/X.java", "", this.wcOwner); setWorkingCopyContents( "package test;\n"+ "public class X implements I {\n"+ @@ -2878,11 +2871,11 @@ " }\n"+ "}\n" ); - this.workingCopy.reconcile(ICompilationUnit.NO_AST, false, owner, null); + this.workingCopy.reconcile(ICompilationUnit.NO_AST, false, this.wcOwner, null); assertProblems( "Unexpected problems", - "----------\n" + + "----------\n" + "----------\n" ); } finally { @@ -2898,7 +2891,6 @@ public void testTypeParameterStartingWithDollar() throws CoreException { this.workingCopy.discardWorkingCopy(); // don't use the one created in setUp() this.workingCopy = null; - WorkingCopyOwner owner = new WorkingCopyOwner() {}; ICompilationUnit workingCopy1 = null; try { workingCopy1 = getWorkingCopy( @@ -2907,12 +2899,11 @@ "public class Y<$T> {\n"+ " void foo($T t);\n"+ "}\n", - owner, - null /*no problem requestor*/ + this.wcOwner ); - + this.problemRequestor = new ProblemRequestor(); - this.workingCopy = getWorkingCopy("Reconciler15/src/test/X.java", "", owner, this.problemRequestor); + this.workingCopy = getWorkingCopy("Reconciler15/src/test/X.java", "", this.wcOwner); setWorkingCopyContents( "package test;\n"+ "public class X {\n"+ @@ -2921,11 +2912,11 @@ " }\n"+ "}\n" ); - this.workingCopy.reconcile(ICompilationUnit.NO_AST, false, owner, null); + this.workingCopy.reconcile(ICompilationUnit.NO_AST, false, this.wcOwner, null); assertProblems( "Unexpected problems", - "----------\n" + + "----------\n" + "----------\n" ); } finally { @@ -2947,17 +2938,17 @@ "public class Y$Z {\n" + "}"; createFile( - "/Reconciler/src/p1/Y$Z.java", + "/Reconciler/src/p1/Y$Z.java", contents ); this.problemRequestor = new ProblemRequestor(); - this.workingCopy = getCompilationUnit("Reconciler/src/p1/Y$Z.java").getWorkingCopy(new WorkingCopyOwner() {}, this.problemRequestor, null); - + this.workingCopy = getCompilationUnit("Reconciler/src/p1/Y$Z.java").getWorkingCopy(this.wcOwner, null); + this.problemRequestor.initialize(contents.toCharArray()); this.workingCopy.reconcile(ICompilationUnit.NO_AST, true, null, null); assertProblems( "Unexpected problems", - "----------\n" + + "----------\n" + "----------\n" ); } finally { @@ -2969,7 +2960,7 @@ * (regression test for bug 125301 Handling of classes with $ in class name.) */ public void testTypeWithDollarName2() throws CoreException { - ICompilationUnit workingCopy2 = null; + ICompilationUnit workingCopy2 = null; try { WorkingCopyOwner owner = this.workingCopy.getOwner(); workingCopy2 = getWorkingCopy( @@ -2977,8 +2968,7 @@ "package p1;\n" + "public class Y$Z {\n" + "}", - owner, - false/*don't compute problems*/ + owner ); setWorkingCopyContents( "package p1;\n" + @@ -2989,7 +2979,7 @@ this.workingCopy.reconcile(ICompilationUnit.NO_AST, false, owner, null); assertProblems( "Unexpected problems", - "----------\n" + + "----------\n" + "----------\n" ); } finally { @@ -3003,7 +2993,6 @@ public void testVarargs() throws CoreException { this.workingCopy.discardWorkingCopy(); // don't use the one created in setUp() this.workingCopy = null; - WorkingCopyOwner owner = new WorkingCopyOwner() {}; ICompilationUnit workingCopy1 = null; try { workingCopy1 = getWorkingCopy( @@ -3012,12 +3001,11 @@ "public class X {\n"+ " void bar(String ... args) {}\n"+ "}\n", - owner, - null /*no problem requestor*/ + this.wcOwner ); - + this.problemRequestor = new ProblemRequestor(); - this.workingCopy = getWorkingCopy("Reconciler15/src/test/Y.java", "", owner, this.problemRequestor); + this.workingCopy = getWorkingCopy("Reconciler15/src/test/Y.java", "", this.wcOwner); setWorkingCopyContents( "package test;\n"+ "public class Y {\n"+ @@ -3027,11 +3015,11 @@ " }\n"+ "}\n" ); - this.workingCopy.reconcile(ICompilationUnit.NO_AST, false, owner, null); + this.workingCopy.reconcile(ICompilationUnit.NO_AST, false, this.wcOwner, null); assertProblems( "Unexpected problems", - "----------\n" + + "----------\n" + "----------\n" ); } finally { @@ -3050,37 +3038,37 @@ // Set initial CU content setWorkingCopyContents( "package p1;\n" + - "public class X {\n" + - " /**\n" + - " * @return a\n" + - " */\n" + - " boolean get() {\n" + - " return false;\n" + - " }\n" + + "public class X {\n" + + " /**\n" + + " * @return a\n" + + " */\n" + + " boolean get() {\n" + + " return false;\n" + + " }\n" + "}"); this.workingCopy.reconcile(AST.JLS3, true, this.wcOwner, null); assertProblems( "Unexpected problems", - "----------\n" + + "----------\n" + "----------\n" ); // Modify content String contents = "package p1;\n" + - "public class X {\n" + - " /**\n" + - " * @return boolean\n" + - " */\n" + - " boolean get() {\n" + - " return false;\n" + - " }\n" + + "public class X {\n" + + " /**\n" + + " * @return boolean\n" + + " */\n" + + " boolean get() {\n" + + " return false;\n" + + " }\n" + "}"; setWorkingCopyContents(contents); this.workingCopy.reconcile(AST.JLS3, true, this.wcOwner, null); assertProblems( "Unexpected problems", - "----------\n" + + "----------\n" + "----------\n" ); } @@ -3093,42 +3081,42 @@ try { // Resources creation createJavaProject("P", new String[] {""}, new String[] {"JCL_LIB"}, "bin"); - String source = - "public class Test {\n" + - " public static void main(String[] args) {\n" + - " new SFoo().foo();\n" + - " }\n" + + String source = + "public class Test {\n" + + " public static void main(String[] args) {\n" + + " new SFoo().foo();\n" + + " }\n" + "}\n"; this.createFile( - "/P/Foo.java", + "/P/Foo.java", "class SFoo { void foo() {} }\n" ); this.createFile( - "/P/Test.java", + "/P/Test.java", source ); - + // Get compilation unit and reconcile it char[] sourceChars = source.toCharArray(); this.problemRequestor.initialize(sourceChars); - this.workingCopy = getCompilationUnit("/P/Test.java").getWorkingCopy(new WorkingCopyOwner() {}, problemRequestor, null); + this.workingCopy = getCompilationUnit("/P/Test.java").getWorkingCopy(this.wcOwner, null); this.workingCopy.getBuffer().setContents(source); this.workingCopy.reconcile(AST.JLS3, true, null, null); assertNoProblem(sourceChars, this.workingCopy); // Add new secondary type this.createFile( - "/P/Bar.java", + "/P/Bar.java", "class SBar{ void bar() {} }\n" ); - source = - "public class Test {\n" + - " public static void main(String[] args) {\n" + - " new SFoo().foo();\n" + - " new SBar().bar();\n" + - " }\n" + + source = + "public class Test {\n" + + " public static void main(String[] args) {\n" + + " new SFoo().foo();\n" + + " new SBar().bar();\n" + + " }\n" + "}\n"; - + // Reconcile with modified source sourceChars = source.toCharArray(); this.problemRequestor.initialize(sourceChars); @@ -3143,30 +3131,30 @@ try { // Resources creation createJavaProject("P", new String[] {""}, new String[] {"JCL_LIB"}, "bin"); - String source = - "public class Test {\n" + - " public static void main(String[] args) {\n" + - " new SFoo().foo();\n" + - " new SBar().bar();\n" + - " }\n" + + String source = + "public class Test {\n" + + " public static void main(String[] args) {\n" + + " new SFoo().foo();\n" + + " new SBar().bar();\n" + + " }\n" + "}\n"; createFile( - "/P/Foo.java", + "/P/Foo.java", "class SFoo { void foo() {} }\n" ); createFile( - "/P/Test.java", + "/P/Test.java", source ); createFile( - "/P/Bar.java", + "/P/Bar.java", "class SBar{ void bar() {} }\n" ); - + // Get compilation unit and reconcile it char[] sourceChars = source.toCharArray(); this.problemRequestor.initialize(sourceChars); - this.workingCopy = getCompilationUnit("/P/Test.java").getWorkingCopy(new WorkingCopyOwner() {}, this.problemRequestor, null); + this.workingCopy = getCompilationUnit("/P/Test.java").getWorkingCopy(this.wcOwner, null); this.workingCopy.getBuffer().setContents(source); this.workingCopy.reconcile(AST.JLS3, true, null, null); assertNoProblem(sourceChars, this.workingCopy); @@ -3187,11 +3175,11 @@ ); // Fix the problem - source = - "public class Test {\n" + - " public static void main(String[] args) {\n" + - " new SFoo().foo();\n" + - " }\n" + + source = + "public class Test {\n" + + " public static void main(String[] args) {\n" + + " new SFoo().foo();\n" + + " }\n" + "}\n"; sourceChars = source.toCharArray(); this.problemRequestor.initialize(sourceChars); @@ -3209,39 +3197,39 @@ createJavaProject("P1", new String[] {""}, new String[] {"JCL_LIB"}, "bin"); createFolder("/P1/test"); createFile( - "/P1/test/Foo.java", + "/P1/test/Foo.java", "package test;\n" + "class Secondary{ void foo() {} }\n" ); createFile( - "/P1/test/Test1.java", + "/P1/test/Test1.java", "package test;\n" + - "public class Test1 {\n" + - " public static void main(String[] args) {\n" + - " new Secondary().foo();\n" + - " }\n" + + "public class Test1 {\n" + + " public static void main(String[] args) {\n" + + " new Secondary().foo();\n" + + " }\n" + "}\n" ); // Create second project createJavaProject("P2", new String[] {""}, new String[] {"JCL_LIB"}, new String[] { "/P1" }, "bin"); - String source = + String source = "package test;\n" + - "public class Test2 {\n" + - " public static void main(String[] args) {\n" + - " new Secondary().foo();\n" + - " }\n" + + "public class Test2 {\n" + + " public static void main(String[] args) {\n" + + " new Secondary().foo();\n" + + " }\n" + "}\n"; createFolder("/P2/test"); createFile( - "/P2/test/Test2.java", + "/P2/test/Test2.java", source ); - + // Get compilation unit and reconcile it => expect no error char[] sourceChars = source.toCharArray(); this.problemRequestor.initialize(sourceChars); - this.workingCopy = getCompilationUnit("/P2/test/Test2.java").getWorkingCopy(new WorkingCopyOwner() {}, this.problemRequestor, null); + this.workingCopy = getCompilationUnit("/P2/test/Test2.java").getWorkingCopy(this.wcOwner, null); this.workingCopy.getBuffer().setContents(source); this.workingCopy.reconcile(AST.JLS3, true, null, null); assertNoProblem(sourceChars, this.workingCopy); @@ -3260,11 +3248,11 @@ createJavaProject("P1", new String[] {""}, new String[] {"JCL_LIB"}, "bin"); String source = "class Test {}\n"; createFile( - "/P1/Test.java", + "/P1/Test.java", source ); createJavaProject("P2", new String[] {""}, new String[] {"JCL_LIB"}, new String[] { "/P1" }, "bin"); - String source2 = + String source2 = "class A {\n" + " Secondary s;\n" + "}\n"; @@ -3274,17 +3262,16 @@ ); waitUntilIndexesReady(); this.workingCopies = new ICompilationUnit[2]; - this.wcOwner = new WorkingCopyOwner() {}; // Get first working copy and verify that there's no error char[] sourceChars = source.toCharArray(); this.problemRequestor.initialize(sourceChars); - this.workingCopies[0] = getCompilationUnit("/P1/Test.java").getWorkingCopy(new WorkingCopyOwner() {}, this.problemRequestor, null); + this.workingCopies[0] = getCompilationUnit("/P1/Test.java").getWorkingCopy(this.wcOwner, null); assertNoProblem(sourceChars, this.workingCopies[0]); // Get second working copy and verify that there's one error (missing secondary type) this.problemRequestor.initialize(source2.toCharArray()); - this.workingCopies[1] = getCompilationUnit("/P2/A.java").getWorkingCopy(new WorkingCopyOwner() {}, this.problemRequestor, null); + this.workingCopies[1] = getCompilationUnit("/P2/A.java").getWorkingCopy(this.wcOwner, null); assertEquals("Working copy should not find secondary type 'Secondary'!", 1, this.problemRequestor.problemCount); assertProblems("Working copy should have problem!", "----------\n" + @@ -3296,15 +3283,15 @@ ); // Delete file and recreate it with secondary - final String source1 = - "public class Test {}\n" + + final String source1 = + "public class Test {}\n" + "class Secondary{}\n"; getWorkspace().run( new IWorkspaceRunnable() { public void run(IProgressMonitor monitor) throws CoreException { deleteFile("/P1/Test.java"); createFile( - "/P1/Test.java", + "/P1/Test.java", source1 ); } @@ -3342,11 +3329,11 @@ createJavaProject("P1", new String[] {""}, new String[] {"JCL_LIB"}, "bin"); String source1 = "class Test {}\n"; createFile( - "/P1/Test.java", + "/P1/Test.java", source1 ); createJavaProject("P2", new String[] {""}, new String[] {"JCL_LIB"}, new String[] { "/P1" }, "bin"); - String source2 = + String source2 = "class A {\n" + " Secondary s;\n" + "}\n"; @@ -3360,12 +3347,12 @@ // Get first working copy and verify that there's no error char[] sourceChars = source1.toCharArray(); this.problemRequestor.initialize(sourceChars); - this.workingCopies[0] = getCompilationUnit("/P1/Test.java").getWorkingCopy(new WorkingCopyOwner() {}, this.problemRequestor, null); + this.workingCopies[0] = getCompilationUnit("/P1/Test.java").getWorkingCopy(this.wcOwner, null); assertNoProblem(sourceChars, this.workingCopies[0]); // Get second working copy and verify that there's one error (missing secondary type) this.problemRequestor.initialize(source2.toCharArray()); - this.workingCopies[1] = getCompilationUnit("/P2/A.java").getWorkingCopy(new WorkingCopyOwner() {}, this.problemRequestor, null); + this.workingCopies[1] = getCompilationUnit("/P2/A.java").getWorkingCopy(this.wcOwner, null); assertEquals("Working copy should not find secondary type 'Secondary'!", 1, this.problemRequestor.problemCount); assertProblems("Working copy should have problem!", "----------\n" + @@ -3377,8 +3364,8 @@ ); // Modify first working copy and verify that there's still no error - source1 = - "public class Test {}\n" + + source1 = + "public class Test {}\n" + "class Secondary{}\n"; sourceChars = source1.toCharArray(); this.problemRequestor.initialize(sourceChars); @@ -3410,11 +3397,11 @@ createJavaProject("P1", new String[] {""}, new String[] {"JCL_LIB"}, "bin"); String source1 = "class Test {}\n"; createFile( - "/P1/Test.java", + "/P1/Test.java", source1 ); createJavaProject("P2", new String[] {""}, new String[] {"JCL_LIB"}, new String[] { "/P1" }, "bin"); - String source2 = + String source2 = "class A {\n" + " Secondary s;\n" + "}\n"; @@ -3424,17 +3411,16 @@ ); waitUntilIndexesReady(); this.workingCopies = new ICompilationUnit[2]; - this.wcOwner = new WorkingCopyOwner() {}; // Get first working copy and verify that there's no error char[] sourceChars = source1.toCharArray(); this.problemRequestor.initialize(sourceChars); - this.workingCopies[0] = getCompilationUnit("/P1/Test.java").getWorkingCopy(new WorkingCopyOwner() {}, this.problemRequestor, null); + this.workingCopies[0] = getCompilationUnit("/P1/Test.java").getWorkingCopy(this.wcOwner, null); assertNoProblem(sourceChars, this.workingCopies[0]); // Get second working copy and verify that there's one error (missing secondary type) this.problemRequestor.initialize(source2.toCharArray()); - this.workingCopies[1] = getCompilationUnit("/P2/A.java").getWorkingCopy(new WorkingCopyOwner() {}, this.problemRequestor, null); + this.workingCopies[1] = getCompilationUnit("/P2/A.java").getWorkingCopy(this.wcOwner, null); assertEquals("Working copy should not find secondary type 'Secondary'!", 1, this.problemRequestor.problemCount); assertProblems("Working copy should have problem!", "----------\n" + @@ -3447,11 +3433,11 @@ // Delete file and recreate it with secondary deleteFile("/P1/Test.java"); - source1 = - "public class Test {}\n" + + source1 = + "public class Test {}\n" + "class Secondary{}\n"; createFile( - "/P1/Test.java", + "/P1/Test.java", source1 ); @@ -3492,11 +3478,11 @@ createJavaProject("P1", new String[] {""}, new String[] {"JCL_LIB"}, "bin"); sources[0] = "class X {}\n"; createFile( - "/P1/X.java", + "/P1/X.java", sources[0] ); createJavaProject("P2", new String[] {""}, new String[] {"JCL_LIB"}, new String[] { "/P1" }, "bin"); - sources[1] = + sources[1] = "interface I {\n" + " void foo();\n" + " void bar(X p);\n" + @@ -3506,7 +3492,7 @@ sources[1] ); createJavaProject("P3", new String[] {""}, new String[] {"JCL_LIB"}, new String[] { "/P2" }, "bin"); - sources[2] = + sources[2] = "class Y implements I {\n" + " // public void foo() { }\n" + " // public void bar(X p) { }\n" + @@ -3520,33 +3506,32 @@ } waitUntilIndexesReady(); this.workingCopies = new ICompilationUnit[3]; - this.wcOwner = new WorkingCopyOwner() {}; // Get first working copy and verify that there's no error this.problemRequestor.initialize(sourcesAsCharArrays[0]); - this.workingCopies[0] = getCompilationUnit("/P1/X.java").getWorkingCopy(new WorkingCopyOwner() {}, this.problemRequestor, null); + this.workingCopies[0] = getCompilationUnit("/P1/X.java").getWorkingCopy(this.wcOwner, null); assertNoProblem(sourcesAsCharArrays[0], this.workingCopies[0]); // Get second working copy and verify that there's no error this.problemRequestor.initialize(sourcesAsCharArrays[1]); - this.workingCopies[1] = getCompilationUnit("/P2/I.java").getWorkingCopy(new WorkingCopyOwner() {}, this.problemRequestor, null); + this.workingCopies[1] = getCompilationUnit("/P2/I.java").getWorkingCopy(this.wcOwner, null); assertNoProblem(sourcesAsCharArrays[1], this.workingCopies[1]); // Get third working copy and verify that all expected errors are here this.problemRequestor.initialize(sourcesAsCharArrays[2]); - this.workingCopies[2] = getCompilationUnit("/P3/Y.java").getWorkingCopy(new WorkingCopyOwner() {}, this.problemRequestor, null); + this.workingCopies[2] = getCompilationUnit("/P3/Y.java").getWorkingCopy(this.wcOwner, null); assertProblems("Working copy should have problems:", - "----------\n" + - "1. ERROR in /P3/Y.java (at line 1)\n" + - " class Y implements I {\n" + + "----------\n" + + "1. ERROR in /P3/Y.java (at line 1)\n" + + " class Y implements I {\n" + " ^\n" + // we miss the first diagnostic - see justification in bugzilla -// "The type Y must implement the inherited abstract method I.bar(X)\n" + -// "----------\n" + -// "2. ERROR in /P3/Y.java (at line 1)\n" + -// " class Y implements I {\n" + -// " ^\n" + - "The type Y must implement the inherited abstract method I.foo()\n" + +// "The type Y must implement the inherited abstract method I.bar(X)\n" + +// "----------\n" + +// "2. ERROR in /P3/Y.java (at line 1)\n" + +// " class Y implements I {\n" + +// " ^\n" + + "The type Y must implement the inherited abstract method I.foo()\n" + "----------\n" ); } finally { @@ -3566,11 +3551,11 @@ createJavaProject("P1", new String[] {""}, new String[] {"JCL_LIB"}, "bin"); sources[0] = "class X {}\n"; createFile( - "/P1/X.java", + "/P1/X.java", sources[0] ); createJavaProject("P2", new String[] {""}, new String[] {"JCL_LIB"}, new String[] { "/P1" }, "bin"); - sources[1] = + sources[1] = "interface I {\n" + " void foo();\n" + " void bar(X p);\n" + @@ -3580,7 +3565,7 @@ sources[1] ); createJavaProject("P3", new String[] {""}, new String[] {"JCL_LIB"}, new String[] { "/P1" /* compare with test1001 */, "/P2" }, "bin"); - sources[2] = + sources[2] = "class Y implements I {\n" + " // public void foo() { }\n" + " // public void bar(X p) { }\n" + @@ -3594,32 +3579,31 @@ } waitUntilIndexesReady(); this.workingCopies = new ICompilationUnit[3]; - this.wcOwner = new WorkingCopyOwner() {}; // Get first working copy and verify that there's no error this.problemRequestor.initialize(sourcesAsCharArrays[0]); - this.workingCopies[0] = getCompilationUnit("/P1/X.java").getWorkingCopy(new WorkingCopyOwner() {}, this.problemRequestor, null); + this.workingCopies[0] = getCompilationUnit("/P1/X.java").getWorkingCopy(this.wcOwner, null); assertNoProblem(sourcesAsCharArrays[0], this.workingCopies[0]); // Get second working copy and verify that there's no error this.problemRequestor.initialize(sourcesAsCharArrays[1]); - this.workingCopies[1] = getCompilationUnit("/P2/I.java").getWorkingCopy(new WorkingCopyOwner() {}, this.problemRequestor, null); + this.workingCopies[1] = getCompilationUnit("/P2/I.java").getWorkingCopy(this.wcOwner, null); assertNoProblem(sourcesAsCharArrays[1], this.workingCopies[1]); // Get third working copy and verify that all expected errors are here this.problemRequestor.initialize(sourcesAsCharArrays[2]); - this.workingCopies[2] = getCompilationUnit("/P3/Y.java").getWorkingCopy(new WorkingCopyOwner() {}, this.problemRequestor, null); + this.workingCopies[2] = getCompilationUnit("/P3/Y.java").getWorkingCopy(this.wcOwner, null); assertProblems("Working copy should have problems:", - "----------\n" + - "1. ERROR in /P3/Y.java (at line 1)\n" + - " class Y implements I {\n" + - " ^\n" + - "The type Y must implement the inherited abstract method I.bar(X)\n" + - "----------\n" + - "2. ERROR in /P3/Y.java (at line 1)\n" + - " class Y implements I {\n" + - " ^\n" + - "The type Y must implement the inherited abstract method I.foo()\n" + + "----------\n" + + "1. ERROR in /P3/Y.java (at line 1)\n" + + " class Y implements I {\n" + + " ^\n" + + "The type Y must implement the inherited abstract method I.bar(X)\n" + + "----------\n" + + "2. ERROR in /P3/Y.java (at line 1)\n" + + " class Y implements I {\n" + + " ^\n" + + "The type Y must implement the inherited abstract method I.foo()\n" + "----------\n" ); } finally { Index: src/org/eclipse/jdt/core/tests/model/WorkingCopyTests.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/WorkingCopyTests.java,v retrieving revision 1.40 diff -u -r1.40 WorkingCopyTests.java --- src/org/eclipse/jdt/core/tests/model/WorkingCopyTests.java 20 Dec 2006 15:20:00 -0000 1.40 +++ src/org/eclipse/jdt/core/tests/model/WorkingCopyTests.java 13 Mar 2007 16:19:33 -0000 @@ -72,7 +72,7 @@ " }\n" + "}"); this.cu = this.getCompilationUnit("P/src/x/y/A.java"); - this.copy = cu.getWorkingCopy(null); + this.copy = this.cu.getWorkingCopy(null); } catch (CoreException e) { e.printStackTrace(); throw new RuntimeException(e.getMessage()); @@ -232,7 +232,7 @@ */ public void testCustomizedBuffer() throws JavaModelException { WorkingCopyOwner owner = new TestWorkingCopyOwner(); - ICompilationUnit customizedCopy = this.cu.getWorkingCopy(owner, null, null); + ICompilationUnit customizedCopy = this.cu.getWorkingCopy(owner, null); try { assertTrue("Unexpected buffer", customizedCopy.getBuffer() instanceof TestBuffer); } finally { @@ -244,7 +244,7 @@ */ public void testCustomizedBuffer2() throws JavaModelException { WorkingCopyOwner owner = new TestWorkingCopyOwner(); - ICompilationUnit customizedCopy = this.cu.getWorkingCopy(owner, null, null); + ICompilationUnit customizedCopy = this.cu.getWorkingCopy(owner, null); try { customizedCopy.close(); customizedCopy.open(null); @@ -263,7 +263,7 @@ JavaCore.run( new IWorkspaceRunnable() { public void run(IProgressMonitor monitor) throws CoreException { - IType type = copy.getType("A"); + IType type = WorkingCopyTests.this.copy.getType("A"); IField field1 = type.getField("field1"); IField field2 = type.getField("field2"); field1.delete(false, monitor); @@ -410,7 +410,7 @@ * Ensures that the primary import declaration can be retrieved. */ public void testGetPrimaryImportDeclaration() { - IImportDeclaration imprt = copy.getImport("java.io.File"); + IImportDeclaration imprt = this.copy.getImport("java.io.File"); IJavaElement primary = imprt.getPrimaryElement(); assertTrue("Element should exist", primary.exists()); } @@ -427,7 +427,7 @@ * Ensures that the primary initializer can be retrieved. */ public void testGetPrimaryInitializer() { - IType type= copy.getType("A"); + IType type= this.copy.getType("A"); IJavaElement primary= type.getInitializer(1).getPrimaryElement(); assertTrue("Element should exist", primary.exists()); } @@ -558,7 +558,7 @@ */ public void testShared1() throws JavaModelException { WorkingCopyOwner owner = new WorkingCopyOwner() {}; - ICompilationUnit shared = this.cu.getWorkingCopy(owner, null, null); + ICompilationUnit shared = this.cu.getWorkingCopy(owner, null); try { assertTrue("Should find shared working copy", this.cu.findWorkingCopy(owner) == shared); } finally { @@ -571,9 +571,9 @@ */ public void testShared2() throws JavaModelException { WorkingCopyOwner owner = new WorkingCopyOwner() {}; - ICompilationUnit shared = this.cu.getWorkingCopy(owner, null, null); + ICompilationUnit shared = this.cu.getWorkingCopy(owner, null); try { - ICompilationUnit shared2 = this.cu.getWorkingCopy(owner, null, null); + ICompilationUnit shared2 = this.cu.getWorkingCopy(owner, null); assertTrue("Second working copy should be identical to first one", shared2 == shared); } finally { shared.discardWorkingCopy(); Index: src/org/eclipse/jdt/core/tests/model/CopyMoveResourcesTests.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CopyMoveResourcesTests.java,v retrieving revision 1.21 diff -u -r1.21 CopyMoveResourcesTests.java --- src/org/eclipse/jdt/core/tests/model/CopyMoveResourcesTests.java 20 Dec 2006 15:20:00 -0000 1.21 +++ src/org/eclipse/jdt/core/tests/model/CopyMoveResourcesTests.java 13 Mar 2007 16:19:24 -0000 @@ -596,7 +596,7 @@ "}" ); copy = getCompilationUnit("/P/src/p2/X.java"); - copy.becomeWorkingCopy(null, null); + copy.becomeWorkingCopy(null); copyPositive(cuSource, pkgDest, null, null, true/*force*/); } finally { @@ -1028,7 +1028,7 @@ "}" ); copy = getCompilationUnit("/P/src/p1/X.java"); - copy.becomeWorkingCopy(null, null); + copy.becomeWorkingCopy(null); this.createFolder("/P/src/p2"); IPackageFragment pkgDest = getPackage("/P/src/p2"); Index: src/org/eclipse/jdt/core/tests/model/WorkingCopySearchTests.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/WorkingCopySearchTests.java,v retrieving revision 1.34 diff -u -r1.34 WorkingCopySearchTests.java --- src/org/eclipse/jdt/core/tests/model/WorkingCopySearchTests.java 16 Oct 2006 12:59:09 -0000 1.34 +++ src/org/eclipse/jdt/core/tests/model/WorkingCopySearchTests.java 13 Mar 2007 16:19:33 -0000 @@ -183,7 +183,7 @@ public void testAllTypeNames3() throws CoreException { ICompilationUnit wc = getCompilationUnit("/JavaSearch/wc3/X44884.java"); try { - wc.becomeWorkingCopy(null, null); + wc.becomeWorkingCopy(null); wc.getBuffer().setContents( "package wc3;\n" + "public class X44884 {\n" + @@ -222,7 +222,7 @@ public void testAllTypeNames4() throws CoreException { ICompilationUnit wc = getCompilationUnit("/JavaSearch/wc3/X44884.java"); try { - wc.becomeWorkingCopy(null, null); + wc.becomeWorkingCopy(null); wc.getBuffer().setContents( "package wc3;\n" + "public class X44884 {\n" + Index: src/org/eclipse/jdt/core/tests/model/ClassFileTests.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ClassFileTests.java,v retrieving revision 1.27 diff -u -r1.27 ClassFileTests.java --- src/org/eclipse/jdt/core/tests/model/ClassFileTests.java 6 Mar 2007 04:43:19 -0000 1.27 +++ src/org/eclipse/jdt/core/tests/model/ClassFileTests.java 13 Mar 2007 16:19:23 -0000 @@ -14,6 +14,7 @@ import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.jdt.core.*; import org.eclipse.jdt.core.search.IJavaSearchConstants; import org.eclipse.jdt.core.search.IJavaSearchScope; @@ -22,11 +23,11 @@ import junit.framework.Test; public class ClassFileTests extends ModifyingResourceTests { - + IPackageFragmentRoot jarRoot; ICompilationUnit workingCopy; IClassFile classFile; - + public ClassFileTests(String name) { super(name); } @@ -47,13 +48,13 @@ super.setUpSuite(); IJavaProject javaProject = createJavaProject("P"); String[] pathAndContents = new String[] { - "nongeneric/A.java", + "nongeneric/A.java", "package nongeneric;\n" + - "public class A {\n" + - "}", - "generic/X.java", + "public class A {\n" + + "}", + "generic/X.java", "package generic;\n" + - "public class X {\n" + + "public class X {\n" + " X foo(X x) throws RuntimeException, U {\n" + " return null;\n" + " }\n" + @@ -61,42 +62,42 @@ " return value;\n" + " }\n" + "}", - "generic/Y.java", + "generic/Y.java", "package generic;\n" + - "public class Y {\n" + + "public class Y {\n" + "}", - "generic/Z.java", + "generic/Z.java", "package generic;\n" + - "public class Z> {\n" + + "public class Z> {\n" + "}", - "generic/I.java", + "generic/I.java", "package generic;\n" + - "public interface I {\n" + + "public interface I {\n" + "}", - "generic/W.java", + "generic/W.java", "package generic;\n" + - "public class W , U extends T> {\n" + + "public class W , U extends T> {\n" + "}", - "generic/V.java", + "generic/V.java", "package generic;\n" + - "public class V extends X implements I {\n" + + "public class V extends X implements I {\n" + "}", - "varargs/X.java", + "varargs/X.java", "package varargs;\n" + - "public class X {\n" + + "public class X {\n" + " void foo(String s, Object ... others) {\n" + " }\n" + "}", - "workingcopy/X.java", + "workingcopy/X.java", "package workingcopy;\n" + - "public class X {\n" + + "public class X {\n" + " void foo() {\n" + " System.out.println();\n" + " }\n" + "}", - "workingcopy/Y.java", + "workingcopy/Y.java", "package workingcopy;\n" + - "public class Y {\n" + + "public class Y {\n" + " T foo(T t, String... args) {\n" + " return t;\n" + " }\n" + @@ -157,7 +158,7 @@ IMethod method = type.getMethod("foo", new String[] {"Lgeneric.X;"}); assertStringsEqual( "Unexpected return type", - "Ljava.lang.RuntimeException;\n" + + "Ljava.lang.RuntimeException;\n" + "TU;\n", method.getExceptionTypes()); } @@ -369,8 +370,8 @@ IJavaElement[] children = this.classFile.getType().getChildrenForCategory("test"); assertElementsEqual( "Unexpected children", - "field [in X [in X.class [in p [in lib2.jar [in P]]]]]\n" + - "foo1() [in X [in X.class [in p [in lib2.jar [in P]]]]]\n" + + "field [in X [in X.class [in p [in lib2.jar [in P]]]]]\n" + + "foo1() [in X [in X.class [in p [in lib2.jar [in P]]]]]\n" + "foo2() [in X [in X.class [in p [in lib2.jar [in P]]]]]", children); } @@ -399,15 +400,15 @@ IJavaElement[] tests = this.classFile.getType().getChildrenForCategory("test"); assertElementsEqual( "Unexpected children", - "field [in X [in X.class [in p [in lib2.jar [in P]]]]]\n" + - "foo1() [in X [in X.class [in p [in lib2.jar [in P]]]]]\n" + + "field [in X [in X.class [in p [in lib2.jar [in P]]]]]\n" + + "foo1() [in X [in X.class [in p [in lib2.jar [in P]]]]]\n" + "foo2() [in X [in X.class [in p [in lib2.jar [in P]]]]]", tests); IJavaElement[] methods = this.classFile.getType().getChildrenForCategory("methods"); assertElementsEqual( "Unexpected children", - "foo1() [in X [in X.class [in p [in lib2.jar [in P]]]]]\n" + - "foo2() [in X [in X.class [in p [in lib2.jar [in P]]]]]\n" + + "foo1() [in X [in X.class [in p [in lib2.jar [in P]]]]]\n" + + "foo2() [in X [in X.class [in p [in lib2.jar [in P]]]]]\n" + "foo3() [in X [in X.class [in p [in lib2.jar [in P]]]]]", methods); IJavaElement[] others = this.classFile.getType().getChildrenForCategory("other"); @@ -418,9 +419,9 @@ IJavaElement[] all = this.classFile.getType().getChildrenForCategory("all"); assertElementsEqual( "Unexpected children", - "field [in X [in X.class [in p [in lib2.jar [in P]]]]]\n" + - "foo1() [in X [in X.class [in p [in lib2.jar [in P]]]]]\n" + - "foo2() [in X [in X.class [in p [in lib2.jar [in P]]]]]\n" + + "field [in X [in X.class [in p [in lib2.jar [in P]]]]]\n" + + "foo1() [in X [in X.class [in p [in lib2.jar [in P]]]]]\n" + + "foo2() [in X [in X.class [in p [in lib2.jar [in P]]]]]\n" + "foo3() [in X [in X.class [in p [in lib2.jar [in P]]]]]", all); } @@ -432,7 +433,7 @@ public void testGetSuperclassTypeSignature() throws JavaModelException { IType type = this.jarRoot.getPackageFragment("generic").getClassFile("V.class").getType(); assertEquals( - "Unexpected signature", + "Unexpected signature", "Lgeneric.X;", type.getSuperclassTypeSignature()); } @@ -444,7 +445,7 @@ public void testGetSuperInterfaceTypeSignatures() throws JavaModelException { IType type = this.jarRoot.getPackageFragment("generic").getClassFile("V.class").getType(); assertStringsEqual( - "Unexpected signatures", + "Unexpected signatures", "Lgeneric.I;\n", type.getSuperInterfaceTypeSignatures()); } @@ -456,8 +457,8 @@ IMethod method = this.jarRoot.getPackageFragment("generic").getClassFile("X.class").getType().getMethod("foo", new String[] {"TK;", "TV;"}); String[] parameterNames = method.getParameterNames(); assertStringsEqual( - "Unexpected parameter names", - "key\n" + + "Unexpected parameter names", + "key\n" + "value\n", parameterNames); } @@ -472,8 +473,8 @@ IMethod method = this.jarRoot.getPackageFragment("generic").getClassFile("X.class").getType().getMethod("foo", new String[] {"TK;", "TV;"}); String[] parameterNames = method.getParameterNames(); assertStringsEqual( - "Unexpected parameter names", - "arg0\n" + + "Unexpected parameter names", + "arg0\n" + "arg1\n", parameterNames); } finally { @@ -510,7 +511,7 @@ IType type = this.jarRoot.getPackageFragment("generic").getClassFile("Y.class").getType(); assertStringsEqual( "Unexpected type parameters", - "K:Ljava.lang.Object;\n" + + "K:Ljava.lang.Object;\n" + "L:Ljava.lang.Object;\n", type.getTypeParameterSignatures()); } @@ -533,7 +534,7 @@ IType type = this.jarRoot.getPackageFragment("generic").getClassFile("W.class").getType(); assertStringsEqual( "Unexpected type parameters", - "T:Lgeneric.X;\n" + + "T:Lgeneric.X;\n" + "U:TT;\n", type.getTypeParameterSignatures()); } @@ -547,7 +548,7 @@ IMethod method = type.getMethod("foo", new String[] {"TK;", "TV;"}); assertStringsEqual( "Unexpected type parameters", - "K:Ljava.lang.Object;\n" + + "K:Ljava.lang.Object;\n" + "V:Ljava.lang.Object;\n", method.getTypeParameterSignatures()); } @@ -559,8 +560,8 @@ IMethod method = this.jarRoot.getPackageFragment("generic").getClassFile("X.class").getType().getMethod("foo", new String[] {"TK;", "TV;"}); String[] parameterNames = method.getRawParameterNames(); assertStringsEqual( - "Unexpected parameter names", - "arg0\n" + + "Unexpected parameter names", + "arg0\n" + "arg1\n", parameterNames); } @@ -575,8 +576,8 @@ IMethod method = this.jarRoot.getPackageFragment("generic").getClassFile("X.class").getType().getMethod("foo", new String[] {"TK;", "TV;"}); String[] parameterNames = method.getParameterNames(); assertStringsEqual( - "Unexpected parameter names", - "arg0\n" + + "Unexpected parameter names", + "arg0\n" + "arg1\n", parameterNames); } finally { @@ -654,7 +655,7 @@ ITypeParameter typeParameter = clazz.getType().getTypeParameter("T"); clazz.close(); assertStringsEqual( - "Unexpected bounds", + "Unexpected bounds", "java.lang.Object\n", typeParameter.getBounds()); } @@ -673,12 +674,12 @@ */ public void testWorkingCopy01() throws CoreException { IClassFile clazz = this.jarRoot.getPackageFragment("workingcopy").getClassFile("X.class"); - this.workingCopy = clazz.becomeWorkingCopy(null/*no problem requestor*/, null/*primary owner*/, null/*no progress*/); + this.workingCopy = clazz.getWorkingCopy(null/*primary owner*/, (IProgressMonitor) null/*no progress*/); assertElementDescendants( - "Unexpected children", - "[Working copy] X.class\n" + - " package workingcopy\n" + - " class X\n" + + "Unexpected children", + "[Working copy] X.class\n" + + " package workingcopy\n" + + " class X\n" + " void foo()", this.workingCopy); } @@ -692,13 +693,13 @@ attachSource(this.jarRoot, null, null); IClassFile clazz = this.jarRoot.getPackageFragment("workingcopy").getClassFile("X.class"); assertNull("Should not have source attached", clazz.getSource()); - this.workingCopy = clazz.becomeWorkingCopy(null/*no problem requestor*/, null/*primary owner*/, null/*no progress*/); + this.workingCopy = clazz.getWorkingCopy(null/*primary owner*/, (IProgressMonitor) null/*no progress*/); assertElementDescendants( - "Unexpected children", - "[Working copy] X.class\n" + - " package workingcopy\n" + - " class X\n" + - " X()\n" + + "Unexpected children", + "[Working copy] X.class\n" + + " package workingcopy\n" + + " class X\n" + + " X()\n" + " void foo()", this.workingCopy); } finally { @@ -711,20 +712,20 @@ */ public void testWorkingCopy03() throws CoreException { IClassFile clazz = this.jarRoot.getPackageFragment("workingcopy").getClassFile("X.class"); - this.workingCopy = clazz.becomeWorkingCopy(null/*no problem requestor*/, null/*primary owner*/, null/*no progress*/); + this.workingCopy = clazz.getWorkingCopy(null/*primary owner*/, (IProgressMonitor) null/*no progress*/); this.workingCopy.getBuffer().setContents( "package workingcopy;\n" + - "public class X {\n" + + "public class X {\n" + " void bar() {\n" + " }\n" + "}" ); this.workingCopy.reconcile(ICompilationUnit.NO_AST, false/*don't force problems*/, null/*primary owner*/, null/*no progress*/); assertElementDescendants( - "Unexpected children", - "[Working copy] X.class\n" + - " package workingcopy\n" + - " class X\n" + + "Unexpected children", + "[Working copy] X.class\n" + + " package workingcopy\n" + + " class X\n" + " void bar()", this.workingCopy); } @@ -734,10 +735,10 @@ */ public void testWorkingCopy04() throws CoreException { IClassFile clazz = this.jarRoot.getPackageFragment("workingcopy").getClassFile("X.class"); - this.workingCopy = clazz.becomeWorkingCopy(null/*no problem requestor*/, null/*primary owner*/, null/*no progress*/); + this.workingCopy = clazz.getWorkingCopy(null/*primary owner*/, (IProgressMonitor) null/*no progress*/); this.workingCopy.getBuffer().setContents( "package workingcopy;\n" + - "public class X {\n" + + "public class X {\n" + " void bar() {\n" + " }\n" + "}" @@ -749,8 +750,8 @@ exception = e; } assertEquals( - "Unxepected JavaModelException", - "Java Model Exception: Java Model Status [Operation not supported for specified element type(s):[Working copy] X.class [in workingcopy [in lib.jar [in P]]]]", + "Unxepected JavaModelException", + "Java Model Exception: Java Model Status [Operation not supported for specified element type(s):[Working copy] X.class [in workingcopy [in lib.jar [in P]]]]", exception.toString()); } @@ -759,19 +760,19 @@ */ public void testWorkingCopy05() throws CoreException { IClassFile clazz = this.jarRoot.getPackageFragment("workingcopy").getClassFile("X.class"); - this.workingCopy = clazz.becomeWorkingCopy(null/*no problem requestor*/, null/*primary owner*/, null/*no progress*/); + this.workingCopy = clazz.getWorkingCopy(null/*primary owner*/, (IProgressMonitor) null/*no progress*/); this.workingCopy.createType( - "class Y {\n" + + "class Y {\n" + "}", null, false/*don't force*/, null); assertElementDescendants( - "Unexpected children", - "[Working copy] X.class\n" + - " package workingcopy\n" + - " class X\n" + - " void foo()\n" + + "Unexpected children", + "[Working copy] X.class\n" + + " package workingcopy\n" + + " class X\n" + + " void foo()\n" + " class Y", this.workingCopy); } @@ -782,7 +783,7 @@ public void testWorkingCopy06() throws CoreException { IClassFile clazz = this.jarRoot.getPackageFragment("workingcopy").getClassFile("X.class"); WorkingCopyOwner owner = new WorkingCopyOwner() {}; - this.workingCopy = clazz.becomeWorkingCopy(null/*no problem requestor*/, owner, null/*no progress*/); + this.workingCopy = clazz.getWorkingCopy(owner, null/*no progress*/); ICompilationUnit primary = this.workingCopy.getPrimary(); assertEquals("Unexpected owner of primary working copy", null, primary.getOwner()); } @@ -793,10 +794,10 @@ public void testWorkingCopy07() throws CoreException { IClassFile clazz = this.jarRoot.getPackageFragment("workingcopy").getClassFile("X.class"); WorkingCopyOwner owner = new WorkingCopyOwner() {}; - this.workingCopy = clazz.becomeWorkingCopy(null/*no problem requestor*/, owner, null/*no progress*/); + this.workingCopy = clazz.getWorkingCopy(owner, null/*no progress*/); this.workingCopy.getBuffer().setContents( "package workingcopy;\n" + - "public class X {\n" + + "public class X {\n" + " void bar() {\n" + " }\n" + "}" @@ -804,10 +805,10 @@ this.workingCopy.reconcile(ICompilationUnit.NO_AST, false/*don't force problems*/, null/*primary owner*/, null/*no progress*/); this.workingCopy.restore(); assertElementDescendants( - "Unexpected children", - "[Working copy] X.class\n" + - " package workingcopy\n" + - " class X\n" + + "Unexpected children", + "[Working copy] X.class\n" + + " package workingcopy\n" + + " class X\n" + " void foo()", this.workingCopy); } @@ -817,22 +818,22 @@ */ public void testWorkingCopy08() throws CoreException { IClassFile clazz = this.jarRoot.getPackageFragment("workingcopy").getClassFile("X.class"); - WorkingCopyOwner owner = new WorkingCopyOwner() {}; - this.workingCopy = clazz.becomeWorkingCopy(null/*no problem requestor*/, owner, null/*no progress*/); + ProblemRequestor problemRequestor = new ProblemRequestor(); + WorkingCopyOwner owner = newWorkingCopyOwner(problemRequestor); + this.workingCopy = clazz.getWorkingCopy(owner, null/*no progress*/); this.workingCopy.getBuffer().setContents( "package workingcopy;\n" + - "public class X {\n" + + "public class X {\n" + " public void bar() {\n" + " }\n" + "}" ); this.workingCopy.makeConsistent(null); - + ICompilationUnit cu = getCompilationUnit("/P/Y.java"); ICompilationUnit copy = null; try { - ProblemRequestor problemRequestor = new ProblemRequestor(); - copy = cu.getWorkingCopy(owner, problemRequestor, null/*no prpgress*/); + copy = cu.getWorkingCopy(owner, null/*no progress*/); copy.getBuffer().setContents( "public class Y {\n" + " void foo(workingcopy.X x) {\n" + @@ -841,10 +842,11 @@ "}" ); problemRequestor.problems = new StringBuffer(); + problemRequestor.problemCount = 0; copy.reconcile(ICompilationUnit.NO_AST, false/*don't force problems*/, owner, null/*no progress*/); assertProblems( - "Unexpected problems", - "----------\n" + + "Unexpected problems", + "----------\n" + "----------\n", problemRequestor); } finally { @@ -858,28 +860,29 @@ */ public void testWorkingCopy09() throws CoreException { IClassFile clazz = this.jarRoot.getPackageFragment("workingcopy").getClassFile("X.class"); - WorkingCopyOwner owner = new WorkingCopyOwner() {}; - this.workingCopy = clazz.becomeWorkingCopy(null/*no problem requestor*/, owner, null/*no progress*/); + ProblemRequestor problemRequestor = new ProblemRequestor(); + WorkingCopyOwner owner = newWorkingCopyOwner(problemRequestor); + this.workingCopy = clazz.getWorkingCopy(owner, null/*no progress*/); this.workingCopy.getBuffer().setContents( ""); this.workingCopy.makeConsistent(null); - + ICompilationUnit cu = getCompilationUnit("/P/Y.java"); ICompilationUnit copy = null; try { - ProblemRequestor problemRequestor = new ProblemRequestor(); - copy = cu.getWorkingCopy(owner, problemRequestor, null/*no prpgress*/); + copy = cu.getWorkingCopy(owner, /*problemRequestor, */null/*no prpgress*/); copy.getBuffer().setContents( "public class Y {\n" + " workingcopy.X x;\n" + "}" ); problemRequestor.problems = new StringBuffer(); + problemRequestor.problemCount = 0; copy.reconcile(ICompilationUnit.NO_AST, false/*don't force problems*/, owner, null/*no progress*/); assertProblems( - "Unexpected problems", - "----------\n" + - "1. ERROR in /P/Y.java\n" + - "workingcopy.X cannot be resolved to a type\n" + + "Unexpected problems", + "----------\n" + + "1. ERROR in /P/Y.java\n" + + "workingcopy.X cannot be resolved to a type\n" + "----------\n", problemRequestor); } finally { @@ -897,18 +900,18 @@ attachSource(this.jarRoot, null, null); IClassFile clazz = this.jarRoot.getPackageFragment("workingcopy").getClassFile("Y.class"); assertNull("Should not have source attached", clazz.getSource()); - this.workingCopy = clazz.becomeWorkingCopy(null/*no problem requestor*/, null/*primary owner*/, null/*no progress*/); + this.workingCopy = clazz.getWorkingCopy(null/*primary owner*/, (IProgressMonitor) null/*no progress*/); assertSourceEquals( - "Unexpected source", - "package workingcopy;\n" + - "public class Y {\n" + - " \n" + - " public Y() {\n" + - " }\n" + - " \n" + - " T foo(T t, java.lang.String... args) {\n" + - " return null;\n" + - " }\n" + + "Unexpected source", + "package workingcopy;\n" + + "public class Y {\n" + + " \n" + + " public Y() {\n" + + " }\n" + + " \n" + + " T foo(T t, java.lang.String... args) {\n" + + " return null;\n" + + " }\n" + "}", this.workingCopy.getSource()); } finally { @@ -922,10 +925,10 @@ public void testWorkingCopy11() throws CoreException { IPackageFragment pkg = this.jarRoot.getPackageFragment("workingcopy"); IClassFile clazz = pkg.getClassFile("X.class"); - this.workingCopy = clazz.becomeWorkingCopy(null/*no problem requestor*/, null/*primary owner*/, null/*no progress*/); + this.workingCopy = clazz.getWorkingCopy(null/*primary owner*/, (IProgressMonitor) null/*no progress*/); this.workingCopy.getBuffer().setContents( ""); this.workingCopy.makeConsistent(null); - + IJavaSearchScope scope = SearchEngine.createJavaSearchScope(new IJavaElement[] {pkg}); AbstractJavaSearchTests.JavaSearchResultCollector requestor = new AbstractJavaSearchTests.JavaSearchResultCollector(); search("*", IJavaSearchConstants.TYPE, IJavaSearchConstants.DECLARATIONS, scope, requestor); Index: src/org/eclipse/jdt/core/tests/dom/ASTConverterTestAST3_2.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverterTestAST3_2.java,v retrieving revision 1.115 diff -u -r1.115 ASTConverterTestAST3_2.java --- src/org/eclipse/jdt/core/tests/dom/ASTConverterTestAST3_2.java 8 Mar 2007 10:00:28 -0000 1.115 +++ src/org/eclipse/jdt/core/tests/dom/ASTConverterTestAST3_2.java 13 Mar 2007 16:19:21 -0000 @@ -4222,7 +4222,7 @@ public void test0538b() throws JavaModelException { ICompilationUnit sourceUnit = getCompilationUnit("Converter", "src", "test0538", "A.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ try { - sourceUnit.becomeWorkingCopy(null, null); + sourceUnit.becomeWorkingCopy(null); sourceUnit.getBuffer().setContents( "package test0538;\n" + "public class A {\n" + Index: src/org/eclipse/jdt/core/tests/dom/ASTConverterTest2.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverterTest2.java,v retrieving revision 1.178 diff -u -r1.178 ASTConverterTest2.java --- src/org/eclipse/jdt/core/tests/dom/ASTConverterTest2.java 6 Mar 2007 04:43:20 -0000 1.178 +++ src/org/eclipse/jdt/core/tests/dom/ASTConverterTest2.java 13 Mar 2007 16:19:17 -0000 @@ -4156,7 +4156,7 @@ public void test0538b() throws JavaModelException { ICompilationUnit sourceUnit = getCompilationUnit("Converter", "src", "test0538", "A.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ try { - sourceUnit.becomeWorkingCopy(null, null); + sourceUnit.becomeWorkingCopy(null); sourceUnit.getBuffer().setContents( "package test0538;\n" + "public class A {\n" + Index: src/org/eclipse/jdt/core/tests/dom/AbstractASTTests.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/AbstractASTTests.java,v retrieving revision 1.29 diff -u -r1.29 AbstractASTTests.java --- src/org/eclipse/jdt/core/tests/dom/AbstractASTTests.java 7 Nov 2006 18:47:36 -0000 1.29 +++ src/org/eclipse/jdt/core/tests/dom/AbstractASTTests.java 13 Mar 2007 16:19:21 -0000 @@ -119,7 +119,7 @@ String markerStart = "/*start" + markerNumber + "*/"; String markerEnd = "/*end" + markerNumber + "*/"; - int astStart = source.indexOf(markerStart); // start of AST inclusive + int astStart = this.source.indexOf(markerStart); // start of AST inclusive this.astStarts[markerIndex-1] = astStart; removeMarkerFromSource(markerStart, astStart, markerIndex-1); int astEnd = this.source.indexOf(markerEnd); // end of AST exclusive @@ -380,15 +380,11 @@ } protected ICompilationUnit[] createWorkingCopies(MarkerInfo[] markerInfos, WorkingCopyOwner owner) throws JavaModelException { - return createWorkingCopies(markerInfos, owner, null); - } - - protected ICompilationUnit[] createWorkingCopies(MarkerInfo[] markerInfos, WorkingCopyOwner owner, IProblemRequestor problemRequestor) throws JavaModelException { int length = markerInfos.length; ICompilationUnit[] copies = new ICompilationUnit[length]; for (int i = 0; i < length; i++) { MarkerInfo markerInfo = markerInfos[i]; - ICompilationUnit workingCopy = getCompilationUnit(markerInfo.path).getWorkingCopy(owner, problemRequestor, null); + ICompilationUnit workingCopy = getCompilationUnit(markerInfo.path).getWorkingCopy(owner, null); workingCopy.getBuffer().setContents(markerInfo.source); workingCopy.makeConsistent(null); copies[i] = workingCopy; @@ -423,6 +419,21 @@ return result; } + /** + * Create a new working copy owner using given problem requestor + * to report problem. + * + * @param problemRequestor The requestor used to report problems + * @return The created working copy owner + */ + protected WorkingCopyOwner newWorkingCopyOwner(final IProblemRequestor problemRequestor) { + return new WorkingCopyOwner() { + public IProblemRequestor getProblemRequestor(ICompilationUnit unit) { + return problemRequestor; + } + }; + } + protected void resolveASTs(ICompilationUnit[] cus, String[] bindingKeys, ASTRequestor requestor, IJavaProject project, WorkingCopyOwner owner) { ASTParser parser = ASTParser.newParser(AST.JLS3); parser.setResolveBindings(true); Index: src/org/eclipse/jdt/core/tests/dom/BatchASTCreationTests.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/BatchASTCreationTests.java,v retrieving revision 1.73 diff -u -r1.73 BatchASTCreationTests.java --- src/org/eclipse/jdt/core/tests/dom/BatchASTCreationTests.java 6 Mar 2007 04:43:20 -0000 1.73 +++ src/org/eclipse/jdt/core/tests/dom/BatchASTCreationTests.java 13 Mar 2007 16:19:22 -0000 @@ -208,7 +208,7 @@ ASTParser parser = ASTParser.newParser(AST.JLS3); parser.createASTs(cus, new String[] {}, requestor, null); } - + protected ICompilationUnit[] createWorkingCopies(String[] pathAndSources) throws JavaModelException { return createWorkingCopies(pathAndSources, this.owner); } @@ -225,7 +225,8 @@ } : null; MarkerInfo[] markerInfos = createMarkerInfos(pathAndSources); - return createWorkingCopies(markerInfos, this.owner, problemRequestor); + this.owner = newWorkingCopyOwner(problemRequestor); + return createWorkingCopies(markerInfos, this.owner); } private void resolveASTs(ICompilationUnit[] cus, TestASTRequestor requestor) { @@ -1465,7 +1466,7 @@ try { // primary working copy with no method foo() primaryWorkingCopy = getCompilationUnit("/P/p1/X.java"); - primaryWorkingCopy.becomeWorkingCopy(null/*no pb requestor*/, null/*no progress*/); + primaryWorkingCopy.becomeWorkingCopy(null/*no progress*/); primaryWorkingCopy.getBuffer().setContents( "package p1;\n" + "public class X {\n" + @@ -1480,8 +1481,7 @@ "public class X {\n" + " void foo() {}\n" + "}", - this.owner, - false/*don't compute problems*/ + this.owner ); // create bindings @@ -2007,8 +2007,8 @@ class BindingRequestor extends ASTRequestor { ITypeBinding _result = null; public void acceptBinding(String bindingKey, IBinding binding) { - if (_result == null && binding != null && binding.getKind() == IBinding.TYPE) - _result = (ITypeBinding) binding; + if (this._result == null && binding != null && binding.getKind() == IBinding.TYPE) + this._result = (ITypeBinding) binding; } } String[] keys = new String[] { @@ -2036,8 +2036,8 @@ class BindingRequestor extends ASTRequestor { ITypeBinding _result = null; public void acceptBinding(String bindingKey, IBinding binding) { - if (_result == null && binding != null && binding.getKind() == IBinding.TYPE) - _result = (ITypeBinding) binding; + if (this._result == null && binding != null && binding.getKind() == IBinding.TYPE) + this._result = (ITypeBinding) binding; } } String[] keys = new String[] { Index: src/org/eclipse/jdt/core/tests/dom/ASTModelBridgeTests.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTModelBridgeTests.java,v retrieving revision 1.47 diff -u -r1.47 ASTModelBridgeTests.java --- src/org/eclipse/jdt/core/tests/dom/ASTModelBridgeTests.java 14 Nov 2006 17:33:03 -0000 1.47 +++ src/org/eclipse/jdt/core/tests/dom/ASTModelBridgeTests.java 13 Mar 2007 16:19:21 -0000 @@ -128,16 +128,16 @@ "}" }, "1.5"); + IProblemRequestor problemRequestor = new IProblemRequestor() { + public void acceptProblem(IProblem problem) {} + public void beginReporting() {} + public void endReporting() {} + public boolean isActive() { + return true; + } + }; this.workingCopy = getCompilationUnit("/P/src/X.java").getWorkingCopy( - new WorkingCopyOwner() {}, - new IProblemRequestor() { - public void acceptProblem(IProblem problem) {} - public void beginReporting() {} - public void endReporting() {} - public boolean isActive() { - return true; - } - }, + newWorkingCopyOwner(problemRequestor), null/*no progress*/); } @@ -443,7 +443,8 @@ " public void foo(int i, String s) {\n" + " }\n" + "}", - owner, false); + owner + ); this.workingCopies[1] = getWorkingCopy( "/P/src/Y.java", "public class Y extends X {\n" + @@ -451,13 +452,15 @@ " new Y() {};\n" + " }\n" + "}", - owner, false); + owner + ); this.workingCopies[2] = getWorkingCopy( "/P/src/I.java", "public interface I {\n" + " int BAR;\n" + "}", - owner, false); + owner + ); IType typeX = this.workingCopies[0].getType("X"); IJavaElement[] elements = new IJavaElement[] { typeX, @@ -852,7 +855,7 @@ bindingKeys, requestor, getJavaProject("P"), - workingCopy.getOwner() + this.workingCopy.getOwner() ); IBinding[] bindings = requestor.getBindings(bindingKeys); @@ -1012,8 +1015,7 @@ "public class Y {\n" + " void foo(int i, String[] args, java.lang.Class clazz) {}\n" + "}", - this.workingCopy.getOwner(), - null + this.workingCopy.getOwner() ); ASTNode node = buildAST( "public class X {\n" + #P org.eclipse.jdt.core.tests.performance Index: src/org/eclipse/jdt/core/tests/performance/FullSourceWorkspaceModelTests.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.performance/src/org/eclipse/jdt/core/tests/performance/FullSourceWorkspaceModelTests.java,v retrieving revision 1.19 diff -u -r1.19 FullSourceWorkspaceModelTests.java --- src/org/eclipse/jdt/core/tests/performance/FullSourceWorkspaceModelTests.java 1 Mar 2007 11:08:15 -0000 1.19 +++ src/org/eclipse/jdt/core/tests/performance/FullSourceWorkspaceModelTests.java 13 Mar 2007 16:19:39 -0000 @@ -667,7 +667,7 @@ try { // Setup workingCopy = (ICompilationUnit) JavaCore.create(ResourcesPlugin.getWorkspace().getRoot().getFile(new Path("/BigProject/src/org/eclipse/jdt/core/tests/BigCu.java"))); - workingCopy.becomeWorkingCopy(null, null); + workingCopy.becomeWorkingCopy(null); // Warm up if (WARMUP_COUNT > 0) { #P org.eclipse.jdt.core Index: model/org/eclipse/jdt/internal/core/DefaultWorkingCopyOwner.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/DefaultWorkingCopyOwner.java,v retrieving revision 1.16 diff -u -r1.16 DefaultWorkingCopyOwner.java --- model/org/eclipse/jdt/internal/core/DefaultWorkingCopyOwner.java 10 May 2006 18:03:47 -0000 1.16 +++ model/org/eclipse/jdt/internal/core/DefaultWorkingCopyOwner.java 13 Mar 2007 16:19:42 -0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2006 IBM Corporation and others. + * Copyright (c) 2000, 2007 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -28,9 +28,6 @@ // only one instance can be created } - /** - * @deprecated Marked deprecated as it is using deprecated code - */ public IBuffer createBuffer(ICompilationUnit workingCopy) { if (this.primaryBufferProvider != null) return this.primaryBufferProvider.createBuffer(workingCopy); return super.createBuffer(workingCopy); Index: model/org/eclipse/jdt/internal/core/CompilationUnit.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CompilationUnit.java,v retrieving revision 1.239 diff -u -r1.239 CompilationUnit.java --- model/org/eclipse/jdt/internal/core/CompilationUnit.java 6 Mar 2007 02:38:49 -0000 1.239 +++ model/org/eclipse/jdt/internal/core/CompilationUnit.java 13 Mar 2007 16:19:42 -0000 @@ -68,6 +68,13 @@ operation.runOperation(monitor); } } +/* + * @see ICompilationUnit#becomeWorkingCopy(IProgressMonitor) + */ +public void becomeWorkingCopy(IProgressMonitor monitor) throws JavaModelException { + IProblemRequestor requestor = this.owner == null ? null : this.owner.getProblemRequestor(this); + becomeWorkingCopy(requestor, monitor); +} protected boolean buildStructure(OpenableElementInfo info, final IProgressMonitor pm, Map newElements, IResource underlyingResource) throws JavaModelException { // check if this compilation unit can be opened @@ -904,6 +911,7 @@ } /** * @see ICompilationUnit#getWorkingCopy(WorkingCopyOwner, IProblemRequestor, IProgressMonitor) + * @deprecated */ public ICompilationUnit getWorkingCopy(WorkingCopyOwner workingCopyOwner, IProblemRequestor problemRequestor, IProgressMonitor monitor) throws JavaModelException { if (!isPrimary()) return this; @@ -1122,7 +1130,7 @@ throws JavaModelException { return reconcile(astLevel, forceProblemDetection, false, workingCopyOwner, monitor); } - + /** * @see ICompilationUnit#reconcile(int, boolean, WorkingCopyOwner, IProgressMonitor) * @since 3.0 Index: model/org/eclipse/jdt/internal/core/ReconcileWorkingCopyOperation.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ReconcileWorkingCopyOperation.java,v retrieving revision 1.42 diff -u -r1.42 ReconcileWorkingCopyOperation.java --- model/org/eclipse/jdt/internal/core/ReconcileWorkingCopyOperation.java 8 Mar 2007 09:33:02 -0000 1.42 +++ model/org/eclipse/jdt/internal/core/ReconcileWorkingCopyOperation.java 13 Mar 2007 16:19:43 -0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2006 IBM Corporation and others. + * Copyright (c) 2000, 2007 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -32,11 +32,11 @@ * High level summmary of what a reconcile does: *
    *
  • populates the model with the new working copy contents
  • - *
  • fires a fine grained delta (flag F_FINE_GRAINED) describing the difference between the previous content + *
  • fires a fine grained delta (flag F_FINE_GRAINED) describing the difference between the previous content * and the new content (which method was added/removed, which field was changed, etc.)
  • *
  • computes problems and reports them to the IProblemRequestor (begingReporting(), n x acceptProblem(...), endReporting()) iff * (working copy is not consistent with its buffer || forceProblemDetection is set) - * && problem requestor is active + * && problem requestor is active *
  • *
  • produces a DOM AST (either JLS_2, JLS_3 or NO_AST) that is resolved if flag is set
  • *
  • notifies compilation participants of the reconcile allowing them to participate in this operation and report problems
  • @@ -44,7 +44,7 @@ */ public class ReconcileWorkingCopyOperation extends JavaModelOperation { public static boolean PERF = false; - + public int astLevel; public boolean resolveBindings; public HashMap problems; @@ -53,7 +53,7 @@ WorkingCopyOwner workingCopyOwner; public org.eclipse.jdt.core.dom.CompilationUnit ast; public JavaElementDeltaBuilder deltaBuilder; - + public ReconcileWorkingCopyOperation(IJavaElement workingCopy, int astLevel, boolean forceProblemDetection, boolean enableStatementsRecovery, WorkingCopyOwner workingCopyOwner) { super(new IJavaElement[] {workingCopy}); this.astLevel = astLevel; @@ -61,7 +61,7 @@ this.enableStatementsRecovery = enableStatementsRecovery; this.workingCopyOwner = workingCopyOwner; } - + /** * @exception JavaModelException if setting the source * of the original compilation unit fails @@ -69,47 +69,40 @@ protected void executeOperation() throws JavaModelException { checkCanceled(); try { - beginTask(Messages.element_reconciling, 2); - + beginTask(Messages.element_reconciling, 2); + CompilationUnit workingCopy = getWorkingCopy(); boolean wasConsistent = workingCopy.isConsistent(); IProblemRequestor problemRequestor = workingCopy.getPerWorkingCopyInfo(); + if (problemRequestor != null) { + problemRequestor = ((JavaModelManager.PerWorkingCopyInfo)problemRequestor).getProblemRequestor(); + } + IProblemRequestor ownerProblemRequestor = this.workingCopyOwner.getProblemRequestor(workingCopy); this.resolveBindings |= problemRequestor != null && problemRequestor.isActive(); - + // create the delta builder (this remembers the current content of the cu) this.deltaBuilder = new JavaElementDeltaBuilder(workingCopy); - + // make working copy consistent if needed and compute AST if needed makeConsistent(workingCopy, problemRequestor); - + // notify reconcile participants notifyParticipants(workingCopy); - + // recreate ast if needed if (this.ast == null && (this.astLevel > ICompilationUnit.NO_AST || this.resolveBindings)) makeConsistent(workingCopy, problemRequestor); - + // report problems if (this.problems != null && (this.forceProblemDetection || !wasConsistent)) { - try { - problemRequestor.beginReporting(); - for (Iterator iteraror = this.problems.values().iterator(); iteraror.hasNext();) { - CategorizedProblem[] categorizedProblems = (CategorizedProblem[]) iteraror.next(); - if (categorizedProblems == null) continue; - for (int i = 0, length = categorizedProblems.length; i < length; i++) { - CategorizedProblem problem = categorizedProblems[i]; - if (JavaModelManager.VERBOSE){ - System.out.println("PROBLEM FOUND while reconciling : " + problem.getMessage());//$NON-NLS-1$ - } - if (this.progressMonitor != null && this.progressMonitor.isCanceled()) break; - problemRequestor.acceptProblem(problem); - } - } - } finally { - problemRequestor.endReporting(); + if (problemRequestor != null) { + reportProblems(workingCopy, problemRequestor); + } + if (ownerProblemRequestor != null && ownerProblemRequestor != problemRequestor) { + reportProblems(workingCopy, ownerProblemRequestor); } } - + // report delta JavaElementDelta delta = this.deltaBuilder.delta; if (delta != null) { @@ -119,18 +112,47 @@ done(); } } + + /** + * Report working copy problems to a given requestor. + * + * @param workingCopy + * @param problemRequestor + */ + private void reportProblems(CompilationUnit workingCopy, IProblemRequestor problemRequestor) { + try { + problemRequestor.beginReporting(); + for (Iterator iteraror = this.problems.values().iterator(); iteraror.hasNext();) { + CategorizedProblem[] categorizedProblems = (CategorizedProblem[]) iteraror.next(); + if (categorizedProblems == null) continue; + for (int i = 0, length = categorizedProblems.length; i < length; i++) { + CategorizedProblem problem = categorizedProblems[i]; + if (JavaModelManager.VERBOSE){ + System.out.println("PROBLEM FOUND while reconciling : " + problem.getMessage());//$NON-NLS-1$ + } + if (this.progressMonitor != null && this.progressMonitor.isCanceled()) break; + problemRequestor.acceptProblem(problem); + } + } + } finally { + problemRequestor.endReporting(); + } + } + /** * Returns the working copy this operation is working on. */ protected CompilationUnit getWorkingCopy() { return (CompilationUnit)getElementToProcess(); } - /** - * @see JavaModelOperation#isReadOnly + + /* (non-Javadoc) + * @see org.eclipse.jdt.internal.core.JavaModelOperation#isReadOnly() */ public boolean isReadOnly() { return true; } + /* * Makes the given working copy consistent, computes the delta and computes an AST if needed. * Returns the AST. @@ -144,7 +166,7 @@ if (this.ast != null && this.deltaBuilder.delta != null) this.deltaBuilder.delta.changedAST(this.ast); return this.ast; - } + } if (this.ast != null) return this.ast; // no need to recompute AST if known already if (this.forceProblemDetection || this.resolveBindings) { if (JavaProject.hasJavaNature(workingCopy.getJavaProject().getProject())) { @@ -159,28 +181,28 @@ try { // find problems char[] contents = workingCopy.getContents(); - unit = + unit = CompilationUnitProblemFinder.process( - workingCopy, - contents, - this.workingCopyOwner, - problemMap, - this.astLevel != ICompilationUnit.NO_AST/*creating AST if level is not NO_AST */, + workingCopy, + contents, + this.workingCopyOwner, + problemMap, + this.astLevel != ICompilationUnit.NO_AST/*creating AST if level is not NO_AST */, this.enableStatementsRecovery, this.progressMonitor); if (this.progressMonitor != null) this.progressMonitor.worked(1); - + // create AST if needed if (this.astLevel != ICompilationUnit.NO_AST && unit != null) { Map options = workingCopy.getJavaProject().getOptions(true); - this.ast = + this.ast = AST.convertCompilationUnit( - this.astLevel, - unit, - contents, - options, - true/*isResolved*/, - workingCopy, + this.astLevel, + unit, + contents, + options, + true/*isResolved*/, + workingCopy, this.progressMonitor); if (this.ast != null) { this.deltaBuilder.delta = new JavaElementDelta(workingCopy); @@ -200,12 +222,12 @@ } } // else working copy not in a Java project return this.ast; - } + } return null; } private void notifyParticipants(final CompilationUnit workingCopy) { IJavaProject javaProject = getWorkingCopy().getJavaProject(); - CompilationParticipant[] participants = JavaModelManager.getJavaModelManager().compilationParticipants.getCompilationParticipants(javaProject); + CompilationParticipant[] participants = JavaModelManager.getJavaModelManager().compilationParticipants.getCompilationParticipants(javaProject); if (participants == null) return; final ReconcileContext context = new ReconcileContext(this, workingCopy); @@ -229,6 +251,7 @@ }); } } + protected IJavaModelStatus verify() { IJavaModelStatus status = super.verify(); if (!status.isOK()) { @@ -241,5 +264,4 @@ return status; } - } Index: model/org/eclipse/jdt/internal/core/JavaModelManager.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaModelManager.java,v retrieving revision 1.361 diff -u -r1.361 JavaModelManager.java --- model/org/eclipse/jdt/internal/core/JavaModelManager.java 7 Mar 2007 16:09:14 -0000 1.361 +++ model/org/eclipse/jdt/internal/core/JavaModelManager.java 13 Mar 2007 16:19:43 -0000 @@ -1092,28 +1092,38 @@ public static class PerWorkingCopyInfo implements IProblemRequestor { int useCount = 0; IProblemRequestor problemRequestor; - ICompilationUnit workingCopy; - public PerWorkingCopyInfo(ICompilationUnit workingCopy, IProblemRequestor problemRequestor) { + CompilationUnit workingCopy; + public PerWorkingCopyInfo(CompilationUnit workingCopy, IProblemRequestor problemRequestor) { this.workingCopy = workingCopy; this.problemRequestor = problemRequestor; } public void acceptProblem(IProblem problem) { - if (this.problemRequestor == null) return; - this.problemRequestor.acceptProblem(problem); + IProblemRequestor requestor = getProblemRequestor(); + if (requestor == null) return; + requestor.acceptProblem(problem); } public void beginReporting() { - if (this.problemRequestor == null) return; - this.problemRequestor.beginReporting(); + IProblemRequestor requestor = getProblemRequestor(); + if (requestor == null) return; + requestor.beginReporting(); } public void endReporting() { - if (this.problemRequestor == null) return; - this.problemRequestor.endReporting(); + IProblemRequestor requestor = getProblemRequestor(); + if (requestor == null) return; + requestor.endReporting(); + } + public IProblemRequestor getProblemRequestor() { + if (this.problemRequestor == null && this.workingCopy.owner != null) { + return this.workingCopy.owner.getProblemRequestor(this.workingCopy); + } + return this.problemRequestor; } public ICompilationUnit getWorkingCopy() { return this.workingCopy; } public boolean isActive() { - return this.problemRequestor != null && this.problemRequestor.isActive(); + IProblemRequestor requestor = getProblemRequestor(); + return requestor != null && requestor.isActive(); } public String toString() { StringBuffer buffer = new StringBuffer(); @@ -1123,6 +1133,11 @@ buffer.append(this.useCount); buffer.append("\nProblem requestor:\n "); //$NON-NLS-1$ buffer.append(this.problemRequestor); + if (this.problemRequestor == null) { + IProblemRequestor requestor = getProblemRequestor(); + buffer.append("\nOwner problem requestor:\n "); //$NON-NLS-1$ + buffer.append(requestor); + } return buffer.toString(); } } Index: model/org/eclipse/jdt/core/WorkingCopyOwner.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/model/org/eclipse/jdt/core/WorkingCopyOwner.java,v retrieving revision 1.22 diff -u -r1.22 WorkingCopyOwner.java --- model/org/eclipse/jdt/core/WorkingCopyOwner.java 6 Mar 2007 02:38:49 -0000 1.22 +++ model/org/eclipse/jdt/core/WorkingCopyOwner.java 13 Mar 2007 16:19:42 -0000 @@ -19,50 +19,50 @@ import org.eclipse.jdt.internal.core.PackageFragment; /** - * The owner of an ICompilationUnit handle in working copy mode. + * The owner of an {@link ICompilationUnit} handle in working copy mode. * An owner is used to identify a working copy and to create its buffer. *

    * Clients should subclass this class to instantiate a working copy owner that is specific to their need and that - * they can pass in to various APIs (e.g. IType.resolveType(String, WorkingCopyOwner). - * Clients can also override the default implementation of createBuffer(ICompilationUnit). + * they can pass in to various APIs (e.g. {@link IType#resolveType(String, WorkingCopyOwner)}. + * Clients can also override the default implementation of {@link #createBuffer(ICompilationUnit)}. *

    * Note: even though this class has no abstract method, which means that it provides functional default behavior, * it is still an abstract class, as clients are intended to own their owner implementation. *

    - * @see ICompilationUnit#becomeWorkingCopy(IProblemRequestor, org.eclipse.core.runtime.IProgressMonitor) + * @see ICompilationUnit#becomeWorkingCopy(org.eclipse.core.runtime.IProgressMonitor) * @see ICompilationUnit#discardWorkingCopy() * @see ICompilationUnit#getWorkingCopy(org.eclipse.core.runtime.IProgressMonitor) * @since 3.0 */ public abstract class WorkingCopyOwner { - + /** * Sets the buffer provider of the primary working copy owner. Note that even if the * buffer provider is a working copy owner, only its createBuffer(ICompilationUnit) - * method is used by the primary working copy owner. It doesn't replace the internal primary + * method is used by the primary working copy owner. It doesn't replace the internal primary * working owner. *

    * This method is for internal use by the jdt-related plug-ins. * Clients outside of the jdt should not reference this method. *

    - * + * * @param primaryBufferProvider the primary buffer provider */ public static void setPrimaryBufferProvider(WorkingCopyOwner primaryBufferProvider) { DefaultWorkingCopyOwner.PRIMARY.primaryBufferProvider = primaryBufferProvider; } - + /** * Creates a buffer for the given working copy. * The new buffer will be initialized with the contents of the underlying file - * if and only if it was not already initialized by the compilation owner (a buffer is + * if and only if it was not already initialized by the compilation owner (a buffer is * uninitialized if its content is null). *

    * Note: This buffer will be associated to the working copy for its entire life-cycle. Another * working copy on same unit but owned by a different owner would not share the same buffer * unless its owner decided to implement such a sharing behaviour. *

    - * + * * @param workingCopy the working copy of the buffer * @return IBuffer the created buffer for the given working copy * @see IBuffer @@ -71,10 +71,27 @@ return BufferManager.createBuffer(workingCopy); } - + + /** + * Returns the problem requestor used by a working copy of this working copy owner. + *

    + * By default, no problem requestor is configured. Clients can override this + * method to provide a requestor. + *

    + * + * @param workingCopy The problem requestor used for the given working copy. + * @return the problem requestor to be used by working copies of this working + * copy owner or null if no problem requestor is configured. + * + * @since 3.3 + */ + public IProblemRequestor getProblemRequestor(ICompilationUnit workingCopy) { + return null; + } + /** - * Returns a new working copy with the given name using this working copy owner to - * create its buffer. + * Returns a new working copy with the given name using this working copy owner to + * create its buffer. *

    * This working copy always belongs to the default package in a package * fragment root that corresponds to its Java project, and this Java project never exists. @@ -87,30 +104,34 @@ * JavaCore#getOptions() is used to create the DOM AST as it is not * possible to set the options on the non-existing Java project. *

    - * When the working copy instance is created, an {@link IJavaElementDelta#ADDED added delta} is + * When the working copy instance is created, an {@link IJavaElementDelta#ADDED added delta} is * reported on this working copy. *

    - * Once done with the working copy, users of this method must discard it using + * Once done with the working copy, users of this method must discard it using * {@link ICompilationUnit#discardWorkingCopy()}. *

    - * Note that when such working copy is committed, only its buffer is saved (see + * Note that when such working copy is committed, only its buffer is saved (see * {@link IBuffer#save(IProgressMonitor, boolean)}) but no resource is created. *

    * This method is not intended to be overriden by clients. *

    - * + * * @param name the name of the working copy (e.g. "X.java") * @param classpath the classpath used to resolve names in this working copy * @param problemRequestor a requestor which will get notified of problems detected during * reconciling as they are discovered. The requestor can be set to null indicating * that the client is not interested in problems. * @param monitor a progress monitor used to report progress while opening the working copy - * or null if no progress should be reported + * or null if no progress should be reported * @throws JavaModelException if the contents of this working copy can - * not be determined. + * not be determined. * @return a new working copy * @see ICompilationUnit#becomeWorkingCopy(IProblemRequestor, IProgressMonitor) * @since 3.2 + * + * @deprecated Use {@link #newWorkingCopy(String, IClasspathEntry[], IProgressMonitor)} instead. + * Note that if this deprecated method is used, problems may be reported twice + * if the given requestor is not the same as the current working copy owner one. */ public final ICompilationUnit newWorkingCopy(String name, IClasspathEntry[] classpath, IProblemRequestor problemRequestor, IProgressMonitor monitor) throws JavaModelException { ExternalJavaProject project = new ExternalJavaProject(classpath); @@ -120,4 +141,51 @@ return result; } + /** + * Returns a new working copy with the given name using this working copy owner to + * create its buffer. + *

    + * This working copy always belongs to the default package in a package + * fragment root that corresponds to its Java project, and this Java project never exists. + * However this Java project has the given classpath that is used when resolving names + * in this working copy. + *

    + * If a DOM AST is created using this working copy, then given classpath will be used + * if bindings need to be resolved. Problems will be reported to the problem requestor + * of the current working copy owner problem if it is not null. + *

    + * Options used to create the DOM AST are got from {@link JavaCore#getOptions()} + * as it is not possible to set the options on a non-existing Java project. + *

    + * When the working copy instance is created, an {@link IJavaElementDelta#ADDED added delta} is + * reported on this working copy. + *

    + * Once done with the working copy, users of this method must discard it using + * {@link ICompilationUnit#discardWorkingCopy()}. + *

    + * Note that when such working copy is committed, only its buffer is saved (see + * {@link IBuffer#save(IProgressMonitor, boolean)}) but no resource is created. + *

    + * This method is not intended to be overriden by clients. + *

    + * + * @param name the name of the working copy (e.g. "X.java") + * @param classpath the classpath used to resolve names in this working copy + * @param monitor a progress monitor used to report progress while opening the working copy + * or null if no progress should be reported + * @throws JavaModelException if the contents of this working copy can + * not be determined. + * @return a new working copy + * @see ICompilationUnit#becomeWorkingCopy(IProgressMonitor) + * + * @since 3.3 + */ + public final ICompilationUnit newWorkingCopy(String name, IClasspathEntry[] classpath, IProgressMonitor monitor) throws JavaModelException { + ExternalJavaProject project = new ExternalJavaProject(classpath); + IPackageFragment parent = project.getPackageFragmentRoot(Path.EMPTY).getPackageFragment(IPackageFragment.DEFAULT_PACKAGE_NAME); + CompilationUnit result = new CompilationUnit((PackageFragment) parent, name, this); + result.becomeWorkingCopy(getProblemRequestor(result), monitor); + return result; + } + } Index: model/org/eclipse/jdt/core/ICompilationUnit.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/model/org/eclipse/jdt/core/ICompilationUnit.java,v retrieving revision 1.59 diff -u -r1.59 ICompilationUnit.java --- model/org/eclipse/jdt/core/ICompilationUnit.java 24 Nov 2006 13:56:36 -0000 1.59 +++ model/org/eclipse/jdt/core/ICompilationUnit.java 13 Mar 2007 16:19:42 -0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2006 IBM Corporation and others. + * Copyright (c) 2000, 2007 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -17,14 +17,14 @@ /** - * Represents an entire Java compilation unit (source file with one of the + * Represents an entire Java compilation unit (source file with one of the * {@link JavaCore#getJavaLikeExtensions() Java-like extensions}). * Compilation unit elements need to be opened before they can be navigated or manipulated. * The children are of type {@link IPackageDeclaration}, * {@link IImportContainer}, and {@link IType}, * and appear in the order in which they are declared in the source. * If a source file cannot be parsed, its structure remains unknown. - * Use {@link IJavaElement#isStructureKnown} to determine whether this is + * Use {@link IJavaElement#isStructureKnown} to determine whether this is * the case. *

    * This interface is not intended to be implemented by clients. @@ -42,7 +42,7 @@ * created using this compilation unit handle's owner. Uses the primary owner is none was * specified when this compilation unit handle was created. *

    - * When switching to working copy mode, problems are reported to given + * When switching to working copy mode, problems are reported to given * {@link IProblemRequestor}. Note that once in working copy mode, the given * {@link IProblemRequestor} is ignored. Only the original {@link IProblemRequestor} * is used to report subsequent problems. @@ -54,22 +54,51 @@ *

    *

    * If this compilation unit was already in working copy mode, an internal counter is incremented and no - * other action is taken on this compilation unit. To bring this compilation unit back into the original mode - * (where it reflects the underlying resource), {@link #discardWorkingCopy} must be call as many + * other action is taken on this compilation unit. To bring this compilation unit back into the original mode + * (where it reflects the underlying resource), {@link #discardWorkingCopy} must be call as many * times as {@link #becomeWorkingCopy(IProblemRequestor, IProgressMonitor)}. *

    - * + * * @param problemRequestor a requestor which will get notified of problems detected during * reconciling as they are discovered. The requestor can be set to null indicating * that the client is not interested in problems. * @param monitor a progress monitor used to report progress while opening this compilation unit - * or null if no progress should be reported + * or null if no progress should be reported * @throws JavaModelException if this compilation unit could not become a working copy. * @see #discardWorkingCopy() * @since 3.0 + * + * @deprecated Use {@link #becomeWorkingCopy(IProgressMonitor)} instead. + * Note that if this deprecated method is used, problems will be reported on the passed problem requester + * as well as on the problem requestor returned by the working copy owner (if not null). */ void becomeWorkingCopy(IProblemRequestor problemRequestor, IProgressMonitor monitor) throws JavaModelException; /** + * Changes this compilation unit handle into a working copy. A new {@link IBuffer} is + * created using this compilation unit handle's owner. Uses the primary owner if none was + * specified when this compilation unit handle was created. + *

    + * When switching to working copy mode, problems are reported to the {@link IProblemRequestor + * problem requestor} of the {@link WorkingCopyOwner working copy owner}. + *

    + * Once in working copy mode, changes to this compilation unit or its children are done in memory. + * Only the new buffer is affected. Using {@link #commitWorkingCopy(boolean, IProgressMonitor)} + * will bring the underlying resource in sync with this compilation unit. + *

    + * If this compilation unit was already in working copy mode, an internal counter is incremented and no + * other action is taken on this compilation unit. To bring this compilation unit back into the original mode + * (where it reflects the underlying resource), {@link #discardWorkingCopy} must be call as many + * times as {@link #becomeWorkingCopy(IProblemRequestor, IProgressMonitor)}. + *

    + * + * @param monitor a progress monitor used to report progress while opening this compilation unit + * or null if no progress should be reported + * @throws JavaModelException if this compilation unit could not become a working copy. + * @see #discardWorkingCopy() + * @since 3.3 + */ +void becomeWorkingCopy(IProgressMonitor monitor) throws JavaModelException; +/** * Commits the contents of this working copy to its underlying resource. * *

    It is possible that the contents of the original resource have changed @@ -100,7 +129,7 @@ void commitWorkingCopy(boolean force, IProgressMonitor monitor) throws JavaModelException; /** * Creates and returns an non-static import declaration in this compilation unit - * with the given name. This method is equivalent to + * with the given name. This method is equivalent to * createImport(name, Flags.AccDefault, sibling, monitor). * * @param name the name of the import declaration to add as defined by JLS2 7.5. (For example: "java.io.File" or @@ -183,7 +212,7 @@ *

  • The name is not a valid package name (INVALID_NAME) *
*/ - IPackageDeclaration createPackageDeclaration(String name, IProgressMonitor monitor) throws JavaModelException; + IPackageDeclaration createPackageDeclaration(String name, IProgressMonitor monitor) throws JavaModelException; /** * Creates and returns a type in this compilation unit with the * given contents. If this compilation unit does not exist, one @@ -223,17 +252,18 @@ * This has no effect if this compilation unit was not in working copy mode. *

*

- * If {@link #becomeWorkingCopy} was called several times on this - * compilation unit, {@link #discardWorkingCopy} must be called as - * many times before it switches back to the original mode. + * If {@link #becomeWorkingCopy(IProgressMonitor)} method was called several + * times on this compilation unit, {@link #discardWorkingCopy()} must be called + * as many times before it switches back to the original mode. Same as + * for method {@link #getWorkingCopy(IProgressMonitor)}. *

- * + * * @throws JavaModelException if this working copy could not return in its original mode. * @see #becomeWorkingCopy(IProblemRequestor, IProgressMonitor) * @since 3.0 */ void discardWorkingCopy() throws JavaModelException; -/** +/** * Finds the elements in this compilation unit that correspond to * the given element. * An element A corresponds to an element B if: @@ -247,19 +277,19 @@ * * Returns null if no such java elements can be found * or if the given element is not included in a compilation unit. - * + * * @param element the given element * @return the found elements in this compilation unit that correspond to the given element - * @since 3.0 + * @since 3.0 */ IJavaElement[] findElements(IJavaElement element); /** - * Finds the working copy for this compilation unit, given a {@link WorkingCopyOwner}. + * Finds the working copy for this compilation unit, given a {@link WorkingCopyOwner}. * If no working copy has been created for this compilation unit associated with this * working copy owner, returns null. *

- * Users of this method must not destroy the resulting working copy. - * + * Users of this method must not destroy the resulting working copy. + * * @param owner the given {@link WorkingCopyOwner} * @return the found working copy for this compilation unit, null if none * @see WorkingCopyOwner @@ -268,7 +298,7 @@ ICompilationUnit findWorkingCopy(WorkingCopyOwner owner); /** * Returns all types declared in this compilation unit in the order - * in which they appear in the source. + * in which they appear in the source. * This includes all top-level types and nested member types. * It does NOT include local types (types defined in methods). * @@ -283,7 +313,7 @@ * is a convenience method - imports can also be accessed from a compilation unit's * import container. * - * @param name the name of the import to find as defined by JLS2 7.5. (For example: "java.io.File" + * @param name the name of the import to find as defined by JLS2 7.5. (For example: "java.io.File" * or "java.awt.*") * @return a handle onto the corresponding import declaration. The import declaration may or may not exist. */ @@ -291,9 +321,9 @@ /** * Returns the import container for this compilation unit. * This is a handle-only method. The import container may or - * may not exist. The import container can used to access the + * may not exist. The import container can used to access the * imports. - * @return a handle onto the corresponding import container. The + * @return a handle onto the corresponding import container. The * import contain may or may not exist. */ IImportContainer getImportContainer(); @@ -315,7 +345,7 @@ *

* Note that the returned primary compilation unit can be in working copy mode. *

- * + * * @return the primary compilation unit this working copy was created from, * or this compilation unit if it is primary * @since 3.0 @@ -324,7 +354,7 @@ /** * Returns the working copy owner of this working copy. * Returns null if it is not a working copy or if it has no owner. - * + * * @return WorkingCopyOwner the owner of this working copy or null * @since 3.0 */ @@ -369,17 +399,17 @@ */ IType[] getTypes() throws JavaModelException; /** - * Returns a new working copy of this compilation unit if it is a primary compilation unit, + * Returns a new working copy of this compilation unit if it is a primary compilation unit, * or this compilation unit if it is already a non-primary working copy. *

- * Note: if intending to share a working copy amongst several clients, then - * {@link #getWorkingCopy(WorkingCopyOwner, IProblemRequestor, IProgressMonitor)} + * Note: if intending to share a working copy amongst several clients, then + * {@link #getWorkingCopy(WorkingCopyOwner, IProblemRequestor, IProgressMonitor)} * should be used instead. *

- * When the working copy instance is created, an ADDED IJavaElementDelta is + * When the working copy instance is created, an ADDED IJavaElementDelta is * reported on this working copy. *

- * Once done with the working copy, users of this method must discard it using + * Once done with the working copy, users of this method must discard it using * {@link #discardWorkingCopy()}. *

* Since 2.1, a working copy can be created on a not-yet existing compilation @@ -387,9 +417,9 @@ * the corresponding compilation unit. *

* @param monitor a progress monitor used to report progress while opening this compilation unit - * or null if no progress should be reported + * or null if no progress should be reported * @throws JavaModelException if the contents of this element can - * not be determined. + * not be determined. * @return a new working copy of this element if this element is not * a working copy, or this element if this element is already a working copy * @since 3.0 @@ -399,11 +429,11 @@ * Returns a shared working copy on this compilation unit using the given working copy owner to create * the buffer, or this compilation unit if it is already a non-primary working copy. * This API can only answer an already existing working copy if it is based on the same - * original compilation unit AND was using the same working copy owner (that is, as defined by {@link Object#equals}). + * original compilation unit AND was using the same working copy owner (that is, as defined by {@link Object#equals}). *

* The life time of a shared working copy is as follows: *

    - *
  • The first call to {@link #getWorkingCopy(WorkingCopyOwner, IProblemRequestor, IProgressMonitor)} + *
  • The first call to {@link #getWorkingCopy(WorkingCopyOwner, IProblemRequestor, IProgressMonitor)} * creates a new working copy for this element
  • *
  • Subsequent calls increment an internal counter.
  • *
  • A call to {@link #discardWorkingCopy()} decrements the internal counter.
  • @@ -411,7 +441,7 @@ *
* So users of this method must discard exactly once the working copy. *

- * Note that the working copy owner will be used for the life time of this working copy, that is if the + * Note that the working copy owner will be used for the life time of this working copy, that is if the * working copy is closed then reopened, this owner will be used. * The buffer will be automatically initialized with the original's compilation unit content * upon creation. @@ -423,32 +453,35 @@ * unit. In particular, such a working copy can then be committed in order to create * the corresponding compilation unit. *

- * @param owner the working copy owner that creates a buffer that is used to get the content + * @param owner the working copy owner that creates a buffer that is used to get the content * of the working copy * @param problemRequestor a requestor which will get notified of problems detected during * reconciling as they are discovered. The requestor can be set to null indicating * that the client is not interested in problems. * @param monitor a progress monitor used to report progress while opening this compilation unit - * or null if no progress should be reported + * or null if no progress should be reported * @throws JavaModelException if the contents of this element can - * not be determined. + * not be determined. * @return a new working copy of this element using the given factory to create * the buffer, or this element if this element is already a working copy * @since 3.0 + * @deprecated Use {@link ITypeRoot#getWorkingCopy(WorkingCopyOwner, IProgressMonitor)} instead. + * Note that if this deprecated method is used, problems will be reported on the passed problem requester + * as well as on the problem requestor returned by the working copy owner (if not null). */ ICompilationUnit getWorkingCopy(WorkingCopyOwner owner, IProblemRequestor problemRequestor, IProgressMonitor monitor) throws JavaModelException; /** * Returns whether the resource of this working copy has changed since the * inception of this working copy. * Returns false if this compilation unit is not in working copy mode. - * + * * @return whether the resource has changed * @since 3.0 */ public boolean hasResourceChanged(); /** * Returns whether this element is a working copy. - * + * * @return true if this element is a working copy, false otherwise * @since 3.0 */ @@ -457,12 +490,12 @@ /** * Reconciles the contents of this working copy, sends out a Java delta * notification indicating the nature of the change of the working copy since - * the last time it was either reconciled or made consistent + * the last time it was either reconciled or made consistent * ({@link IOpenable#makeConsistent(IProgressMonitor)}), and returns a * compilation unit AST if requested. *

- * It performs the reconciliation by locally caching the contents of - * the working copy, updating the contents, then creating a delta + * It performs the reconciliation by locally caching the contents of + * the working copy, updating the contents, then creating a delta * over the cached contents and the new contents, and finally firing * this delta. *

@@ -491,7 +524,7 @@ * creation of the DOM AST was not requested, or if the requested level of AST * API is not supported, or if the working copy was already consistent. *

- * + * *

* This method doesn't perform statements recovery. To recover statements with syntax * errors, {@link #reconcile(int, boolean, boolean, WorkingCopyOwner, IProgressMonitor)} must be use. @@ -499,13 +532,13 @@ * * @param astLevel either {@link #NO_AST} if no AST is wanted, * or the {@linkplain AST#newAST(int) AST API level} of the AST if one is wanted - * @param forceProblemDetection boolean indicating whether problem should be + * @param forceProblemDetection boolean indicating whether problem should be * recomputed even if the source hasn't changed - * @param owner the owner of working copies that take precedence over the + * @param owner the owner of working copies that take precedence over the * original compilation units, or null if the primary working * copy owner should be used * @param monitor a progress monitor - * @return the compilation unit AST or null if not requested, + * @return the compilation unit AST or null if not requested, * or if the requested level of AST API is not supported, * or if the working copy was consistent * @throws JavaModelException if the contents of the original element @@ -520,12 +553,12 @@ /** * Reconciles the contents of this working copy, sends out a Java delta * notification indicating the nature of the change of the working copy since - * the last time it was either reconciled or made consistent + * the last time it was either reconciled or made consistent * ({@link IOpenable#makeConsistent(IProgressMonitor)}), and returns a * compilation unit AST if requested. *

- * It performs the reconciliation by locally caching the contents of - * the working copy, updating the contents, then creating a delta + * It performs the reconciliation by locally caching the contents of + * the working copy, updating the contents, then creating a delta * over the cached contents and the new contents, and finally firing * this delta. *

@@ -554,7 +587,7 @@ * creation of the DOM AST was not requested, or if the requested level of AST * API is not supported, or if the working copy was already consistent. *

- * + * *

* If statements recovery is enabled then this method tries to rebuild statements * with syntax error. Otherwise statements with syntax error won't be present in @@ -563,14 +596,14 @@ * * @param astLevel either {@link #NO_AST} if no AST is wanted, * or the {@linkplain AST#newAST(int) AST API level} of the AST if one is wanted - * @param forceProblemDetection boolean indicating whether problem should be + * @param forceProblemDetection boolean indicating whether problem should be * recomputed even if the source hasn't changed * @param enableStatementsRecovery if true statements recovery is enabled. - * @param owner the owner of working copies that take precedence over the + * @param owner the owner of working copies that take precedence over the * original compilation units, or null if the primary working * copy owner should be used * @param monitor a progress monitor - * @return the compilation unit AST or null if not requested, + * @return the compilation unit AST or null if not requested, * or if the requested level of AST API is not supported, * or if the working copy was consistent * @throws JavaModelException if the contents of the original element Index: model/org/eclipse/jdt/core/ITypeRoot.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/model/org/eclipse/jdt/core/ITypeRoot.java,v retrieving revision 1.4 diff -u -r1.4 ITypeRoot.java --- model/org/eclipse/jdt/core/ITypeRoot.java 6 Dec 2006 01:43:50 -0000 1.4 +++ model/org/eclipse/jdt/core/ITypeRoot.java 13 Mar 2007 16:19:42 -0000 @@ -79,7 +79,9 @@ * In particular, such a working copy can then be committed in order to create * the corresponding compilation unit. *

- * Note that possible problems of this working copy are not reported using this method. + * Note that possible problems of this working copy are reported using this method only + * if the given working copy owner returns a problem requestor for this working copy + * (see {@link WorkingCopyOwner#getProblemRequestor(ICompilationUnit)}). *

* * @param owner the working copy owner that creates a buffer that is used to get the content Index: model/org/eclipse/jdt/core/IClassFile.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/model/org/eclipse/jdt/core/IClassFile.java,v retrieving revision 1.25 diff -u -r1.25 IClassFile.java --- model/org/eclipse/jdt/core/IClassFile.java 6 Mar 2007 02:38:49 -0000 1.25 +++ model/org/eclipse/jdt/core/IClassFile.java 13 Mar 2007 16:19:42 -0000 @@ -13,10 +13,10 @@ import org.eclipse.core.runtime.IProgressMonitor; /** - * Represents an entire binary type (single .class file). + * Represents an entire binary type (single .class file). * A class file has a single child of type IType. * Class file elements need to be opened before they can be navigated. - * If a class file cannot be parsed, its structure remains unknown. Use + * If a class file cannot be parsed, its structure remains unknown. Use * IJavaElement.isStructureKnown to determine whether this is the * case. *

@@ -31,22 +31,22 @@ * * @see IPackageFragmentRoot#attachSource(org.eclipse.core.runtime.IPath, org.eclipse.core.runtime.IPath, IProgressMonitor) */ - + public interface IClassFile extends ITypeRoot { - + /** * Changes this class file handle into a working copy. A new {@link IBuffer} is * created using the given owner. Uses the primary owner if null is * specified. *

- * When switching to working copy mode, problems are reported to the given + * When switching to working copy mode, problems are reported to the given * {@link IProblemRequestor}. Note that once in working copy mode, the given * {@link IProblemRequestor} is ignored. Only the original {@link IProblemRequestor} * is used to report subsequent problems. *

*

* Once in working copy mode, changes to this working copy or its children are done in memory. - * Only the new buffer is affected. + * Only the new buffer is affected. *

*

* Using {@link ICompilationUnit#commitWorkingCopy(boolean, IProgressMonitor)} on the working copy @@ -54,8 +54,8 @@ *

*

* If this class file was already in working copy mode, an internal counter is incremented and no - * other action is taken on this working copy. To bring this working copy back into the original mode - * (where it reflects the underlying resource), {@link ICompilationUnit#discardWorkingCopy} must be call as many + * other action is taken on this working copy. To bring this working copy back into the original mode + * (where it reflects the underlying resource), {@link ICompilationUnit#discardWorkingCopy} must be call as many * times as {@link #becomeWorkingCopy(IProblemRequestor, WorkingCopyOwner, IProgressMonitor)}. *

*

@@ -65,17 +65,20 @@ *

* The resource of a class file's working copy is null if the class file is in an external jar file. *

- * + * * @param problemRequestor a requestor which will get notified of problems detected during * reconciling as they are discovered. The requestor can be set to null indicating * that the client is not interested in problems. * @param owner the given {@link WorkingCopyOwner}, or null for the primary owner * @param monitor a progress monitor used to report progress while opening this compilation unit - * or null if no progress should be reported + * or null if no progress should be reported * @return a working copy for this class file * @throws JavaModelException if this compilation unit could not become a working copy. * @see ICompilationUnit#discardWorkingCopy() * @since 3.2 + * @deprecated Use {@link ITypeRoot#getWorkingCopy(WorkingCopyOwner, IProgressMonitor)} instead. + * Note that if this deprecated method is used, problems will be reported on the passed problem requester + * as well as on the problem requestor returned by the working copy owner (if not null). */ ICompilationUnit becomeWorkingCopy(IProblemRequestor problemRequestor, WorkingCopyOwner owner, IProgressMonitor monitor) throws JavaModelException; /** @@ -96,7 +99,7 @@ */ IType getType(); /** - * Returns a working copy on the source associated with this class file using the given + * Returns a working copy on the source associated with this class file using the given * factory to create the buffer, or null if there is no source associated * with the class file. *

What's new in this drop

+
    +
  • The working copy owner (WorkingCopyOwner) now specifies the problem requestor +(IProblemrequestor) used to report problems on working copies it owns +(see bug 175243).
    +To implement this new responsibility, a new API method has been added on WorkingCopyOwner class: +
    +/**
    + * Returns the problem requestor used by a working copy of this working copy owner.
    + *
    + * By default, no problem requestor is configured. Clients can override this 
    + * method to provide a requestor.
    + * 
    + * @param workingCopy The problem requestor used for the given working copy.
    + * If null, then return the problem requestor used for all working 
    + * copies of the working copy owner.
    + * @return the problem requestor to be used by working copies of this working 
    + * copy owner or null if no problem requestor is configured.
    + * 
    + * @since 3.3
    + */
    +public IProblemRequestor getProblemRequestor(ICompilationUnit workingCopy) {
    +	return null;
    +}
    +
    +As a consequence of this addition, IProblemRequestor parameter +of *WorkingCopy methods becomes unnecessary and corresponding +methods have been deprecated: +
      +
    1. ICompilationUnit#becomeWorkingCopy(IProblemRequestor, IProgressMonitor)
    2. +
    3. ICompilationUnit#getWorkingCopy(WorkingCopyOwner, IProblemRequestor, IProgressMonitor)
    4. +
    5. IClassFile#becomeWorkingCopy(IProblemRequestor, WorkingCopyOwner, IProgressMonitor)
    6. +
    7. WorkingCopyOwner#newWorkingCopy(String, IClasspathEntry[], IProblemRequestor, IProgressMonitor)
    8. +
    +And are obviously replaced by following methods: +
      +
    1. ICompilationUnit#becomeWorkingCopy(IProgressMonitor)
    2. +
    3. ICompilationUnit#getWorkingCopy(WorkingCopyOwner, IProgressMonitor)
    4. +
    5. IClassFile#becomeWorkingCopy(WorkingCopyOwner, IProgressMonitor)
    6. +
    7. WorkingCopyOwner#newWorkingCopy(String, IClasspathEntry[], IProgressMonitor)
    8. +
    +
  • +

Problem Reports Fixed

#P org.eclipse.jdt.core.tests Index: Eclipse Java Tests Runner/org/eclipse/jdt/core/tests/RunAllJDTCoreTests.java =================================================================== RCS file: /home/cvs/numbat/org.eclipse.jdt.core.tests/Eclipse Java Tests Runner/org/eclipse/jdt/core/tests/RunAllJDTCoreTests.java,v retrieving revision 1.4 diff -u -r1.4 RunAllJDTCoreTests.java --- Eclipse Java Tests Runner/org/eclipse/jdt/core/tests/RunAllJDTCoreTests.java 6 Mar 2007 04:29:57 -0000 1.4 +++ Eclipse Java Tests Runner/org/eclipse/jdt/core/tests/RunAllJDTCoreTests.java 13 Mar 2007 16:19:46 -0000 @@ -18,16 +18,43 @@ * Runs all (public and private) JDT Core tests. */ public class RunAllJDTCoreTests extends TestCase { + private final static String SUITES = System.getProperty("suites"); + public RunAllJDTCoreTests(String name) { super(name); } public static Test suite() { TestSuite suite = new TestSuite(RunAllJDTCoreTests.class.getName()); - suite.addTest(RunAllBuilderTests.suite()); - suite.addTest(RunAllCompilerTests.suite()); - suite.addTest(RunAllDOMTests.suite()); - suite.addTest(RunAllFormatterTests.suite()); - suite.addTest(RunAllModelTests.suite()); + + // Get test suites subset + if (SUITES == null) { + suite.addTest(RunAllBuilderTests.suite()); + suite.addTest(RunAllCompilerTests.suite()); + suite.addTest(RunAllDOMTests.suite()); + suite.addTest(RunAllFormatterTests.suite()); + suite.addTest(RunAllModelTests.suite()); + } else { + int length = SUITES.length(); + for (int i = 0; i < length; i++) { + switch (Character.toUpperCase(SUITES.charAt(i))) { + case 'B': + suite.addTest(RunAllBuilderTests.suite()); + break; + case 'C': + suite.addTest(RunAllCompilerTests.suite()); + break; + case 'D': + suite.addTest(RunAllDOMTests.suite()); + break; + case 'F': + suite.addTest(RunAllFormatterTests.suite()); + break; + case 'M': + suite.addTest(RunAllModelTests.suite()); + break; + } + } + } return suite; } }

@@ -106,7 +109,7 @@ * The only valid operations on this working copy are getBuffer() or getOriginalElement. * * @param monitor a progress monitor used to report progress while opening this compilation unit - * or null if no progress should be reported + * or null if no progress should be reported * @param factory the factory that creates a buffer that is used to get the content of the working copy * or null if the internal factory should be used * @return a a working copy on the source associated with this class file @@ -131,7 +134,7 @@ boolean isClass() throws JavaModelException; /** * Returns whether this type represents an interface. This is not guaranteed to - * be instantaneous, as it may require parsing the underlying file. + * be instantaneous, as it may require parsing the underlying file. * * @return true if the class file represents an interface. * Index: buildnotes_jdt-core.html =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/buildnotes_jdt-core.html,v retrieving revision 1.5749 diff -u -r1.5749 buildnotes_jdt-core.html --- buildnotes_jdt-core.html 13 Mar 2007 15:13:21 -0000 1.5749 +++ buildnotes_jdt-core.html 13 Mar 2007 16:19:41 -0000 @@ -50,6 +50,48 @@
Project org.eclipse.jdt.core v_742 (
cvs).