### Eclipse Workspace Patch 1.0 #P org.eclipse.jdt.core.tests.model 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.116 diff -u -r1.116 ReconcilerTests.java --- src/org/eclipse/jdt/core/tests/model/ReconcilerTests.java 26 Mar 2007 10:43:15 -0000 1.116 +++ src/org/eclipse/jdt/core/tests/model/ReconcilerTests.java 27 Mar 2007 09:20:44 -0000 @@ -2260,6 +2260,19 @@ ); } /* + * Ensures that the problem requestor is not called when the source + * to reconcile is the same as the current contents, + * no ast is requested, no problem is requested and problem requestor is not active. + * (regression test for bug 179258 simple reconcile starts problem finder - main thread waiting) + * + */ +public void testNoChanges3() throws JavaModelException { + setWorkingCopyContents(this.workingCopy.getSource()); + this.problemRequestor.isActive = false; + this.workingCopy.reconcile(ICompilationUnit.NO_AST, false, null, null); + assertProblems("Unexpected problems", ""); +} +/* * Ensures that using a non-generic method with no parameter and with a raw receiver type doesn't create a type safety warning * (regression test for bug 105756 [1.5][model] Incorrect warning on using raw types) */ 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.183 diff -u -r1.183 AbstractJavaModelTests.java --- src/org/eclipse/jdt/core/tests/model/AbstractJavaModelTests.java 26 Mar 2007 10:43:15 -0000 1.183 +++ src/org/eclipse/jdt/core/tests/model/AbstractJavaModelTests.java 27 Mar 2007 09:20:43 -0000 @@ -70,6 +70,7 @@ public StringBuffer problems; public int problemCount; protected char[] unitSource; + public boolean isActive = true; public ProblemRequestor() { initialize(null); } @@ -85,7 +86,7 @@ this.problems.append("----------\n"); } public boolean isActive() { - return true; + return this.isActive; } public void initialize(char[] source) { this.problems = new StringBuffer(); #P org.eclipse.jdt.core Index: model/org/eclipse/jdt/core/compiler/ReconcileContext.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/model/org/eclipse/jdt/core/compiler/ReconcileContext.java,v retrieving revision 1.9 diff -u -r1.9 ReconcileContext.java --- model/org/eclipse/jdt/core/compiler/ReconcileContext.java 16 Mar 2007 18:28:59 -0000 1.9 +++ model/org/eclipse/jdt/core/compiler/ReconcileContext.java 27 Mar 2007 09:20:45 -0000 @@ -98,7 +98,7 @@ parser.setSource(workingCopy); return (org.eclipse.jdt.core.dom.CompilationUnit) parser.createAST(this.operation.progressMonitor); } - return this.operation.makeConsistent(this.workingCopy, null/*don't report problems to the working copy's problem requestor*/); + return this.operation.makeConsistent(this.workingCopy); } /** 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.45 diff -u -r1.45 ReconcileWorkingCopyOperation.java --- model/org/eclipse/jdt/internal/core/ReconcileWorkingCopyOperation.java 15 Mar 2007 16:06:40 -0000 1.45 +++ model/org/eclipse/jdt/internal/core/ReconcileWorkingCopyOperation.java 27 Mar 2007 09:20:45 -0000 @@ -22,6 +22,7 @@ import org.eclipse.jdt.core.compiler.CompilationParticipant; import org.eclipse.jdt.core.compiler.ReconcileContext; import org.eclipse.jdt.core.dom.AST; +import org.eclipse.jdt.core.dom.ASTParser; import org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration; import org.eclipse.jdt.internal.core.util.Messages; import org.eclipse.jdt.internal.core.util.Util; @@ -52,6 +53,7 @@ WorkingCopyOwner workingCopyOwner; public org.eclipse.jdt.core.dom.CompilationUnit ast; public JavaElementDeltaBuilder deltaBuilder; + public boolean requestorIsActive; public ReconcileWorkingCopyOperation(IJavaElement workingCopy, int astLevel, int reconcileFlags, WorkingCopyOwner workingCopyOwner) { super(new IJavaElement[] {workingCopy}); @@ -71,34 +73,38 @@ CompilationUnit workingCopy = getWorkingCopy(); boolean wasConsistent = workingCopy.isConsistent(); + + // check is problem requestor is active IProblemRequestor problemRequestor = workingCopy.getPerWorkingCopyInfo(); - if (problemRequestor != null) { + if (problemRequestor != null) problemRequestor = ((JavaModelManager.PerWorkingCopyInfo)problemRequestor).getProblemRequestor(); - } + boolean defaultRequestorIsActive = problemRequestor != null && problemRequestor.isActive(); IProblemRequestor ownerProblemRequestor = this.workingCopyOwner.getProblemRequestor(workingCopy); - this.resolveBindings |= problemRequestor != null && problemRequestor.isActive(); + boolean ownerRequestorIsActive = ownerProblemRequestor != null && ownerProblemRequestor != problemRequestor && ownerProblemRequestor.isActive(); + this.requestorIsActive = defaultRequestorIsActive || ownerRequestorIsActive; // 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); + makeConsistent(workingCopy); // notify reconcile participants only if working copy was not consistent or if forcing problem detection // (see https://bugs.eclipse.org/bugs/show_bug.cgi?id=177319) - if (!wasConsistent || ((this.reconcileFlags & ICompilationUnit.FORCE_PROBLEM_DETECTION) != 0)) - notifyParticipants(workingCopy); + if (!wasConsistent || ((this.reconcileFlags & ICompilationUnit.FORCE_PROBLEM_DETECTION) != 0)) { + notifyParticipants(workingCopy); - // recreate ast if needed - if (this.ast == null && (this.astLevel > ICompilationUnit.NO_AST || this.resolveBindings)) - makeConsistent(workingCopy, problemRequestor); + // recreate ast if one participant reset it + if (this.ast == null) + makeConsistent(workingCopy); + } // report problems if (this.problems != null && (((this.reconcileFlags & ICompilationUnit.FORCE_PROBLEM_DETECTION) != 0) || !wasConsistent)) { - if (problemRequestor != null) { + if (defaultRequestorIsActive) { reportProblems(workingCopy, problemRequestor); } - if (ownerProblemRequestor != null && ownerProblemRequestor != problemRequestor) { + if (ownerRequestorIsActive) { reportProblems(workingCopy, ownerProblemRequestor); } } @@ -157,75 +163,84 @@ * Makes the given working copy consistent, computes the delta and computes an AST if needed. * Returns the AST. */ - public org.eclipse.jdt.core.dom.CompilationUnit makeConsistent(CompilationUnit workingCopy, IProblemRequestor problemRequestor) throws JavaModelException { + public org.eclipse.jdt.core.dom.CompilationUnit makeConsistent(CompilationUnit workingCopy) throws JavaModelException { if (!workingCopy.isConsistent()) { // make working copy consistent if (this.problems == null) this.problems = new HashMap(); + this.resolveBindings = this.requestorIsActive; this.ast = workingCopy.makeConsistent(this.astLevel, this.resolveBindings, reconcileFlags, this.problems, this.progressMonitor); this.deltaBuilder.buildDeltas(); 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.reconcileFlags & ICompilationUnit.FORCE_PROBLEM_DETECTION) != 0) || this.resolveBindings) { - if (JavaProject.hasJavaNature(workingCopy.getJavaProject().getProject())) { - HashMap problemMap; - if (this.problems == null) { - problemMap = new HashMap(); - if ((this.reconcileFlags & ICompilationUnit.FORCE_PROBLEM_DETECTION) != 0) - this.problems = problemMap; - } else - problemMap = this.problems; - CompilationUnitDeclaration unit = null; - try { - // find problems - char[] contents = workingCopy.getContents(); - unit = - CompilationUnitProblemFinder.process( - workingCopy, + if (this.ast != null) + return this.ast; // no need to recompute AST if known already + + CompilationUnitDeclaration unit = null; + char[] contents = null; + try { + // find problems if needed + if (JavaProject.hasJavaNature(workingCopy.getJavaProject().getProject()) + && (this.reconcileFlags & ICompilationUnit.FORCE_PROBLEM_DETECTION) != 0) { + this.resolveBindings = this.requestorIsActive; + if (this.problems == null) + this.problems = new HashMap(); + contents = workingCopy.getContents(); + unit = + CompilationUnitProblemFinder.process( + workingCopy, + contents, + this.workingCopyOwner, + this.problems, + this.astLevel != ICompilationUnit.NO_AST/*creating AST if level is not NO_AST */, + reconcileFlags, + this.progressMonitor); + if (this.progressMonitor != null) this.progressMonitor.worked(1); + } + + // create AST if needed + if (this.astLevel != ICompilationUnit.NO_AST) { + Map options = workingCopy.getJavaProject().getOptions(true); + if (unit == null) { + // problem detection not forced or non-Java project -> no bindings + ASTParser parser = ASTParser.newParser(this.astLevel); + parser.setCompilerOptions(options); + parser.setStatementsRecovery((this.reconcileFlags & ICompilationUnit.ENABLE_STATEMENTS_RECOVERY) != 0); + parser.setSource(workingCopy); + this.ast = (org.eclipse.jdt.core.dom.CompilationUnit) parser.createAST(this.progressMonitor); + } else { + // convert AST + this.ast = + AST.convertCompilationUnit( + this.astLevel, + unit, contents, - this.workingCopyOwner, - problemMap, - this.astLevel != ICompilationUnit.NO_AST/*creating AST if level is not NO_AST */, + options, + this.resolveBindings, + workingCopy, reconcileFlags, 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 = - AST.convertCompilationUnit( - this.astLevel, - unit, - contents, - options, - true/*isResolved*/, - workingCopy, - reconcileFlags, - this.progressMonitor); - if (this.ast != null) { - this.deltaBuilder.delta = new JavaElementDelta(workingCopy); - this.deltaBuilder.delta.changedAST(this.ast); - } - if (this.progressMonitor != null) this.progressMonitor.worked(1); - } - } catch (JavaModelException e) { - if (JavaProject.hasJavaNature(workingCopy.getJavaProject().getProject())) - throw e; - // else JavaProject has lost its nature (or most likely was closed/deleted) while reconciling -> ignore - // (see https://bugs.eclipse.org/bugs/show_bug.cgi?id=100919) - } finally { - if (unit != null) { - unit.cleanUp(); - } - } - } // else working copy not in a Java project - return this.ast; - } - return null; + } + if (this.ast != null) { + this.deltaBuilder.delta = new JavaElementDelta(workingCopy); + this.deltaBuilder.delta.changedAST(this.ast); + } + if (this.progressMonitor != null) this.progressMonitor.worked(1); + } + } catch (JavaModelException e) { + if (JavaProject.hasJavaNature(workingCopy.getJavaProject().getProject())) + throw e; + // else JavaProject has lost its nature (or most likely was closed/deleted) while reconciling -> ignore + // (see https://bugs.eclipse.org/bugs/show_bug.cgi?id=100919) + } finally { + if (unit != null) { + unit.cleanUp(); + } + } + return this.ast; } + private void notifyParticipants(final CompilationUnit workingCopy) { IJavaProject javaProject = getWorkingCopy().getJavaProject(); CompilationParticipant[] participants = JavaModelManager.getJavaModelManager().compilationParticipants.getCompilationParticipants(javaProject);