List of usage examples for org.eclipse.jdt.internal.core CompilationUnit getPerWorkingCopyInfo
public JavaModelManager.PerWorkingCopyInfo getPerWorkingCopyInfo()
From source file:org.codehaus.jdt.groovy.model.GroovyReconcileWorkingCopyOperation.java
License:Open Source License
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, this.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; }//from www. jav a2 s . com if (this.ast != null) return this.ast; // no need to recompute AST if known already CompilationUnitDeclaration unit = null; try { JavaModelManager.getJavaModelManager().abortOnMissingSource.set(Boolean.TRUE); CompilationUnit source = workingCopy.cloneCachingContents(); // 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(); unit = CompilationUnitProblemFinder.process(source, this.workingCopyOwner, this.problems, this.astLevel != ICompilationUnit.NO_AST/* creating AST if level is not NO_AST */, this.reconcileFlags, this.progressMonitor); // GROOVY cache the ModuleNode in the ModuleNodeMapper if (unit instanceof GroovyCompilationUnitDeclaration) { // should always be true ModuleNodeMapper.getInstance().maybeCacheModuleNode(workingCopy.getPerWorkingCopyInfo(), (GroovyCompilationUnitDeclaration) unit); } // GROOVY end if (this.progressMonitor != null) this.progressMonitor.worked(1); } // create AST if needed if (this.astLevel != ICompilationUnit.NO_AST && unit != null/* * unit is null if working copy is consistent && (problem * detection not forced || non-Java project) -> don't create * AST as per API */) { Map options = workingCopy.getJavaProject().getOptions(true); // convert AST this.ast = AST.convertCompilationUnit(this.astLevel, unit, options, this.resolveBindings, source, this.reconcileFlags, this.progressMonitor); if (this.ast != null) { if (this.deltaBuilder.delta == 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 { JavaModelManager.getJavaModelManager().abortOnMissingSource.set(null); if (unit != null) { unit.cleanUp(); } } return this.ast; }
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 *///from ww w . j a va 2 s. c om 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.CompilationUnit.java
License:Open Source License
/** * @see ICompilationUnit#findWorkingCopy(WorkingCopyOwner) *///from ww w .ja v a 2 s . co m public ICompilationUnit findWorkingCopy(WorkingCopyOwner workingCopyOwner) { // GROOVY start /* old { CompilationUnit cu = new CompilationUnit((PackageFragment)this.parent, getElementName(), workingCopyOwner); } new */ CompilationUnit cu = LanguageSupportFactory.newCompilationUnit((PackageFragment) this.parent, getElementName(), workingCopyOwner); // GROOVY end if (workingCopyOwner == DefaultWorkingCopyOwner.PRIMARY) { return cu; } else { // must be a working copy JavaModelManager.PerWorkingCopyInfo perWorkingCopyInfo = cu.getPerWorkingCopyInfo(); if (perWorkingCopyInfo != null) { return perWorkingCopyInfo.getWorkingCopy(); } else { return null; } } }