### 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
+ * 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 + * ornull
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 tonull
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 + * ornull
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 @@
*
- * 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 @@ * * Returnsnull
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 ornull
* @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 - * ornull
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: *
- * 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 tonull
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.
*
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.
*
@@ -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).
WorkingCopyOwner
) now specifies the problem requestor
+(IProblemrequestor
) used to report problems on working copies it owns
+(see bug 175243).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+As a consequence of this addition,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 ornull
if no problem requestor is configured. + * + * @since 3.3 + */ +public IProblemRequestor getProblemRequestor(ICompilationUnit workingCopy) { + return null; +} +
IProblemRequestor
parameter
+of *WorkingCopy
methods becomes unnecessary and corresponding
+methods have been deprecated:
+ICompilationUnit#becomeWorkingCopy(IProblemRequestor, IProgressMonitor)
ICompilationUnit#getWorkingCopy(WorkingCopyOwner, IProblemRequestor, IProgressMonitor)
IClassFile#becomeWorkingCopy(IProblemRequestor, WorkingCopyOwner, IProgressMonitor)
WorkingCopyOwner#newWorkingCopy(String, IClasspathEntry[], IProblemRequestor, IProgressMonitor)
ICompilationUnit#becomeWorkingCopy(IProgressMonitor)
ICompilationUnit#getWorkingCopy(WorkingCopyOwner, IProgressMonitor)
IClassFile#becomeWorkingCopy(WorkingCopyOwner, IProgressMonitor)
WorkingCopyOwner#newWorkingCopy(String, IClasspathEntry[], IProgressMonitor)