List of usage examples for org.eclipse.jdt.internal.core JavaElementDeltaBuilder JavaElementDeltaBuilder
public JavaElementDeltaBuilder(IJavaElement javaElement)
From source file:org.eclipse.ajdt.core.reconcile.AJReconcileWorkingCopyOperation.java
License:Open Source License
/** * @exception JavaModelException if setting the source * of the original compilation unit fails */// w ww.java 2 s . co m protected void executeOperation() throws JavaModelException { checkCanceled(); try { beginTask(Messages.element_reconciling, 2); CompilationUnit workingCopy = getWorkingCopy(); boolean wasConsistent = workingCopy.isConsistent(); // check is problem requestor is active IProblemRequestor problemRequestor = workingCopy.getPerWorkingCopyInfo(); if (problemRequestor != null) problemRequestor = ((JavaModelManager.PerWorkingCopyInfo) problemRequestor).getProblemRequestor(); boolean defaultRequestorIsActive = problemRequestor != null && problemRequestor.isActive(); IProblemRequestor ownerProblemRequestor = this.workingCopyOwner.getProblemRequestor(workingCopy); 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); // 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); // 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 (defaultRequestorIsActive) { reportProblems(workingCopy, problemRequestor); } if (ownerRequestorIsActive) { reportProblems(workingCopy, ownerProblemRequestor); } } // register the deltas // AspectJ Change Begin JavaElementDelta delta = getDelta(deltaBuilder); if (delta != null) { addReconcileDelta(workingCopy, delta); } // AspectJ Change End } finally { done(); } }
From source file:org.eclipse.jdt.internal.core.JavaModelManager.java
License:Open Source License
public int discardPerWorkingCopyInfo(CompilationUnit workingCopy) throws JavaModelException { // create the delta builder (this remembers the current content of the working copy) // outside the perWorkingCopyInfos lock (see bug 50667) JavaElementDeltaBuilder deltaBuilder = null; if (workingCopy.isPrimary() && workingCopy.hasUnsavedChanges()) { deltaBuilder = new JavaElementDeltaBuilder(workingCopy); }//from w w w .j av a2s . co m PerWorkingCopyInfo info = null; synchronized (this.perWorkingCopyInfos) { WorkingCopyOwner owner = workingCopy.owner; Map workingCopyToInfos = (Map) this.perWorkingCopyInfos.get(owner); if (workingCopyToInfos == null) return -1; info = (PerWorkingCopyInfo) workingCopyToInfos.get(workingCopy); if (info == null) return -1; if (--info.useCount == 0) { // remove per working copy info workingCopyToInfos.remove(workingCopy); if (workingCopyToInfos.isEmpty()) { this.perWorkingCopyInfos.remove(owner); } } } if (info.useCount == 0) { // info cannot be null here (check was done above) // remove infos + close buffer (since no longer working copy) // outside the perWorkingCopyInfos lock (see bug 50667) removeInfoAndChildren(workingCopy); workingCopy.closeBuffer(); // compute the delta if needed and register it if there are changes if (deltaBuilder != null) { deltaBuilder.buildDeltas(); if (deltaBuilder.delta != null) { getDeltaProcessor().registerJavaModelDelta(deltaBuilder.delta); } } } return info.useCount; }