Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 60709 Details for
Bug 130001
[api][AST] org.eclipse.jdt.core.dom.AST: should have API hasResolvedBindings, hasStatementRecovery
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
First draft
patch_130001.txt (text/plain), 125.06 KB, created by
Olivier Thomann
on 2007-03-13 14:47:05 EDT
(
hide
)
Description:
First draft
Filename:
MIME Type:
Creator:
Olivier Thomann
Created:
2007-03-13 14:47:05 EDT
Size:
125.06 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.jdt.core >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 18:45:41 -0000 >@@ -7,7 +7,7 @@ > * > * Contributors: > * IBM Corporation - initial API and implementation >- * Alex Smirnoff (alexsmr@sympatico.ca) - part of the changes to support Java-like extension >+ * Alex Smirnoff (alexsmr@sympatico.ca) - part of the changes to support Java-like extension > * (see https://bugs.eclipse.org/bugs/show_bug.cgi?id=71460) > *******************************************************************************/ > package org.eclipse.jdt.internal.core; >@@ -39,9 +39,9 @@ > * @deprecated > */ > /*package*/ static final int JLS2_INTERNAL = AST.JLS2; >- >+ > private static final IImportDeclaration[] NO_IMPORTS = new IImportDeclaration[0]; >- >+ > protected String name; > public WorkingCopyOwner owner; > >@@ -75,7 +75,7 @@ > IStatus status = validateCompilationUnit(underlyingResource); > if (!status.isOK()) throw newJavaModelException(status); > } >- >+ > // prevents reopening of non-primary working copies (they are closed when they are discarded and should not be reopened) > if (!isPrimary() && getPerWorkingCopyInfo() == null) { > throw newNotPresentException(); >@@ -117,7 +117,7 @@ > statementsRecovery = false; > problems = null; > } >- >+ > boolean computeProblems = perWorkingCopyInfo != null && perWorkingCopyInfo.isActive() && project != null && JavaProject.hasJavaNature(project.getProject()); > IProblemFactory problemFactory = new DefaultProblemFactory(); > Map options = project == null ? JavaCore.getOptions() : project.getOptions(true); >@@ -126,15 +126,15 @@ > options.put(JavaCore.COMPILER_TASK_TAGS, ""); //$NON-NLS-1$ > } > SourceElementParser parser = new SourceElementParser( >- requestor, >- problemFactory, >+ requestor, >+ problemFactory, > new CompilerOptions(options), > true/*report local declarations*/, > !createAST /*optimize string literals only if not creating a DOM AST*/); > parser.reportOnlyOneSyntaxError = !computeProblems; > parser.setMethodsFullRecovery(true); > parser.setStatementsRecovery(statementsRecovery); >- >+ > if (!computeProblems && !resolveBindings && !createAST) // disable javadoc parsing if not computing problems, not resolving and not creating ast > parser.javadocParser.checkDocComment = false; > requestor.parser = parser; >@@ -152,9 +152,9 @@ > public char[] getFileName() { > return CompilationUnit.this.getFileName(); > } >- }, >+ }, > true /*full parse to find local elements*/); >- >+ > // update timestamp (might be IResource.NULL_STAMP if original does not exist) > if (underlyingResource == null) { > underlyingResource = getResource(); >@@ -162,7 +162,7 @@ > // underlying resource is null in the case of a working copy on a class file in a jar > if (underlyingResource != null) > unitInfo.timestamp = ((IFile)underlyingResource).getModificationStamp(); >- >+ > // compute other problems if needed > CompilationUnitDeclaration compilationUnitDeclaration = null; > try { >@@ -188,18 +188,18 @@ > compilationUnitDeclaration = CompilationUnitProblemFinder.process(unit, this, contents, parser, this.owner, problems, createAST, true, pm); > } > } >- >+ > if (createAST) { > int astLevel = ((ASTHolderCUInfo) info).astLevel; >- org.eclipse.jdt.core.dom.CompilationUnit cu = AST.convertCompilationUnit(astLevel, unit, contents, options, computeProblems, this, pm); >+ org.eclipse.jdt.core.dom.CompilationUnit cu = AST.convertCompilationUnit(astLevel, unit, contents, options, computeProblems, this, statementsRecovery, pm); > ((ASTHolderCUInfo) info).ast = cu; > } > } finally { >- if (compilationUnitDeclaration != null) { >- compilationUnitDeclaration.cleanUp(); >- } >+ if (compilationUnitDeclaration != null) { >+ compilationUnitDeclaration.cleanUp(); >+ } > } >- >+ > return unitInfo.isStructureKnown(); > } > /* >@@ -252,7 +252,7 @@ > * @deprecated - use codeComplete(int, ICompletionRequestor) > */ > public void codeComplete(int offset, final ICodeCompletionRequestor requestor) throws JavaModelException { >- >+ > if (requestor == null){ > codeComplete(offset, (ICompletionRequestor)null); > return; >@@ -351,7 +351,7 @@ > */ > public void copy(IJavaElement container, IJavaElement sibling, String rename, boolean force, IProgressMonitor monitor) throws JavaModelException { > if (container == null) { >- throw new IllegalArgumentException(Messages.operation_nullContainer); >+ throw new IllegalArgumentException(Messages.operation_nullContainer); > } > IJavaElement[] elements = new IJavaElement[] {this}; > IJavaElement[] containers = new IJavaElement[] {container}; >@@ -391,7 +391,7 @@ > * @see ICompilationUnit#createPackageDeclaration(String, IProgressMonitor) > */ > public IPackageDeclaration createPackageDeclaration(String pkg, IProgressMonitor monitor) throws JavaModelException { >- >+ > CreatePackageDeclarationOperation op= new CreatePackageDeclarationOperation(pkg, this); > op.runOperation(monitor); > return getPackageDeclaration(pkg); >@@ -459,8 +459,8 @@ > } > public boolean exists() { > // working copy always exists in the model until it is gotten rid of (even if not on classpath) >- if (getPerWorkingCopyInfo() != null) return true; >- >+ if (getPerWorkingCopyInfo() != null) return true; >+ > // if not a working copy, it exists only if it is a primary compilation unit > return isPrimary() && validateCompilationUnit(getResource()).isOK(); > } >@@ -512,7 +512,7 @@ > currentElement = ((IType)currentElement).getMethod(child.getElementName(), ((IMethod)child).getParameterTypes()); > break; > } >- >+ > } > if (currentElement != null && currentElement.exists()) { > return new IJavaElement[] {currentElement}; >@@ -540,7 +540,7 @@ > > // if factory is null, default factory must be used > if (factory == null) factory = this.getBufferManager().getDefaultBufferFactory(); >- >+ > return findWorkingCopy(BufferFactoryWrapper.create(factory)); > } > >@@ -580,7 +580,7 @@ > for (i = 0; i < types.length; i++) { > typesToTraverse.add(types[i]); > } >- } >+ } > IType[] arrayOfAllTypes = new IType[allTypes.size()]; > allTypes.toArray(arrayOfAllTypes); > return arrayOfAllTypes; >@@ -708,10 +708,10 @@ > else { > open(null); // force opening of CU > info = manager.getInfo(container); >- if (info == null) >+ if (info == null) > // after opening, if no import container, then no imports > return NO_IMPORTS; >- } >+ } > } > IJavaElement[] elements = ((JavaElementInfo) info).children; > int length = elements.length; >@@ -742,7 +742,7 @@ > if (cu == null || !this.owner.equals(cu.owner)) { > return null; > } >- >+ > return workingCopyElement.getPrimaryElement(); > } > /** >@@ -752,7 +752,7 @@ > public IJavaElement getOriginalElement() { > // backward compatibility > if (!isWorkingCopy()) return null; >- >+ > return getPrimaryElement(); > } > /* >@@ -870,10 +870,10 @@ > * @deprecated > */ > public IJavaElement getSharedWorkingCopy(IProgressMonitor pm, IBufferFactory factory, IProblemRequestor problemRequestor) throws JavaModelException { >- >+ > // if factory is null, default factory must be used > if (factory == null) factory = this.getBufferManager().getDefaultBufferFactory(); >- >+ > return getWorkingCopy(BufferFactoryWrapper.create(factory), problemRequestor, pm); > } > /** >@@ -907,11 +907,11 @@ > */ > public ICompilationUnit getWorkingCopy(WorkingCopyOwner workingCopyOwner, IProblemRequestor problemRequestor, IProgressMonitor monitor) throws JavaModelException { > if (!isPrimary()) return this; >- >+ > JavaModelManager manager = JavaModelManager.getJavaModelManager(); >- >+ > CompilationUnit workingCopy = new CompilationUnit((PackageFragment)getParent(), getElementName(), workingCopyOwner); >- JavaModelManager.PerWorkingCopyInfo perWorkingCopyInfo = >+ JavaModelManager.PerWorkingCopyInfo perWorkingCopyInfo = > manager.getPerWorkingCopyInfo(workingCopy, false/*don't create*/, true/*record usage*/, null/*not used since don't create*/); > if (perWorkingCopyInfo != null) { > return perWorkingCopyInfo.getWorkingCopy(); // return existing handle instead of the one created above >@@ -931,7 +931,7 @@ > */ > public boolean hasResourceChanged() { > if (!isWorkingCopy()) return false; >- >+ > // if resource got deleted, then #getModificationStamp() will answer IResource.NULL_STAMP, which is always different from the cached > // timestamp > Object info = JavaModelManager.getJavaModelManager().getInfo(this); >@@ -968,7 +968,7 @@ > IPackageFragmentRoot root = getPackageFragmentRoot(); > // root never null as validation is not done for working copies > try { >- if (root.getKind() != IPackageFragmentRoot.K_SOURCE) >+ if (root.getKind() != IPackageFragmentRoot.K_SOURCE) > return new JavaModelStatus(IJavaModelStatusConstants.INVALID_ELEMENT_TYPES, root); > } catch (JavaModelException e) { > return e.getJavaModelStatus(); >@@ -976,7 +976,7 @@ > if (resource != null) { > char[][] inclusionPatterns = ((PackageFragmentRoot)root).fullInclusionPatternChars(); > char[][] exclusionPatterns = ((PackageFragmentRoot)root).fullExclusionPatternChars(); >- if (Util.isExcluded(resource, inclusionPatterns, exclusionPatterns)) >+ if (Util.isExcluded(resource, inclusionPatterns, exclusionPatterns)) > return new JavaModelStatus(IJavaModelStatusConstants.ELEMENT_NOT_ON_CLASSPATH, this); > if (!resource.isAccessible()) > return new JavaModelStatus(IJavaModelStatusConstants.ELEMENT_DOES_NOT_EXIST, this); >@@ -1000,7 +1000,7 @@ > } > public org.eclipse.jdt.core.dom.CompilationUnit makeConsistent(int astLevel, boolean resolveBindings, boolean statementsRecovery, HashMap problems, IProgressMonitor monitor) throws JavaModelException { > if (isConsistent()) return null; >- >+ > // create a new info and make it the current info > // (this will remove the info and its children just before storing the new infos) > if (astLevel != NO_AST || problems != null) { >@@ -1023,11 +1023,11 @@ > */ > public void move(IJavaElement container, IJavaElement sibling, String rename, boolean force, IProgressMonitor monitor) throws JavaModelException { > if (container == null) { >- throw new IllegalArgumentException(Messages.operation_nullContainer); >+ throw new IllegalArgumentException(Messages.operation_nullContainer); > } > IJavaElement[] elements= new IJavaElement[] {this}; > IJavaElement[] containers= new IJavaElement[] {container}; >- >+ > String[] renamings= null; > if (rename != null) { > renamings= new String[] {rename}; >@@ -1043,24 +1043,24 @@ > // create buffer > BufferManager bufManager = getBufferManager(); > boolean isWorkingCopy = isWorkingCopy(); >- IBuffer buffer = >- isWorkingCopy >- ? this.owner.createBuffer(this) >+ IBuffer buffer = >+ isWorkingCopy >+ ? this.owner.createBuffer(this) > : BufferManager.createBuffer(this); > if (buffer == null) return null; >- >+ > // synchronize to ensure that 2 threads are not putting 2 different buffers at the same time > // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=146331 > synchronized(bufManager) { > IBuffer existingBuffer = bufManager.getBuffer(this); > if (existingBuffer != null) > return existingBuffer; >- >+ > // set the buffer source > if (buffer.getCharacters() == null) { > if (isWorkingCopy) { > ICompilationUnit original; >- if (!isPrimary() >+ if (!isPrimary() > && (original = new CompilationUnit((PackageFragment)getParent(), getElementName(), DefaultWorkingCopyOwner.PRIMARY)).isOpen()) { > buffer.setContents(original.getSource()); > } else { >@@ -1078,15 +1078,15 @@ > buffer.setContents(Util.getResourceContentsAsCharArray(file)); > } > } >- >+ > // add buffer to buffer cache > // note this may cause existing buffers to be removed from the buffer cache, but only primary compilation unit's buffer > // can be closed, thus no call to a client's IBuffer#close() can be done in this synchronized block. > bufManager.addBuffer(buffer); >- >+ > // listen to buffer changes > buffer.addBufferChangedListener(this); >- } >+ } > return buffer; > } > protected void openParent(Object childInfo, HashMap newElements, IProgressMonitor pm) throws JavaModelException { >@@ -1122,7 +1122,7 @@ > throws JavaModelException { > return reconcile(astLevel, forceProblemDetection, false, workingCopyOwner, monitor); > } >- >+ > /** > * @see ICompilationUnit#reconcile(int, boolean, WorkingCopyOwner, IProgressMonitor) > * @since 3.0 >@@ -1134,11 +1134,11 @@ > WorkingCopyOwner workingCopyOwner, > IProgressMonitor monitor) > throws JavaModelException { >- >+ > if (!isWorkingCopy()) return null; // Reconciling is not supported on non working copies > if (workingCopyOwner == null) workingCopyOwner = DefaultWorkingCopyOwner.PRIMARY; >- >- >+ >+ > PerformanceStats stats = null; > if(ReconcileWorkingCopyOperation.PERF) { > stats = PerformanceStats.getStats(JavaModelManager.RECONCILE_PERF, this); >@@ -1163,7 +1163,7 @@ > */ > public void rename(String newName, boolean force, IProgressMonitor monitor) throws JavaModelException { > if (newName == null) { >- throw new IllegalArgumentException(Messages.operation_nullName); >+ throw new IllegalArgumentException(Messages.operation_nullName); > } > IJavaElement[] elements= new IJavaElement[] {this}; > IJavaElement[] dests= new IJavaElement[] {this.getParent()}; >@@ -1193,7 +1193,7 @@ > reconcile(); // not simply makeConsistent, also computes fine-grain deltas > // in case the working copy is being reconciled already (if not it would miss > // one iteration of deltas). >- } else { >+ } else { > super.save(pm, force); > } > } >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 18:45:41 -0000 >@@ -32,11 +32,11 @@ > * High level summmary of what a reconcile does: > * <ul> > * <li>populates the model with the new working copy contents</li> >- * <li>fires a fine grained delta (flag F_FINE_GRAINED) describing the difference between the previous content >+ * <li>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.)</li> > * <li>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 > * </li> > * <li>produces a DOM AST (either JLS_2, JLS_3 or NO_AST) that is resolved if flag is set</li> > * <li>notifies compilation participants of the reconcile allowing them to participate in this operation and report problems</li> >@@ -44,16 +44,16 @@ > */ > public class ReconcileWorkingCopyOperation extends JavaModelOperation { > public static boolean PERF = false; >- >+ > public int astLevel; > public boolean resolveBindings; > public HashMap problems; > boolean forceProblemDetection; >- boolean enableStatementsRecovery; >+ public boolean enableStatementsRecovery; > 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,26 +69,26 @@ > 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(); > 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 { >@@ -109,7 +109,7 @@ > problemRequestor.endReporting(); > } > } >- >+ > // report delta > JavaElementDelta delta = this.deltaBuilder.delta; > if (delta != null) { >@@ -144,7 +144,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())) { >@@ -155,32 +155,33 @@ > this.problems = problemMap; > } else > problemMap = this.problems; >- CompilationUnitDeclaration unit = null; >- try { >- // find problems >+ CompilationUnitDeclaration unit = null; >+ 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.enableStatementsRecovery, > this.progressMonitor); > if (this.ast != null) { > this.deltaBuilder.delta = new JavaElementDelta(workingCopy); >@@ -200,12 +201,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); >Index: dom/org/eclipse/jdt/core/dom/CompilationUnitResolver.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/CompilationUnitResolver.java,v >retrieving revision 1.122 >diff -u -r1.122 CompilationUnitResolver.java >--- dom/org/eclipse/jdt/core/dom/CompilationUnitResolver.java 24 Nov 2006 13:56:36 -0000 1.122 >+++ dom/org/eclipse/jdt/core/dom/CompilationUnitResolver.java 13 Mar 2007 18:45:41 -0000 >@@ -58,7 +58,7 @@ > import org.eclipse.jdt.internal.core.util.DOMFinder; > > class CompilationUnitResolver extends Compiler { >- >+ > /* A list of int */ > static class IntArrayList { > public int[] list = new int[5]; >@@ -70,23 +70,23 @@ > this.list[this.length++] = i; > } > } >- >+ > /* > * The sources that were requested. > * Map from file name (char[]) to ICompilationUnit. > */ > HashtableOfObject requestedSources; >- >+ > /* > * The binding keys that were requested. > * Map from file name (char[]) to BindingKey (or ArrayList if multiple keys in the same file). > */ > HashtableOfObject requestedKeys; >- >+ > DefaultBindingResolver.BindingTables bindingTables; >- >+ > boolean hasCompilationAborted; >- >+ > private IProgressMonitor monitor; > > /** >@@ -108,12 +108,12 @@ > * them all) and at the same time perform some actions such as opening a dialog > * in UI when compiling interactively. > * @see org.eclipse.jdt.internal.compiler.DefaultErrorHandlingPolicies >- * >+ * > * @param compilerOptions The compiler options to use for the resolution. >- * >+ * > * @param requestor org.eclipse.jdt.internal.compiler.api.ICompilerRequestor > * Component which will receive and persist all compilation results and is intended >- * to consume them as they are produced. Typically, in a batch compiler, it is >+ * to consume them as they are produced. Typically, in a batch compiler, it is > * responsible for writing out the actual .class files to the file system. > * @see org.eclipse.jdt.internal.compiler.CompilationResult > * >@@ -136,7 +136,7 @@ > this.hasCompilationAborted = false; > this.monitor =monitor; > } >- >+ > /* > * Add additional source types > */ >@@ -197,7 +197,7 @@ > for (int i = 0; i < keyLength; i++) { > BindingKeyResolver resolver = new BindingKeyResolver(bindingKeys[i], this, this.lookupEnvironment); > resolver.parse(true/*pause after fully qualified name*/); >- // If it doesn't have a type name, then it is either an array type, package or base type, which will definitely not have a compilation unit. >+ // If it doesn't have a type name, then it is either an array type, package or base type, which will definitely not have a compilation unit. > // Skipping it will speed up performance because the call will open jars. (theodora) > CompilationUnitDeclaration parsedUnit = resolver.hasTypeName() ? resolver.getCompilationUnitDeclaration() : null; > if (parsedUnit != null) { >@@ -212,21 +212,21 @@ > list.add(existing); > list.add(resolver); > this.requestedKeys.put(fileName, list); >- } >- >+ } >+ > } else { >- char[] key = resolver.hasTypeName() >+ char[] key = resolver.hasTypeName() > ? resolver.getKey().toCharArray() // binary binding > : CharOperation.concatWith(resolver.compoundName(), '.'); // package binding or base type binding > this.requestedKeys.put(key, resolver); > } > worked(1); > } >- >+ > // binding resolution > lookupEnvironment.completeTypeBindings(); > } >- >+ > IBinding createBinding(String key) { > if (this.bindingTables == null) > throw new RuntimeException("Cannot be called outside ASTParser#createASTs(...)"); //$NON-NLS-1$ >@@ -236,14 +236,18 @@ > DefaultBindingResolver resolver = new DefaultBindingResolver(this.lookupEnvironment, null/*no owner*/, this.bindingTables); > return resolver.getBinding(compilerBinding); > } >- >- public static CompilationUnit convert(CompilationUnitDeclaration compilationUnitDeclaration, char[] source, int apiLevel, Map options, boolean needToResolveBindings, WorkingCopyOwner owner, DefaultBindingResolver.BindingTables bindingTables, IProgressMonitor monitor) { >+ >+ public static CompilationUnit convert(CompilationUnitDeclaration compilationUnitDeclaration, char[] source, int apiLevel, Map options, boolean needToResolveBindings, WorkingCopyOwner owner, DefaultBindingResolver.BindingTables bindingTables, boolean statementRecovery, IProgressMonitor monitor) { > BindingResolver resolver = null; > AST ast = AST.newAST(apiLevel); >+ if (statementRecovery) { >+ ast.setFlag(AST.STATEMENT_RECOVERY); >+ } > ast.setDefaultNodeFlag(ASTNode.ORIGINAL); > CompilationUnit compilationUnit = null; > ASTConverter converter = new ASTConverter(options, needToResolveBindings, monitor); > if (needToResolveBindings) { >+ ast.setFlag(AST.RESOLVED_BINDINGS); > resolver = new DefaultBindingResolver(compilationUnitDeclaration.scope, owner, bindingTables); > } else { > resolver = new BindingResolver(); >@@ -256,7 +260,7 @@ > ast.setOriginalModificationCount(ast.modificationCount()); > return compilationUnit; > } >- >+ > protected static CompilerOptions getCompilerOptions(Map options, boolean statementsRecovery) { > CompilerOptions compilerOptions = new CompilerOptions(options); > compilerOptions.performMethodsFullRecovery = statementsRecovery; >@@ -270,13 +274,13 @@ > */ > protected static IErrorHandlingPolicy getHandlingPolicy() { > >- // passes the initial set of files to the batch oracle (to avoid finding more than once the same units when case insensitive match) >+ // passes the initial set of files to the batch oracle (to avoid finding more than once the same units when case insensitive match) > return new IErrorHandlingPolicy() { > public boolean stopOnFirstError() { > return false; > } > public boolean proceedOnErrors() { >- return false; // stop if there are some errors >+ return false; // stop if there are some errors > } > }; > } >@@ -316,7 +320,7 @@ > removeUnresolvedBindings(unit); > } > } >- >+ > /* > * Compiler recovery in case of internal AbortCompilation event > */ >@@ -328,15 +332,15 @@ > removeUnresolvedBindings(unit); > } > this.hasCompilationAborted = true; >- } >- >- public static void parse(ICompilationUnit[] compilationUnits, ASTRequestor astRequestor, int apiLevel, Map options, IProgressMonitor monitor) { >+ } >+ >+ public static void parse(ICompilationUnit[] compilationUnits, ASTRequestor astRequestor, int apiLevel, Map options, boolean statementRecovery, IProgressMonitor monitor) { > try { > CompilerOptions compilerOptions = new CompilerOptions(options); > Parser parser = new CommentRecorderParser( > new ProblemReporter( >- DefaultErrorHandlingPolicies.proceedWithAllProblems(), >- compilerOptions, >+ DefaultErrorHandlingPolicies.proceedWithAllProblems(), >+ compilerOptions, > new DefaultProblemFactory()), > false); > int length = compilationUnits.length; >@@ -345,13 +349,13 @@ > org.eclipse.jdt.internal.compiler.env.ICompilationUnit sourceUnit = (org.eclipse.jdt.internal.compiler.env.ICompilationUnit) compilationUnits[i]; > CompilationResult compilationResult = new CompilationResult(sourceUnit, 0, 0, compilerOptions.maxProblemsPerUnit); > CompilationUnitDeclaration compilationUnitDeclaration = parser.dietParse(sourceUnit, compilationResult); >- >+ > if (compilationUnitDeclaration.ignoreMethodBodies) { > compilationUnitDeclaration.ignoreFurtherInvestigation = true; > // if initial diet parse did not work, no need to dig into method bodies. >- continue; >+ continue; > } >- >+ > //fill the methods bodies in order for the code to be generated > //real parse of the method.... > org.eclipse.jdt.internal.compiler.ast.TypeDeclaration[] types = compilationUnitDeclaration.types; >@@ -359,21 +363,21 @@ > for (int j = types.length; --j >= 0;) > types[j].parseMethod(parser, compilationUnitDeclaration); > } >- >+ > // convert AST >- CompilationUnit node = convert(compilationUnitDeclaration, parser.scanner.getSource(), apiLevel, options, false/*don't resolve binding*/, null/*no owner needed*/, null/*no binding table needed*/, monitor); >+ CompilationUnit node = convert(compilationUnitDeclaration, parser.scanner.getSource(), apiLevel, options, false/*don't resolve binding*/, null/*no owner needed*/, null/*no binding table needed*/, statementRecovery, monitor); > node.setTypeRoot(compilationUnits[i]); >- >+ > // accept AST > astRequestor.acceptAST(compilationUnits[i], node); >- >+ > if (monitor != null) monitor.worked(1); > } > } finally { > if (monitor != null) monitor.done(); > } > } >- >+ > public static CompilationUnitDeclaration parse(org.eclipse.jdt.internal.compiler.env.ICompilationUnit sourceUnit, NodeSearcher nodeSearcher, Map settings, boolean statementsRecovery) { > if (sourceUnit == null) { > throw new IllegalStateException(); >@@ -383,19 +387,19 @@ > compilerOptions.performStatementsRecovery = statementsRecovery; > Parser parser = new CommentRecorderParser( > new ProblemReporter( >- DefaultErrorHandlingPolicies.proceedWithAllProblems(), >- compilerOptions, >+ DefaultErrorHandlingPolicies.proceedWithAllProblems(), >+ compilerOptions, > new DefaultProblemFactory()), > false); > CompilationResult compilationResult = new CompilationResult(sourceUnit, 0, 0, compilerOptions.maxProblemsPerUnit); > CompilationUnitDeclaration compilationUnitDeclaration = parser.dietParse(sourceUnit, compilationResult); >- >+ > if (compilationUnitDeclaration.ignoreMethodBodies) { > compilationUnitDeclaration.ignoreFurtherInvestigation = true; > // if initial diet parse did not work, no need to dig into method bodies. >- return null; >+ return null; > } >- >+ > if (nodeSearcher != null) { > char[] source = parser.scanner.getSource(); > int searchPosition = nodeSearcher.position; >@@ -403,24 +407,24 @@ > // the position is out of range. There is no need to search for a node. > return compilationUnitDeclaration; > } >- >+ > compilationUnitDeclaration.traverse(nodeSearcher, compilationUnitDeclaration.scope); >- >+ > org.eclipse.jdt.internal.compiler.ast.ASTNode node = nodeSearcher.found; > if (node == null) { > return compilationUnitDeclaration; > } >- >+ > org.eclipse.jdt.internal.compiler.ast.TypeDeclaration enclosingTypeDeclaration = nodeSearcher.enclosingType; >- >+ > if (node instanceof AbstractMethodDeclaration) { > ((AbstractMethodDeclaration)node).parseStatements(parser, compilationUnitDeclaration); > } else if (enclosingTypeDeclaration != null) { > if (node instanceof org.eclipse.jdt.internal.compiler.ast.Initializer) { > ((org.eclipse.jdt.internal.compiler.ast.Initializer) node).parseStatements(parser, enclosingTypeDeclaration, compilationUnitDeclaration); >- } else { >+ } else { > ((org.eclipse.jdt.internal.compiler.ast.TypeDeclaration)node).parseMethod(parser, compilationUnitDeclaration); >- } >+ } > } > } else { > //fill the methods bodies in order for the code to be generated >@@ -444,7 +448,7 @@ > WorkingCopyOwner owner, > boolean statementsRecovery, > IProgressMonitor monitor) { >- >+ > CancelableNameEnvironment environment = null; > CancelableProblemFactory problemFactory = null; > try { >@@ -460,17 +464,17 @@ > getHandlingPolicy(), > getCompilerOptions(options, statementsRecovery), > getRequestor(), >- problemFactory, >+ problemFactory, > monitor); > >- resolver.resolve(compilationUnits, bindingKeys, requestor, apiLevel, options, owner); >+ resolver.resolve(compilationUnits, bindingKeys, requestor, apiLevel, options, owner, statementsRecovery); > if (NameLookup.VERBOSE) { > System.out.println(Thread.currentThread() + " TIME SPENT in NameLoopkup#seekTypesInSourcePackage: " + environment.nameLookup.timeSpentInSeekTypesInSourcePackage + "ms"); //$NON-NLS-1$ //$NON-NLS-2$ > System.out.println(Thread.currentThread() + " TIME SPENT in NameLoopkup#seekTypesInBinaryPackage: " + environment.nameLookup.timeSpentInSeekTypesInBinaryPackage + "ms"); //$NON-NLS-1$ //$NON-NLS-2$ > } > } catch (JavaModelException e) { > // project doesn't exist -> simple parse without resolving >- parse(compilationUnits, requestor, apiLevel, options, monitor); >+ parse(compilationUnits, requestor, apiLevel, options, statementsRecovery, monitor); > } finally { > if (monitor != null) monitor.done(); > if (environment != null) { >@@ -489,7 +493,7 @@ > WorkingCopyOwner owner, > boolean statementsRecovery, > IProgressMonitor monitor) throws JavaModelException { >- >+ > CompilationUnitDeclaration unit = null; > CancelableNameEnvironment environment = null; > CancelableProblemFactory problemFactory = null; >@@ -506,7 +510,7 @@ > problemFactory, > monitor); > >- unit = >+ unit = > resolver.resolve( > null, // no existing compilation unit declaration > sourceUnit, >@@ -529,7 +533,7 @@ > if (NameLookup.VERBOSE) { > System.out.println(Thread.currentThread() + " TIME SPENT in NameLoopkup#seekTypesInSourcePackage: " + environment.nameLookup.timeSpentInSeekTypesInSourcePackage + "ms"); //$NON-NLS-1$ //$NON-NLS-2$ > System.out.println(Thread.currentThread() + " TIME SPENT in NameLoopkup#seekTypesInBinaryPackage: " + environment.nameLookup.timeSpentInSeekTypesInBinaryPackage + "ms"); //$NON-NLS-1$ //$NON-NLS-2$ >- } >+ } > return unit; > } finally { > if (environment != null) { >@@ -542,7 +546,7 @@ > // if (resolver != null) { > // for (int i = 1; i < resolver.totalUnits; i++) { // could be more requested units > // CompilationUnitDeclaration parsedUnit = resolver.unitsToProcess[i]; >-// if (parsedUnit.scope != null) >+// if (parsedUnit.scope != null) > // parsedUnit.scope.faultInTypes(); // force resolution of signatures, so clients can query DOM AST > // parsedUnit.cleanUp(); > // } >@@ -583,15 +587,15 @@ > } catch (JavaModelException e) { > throw new IllegalArgumentException(element + " does not exist"); //$NON-NLS-1$ > } >- } >+ } > } > ICompilationUnit[] cus = new ICompilationUnit[cuNumber]; > sourceElementPositions.keySet().toArray(cus); >- >+ > int bindingKeyNumber = binaryElementPositions.size(); > String[] bindingKeys = new String[bindingKeyNumber]; > binaryElementPositions.keysToArray(bindingKeys); >- >+ > class Requestor extends ASTRequestor { > IBinding[] bindings = new IBinding[length]; > public void acceptAST(ICompilationUnit source, CompilationUnit ast) { >@@ -640,7 +644,7 @@ > if (type.binding != null && (type.binding.modifiers & ExtraCompilerModifiers.AccUnresolved) != 0) { > type.binding = null; > } >- >+ > final org.eclipse.jdt.internal.compiler.ast.FieldDeclaration[] fields = type.fields; > if (fields != null) { > for (int i = 0, max = fields.length; i < max; i++){ >@@ -649,7 +653,7 @@ > } > } > } >- >+ > final AbstractMethodDeclaration[] methods = type.methods; > if (methods != null) { > for (int i = 0, max = methods.length; i < max; i++){ >@@ -660,8 +664,8 @@ > } > } > >- private void resolve(ICompilationUnit[] compilationUnits, String[] bindingKeys, ASTRequestor astRequestor, int apiLevel, Map compilerOptions, WorkingCopyOwner owner) { >- >+ private void resolve(ICompilationUnit[] compilationUnits, String[] bindingKeys, ASTRequestor astRequestor, int apiLevel, Map compilerOptions, WorkingCopyOwner owner, boolean statementRecovery) { >+ > // temporararily connect ourselves to the ASTResolver - must disconnect when done > astRequestor.compilationUnitResolver = this; > this.bindingTables = new DefaultBindingResolver.BindingTables(); >@@ -689,7 +693,7 @@ > super.process(unit, i); // this.process(...) is optimized to not process already known units > > // requested AST >- char[] fileName = unit.compilationResult.getFileName(); >+ char[] fileName = unit.compilationResult.getFileName(); > ICompilationUnit source = (ICompilationUnit) this.requestedSources.get(fileName); > if (source != null) { > // convert AST >@@ -697,6 +701,10 @@ > org.eclipse.jdt.internal.compiler.env.ICompilationUnit sourceUnit = compilationResult.compilationUnit; > char[] contents = sourceUnit.getContents(); > AST ast = AST.newAST(apiLevel); >+ if (statementRecovery) { >+ ast.setFlag(AST.STATEMENT_RECOVERY); >+ } >+ ast.setFlag(AST.RESOLVED_BINDINGS); > ast.setDefaultNodeFlag(ASTNode.ORIGINAL); > ASTConverter converter = new ASTConverter(compilerOptions, true/*need to resolve bindings*/, this.monitor); > BindingResolver resolver = new DefaultBindingResolver(unit.scope, owner, this.bindingTables); >@@ -707,13 +715,13 @@ > compilationUnit.setLineEndTable(compilationResult.getLineSeparatorPositions()); > ast.setDefaultNodeFlag(0); > ast.setOriginalModificationCount(ast.modificationCount()); >- >+ > // pass it to requestor > astRequestor.acceptAST(source, compilationUnit); >- >+ > worked(1); >- } >- >+ } >+ > // requested binding > Object key = this.requestedKeys.get(fileName); > if (key instanceof BindingKeyResolver) { >@@ -726,11 +734,11 @@ > worked(1); > } > } >- >+ > // remove at the end so that we don't resolve twice if a source and a key for the same file name have been requested > this.requestedSources.removeKey(fileName); > this.requestedKeys.removeKey(fileName); >- >+ > /* Code used to fault in types and resolve which is no longer necessary as all questions asked to forward references are > * lazily resolved. > * Code used to be: >@@ -740,12 +748,12 @@ > > if (unit.scope != null) > unit.scope.faultInTypes();// still force resolution of signatures, so clients can query DOM AST >- >+ > // the following ensures that all type, method and field bindings are correctly initialized > // as they may be needed by further units > // (see https://bugs.eclipse.org/bugs/show_bug.cgi?id=111822) > unit.resolve(); >- >+ > // note that if this has a performance penalty on clients, the above code should be removed > // the following patch would workaround bug 111822: > >@@ -757,7 +765,7 @@ > --- FieldReference.java 24 Sep 2005 15:23:46 -0000 1.87 > +++ FieldReference.java 7 Oct 2005 13:46:12 -0000 > @@ -407,7 +407,14 @@ >- >+ > FieldBinding originalField = binding.original(); > SourceTypeBinding sourceType = (SourceTypeBinding) originalField.declaringClass; > - TypeDeclaration typeDecl = sourceType.scope.referenceContext; >@@ -770,9 +778,9 @@ > + } > + TypeDeclaration typeDecl = classScope.referenceContext; > FieldDeclaration fieldDecl = typeDecl.declarationOf(originalField); >- >- fieldDecl.resolve(originalField.isStatic() //side effect on binding >-*/ >+ >+ fieldDecl.resolve(originalField.isStatic() //side effect on binding >+*/ > } finally { > // cleanup compilation unit result > unit.cleanUp(); >@@ -780,7 +788,7 @@ > this.unitsToProcess[i] = null; // release reference to processed unit declaration > this.requestor.acceptResult(unit.compilationResult.tagAsAccepted()); > } >- >+ > // remaining binding keys > DefaultBindingResolver resolver = new DefaultBindingResolver(this.lookupEnvironment, owner, this.bindingTables); > Object[] keys = this.requestedKeys.valueTable; >@@ -819,7 +827,7 @@ > astRequestor.acceptBinding(keyResolver.getKey(), binding); > } > } >- >+ > private CompilationUnitDeclaration resolve( > CompilationUnitDeclaration unit, > org.eclipse.jdt.internal.compiler.env.ICompilationUnit sourceUnit, >@@ -852,11 +860,11 @@ > int length = source.length; > if (searchPosition >= 0 && searchPosition <= length) { > unit.traverse(nodeSearcher, unit.scope); >- >+ > org.eclipse.jdt.internal.compiler.ast.ASTNode node = nodeSearcher.found; >- >+ > this.parser.scanner.setSource(source, unit.compilationResult); >- >+ > if (node != null) { > org.eclipse.jdt.internal.compiler.ast.TypeDeclaration enclosingTypeDeclaration = nodeSearcher.enclosingType; > if (node instanceof AbstractMethodDeclaration) { >@@ -864,14 +872,14 @@ > } else if (enclosingTypeDeclaration != null) { > if (node instanceof org.eclipse.jdt.internal.compiler.ast.Initializer) { > ((org.eclipse.jdt.internal.compiler.ast.Initializer) node).parseStatements(this.parser, enclosingTypeDeclaration, unit); >- } else if (node instanceof org.eclipse.jdt.internal.compiler.ast.TypeDeclaration) { >+ } else if (node instanceof org.eclipse.jdt.internal.compiler.ast.TypeDeclaration) { > ((org.eclipse.jdt.internal.compiler.ast.TypeDeclaration)node).parseMethod(this.parser, unit); >- } >+ } > } > } > } > } >- >+ > if (unit.scope != null) { > // fault in fields & methods > unit.scope.faultInTypes(); >@@ -881,11 +889,11 @@ > unit.scope.verifyMethods(this.lookupEnvironment.methodVerifier()); > } > // type checking >- unit.resolve(); >+ unit.resolve(); > > // flow analysis > if (analyzeCode) unit.analyseCode(); >- >+ > // code generation > if (generateCode) unit.generateCode(); > } >@@ -915,15 +923,15 @@ > * Internal API used to resolve a given compilation unit. Can run a subset of the compilation process > */ > public CompilationUnitDeclaration resolve( >- org.eclipse.jdt.internal.compiler.env.ICompilationUnit sourceUnit, >+ org.eclipse.jdt.internal.compiler.env.ICompilationUnit sourceUnit, > boolean verifyMethods, > boolean analyzeCode, > boolean generateCode) { >- >+ > return resolve( > null, /* no existing compilation unit declaration*/ > sourceUnit, >- null/*no node searcher*/, >+ null/*no node searcher*/, > verifyMethods, > analyzeCode, > generateCode); >@@ -933,21 +941,21 @@ > * Internal API used to resolve a given compilation unit. Can run a subset of the compilation process > */ > public CompilationUnitDeclaration resolve( >- CompilationUnitDeclaration unit, >- org.eclipse.jdt.internal.compiler.env.ICompilationUnit sourceUnit, >+ CompilationUnitDeclaration unit, >+ org.eclipse.jdt.internal.compiler.env.ICompilationUnit sourceUnit, > boolean verifyMethods, > boolean analyzeCode, > boolean generateCode) { >- >+ > return resolve( >- unit, >- sourceUnit, >- null/*no node searcher*/, >- verifyMethods, >- analyzeCode, >+ unit, >+ sourceUnit, >+ null/*no node searcher*/, >+ verifyMethods, >+ analyzeCode, > generateCode); > } >- >+ > private void worked(int work) { > if (this.monitor != null) { > if (this.monitor.isCanceled()) >Index: dom/org/eclipse/jdt/core/dom/ASTParser.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ASTParser.java,v >retrieving revision 1.74 >diff -u -r1.74 ASTParser.java >--- dom/org/eclipse/jdt/core/dom/ASTParser.java 6 Mar 2007 02:38:49 -0000 1.74 >+++ dom/org/eclipse/jdt/core/dom/ASTParser.java 13 Mar 2007 18:45:41 -0000 >@@ -704,7 +704,7 @@ > throw new IllegalStateException("project not specified"); //$NON-NLS-1$ > CompilationUnitResolver.resolve(compilationUnits, bindingKeys, requestor, this.apiLevel, this.compilerOptions, this.project, this.workingCopyOwner, this.statementsRecovery, monitor); > } else { >- CompilationUnitResolver.parse(compilationUnits, requestor, this.apiLevel, this.compilerOptions, monitor); >+ CompilationUnitResolver.parse(compilationUnits, requestor, this.apiLevel, this.compilerOptions, this.statementsRecovery, monitor); > } > } finally { > // re-init defaults to allow reuse (and avoid leaking) >@@ -864,6 +864,7 @@ > needToResolveBindings, > wcOwner, > needToResolveBindings ? new DefaultBindingResolver.BindingTables() : null, >+ this.statementsRecovery, > monitor); > result.setTypeRoot(this.typeRoot); > return result; >@@ -953,6 +954,9 @@ > converter.scanner.setSource(this.rawSource); > > AST ast = AST.newAST(this.apiLevel); >+ if (this.statementsRecovery) { >+ ast.setFlag(AST.STATEMENT_RECOVERY); >+ } > ast.setDefaultNodeFlag(ASTNode.ORIGINAL); > ast.setBindingResolver(new BindingResolver()); > converter.setAST(ast); >Index: dom/org/eclipse/jdt/core/dom/AST.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/AST.java,v >retrieving revision 1.152 >diff -u -r1.152 AST.java >--- dom/org/eclipse/jdt/core/dom/AST.java 24 Nov 2006 13:56:36 -0000 1.152 >+++ dom/org/eclipse/jdt/core/dom/AST.java 13 Mar 2007 18:45:40 -0000 >@@ -32,12 +32,12 @@ > /** > * Umbrella owner and abstract syntax tree node factory. > * An <code>AST</code> instance serves as the common owner of any number of >- * AST nodes, and as the factory for creating new AST nodes owned by that >+ * AST nodes, and as the factory for creating new AST nodes owned by that > * instance. > * <p> > * Abstract syntax trees may be hand constructed by clients, using the > * <code>new<i>TYPE</i></code> factory methods to create new nodes, and the >- * various <code>set<i>CHILD</i></code> methods >+ * various <code>set<i>CHILD</i></code> methods > * (see {@link org.eclipse.jdt.core.dom.ASTNode ASTNode} and its subclasses) > * to connect them together. > * </p> >@@ -84,15 +84,18 @@ > * read-only AST. > * </p> > * <p> >- * Clients may create instances of this class using {@link #newAST(int)}, >+ * Clients may create instances of this class using {@link #newAST(int)}, > * but this class is not intended to be subclassed. > * </p> >- * >+ * > * @see ASTParser > * @see ASTNode > * @since 2.0 > */ > public final class AST { >+ >+ static final int RESOLVED_BINDINGS = 0x01; >+ static final int STATEMENT_RECOVERY = 0x02; > /** > * Constant for indicating the AST API that handles JLS2. > * This API is capable of handling all constructs >@@ -107,7 +110,7 @@ > * @deprecated Clients should use the {@link #JLS3} AST API instead. > */ > public static final int JLS2 = 2; >- >+ > /** > * Internal synonym for {@link #JLS2}. Use to alleviate > * deprecation warnings. >@@ -123,37 +126,37 @@ > * JLS3 is a superset of all earlier versions of the > * Java language, and the JLS3 API can be used to manipulate > * programs written in all versions of the Java language >- * up to and including J2SE 5 (aka JDK 1.5). >+ * up to and including J2SE 5 (aka JDK 1.5). > * > * @since 3.1 > */ > public static final int JLS3 = 3; >- >+ > /** > * The binding resolver for this AST. Initially a binding resolver that > * does not resolve names at all. > */ > private BindingResolver resolver = new BindingResolver(); >- >+ > /** >- * The event handler for this AST. >+ * The event handler for this AST. > * Initially an event handler that does not nothing. > * @since 3.0 > */ > private NodeEventHandler eventHandler = new NodeEventHandler(); >- >+ > /** > * Level of AST API supported by this AST. > * @since 3.0 > */ > int apiLevel; >- >+ > /** > * Internal modification count; initially 0; increases monotonically > * <b>by one or more</b> as the AST is successively modified. > */ > private long modificationCount = 0; >- >+ > /** > * Internal original modification count; value is equals to <code> > * modificationCount</code> at the end of the parse (<code>ASTParser >@@ -173,7 +176,7 @@ > * @since 3.0 > */ > private int disableEvents = 0; >- >+ > /** > * Internal object unique to the AST instance. Readers must synchronize on > * this object when the modifying instance fields. >@@ -186,21 +189,26 @@ > * like CharacterLiteral, NumberLiteral, StringLiteral or SimpleName. > */ > Scanner scanner; >- >+ > /** > * Internal ast rewriter used to record ast modification when record mode is enabled. > */ > InternalASTRewrite rewriter; >- >+ > /** > * Default value of <code>flag<code> when a new node is created. > */ > private int defaultNodeFlag = 0; >- >+ >+ /** >+ * Tag bit value. This represents internal state of the tree. >+ */ >+ private int bits; >+ > /** > * Creates a new Java abstract syntax tree >- * (AST) following the specified set of API rules. >- * >+ * (AST) following the specified set of API rules. >+ * > * @param level the API level; one of the LEVEL constants > * @since 3.0 > */ >@@ -212,19 +220,19 @@ > this.apiLevel = level; > // initialize a scanner > this.scanner = new Scanner( >- true /*comment*/, >- true /*whitespace*/, >- false /*nls*/, >- ClassFileConstants.JDK1_3 /*sourceLevel*/, >- ClassFileConstants.JDK1_5 /*complianceLevel*/, >- null/*taskTag*/, >+ true /*comment*/, >+ true /*whitespace*/, >+ false /*nls*/, >+ ClassFileConstants.JDK1_3 /*sourceLevel*/, >+ ClassFileConstants.JDK1_5 /*complianceLevel*/, >+ null/*taskTag*/, > null/*taskPriorities*/, > true/*taskCaseSensitive*/); > } > > /** > * Creates a new, empty abstract syntax tree using default options. >- * >+ * > * @see JavaCore#getDefaultOptions() > * @deprecated Clients should port their code to use the new JLS3 AST API and call > * {@link #newAST(int) AST.newAST(AST.JLS3)} instead of using this constructor. >@@ -239,7 +247,7 @@ > * This method converts the given internal compiler AST for the given source string > * into a compilation unit. This method is not intended to be called by clients. > * </p> >- * >+ * > * @param level the API level; one of the LEVEL constants > * @param compilationUnitDeclaration an internal AST node for a compilation unit declaration > * @param source the string of the Java compilation unit >@@ -257,16 +265,26 @@ > Map options, > boolean isResolved, > org.eclipse.jdt.internal.core.CompilationUnit workingCopy, >+ boolean statementRecovery, > IProgressMonitor monitor) { >- >+ > ASTConverter converter = new ASTConverter(options, isResolved, monitor); > AST ast = AST.newAST(level); >+ if (statementRecovery) { >+ ast.setFlag(AST.STATEMENT_RECOVERY); >+ } > int savedDefaultNodeFlag = ast.getDefaultNodeFlag(); > ast.setDefaultNodeFlag(ASTNode.ORIGINAL); >- BindingResolver resolver = isResolved ? new DefaultBindingResolver(compilationUnitDeclaration.scope, workingCopy.owner, new DefaultBindingResolver.BindingTables()) : new BindingResolver(); >+ BindingResolver resolver = null; >+ if (isResolved) { >+ ast.setFlag(AST.RESOLVED_BINDINGS); >+ resolver = new DefaultBindingResolver(compilationUnitDeclaration.scope, workingCopy.owner, new DefaultBindingResolver.BindingTables()); >+ } else { >+ resolver = new BindingResolver(); >+ } > ast.setBindingResolver(resolver); > converter.setAST(ast); >- >+ > CompilationUnit unit = converter.convert(compilationUnitDeclaration, source); > unit.setLineEndTable(compilationUnitDeclaration.compilationResult.getLineSeparatorPositions()); > unit.setTypeRoot(workingCopy); >@@ -279,7 +297,7 @@ > * <p> > * Following option keys are significant: > * <ul> >- * <li><code>"org.eclipse.jdt.core.compiler.source"</code> - >+ * <li><code>"org.eclipse.jdt.core.compiler.source"</code> - > * indicates source compatibility mode (as per <code>JavaCore</code>); > * <code>"1.3"</code> means the source code is as per JDK 1.3; > * <code>"1.4"</code> means the source code is as per JDK 1.4 >@@ -290,7 +308,7 @@ > * </ul> > * Options other than the above are ignored. > * </p> >- * >+ * > * @param options the table of options (key type: <code>String</code>; > * value type: <code>String</code>) > * @see JavaCore#getDefaultOptions() >@@ -315,24 +333,24 @@ > } > // override scanner if 1.4 or 1.5 asked for > this.scanner = new Scanner( >- true /*comment*/, >- true /*whitespace*/, >- false /*nls*/, >+ true /*comment*/, >+ true /*whitespace*/, >+ false /*nls*/, > sourceLevel /*sourceLevel*/, > complianceLevel /*complianceLevel*/, >- null/*taskTag*/, >+ null/*taskTag*/, > null/*taskPriorities*/, > true/*taskCaseSensitive*/); > } >- >+ > /** > * Creates a new Java abstract syntax tree >- * (AST) following the specified set of API rules. >+ * (AST) following the specified set of API rules. > * <p> > * Clients should use this method specifing {@link #JLS3} as the > * AST level in all cases, even when dealing with JDK 1.3 or 1.4.. > * </p> >- * >+ * > * @param level the API level; one of the LEVEL constants > * @return new AST instance following the specified set of API rules. > * @exception IllegalArgumentException if: >@@ -367,10 +385,10 @@ > * <p> > * N.B. This method may be called several times in the course > * of a single client operation. The only promise is that the modification >- * count increases monotonically as the AST or its nodes change; there is >+ * count increases monotonically as the AST or its nodes change; there is > * no promise that a modifying operation increases the count by exactly 1. > * </p> >- * >+ * > * @return the current value (non-negative) of the modification counter of > * this AST > */ >@@ -380,13 +398,13 @@ > > /** > * Return the API level supported by this AST. >- * >+ * > * @return level the API level; one of the <code>JLS*</code>LEVEL > * declared on <code>AST</code>; assume this set is open-ended > * @since 3.0 > */ > public int apiLevel() { >- return this.apiLevel; >+ return this.apiLevel; > } > > /** >@@ -403,7 +421,7 @@ > * <p> > * N.B. This method may be called several times in the course > * of a single client operation. >- * </p> >+ * </p> > */ > void modifying() { > // when this method is called during lazy init, events are disabled >@@ -418,7 +436,7 @@ > /** > * Disable events. > * This method is thread-safe for AST readers. >- * >+ * > * @see #reenableEvents() > * @since 3.0 > */ >@@ -429,11 +447,11 @@ > } > // while disableEvents > 0 no events will be reported, and mod count will stay fixed > } >- >+ > /** > * Reenable events. > * This method is thread-safe for AST readers. >- * >+ * > * @see #disableEvents() > * @since 3.0 > */ >@@ -443,10 +461,10 @@ > this.disableEvents--; > } > } >- >+ > /** > * Reports that the given node is about to lose a child. >- * >+ * > * @param node the node about to be modified > * @param child the node about to be removed > * @param property the child or child list property descriptor >@@ -472,10 +490,10 @@ > reenableEvents(); > } > } >- >+ > /** > * Reports that the given node jsut lost a child. >- * >+ * > * @param node the node that was modified > * @param child the child node that was removed > * @param property the child or child list property descriptor >@@ -501,10 +519,10 @@ > reenableEvents(); > } > } >- >+ > /** > * Reports that the given node is about have a child replaced. >- * >+ * > * @param node the node about to be modified > * @param child the child node about to be removed > * @param newChild the replacement child >@@ -531,10 +549,10 @@ > reenableEvents(); > } > } >- >+ > /** > * Reports that the given node has just had a child replaced. >- * >+ * > * @param node the node modified > * @param child the child removed > * @param newChild the replacement child >@@ -561,10 +579,10 @@ > reenableEvents(); > } > } >- >+ > /** > * Reports that the given node is about to gain a child. >- * >+ * > * @param node the node that to be modified > * @param child the node that to be added as a child > * @param property the child or child list property descriptor >@@ -590,10 +608,10 @@ > reenableEvents(); > } > } >- >+ > /** > * Reports that the given node has just gained a child. >- * >+ * > * @param node the node that was modified > * @param child the node that was added as a child > * @param property the child or child list property descriptor >@@ -619,11 +637,11 @@ > reenableEvents(); > } > } >- >+ > /** > * Reports that the given node is about to change the value of a > * non-child property. >- * >+ * > * @param node the node to be modified > * @param property the property descriptor > * @since 3.0 >@@ -648,11 +666,11 @@ > reenableEvents(); > } > } >- >+ > /** > * Reports that the given node has just changed the value of a > * non-child property. >- * >+ * > * @param node the node that was modified > * @param property the property descriptor > * @since 3.0 >@@ -677,10 +695,10 @@ > reenableEvents(); > } > } >- >+ > /** > * Reports that the given node is about to be cloned. >- * >+ * > * @param node the node to be cloned > * @since 3.0 > */ >@@ -703,10 +721,10 @@ > reenableEvents(); > } > } >- >+ > /** > * Reports that the given node has just been cloned. >- * >+ * > * @param node the node that was cloned > * @param clone the clone of <code>node</code> > * @since 3.0 >@@ -730,10 +748,10 @@ > reenableEvents(); > } > } >- >+ > /** > * Parses the source string of the given Java model compilation unit element >- * and creates and returns a corresponding abstract syntax tree. The source >+ * and creates and returns a corresponding abstract syntax tree. The source > * string is obtained from the Java model element using > * <code>ICompilationUnit.getSource()</code>. > * <p> >@@ -741,7 +759,7 @@ > * Each node in the subtree carries source range(s) information relating back > * to positions in the source string (the source string is not remembered > * with the AST). >- * The source range usually begins at the first character of the first token >+ * The source range usually begins at the first character of the first token > * corresponding to the node; leading whitespace and comments are <b>not</b> > * included. The source range usually extends through the last character of > * the last token corresponding to the node; trailing whitespace and >@@ -757,12 +775,12 @@ > * <p> > * If <code>resolveBindings</code> is <code>true</code>, the various names > * and types appearing in the compilation unit can be resolved to "bindings" >- * by calling the <code>resolveBinding</code> methods. These bindings >- * draw connections between the different parts of a program, and >+ * by calling the <code>resolveBinding</code> methods. These bindings >+ * draw connections between the different parts of a program, and > * generally afford a more powerful vantage point for clients who wish to >- * analyze a program's structure more deeply. These bindings come at a >+ * analyze a program's structure more deeply. These bindings come at a > * considerable cost in both time and space, however, and should not be >- * requested frivolously. The additional space is not reclaimed until the >+ * requested frivolously. The additional space is not reclaimed until the > * AST, all its nodes, and all its bindings become garbage. So it is very > * important to not retain any of these objects longer than absolutely > * necessary. Bindings are resolved at the time the AST is created. Subsequent >@@ -770,17 +788,17 @@ > * <code>resolveBinding</code> methods in any way; these methods return the > * same binding as before the AST was modified (including modifications > * that rearrange subtrees by reparenting nodes). >- * If <code>resolveBindings</code> is <code>false</code>, the analysis >- * does not go beyond parsing and building the tree, and all >- * <code>resolveBinding</code> methods return <code>null</code> from the >+ * If <code>resolveBindings</code> is <code>false</code>, the analysis >+ * does not go beyond parsing and building the tree, and all >+ * <code>resolveBinding</code> methods return <code>null</code> from the > * outset. > * </p> >- * >+ * > * @param unit the Java model compilation unit whose source code is to be parsed >- * @param resolveBindings <code>true</code> if bindings are wanted, >+ * @param resolveBindings <code>true</code> if bindings are wanted, > * and <code>false</code> if bindings are not of interest > * @return the compilation unit node >- * @exception IllegalArgumentException if the given Java element does not >+ * @exception IllegalArgumentException if the given Java element does not > * exist or if its source string cannot be obtained > * @see ASTNode#getFlags() > * @see ASTNode#MALFORMED >@@ -804,7 +822,7 @@ > throw new IllegalArgumentException(); > } > } >- >+ > /** > * Parses the source string corresponding to the given Java class file > * element and creates and returns a corresponding abstract syntax tree. >@@ -816,7 +834,7 @@ > * Each node in the subtree carries source range(s) information relating back > * to positions in the source string (the source string is not remembered > * with the AST). >- * The source range usually begins at the first character of the first token >+ * The source range usually begins at the first character of the first token > * corresponding to the node; leading whitespace and comments are <b>not</b> > * included. The source range usually extends through the last character of > * the last token corresponding to the node; trailing whitespace and >@@ -832,12 +850,12 @@ > * <p> > * If <code>resolveBindings</code> is <code>true</code>, the various names > * and types appearing in the compilation unit can be resolved to "bindings" >- * by calling the <code>resolveBinding</code> methods. These bindings >- * draw connections between the different parts of a program, and >+ * by calling the <code>resolveBinding</code> methods. These bindings >+ * draw connections between the different parts of a program, and > * generally afford a more powerful vantage point for clients who wish to >- * analyze a program's structure more deeply. These bindings come at a >+ * analyze a program's structure more deeply. These bindings come at a > * considerable cost in both time and space, however, and should not be >- * requested frivolously. The additional space is not reclaimed until the >+ * requested frivolously. The additional space is not reclaimed until the > * AST, all its nodes, and all its bindings become garbage. So it is very > * important to not retain any of these objects longer than absolutely > * necessary. Bindings are resolved at the time the AST is created. Subsequent >@@ -845,17 +863,17 @@ > * <code>resolveBinding</code> methods in any way; these methods return the > * same binding as before the AST was modified (including modifications > * that rearrange subtrees by reparenting nodes). >- * If <code>resolveBindings</code> is <code>false</code>, the analysis >- * does not go beyond parsing and building the tree, and all >- * <code>resolveBinding</code> methods return <code>null</code> from the >+ * If <code>resolveBindings</code> is <code>false</code>, the analysis >+ * does not go beyond parsing and building the tree, and all >+ * <code>resolveBinding</code> methods return <code>null</code> from the > * outset. > * </p> >- * >+ * > * @param classFile the Java model class file whose corresponding source code is to be parsed >- * @param resolveBindings <code>true</code> if bindings are wanted, >+ * @param resolveBindings <code>true</code> if bindings are wanted, > * and <code>false</code> if bindings are not of interest > * @return the compilation unit node >- * @exception IllegalArgumentException if the given Java element does not >+ * @exception IllegalArgumentException if the given Java element does not > * exist or if its source string cannot be obtained > * @see ASTNode#getFlags() > * @see ASTNode#MALFORMED >@@ -882,7 +900,7 @@ > throw new IllegalArgumentException(); > } > } >- >+ > /** > * Parses the given string as the hypothetical contents of the named > * compilation unit and creates and returns a corresponding abstract syntax tree. >@@ -891,7 +909,7 @@ > * Each node in the subtree carries source range(s) information relating back > * to positions in the given source string (the given source string itself > * is not remembered with the AST). >- * The source range usually begins at the first character of the first token >+ * The source range usually begins at the first character of the first token > * corresponding to the node; leading whitespace and comments are <b>not</b> > * included. The source range usually extends through the last character of > * the last token corresponding to the node; trailing whitespace and >@@ -907,12 +925,12 @@ > * <p> > * If the given project is not <code>null</code>, the various names > * and types appearing in the compilation unit can be resolved to "bindings" >- * by calling the <code>resolveBinding</code> methods. These bindings >- * draw connections between the different parts of a program, and >+ * by calling the <code>resolveBinding</code> methods. These bindings >+ * draw connections between the different parts of a program, and > * generally afford a more powerful vantage point for clients who wish to >- * analyze a program's structure more deeply. These bindings come at a >+ * analyze a program's structure more deeply. These bindings come at a > * considerable cost in both time and space, however, and should not be >- * requested frivolously. The additional space is not reclaimed until the >+ * requested frivolously. The additional space is not reclaimed until the > * AST, all its nodes, and all its bindings become garbage. So it is very > * important to not retain any of these objects longer than absolutely > * necessary. Bindings are resolved at the time the AST is created. Subsequent >@@ -920,15 +938,15 @@ > * <code>resolveBinding</code> methods in any way; these methods return the > * same binding as before the AST was modified (including modifications > * that rearrange subtrees by reparenting nodes). >- * If the given project is <code>null</code>, the analysis >- * does not go beyond parsing and building the tree, and all >- * <code>resolveBinding</code> methods return <code>null</code> from the >+ * If the given project is <code>null</code>, the analysis >+ * does not go beyond parsing and building the tree, and all >+ * <code>resolveBinding</code> methods return <code>null</code> from the > * outset. > * </p> > * <p> > * The name of the compilation unit must be supplied for resolving bindings. >- * This name should be suffixed by a dot ('.') followed by one of the >- * {@link JavaCore#getJavaLikeExtensions() Java-like extensions} >+ * This name should be suffixed by a dot ('.') followed by one of the >+ * {@link JavaCore#getJavaLikeExtensions() Java-like extensions} > * and match the name of the main > * (public) class or interface declared in the source. For example, if the source > * declares a public class named "Foo", the name of the compilation can be >@@ -936,11 +954,11 @@ > * source string hide types by the same name available through the classpath > * of the given project. > * </p> >- * >+ * > * @param source the string to be parsed as a Java compilation unit > * @param unitName the name of the compilation unit that would contain the source > * string, or <code>null</code> if <code>javaProject</code> is also <code>null</code> >- * @param project the Java project used to resolve names, or >+ * @param project the Java project used to resolve names, or > * <code>null</code> if bindings are not resolved > * @return the compilation unit node > * @see ASTNode#getFlags() >@@ -966,16 +984,16 @@ > ASTNode result = astParser.createAST(null); > return (CompilationUnit) result; > } >- >+ > /** >- * Parses the given string as a Java compilation unit and creates and >+ * Parses the given string as a Java compilation unit and creates and > * returns a corresponding abstract syntax tree. > * <p> > * The returned compilation unit node is the root node of a new AST. > * Each node in the subtree carries source range(s) information relating back > * to positions in the given source string (the given source string itself >- * is not remembered with the AST). >- * The source range usually begins at the first character of the first token >+ * is not remembered with the AST). >+ * The source range usually begins at the first character of the first token > * corresponding to the node; leading whitespace and comments are <b>not</b> > * included. The source range usually extends through the last character of > * the last token corresponding to the node; trailing whitespace and >@@ -992,7 +1010,7 @@ > * This method does not compute binding information; all <code>resolveBinding</code> > * methods applied to nodes of the resulting AST return <code>null</code>. > * </p> >- * >+ * > * @param source the string to be parsed as a Java compilation unit > * @return the compilation unit node > * @see ASTNode#getFlags() >@@ -1014,7 +1032,7 @@ > > /** > * Returns the binding resolver for this AST. >- * >+ * > * @return the binding resolver for this AST > */ > BindingResolver getBindingResolver() { >@@ -1023,7 +1041,7 @@ > > /** > * Returns the event handler for this AST. >- * >+ * > * @return the event handler for this AST > * @since 3.0 > */ >@@ -1033,7 +1051,7 @@ > > /** > * Sets the event handler for this AST. >- * >+ * > * @param eventHandler the event handler for this AST > * @since 3.0 > */ >@@ -1043,37 +1061,37 @@ > } > this.eventHandler = eventHandler; > } >- >+ > /** > * Returns default node flags of new nodes of this AST. >- * >+ * > * @return the default node flags of new nodes of this AST > * @since 3.0 > */ > int getDefaultNodeFlag() { > return this.defaultNodeFlag; > } >- >+ > /** > * Sets default node flags of new nodes of this AST. >- * >+ * > * @param flag node flags of new nodes of this AST > * @since 3.0 > */ > void setDefaultNodeFlag(int flag) { > this.defaultNodeFlag = flag; > } >- >+ > /** > * Set <code>originalModificationCount</code> to the current modification count >- * >+ * > * @since 3.0 > */ > void setOriginalModificationCount(long count) { > this.originalModificationCount = count; > } > >- /** >+ /** > * Returns the type binding for a "well known" type. > * <p> > * Note that bindings are generally unavailable unless requested when the >@@ -1112,9 +1130,9 @@ > * <li><code>"java.io.Serializable"</code></li> > * </ul> > * </p> >- * >+ * > * @param name the name of a well known type >- * @return the corresponding type binding, or <code>null</code> if the >+ * @return the corresponding type binding, or <code>null</code> if the > * named type is not considered well known or if no binding can be found > * for it > */ >@@ -1124,10 +1142,10 @@ > } > return getBindingResolver().resolveWellKnownType(name); > } >- >+ > /** > * Sets the binding resolver for this AST. >- * >+ * > * @param resolver the new binding resolver for this AST > */ > void setBindingResolver(BindingResolver resolver) { >@@ -1174,14 +1192,14 @@ > * @since 3.0 > */ > private final Object[] THIS_AST= new Object[] {this}; >- >+ > /** > * Creates an unparented node of the given node class >- * (non-abstract subclass of {@link ASTNode}). >- * >+ * (non-abstract subclass of {@link ASTNode}). >+ * > * @param nodeClass AST node class > * @return a new unparented node owned by this AST >- * @exception IllegalArgumentException if <code>nodeClass</code> is >+ * @exception IllegalArgumentException if <code>nodeClass</code> is > * <code>null</code> or is not a concrete node type class > * @since 3.0 > */ >@@ -1210,7 +1228,7 @@ > // concrete AST node classes do not die in the constructor > // therefore nodeClass is not legit > throw new IllegalArgumentException(); >- } >+ } > } > > /** >@@ -1219,11 +1237,11 @@ > * <pre> > * createInstance(ASTNode.nodeClassForType(nodeType)) > * </pre> >- * >+ * > * @param nodeType AST node type, one of the node type > * constants declared on {@link ASTNode} > * @return a new unparented node owned by this AST >- * @exception IllegalArgumentException if <code>nodeType</code> is >+ * @exception IllegalArgumentException if <code>nodeType</code> is > * not a legal AST node type > * @since 3.0 > */ >@@ -1233,12 +1251,30 @@ > return createInstance(nodeClass); > } > >+ /** >+ * Returns true if the ast tree was created with bindings, false otherwise >+ * >+ * @return true if the ast tree was created with bindings, false otherwise >+ */ >+ public boolean hasResolvedBindings() { >+ return (this.bits & RESOLVED_BINDINGS) != 0; >+ } >+ >+ /** >+ * Returns true if the ast tree was created with statement recovery, false otherwise >+ * >+ * @return true if the ast tree was created with statement recovery, false otherwise >+ */ >+ public boolean hasStatementRecovery() { >+ return (this.bits & STATEMENT_RECOVERY) != 0; >+ } >+ > //=============================== NAMES =========================== > /** > * Creates and returns a new unparented simple name node for the given > * identifier. The identifier should be a legal Java identifier, but not > * a keyword, boolean literal ("true", "false") or null literal ("null"). >- * >+ * > * @param identifier the identifier > * @return a new unparented simple name node > * @exception IllegalArgumentException if the identifier is invalid >@@ -1253,9 +1289,9 @@ > } > > /** >- * Creates and returns a new unparented qualified name node for the given >+ * Creates and returns a new unparented qualified name node for the given > * qualifier and simple name child node. >- * >+ * > * @param qualifier the qualifier name node > * @param name the simple name being qualified > * @return a new unparented qualified name node >@@ -1272,16 +1308,16 @@ > result.setQualifier(qualifier); > result.setName(name); > return result; >- >+ > } >- >+ > /** >- * Creates and returns a new unparented name node for the given name >+ * Creates and returns a new unparented name node for the given name > * segments. Returns a simple name if there is only one name segment, and > * a qualified name if there are multiple name segments. Each of the name >- * segments should be legal Java identifiers (this constraint may or may >+ * segments should be legal Java identifiers (this constraint may or may > * not be enforced), and there must be at least one name segment. >- * >+ * > * @param identifiers a list of 1 or more name segments, each of which > * is a legal Java identifier > * @return a new unparented name node >@@ -1304,7 +1340,7 @@ > } > return result; > } >- >+ > /* (omit javadoc for this method) > * This method is a copy of setName(String[]) that doesn't do any validation. > */ >@@ -1326,15 +1362,15 @@ > > /** > * Creates and returns a new unparented name node for the given name. >- * The name string must consist of 1 or more name segments separated >+ * The name string must consist of 1 or more name segments separated > * by single dots '.'. Returns a {@link QualifiedName} if the name has > * dots, and a {@link SimpleName} otherwise. Each of the name >- * segments should be legal Java identifiers (this constraint may or may >+ * segments should be legal Java identifiers (this constraint may or may > * not be enforced), and there must be at least one name segment. > * The string must not contains white space, '<', '>', > * '[', ']', or other any other characters that are not > * part of the Java identifiers or separating '.'s. >- * >+ * > * @param qualifiedName string consisting of 1 or more name segments, > * each of which is a legal Java identifier, separated by single dots '.' > * @return a new unparented name node >@@ -1390,7 +1426,7 @@ > * This method can be used to convert a name (<code>Name</code>) into a > * type (<code>Type</code>) by wrapping it. > * </p> >- * >+ * > * @param typeName the name of the class or interface > * @return a new unparented simple type node > * @exception IllegalArgumentException if: >@@ -1408,7 +1444,7 @@ > /** > * Creates and returns a new unparented array type node with the given > * component type, which may be another array type. >- * >+ * > * @param componentType the component type (possibly another array type) > * @return a new unparented array type node > * @exception IllegalArgumentException if: >@@ -1426,12 +1462,12 @@ > > /** > * Creates and returns a new unparented array type node with the given >- * element type and number of dimensions. >+ * element type and number of dimensions. > * <p> > * Note that if the element type passed in is an array type, the > * element type of the result will not be the same as what was passed in. > * </p> >- * >+ * > * @param elementType the element type (never an array type) > * @param dimensions the number of dimensions, a positive number > * @return a new unparented array type node >@@ -1460,14 +1496,14 @@ > result = newArrayType(result); > } > return result; >- >+ > } > > /** > * Creates and returns a new unparented primitive type node with the given > * type code. >- * >- * @param typeCode one of the primitive type code constants declared in >+ * >+ * @param typeCode one of the primitive type code constants declared in > * <code>PrimitiveType</code> > * @return a new unparented primitive type node > * @exception IllegalArgumentException if the primitive type code is invalid >@@ -1481,7 +1517,7 @@ > /** > * Creates and returns a new unparented parameterized type node with the > * given type and an empty list of type arguments. >- * >+ * > * @param type the type that is parameterized > * @return a new unparented parameterized type node > * @exception IllegalArgumentException if: >@@ -1500,9 +1536,9 @@ > } > > /** >- * Creates and returns a new unparented qualified type node with >+ * Creates and returns a new unparented qualified type node with > * the given qualifier type and name. >- * >+ * > * @param qualifier the qualifier type node > * @param name the simple name being qualified > * @return a new unparented qualified type node >@@ -1521,11 +1557,11 @@ > result.setName(name); > return result; > } >- >+ > /** >- * Creates and returns a new unparented wildcard type node with no >+ * Creates and returns a new unparented wildcard type node with no > * type bound. >- * >+ * > * @return a new unparented wildcard type node > * @exception UnsupportedOperationException if this operation is used in > * a JLS2 AST >@@ -1541,41 +1577,41 @@ > * Creates an unparented compilation unit node owned by this AST. > * The compilation unit initially has no package declaration, no > * import declarations, and no type declarations. >- * >+ * > * @return the new unparented compilation unit node > */ > public CompilationUnit newCompilationUnit() { > return new CompilationUnit(this); > } >- >+ > /** > * Creates an unparented package declaration node owned by this AST. > * The package declaration initially declares a package with an > * unspecified name. >- * >+ * > * @return the new unparented package declaration node > */ > public PackageDeclaration newPackageDeclaration() { > PackageDeclaration result = new PackageDeclaration(this); > return result; > } >- >+ > /** > * Creates an unparented import declaration node owned by this AST. > * The import declaration initially contains a single-type import > * of a type with an unspecified name. >- * >+ * > * @return the new unparented import declaration node > */ > public ImportDeclaration newImportDeclaration() { > ImportDeclaration result = new ImportDeclaration(this); > return result; > } >- >+ > /** > * Creates an unparented class declaration node owned by this AST. >- * The name of the class is an unspecified, but legal, name; >- * no modifiers; no doc comment; no superclass or superinterfaces; >+ * The name of the class is an unspecified, but legal, name; >+ * no modifiers; no doc comment; no superclass or superinterfaces; > * and an empty class body. > * <p> > * To create an interface, use this method and then call >@@ -1585,7 +1621,7 @@ > * To create an enum declaration, use this method and then call > * <code>TypeDeclaration.setEnumeration(true)</code>. > * </p> >- * >+ * > * @return a new unparented type declaration node > */ > public TypeDeclaration newTypeDeclaration() { >@@ -1593,10 +1629,10 @@ > result.setInterface(false); > return result; > } >- >+ > /** > * Creates an unparented method declaration node owned by this AST. >- * By default, the declaration is for a method of an unspecified, but >+ * By default, the declaration is for a method of an unspecified, but > * legal, name; no modifiers; no doc comment; no parameters; return > * type void; no extra array dimensions; no thrown exceptions; and no > * body (as opposed to an empty body). >@@ -1605,7 +1641,7 @@ > * <code>MethodDeclaration.setConstructor(true)</code> and > * <code>MethodDeclaration.setName(className)</code>. > * </p> >- * >+ * > * @return a new unparented method declaration node > */ > public MethodDeclaration newMethodDeclaration() { >@@ -1613,37 +1649,37 @@ > result.setConstructor(false); > return result; > } >- >+ > /** > * Creates an unparented single variable declaration node owned by this AST. >- * By default, the declaration is for a variable with an unspecified, but >+ * By default, the declaration is for a variable with an unspecified, but > * legal, name and type; no modifiers; no array dimensions after the > * variable; no initializer; not variable arity. >- * >+ * > * @return a new unparented single variable declaration node > */ > public SingleVariableDeclaration newSingleVariableDeclaration() { > SingleVariableDeclaration result = new SingleVariableDeclaration(this); > return result; > } >- >+ > /** >- * Creates an unparented variable declaration fragment node owned by this >- * AST. By default, the fragment is for a variable with an unspecified, but >+ * Creates an unparented variable declaration fragment node owned by this >+ * AST. By default, the fragment is for a variable with an unspecified, but > * legal, name; no extra array dimensions; and no initializer. >- * >+ * > * @return a new unparented variable declaration fragment node > */ > public VariableDeclarationFragment newVariableDeclarationFragment() { > VariableDeclarationFragment result = new VariableDeclarationFragment(this); > return result; > } >- >+ > /** >- * Creates an unparented initializer node owned by this AST, with an >- * empty block. By default, the initializer has no modifiers and >+ * Creates an unparented initializer node owned by this AST, with an >+ * empty block. By default, the initializer has no modifiers and > * an empty block. >- * >+ * > * @return a new unparented initializer node > */ > public Initializer newInitializer() { >@@ -1653,10 +1689,10 @@ > > /** > * Creates an unparented enum constant declaration node owned by this AST. >- * The name of the constant is an unspecified, but legal, name; >- * no doc comment; no modifiers or annotations; no arguments; >+ * The name of the constant is an unspecified, but legal, name; >+ * no doc comment; no modifiers or annotations; no arguments; > * and does not declare an anonymous class. >- * >+ * > * @return a new unparented enum constant declaration node > * @exception UnsupportedOperationException if this operation is used in > * a JLS2 AST >@@ -1666,14 +1702,14 @@ > EnumConstantDeclaration result = new EnumConstantDeclaration(this); > return result; > } >- >+ > /** > * Creates an unparented enum declaration node owned by this AST. >- * The name of the enum is an unspecified, but legal, name; >- * no doc comment; no modifiers or annotations; >+ * The name of the enum is an unspecified, but legal, name; >+ * no doc comment; no modifiers or annotations; > * no superinterfaces; and empty lists of enum constants > * and body declarations. >- * >+ * > * @return a new unparented enum declaration node > * @exception UnsupportedOperationException if this operation is used in > * a JLS2 AST >@@ -1683,11 +1719,11 @@ > EnumDeclaration result = new EnumDeclaration(this); > return result; > } >- >+ > /** > * Creates and returns a new unparented type parameter type node with an > * unspecified type variable name and an empty list of type bounds. >- * >+ * > * @return a new unparented type parameter node > * @exception UnsupportedOperationException if this operation is used in > * a JLS2 AST >@@ -1700,9 +1736,9 @@ > > /** > * Creates and returns a new unparented annotation type declaration >- * node for an unspecified, but legal, name; no modifiers; no javadoc; >+ * node for an unspecified, but legal, name; no modifiers; no javadoc; > * and an empty list of member declarations. >- * >+ * > * @return a new unparented annotation type declaration node > * @exception UnsupportedOperationException if this operation is used in > * a JLS2 AST >@@ -1712,13 +1748,13 @@ > AnnotationTypeDeclaration result = new AnnotationTypeDeclaration(this); > return result; > } >- >+ > /** >- * Creates and returns a new unparented annotation type >- * member declaration node for an unspecified, but legal, >- * member name and type; no modifiers; no javadoc; >+ * Creates and returns a new unparented annotation type >+ * member declaration node for an unspecified, but legal, >+ * member name and type; no modifiers; no javadoc; > * and no default value. >- * >+ * > * @return a new unparented annotation type member declaration node > * @exception UnsupportedOperationException if this operation is used in > * a JLS2 AST >@@ -1728,11 +1764,11 @@ > AnnotationTypeMemberDeclaration result = new AnnotationTypeMemberDeclaration(this); > return result; > } >- >+ > /** > * Creates and returns a new unparented modifier node for the given > * modifier. >- * >+ * > * @param keyword one of the modifier keyword constants > * @return a new unparented modifier node > * @exception IllegalArgumentException if the primitive type code is invalid >@@ -1747,13 +1783,13 @@ > } > > /** >- * Creates and returns a list of new unparented modifier nodes >- * for the given modifier flags. When multiple modifiers are >+ * Creates and returns a list of new unparented modifier nodes >+ * for the given modifier flags. When multiple modifiers are > * requested the modifiers nodes will appear in the following order: > * public, protected, private, abstract, static, final, synchronized, > * native, strictfp, transient, volatile. This order is consistent > * with the recommendations in JLS2 8.1.1, 8.3.1, and 8.4.3. >- * >+ * > * @param flags bitwise or of modifier flags declared on {@link Modifier} > * @return a possibly empty list of new unparented modifier nodes > * (element type <code>Modifier</code>) >@@ -1809,11 +1845,11 @@ > * <p> > * Note that this node type is used to recording the source > * range where a comment was found in the source string. >- * These comment nodes are normally found (only) in >- * {@linkplain CompilationUnit#getCommentList() >+ * These comment nodes are normally found (only) in >+ * {@linkplain CompilationUnit#getCommentList() > * the comment table} for parsed compilation units. > * </p> >- * >+ * > * @return a new unparented block comment node > * @since 3.0 > */ >@@ -1821,17 +1857,17 @@ > BlockComment result = new BlockComment(this); > return result; > } >- >+ > /** > * Creates and returns a new line comment placeholder node. > * <p> > * Note that this node type is used to recording the source > * range where a comment was found in the source string. >- * These comment nodes are normally found (only) in >- * {@linkplain CompilationUnit#getCommentList() >+ * These comment nodes are normally found (only) in >+ * {@linkplain CompilationUnit#getCommentList() > * the comment table} for parsed compilation units. > * </p> >- * >+ * > * @return a new unparented line comment node > * @since 3.0 > */ >@@ -1839,20 +1875,20 @@ > LineComment result = new LineComment(this); > return result; > } >- >+ > /** > * Creates and returns a new doc comment node. > * Initially the new node has an empty list of tag elements > * (and, for backwards compatability, an unspecified, but legal, > * doc comment string) >- * >+ * > * @return a new unparented doc comment node > */ > public Javadoc newJavadoc() { > Javadoc result = new Javadoc(this); > return result; > } >- >+ > /** > * Creates and returns a new tag element node. > * Initially the new node has no tag name and an empty list of fragments. >@@ -1860,7 +1896,7 @@ > * Note that this node type is used only inside doc comments > * ({@link Javadoc}). > * </p> >- * >+ * > * @return a new unparented tag element node > * @since 3.0 > */ >@@ -1868,7 +1904,7 @@ > TagElement result = new TagElement(this); > return result; > } >- >+ > /** > * Creates and returns a new text element node. > * Initially the new node has an empty text string. >@@ -1876,7 +1912,7 @@ > * Note that this node type is used only inside doc comments > * ({@link Javadoc Javadoc}). > * </p> >- * >+ * > * @return a new unparented text element node > * @since 3.0 > */ >@@ -1884,16 +1920,16 @@ > TextElement result = new TextElement(this); > return result; > } >- >+ > /** > * Creates and returns a new member reference node. >- * Initially the new node has no qualifier name and >+ * Initially the new node has no qualifier name and > * an unspecified, but legal, member name. > * <p> > * Note that this node type is used only inside doc comments > * ({@link Javadoc}). > * </p> >- * >+ * > * @return a new unparented member reference node > * @since 3.0 > */ >@@ -1901,17 +1937,17 @@ > MemberRef result = new MemberRef(this); > return result; > } >- >+ > /** > * Creates and returns a new method reference node. >- * Initially the new node has no qualifier name, >+ * Initially the new node has no qualifier name, > * an unspecified, but legal, method name, and an >- * empty parameter list. >+ * empty parameter list. > * <p> > * Note that this node type is used only inside doc comments > * ({@link Javadoc Javadoc}). > * </p> >- * >+ * > * @return a new unparented method reference node > * @since 3.0 > */ >@@ -1919,16 +1955,16 @@ > MethodRef result = new MethodRef(this); > return result; > } >- >+ > /** > * Creates and returns a new method reference node. > * Initially the new node has an unspecified, but legal, >- * type, not variable arity, and no parameter name. >+ * type, not variable arity, and no parameter name. > * <p> > * Note that this node type is used only inside doc comments > * ({@link Javadoc}). > * </p> >- * >+ * > * @return a new unparented method reference parameter node > * @since 3.0 > */ >@@ -1936,11 +1972,11 @@ > MethodRefParameter result = new MethodRefParameter(this); > return result; > } >- >+ > //=============================== STATEMENTS =========================== > /** >- * Creates a new unparented local variable declaration statement node >- * owned by this AST, for the given variable declaration fragment. >+ * Creates a new unparented local variable declaration statement node >+ * owned by this AST, for the given variable declaration fragment. > * By default, there are no modifiers and the base type is unspecified > * (but legal). > * <p> >@@ -1949,7 +1985,7 @@ > * (<code>Statement</code>) by wrapping it. Additional variable > * declaration fragments can be added afterwards. > * </p> >- * >+ * > * @param fragment the variable declaration fragment > * @return a new unparented variable declaration statement node > * @exception IllegalArgumentException if: >@@ -1970,16 +2006,16 @@ > result.fragments().add(fragment); > return result; > } >- >+ > /** >- * Creates a new unparented local type declaration statement node >+ * Creates a new unparented local type declaration statement node > * owned by this AST, for the given type declaration. > * <p> > * This method can be used to convert a type declaration > * (<code>TypeDeclaration</code>) into a statement > * (<code>Statement</code>) by wrapping it. > * </p> >- * >+ * > * @param decl the type declaration > * @return a new unparented local type declaration statement node > * @exception IllegalArgumentException if: >@@ -1989,22 +2025,22 @@ > * <li>a cycle in would be created</li> > * </ul> > */ >- public TypeDeclarationStatement >+ public TypeDeclarationStatement > newTypeDeclarationStatement(TypeDeclaration decl) { > TypeDeclarationStatement result = new TypeDeclarationStatement(this); > result.setDeclaration(decl); > return result; > } >- >+ > /** >- * Creates a new unparented local type declaration statement node >+ * Creates a new unparented local type declaration statement node > * owned by this AST, for the given type declaration. > * <p> > * This method can be used to convert any kind of type declaration > * (<code>AbstractTypeDeclaration</code>) into a statement > * (<code>Statement</code>) by wrapping it. > * </p> >- * >+ * > * @param decl the type declaration > * @return a new unparented local type declaration statement node > * @exception IllegalArgumentException if: >@@ -2015,7 +2051,7 @@ > * </ul> > * @since 3.0 > */ >- public TypeDeclarationStatement >+ public TypeDeclarationStatement > newTypeDeclarationStatement(AbstractTypeDeclaration decl) { > TypeDeclarationStatement result = new TypeDeclarationStatement(this); > if (this.apiLevel == AST.JLS2) { >@@ -2026,48 +2062,48 @@ > } > return result; > } >- >+ > /** >- * Creates an unparented block node owned by this AST, for an empty list >+ * Creates an unparented block node owned by this AST, for an empty list > * of statements. >- * >+ * > * @return a new unparented, empty block node > */ > public Block newBlock() { > return new Block(this); > } >- >+ > /** > * Creates an unparented continue statement node owned by this AST. > * The continue statement has no label. >- * >+ * > * @return a new unparented continue statement node > */ > public ContinueStatement newContinueStatement() { > return new ContinueStatement(this); > } >- >+ > /** > * Creates an unparented break statement node owned by this AST. > * The break statement has no label. >- * >+ * > * @return a new unparented break statement node > */ > public BreakStatement newBreakStatement() { > return new BreakStatement(this); > } >- >+ > /** > * Creates a new unparented expression statement node owned by this AST, > * for the given expression. > * <p> >- * This method can be used to convert an expression >- * (<code>Expression</code>) into a statement (<code>Type</code>) >- * by wrapping it. Note, however, that the result is only legal for >+ * This method can be used to convert an expression >+ * (<code>Expression</code>) into a statement (<code>Type</code>) >+ * by wrapping it. Note, however, that the result is only legal for > * limited expression types, including method invocations, assignments, > * and increment/decrement operations. > * </p> >- * >+ * > * @param expression the expression > * @return a new unparented statement node > * @exception IllegalArgumentException if: >@@ -2082,12 +2118,12 @@ > result.setExpression(expression); > return result; > } >- >+ > /** > * Creates a new unparented if statement node owned by this AST. >- * By default, the expression is unspecified (but legal), >+ * By default, the expression is unspecified (but legal), > * the then statement is an empty block, and there is no else statement. >- * >+ * > * @return a new unparented if statement node > */ > public IfStatement newIfStatement() { >@@ -2098,7 +2134,7 @@ > * Creates a new unparented while statement node owned by this AST. > * By default, the expression is unspecified (but legal), and > * the body statement is an empty block. >- * >+ * > * @return a new unparented while statement node > */ > public WhileStatement newWhileStatement() { >@@ -2109,7 +2145,7 @@ > * Creates a new unparented do statement node owned by this AST. > * By default, the expression is unspecified (but legal), and > * the body statement is an empty block. >- * >+ * > * @return a new unparented do statement node > */ > public DoStatement newDoStatement() { >@@ -2120,7 +2156,7 @@ > * Creates a new unparented try statement node owned by this AST. > * By default, the try statement has an empty block, no catch > * clauses, and no finally block. >- * >+ * > * @return a new unparented try statement node > */ > public TryStatement newTryStatement() { >@@ -2129,9 +2165,9 @@ > > /** > * Creates a new unparented catch clause node owned by this AST. >- * By default, the catch clause declares an unspecified, but legal, >+ * By default, the catch clause declares an unspecified, but legal, > * exception declaration and has an empty block. >- * >+ * > * @return a new unparented catch clause node > */ > public CatchClause newCatchClause() { >@@ -2141,7 +2177,7 @@ > /** > * Creates a new unparented return statement node owned by this AST. > * By default, the return statement has no expression. >- * >+ * > * @return a new unparented return statement node > */ > public ReturnStatement newReturnStatement() { >@@ -2151,7 +2187,7 @@ > /** > * Creates a new unparented throw statement node owned by this AST. > * By default, the expression is unspecified, but legal. >- * >+ * > * @return a new unparented throw statement node > */ > public ThrowStatement newThrowStatement() { >@@ -2162,7 +2198,7 @@ > * Creates a new unparented assert statement node owned by this AST. > * By default, the first expression is unspecified, but legal, and has no > * message expression. >- * >+ * > * @return a new unparented assert statement node > */ > public AssertStatement newAssertStatement() { >@@ -2171,7 +2207,7 @@ > > /** > * Creates a new unparented empty statement node owned by this AST. >- * >+ * > * @return a new unparented empty statement node > */ > public EmptyStatement newEmptyStatement() { >@@ -2181,7 +2217,7 @@ > /** > * Creates a new unparented labeled statement node owned by this AST. > * By default, the label and statement are both unspecified, but legal. >- * >+ * > * @return a new unparented labeled statement node > */ > public LabeledStatement newLabeledStatement() { >@@ -2192,7 +2228,7 @@ > * Creates a new unparented switch statement node owned by this AST. > * By default, the expression is unspecified, but legal, and there are > * no statements or switch cases. >- * >+ * > * @return a new unparented labeled statement node > */ > public SwitchStatement newSwitchStatement() { >@@ -2200,9 +2236,9 @@ > } > > /** >- * Creates a new unparented switch case statement node owned by >+ * Creates a new unparented switch case statement node owned by > * this AST. By default, the expression is unspecified, but legal. >- * >+ * > * @return a new unparented switch case node > */ > public SwitchCase newSwitchCase() { >@@ -2213,7 +2249,7 @@ > * Creates a new unparented synchronized statement node owned by this AST. > * By default, the expression is unspecified, but legal, and the body is > * an empty block. >- * >+ * > * @return a new unparented synchronized statement node > */ > public SynchronizedStatement newSynchronizedStatement() { >@@ -2222,9 +2258,9 @@ > > /** > * Creates a new unparented for statement node owned by this AST. >- * By default, there are no initializers, no condition expression, >+ * By default, there are no initializers, no condition expression, > * no updaters, and the body is an empty block. >- * >+ * > * @return a new unparented for statement node > */ > public ForStatement newForStatement() { >@@ -2235,7 +2271,7 @@ > * Creates a new unparented enhanced for statement node owned by this AST. > * By default, the paramter and expression are unspecified > * but legal subtrees, and the body is an empty block. >- * >+ * > * @return a new unparented throw statement node > * @exception UnsupportedOperationException if this operation is used in > * a JLS2 AST >@@ -2247,20 +2283,20 @@ > > //=============================== EXPRESSIONS =========================== > /** >- * Creates and returns a new unparented string literal node for >+ * Creates and returns a new unparented string literal node for > * the empty string literal. >- * >+ * > * @return a new unparented string literal node > */ > public StringLiteral newStringLiteral() { > return new StringLiteral(this); > } >- >+ > > /** > * Creates and returns a new unparented character literal node. > * Initially the node has an unspecified character literal. >- * >+ * > * @return a new unparented character literal node > */ > public CharacterLiteral newCharacterLiteral() { >@@ -2269,8 +2305,8 @@ > > /** > * Creates and returns a new unparented number literal node. >- * >- * @param literal the token for the numeric literal as it would >+ * >+ * @param literal the token for the numeric literal as it would > * appear in Java source code > * @return a new unparented number literal node > * @exception IllegalArgumentException if the literal is null >@@ -2283,27 +2319,27 @@ > result.setToken(literal); > return result; > } >- >+ > /** > * Creates and returns a new unparented number literal node. > * Initially the number literal token is <code>"0"</code>. >- * >+ * > * @return a new unparented number literal node > */ > public NumberLiteral newNumberLiteral() { > NumberLiteral result = new NumberLiteral(this); > return result; > } >- >+ > /** > * Creates and returns a new unparented null literal node. >- * >+ * > * @return a new unparented null literal node > */ > public NullLiteral newNullLiteral() { > return new NullLiteral(this); > } >- >+ > /** > * Creates and returns a new unparented boolean literal node. > * <p> >@@ -2317,7 +2353,7 @@ > * </pre> > * </code> > * </p> >- * >+ * > * @param value the boolean value > * @return a new unparented boolean literal node > */ >@@ -2326,73 +2362,73 @@ > result.setBooleanValue(value); > return result; > } >- >+ > /** >- * Creates and returns a new unparented assignment expression node >+ * Creates and returns a new unparented assignment expression node > * owned by this AST. By default, the assignment operator is "=" and >- * the left and right hand side expressions are unspecified, but >+ * the left and right hand side expressions are unspecified, but > * legal, names. >- * >+ * > * @return a new unparented assignment expression node > */ > public Assignment newAssignment() { > Assignment result = new Assignment(this); > return result; > } >- >+ > /** >- * Creates an unparented method invocation expression node owned by this >- * AST. By default, the name of the method is unspecified (but legal) >+ * Creates an unparented method invocation expression node owned by this >+ * AST. By default, the name of the method is unspecified (but legal) > * there is no receiver expression, no type arguments, and the list of > * arguments is empty. >- * >+ * > * @return a new unparented method invocation expression node > */ > public MethodInvocation newMethodInvocation() { > MethodInvocation result = new MethodInvocation(this); > return result; > } >- >+ > /** >- * Creates an unparented "super" method invocation expression node owned by >- * this AST. By default, the name of the method is unspecified (but legal) >+ * Creates an unparented "super" method invocation expression node owned by >+ * this AST. By default, the name of the method is unspecified (but legal) > * there is no qualifier, no type arguments, and the list of arguments is empty. >- * >- * @return a new unparented "super" method invocation >+ * >+ * @return a new unparented "super" method invocation > * expression node > */ > public SuperMethodInvocation newSuperMethodInvocation() { > SuperMethodInvocation result = new SuperMethodInvocation(this); > return result; > } >- >+ > /** >- * Creates an unparented alternate constructor ("this(...);") invocation >+ * Creates an unparented alternate constructor ("this(...);") invocation > * statement node owned by this AST. By default, the lists of arguments > * and type arguments are both empty. > * <p> > * Note that this type of node is a Statement, whereas a regular >- * method invocation is an Expression. The only valid use of these >+ * method invocation is an Expression. The only valid use of these > * statements are as the first statement of a constructor body. > * </p> >- * >+ * > * @return a new unparented alternate constructor invocation statement node > */ > public ConstructorInvocation newConstructorInvocation() { > ConstructorInvocation result = new ConstructorInvocation(this); > return result; > } >- >+ > /** >- * Creates an unparented alternate super constructor ("super(...);") >+ * Creates an unparented alternate super constructor ("super(...);") > * invocation statement node owned by this AST. By default, there is no > * qualifier, no type arguments, and the list of arguments is empty. > * <p> > * Note that this type of node is a Statement, whereas a regular >- * super method invocation is an Expression. The only valid use of these >+ * super method invocation is an Expression. The only valid use of these > * statements are as the first statement of a constructor body. > * </p> >- * >+ * > * @return a new unparented super constructor invocation statement node > */ > public SuperConstructorInvocation newSuperConstructorInvocation() { >@@ -2400,10 +2436,10 @@ > new SuperConstructorInvocation(this); > return result; > } >- >+ > /** >- * Creates a new unparented local variable declaration expression node >- * owned by this AST, for the given variable declaration fragment. By >+ * Creates a new unparented local variable declaration expression node >+ * owned by this AST, for the given variable declaration fragment. By > * default, there are no modifiers and the base type is unspecified > * (but legal). > * <p> >@@ -2412,7 +2448,7 @@ > * (<code>Expression</code>) by wrapping it. Additional variable > * declaration fragments can be added afterwards. > * </p> >- * >+ * > * @param fragment the first variable declaration fragment > * @return a new unparented variable declaration expression node > * @exception IllegalArgumentException if: >@@ -2434,11 +2470,11 @@ > result.fragments().add(fragment); > return result; > } >- >+ > /** >- * Creates a new unparented field declaration node owned by this AST, >+ * Creates a new unparented field declaration node owned by this AST, > * for the given variable declaration fragment. By default, there are no >- * modifiers, no doc comment, and the base type is unspecified >+ * modifiers, no doc comment, and the base type is unspecified > * (but legal). > * <p> > * This method can be used to wrap a variable declaration fragment >@@ -2447,7 +2483,7 @@ > * (<code>FieldDeclaration</code> implements <code>BodyDeclaration</code>). > * Additional variable declaration fragments can be added afterwards. > * </p> >- * >+ * > * @param fragment the variable declaration fragment > * @return a new unparented field declaration node > * @exception IllegalArgumentException if: >@@ -2466,11 +2502,11 @@ > result.fragments().add(fragment); > return result; > } >- >+ > /** >- * Creates and returns a new unparented "this" expression node >+ * Creates and returns a new unparented "this" expression node > * owned by this AST. By default, there is no qualifier. >- * >+ * > * @return a new unparented "this" expression node > */ > public ThisExpression newThisExpression() { >@@ -2479,10 +2515,10 @@ > } > > /** >- * Creates and returns a new unparented field access expression node >+ * Creates and returns a new unparented field access expression node > * owned by this AST. By default, the expression and field are both > * unspecified, but legal, names. >- * >+ * > * @return a new unparented field access expression node > */ > public FieldAccess newFieldAccess() { >@@ -2491,10 +2527,10 @@ > } > > /** >- * Creates and returns a new unparented super field access expression node >+ * Creates and returns a new unparented super field access expression node > * owned by this AST. By default, the expression and field are both > * unspecified, but legal, names. >- * >+ * > * @return a new unparented super field access expression node > */ > public SuperFieldAccess newSuperFieldAccess() { >@@ -2503,9 +2539,9 @@ > } > > /** >- * Creates and returns a new unparented type literal expression node >+ * Creates and returns a new unparented type literal expression node > * owned by this AST. By default, the type is unspecified (but legal). >- * >+ * > * @return a new unparented type literal node > */ > public TypeLiteral newTypeLiteral() { >@@ -2514,10 +2550,10 @@ > } > > /** >- * Creates and returns a new unparented cast expression node >+ * Creates and returns a new unparented cast expression node > * owned by this AST. By default, the type and expression are unspecified > * (but legal). >- * >+ * > * @return a new unparented cast expression node > */ > public CastExpression newCastExpression() { >@@ -2526,9 +2562,9 @@ > } > > /** >- * Creates and returns a new unparented parenthesized expression node >+ * Creates and returns a new unparented parenthesized expression node > * owned by this AST. By default, the expression is unspecified (but legal). >- * >+ * > * @return a new unparented parenthesized expression node > */ > public ParenthesizedExpression newParenthesizedExpression() { >@@ -2537,11 +2573,11 @@ > } > > /** >- * Creates and returns a new unparented infix expression node >+ * Creates and returns a new unparented infix expression node > * owned by this AST. By default, the operator and left and right > * operand are unspecified (but legal), and there are no extended > * operands. >- * >+ * > * @return a new unparented infix expression node > */ > public InfixExpression newInfixExpression() { >@@ -2550,10 +2586,10 @@ > } > > /** >- * Creates and returns a new unparented instanceof expression node >+ * Creates and returns a new unparented instanceof expression node > * owned by this AST. By default, the operator and left and right > * operand are unspecified (but legal). >- * >+ * > * @return a new unparented instanceof expression node > */ > public InstanceofExpression newInstanceofExpression() { >@@ -2562,10 +2598,10 @@ > } > > /** >- * Creates and returns a new unparented postfix expression node >- * owned by this AST. By default, the operator and operand are >+ * Creates and returns a new unparented postfix expression node >+ * owned by this AST. By default, the operator and operand are > * unspecified (but legal). >- * >+ * > * @return a new unparented postfix expression node > */ > public PostfixExpression newPostfixExpression() { >@@ -2574,10 +2610,10 @@ > } > > /** >- * Creates and returns a new unparented prefix expression node >- * owned by this AST. By default, the operator and operand are >+ * Creates and returns a new unparented prefix expression node >+ * owned by this AST. By default, the operator and operand are > * unspecified (but legal). >- * >+ * > * @return a new unparented prefix expression node > */ > public PrefixExpression newPrefixExpression() { >@@ -2586,10 +2622,10 @@ > } > > /** >- * Creates and returns a new unparented array access expression node >- * owned by this AST. By default, the array and index expression are >+ * Creates and returns a new unparented array access expression node >+ * owned by this AST. By default, the array and index expression are > * both unspecified (but legal). >- * >+ * > * @return a new unparented array access expression node > */ > public ArrayAccess newArrayAccess() { >@@ -2598,7 +2634,7 @@ > } > > /** >- * Creates and returns a new unparented array creation expression node >+ * Creates and returns a new unparented array creation expression node > * owned by this AST. By default, the array type is an unspecified > * 1-dimensional array, the list of dimensions is empty, and there is no > * array initializer. >@@ -2633,7 +2669,7 @@ > * </pre> > * </code> > * </p> >- * >+ * > * @return a new unparented array creation expression node > */ > public ArrayCreation newArrayCreation() { >@@ -2642,12 +2678,12 @@ > } > > /** >- * Creates and returns a new unparented class instance creation >- * ("new") expression node owned by this AST. By default, >+ * Creates and returns a new unparented class instance creation >+ * ("new") expression node owned by this AST. By default, > * there is no qualifying expression, no type parameters, > * an unspecified (but legal) type name, an empty list of > * arguments, and does not declare an anonymous class declaration. >- * >+ * > * @return a new unparented class instance creation expression node > */ > public ClassInstanceCreation newClassInstanceCreation() { >@@ -2658,7 +2694,7 @@ > /** > * Creates and returns a new unparented anonymous class declaration > * node owned by this AST. By default, the body declaration list is empty. >- * >+ * > * @return a new unparented anonymous class declaration node > */ > public AnonymousClassDeclaration newAnonymousClassDeclaration() { >@@ -2667,9 +2703,9 @@ > } > > /** >- * Creates and returns a new unparented array initializer node >+ * Creates and returns a new unparented array initializer node > * owned by this AST. By default, the initializer has no expressions. >- * >+ * > * @return a new unparented array initializer node > */ > public ArrayInitializer newArrayInitializer() { >@@ -2678,24 +2714,24 @@ > } > > /** >- * Creates and returns a new unparented conditional expression node >+ * Creates and returns a new unparented conditional expression node > * owned by this AST. By default, the condition and both expressions > * are unspecified (but legal). >- * >+ * > * @return a new unparented array conditional expression node > */ > public ConditionalExpression newConditionalExpression() { > ConditionalExpression result = new ConditionalExpression(this); > return result; > } >- >+ > //=============================== ANNOTATIONS ==================== >- >+ > /** > * Creates and returns a new unparented normal annotation node with > * an unspecified type name and an empty list of member value > * pairs. >- * >+ * > * @return a new unparented normal annotation node > * @exception UnsupportedOperationException if this operation is used in > * a JLS2 AST >@@ -2705,11 +2741,11 @@ > NormalAnnotation result = new NormalAnnotation(this); > return result; > } >- >+ > /** > * Creates and returns a new unparented marker annotation node with > * an unspecified type name. >- * >+ * > * @return a new unparented marker annotation node > * @exception UnsupportedOperationException if this operation is used in > * a JLS2 AST >@@ -2719,11 +2755,11 @@ > MarkerAnnotation result = new MarkerAnnotation(this); > return result; > } >- >+ > /** > * Creates and returns a new unparented single member annotation node with > * an unspecified type name and value. >- * >+ * > * @return a new unparented single member annotation node > * @exception UnsupportedOperationException if this operation is used in > * a JLS2 AST >@@ -2733,11 +2769,11 @@ > SingleMemberAnnotation result = new SingleMemberAnnotation(this); > return result; > } >- >+ > /** > * Creates and returns a new unparented member value pair node with > * an unspecified member name and value. >- * >+ * > * @return a new unparented member value pair node > * @exception UnsupportedOperationException if this operation is used in > * a JLS2 AST >@@ -2747,7 +2783,7 @@ > MemberValuePair result = new MemberValuePair(this); > return result; > } >- >+ > /** > * Enables the recording of changes to the given compilation > * unit and its descendents. The compilation unit must have >@@ -2756,11 +2792,11 @@ > * arbitrary changes to the subtree rooted at the compilation > * unit are recorded internally. Once the modification has > * been completed, call <code>rewrite</code> to get an object >- * representing the corresponding edits to the original >+ * representing the corresponding edits to the original > * source code string. > * > * @exception IllegalArgumentException if this compilation unit is >- * marked as unmodifiable, or if this compilation unit has already >+ * marked as unmodifiable, or if this compilation unit has already > * been tampered with, or if recording has already been enabled, > * or if <code>root</code> is not owned by this AST > * @see CompilationUnit#recordModifications() >@@ -2776,7 +2812,7 @@ > } else if(root.getAST() != this) { > throw new IllegalArgumentException("Root node is not owned by this ast"); //$NON-NLS-1$ > } >- >+ > this.rewriter = new InternalASTRewrite(root); > this.setEventHandler(this.rewriter); > } >@@ -2787,7 +2823,7 @@ > * given document containing the original source > * code for the compilation unit that gave rise to > * this AST. >- * >+ * > * @param document original document containing source code > * for the compilation unit > * @param options the table of formatter options >@@ -2812,5 +2848,9 @@ > } > return this.rewriter.rewriteAST(document, options); > } >+ >+ void setFlag(int newValue) { >+ this.bits |= newValue; >+ } > } > >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.7 >diff -u -r1.7 ReconcileContext.java >--- model/org/eclipse/jdt/core/compiler/ReconcileContext.java 29 Mar 2006 03:08:49 -0000 1.7 >+++ model/org/eclipse/jdt/core/compiler/ReconcileContext.java 13 Mar 2007 18:45:41 -0000 >@@ -9,7 +9,7 @@ > * mkaufman@bea.com - initial API and implementation > * IBM - renamed from PreReconcileCompilationResult to ReconcileContext > * IBM - rewrote spec >- * >+ * > *******************************************************************************/ > > package org.eclipse.jdt.core.compiler; >@@ -27,27 +27,27 @@ > import org.eclipse.jdt.internal.core.ReconcileWorkingCopyOperation; > > /** >- * The context of a reconcile event that is notified to interested compilation >+ * The context of a reconcile event that is notified to interested compilation > * participants while a reconcile operation is running. > * <p> > * A reconcile participant can get the AST for the reconcile-operation using >- * {@link #getAST3()}. If the participant modifies in any way the AST >- * (either by modifying the source of the working copy, or modifying another entity >- * that would result in different bindings for the AST), it is expected to reset the >+ * {@link #getAST3()}. If the participant modifies in any way the AST >+ * (either by modifying the source of the working copy, or modifying another entity >+ * that would result in different bindings for the AST), it is expected to reset the > * AST in the context using {@link #resetAST()}. > * </p><p> >- * A reconcile participant can also create and return problems using >- * {@link #putProblems(String, CategorizedProblem[])}. These problems are then reported >+ * A reconcile participant can also create and return problems using >+ * {@link #putProblems(String, CategorizedProblem[])}. These problems are then reported > * to the problem requestor of the reconcile operation. > * </p><p> > * This class is not intended to be instanciated or subclassed by clients. > * </p> >- * >+ * > * @see CompilationParticipant#reconcile(ReconcileContext) > * @since 3.2 > */ > public class ReconcileContext { >- >+ > private ReconcileWorkingCopyOperation operation; > private CompilationUnit workingCopy; > >@@ -56,7 +56,7 @@ > * <p> > * This constructor is not intended to be called by clients. > * </p> >- * >+ * > * @param operation the reconcile operation > */ > public ReconcileContext(ReconcileWorkingCopyOperation operation, CompilationUnit workingCopy) { >@@ -69,15 +69,15 @@ > * It is created from the current state of the working copy. > * Creates one if none exists yet. > * Returns <code>null</code> if the current state of the working copy >- * doesn't allow the AST to be created (e.g. if the working copy's content >+ * doesn't allow the AST to be created (e.g. if the working copy's content > * cannot be parsed). > * <p> > * If the AST level requested during reconciling is not {@link AST#JLS3} >- * or if binding resolutions was not requested, then a different AST is created. >- * Note that this AST does not become the current AST and it is only valid for >+ * or if binding resolutions was not requested, then a different AST is created. >+ * Note that this AST does not become the current AST and it is only valid for > * the requestor. > * </p> >- * >+ * > * @return the AST created from the current state of the working copy, > * or <code>null</code> if none could be created > * @exception JavaModelException if the contents of the working copy >@@ -94,7 +94,8 @@ > if (JavaProject.hasJavaNature(workingCopy.getJavaProject().getProject())) > parser.setResolveBindings(true); > parser.setSource(workingCopy); >- return (org.eclipse.jdt.core.dom.CompilationUnit) parser.createAST(this.operation.progressMonitor); >+ parser.setStatementsRecovery(this.operation.enableStatementsRecovery); >+ 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*/); > } >@@ -102,7 +103,7 @@ > /** > * Returns the AST level requested by the reconcile operation. > * It is either {@link ICompilationUnit#NO_AST}, or one of the JLS constants defined on {@link AST}. >- * >+ * > * @return the AST level requested by the reconcile operation > */ > public int getASTLevel() { >@@ -111,7 +112,7 @@ > > /** > * Returns whether the reconcile operation is resolving bindings. >- * >+ * > * @return whether the reconcile operation is resolving bindings > */ > public boolean isResolvingBindings() { >@@ -134,7 +135,7 @@ > * Returns the problems to be reported to the problem requestor of the reconcile operation > * for the given marker type. > * Returns <code>null</code> if no problems need to be reported for this marker type. >- * >+ * > * @param markerType the given marker type > * @return problems to be reported to the problem requesto > */ >@@ -145,7 +146,7 @@ > > /** > * Returns the working copy this context refers to. >- * >+ * > * @return the working copy this context refers to > */ > public ICompilationUnit getWorkingCopy() { >@@ -154,13 +155,13 @@ > > /** > * Resets the AST carried by this context. >- * A compilation participant that modifies the environment that would result in different >- * bindings for the AST is expected to reset the AST on this context, so that other >+ * A compilation participant that modifies the environment that would result in different >+ * bindings for the AST is expected to reset the AST on this context, so that other > * participants don't get a stale AST. > * <p> >- * Note that resetting the AST will not restart the reconcile process. Only further >+ * Note that resetting the AST will not restart the reconcile process. Only further > * participants will see the new AST. Thus participants running before the one that >- * resets the AST will have a stale view of the AST and its problems. Use >+ * resets the AST will have a stale view of the AST and its problems. Use > * the compilation participant extension point to order the participants. > * </p> > */ >@@ -175,10 +176,10 @@ > * for the given marker type. > * <code>null</code> indicates that no problems need to be reported. > * <p> >- * Using this functionality, a participant that resolves problems for a given marker type >+ * Using this functionality, a participant that resolves problems for a given marker type > * can hide those problems since they don't exist any longer. > * </p> >- * >+ * > * @param markerType the marker type of the given problems > * @param problems the problems to be reported to the problem requestor of the reconcile operation, > * or <code>null</code> if none
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 130001
: 60709