View | Details | Raw Unified | Return to bug 130001
Collapse All | Expand All

(-)model/org/eclipse/jdt/internal/core/CompilationUnit.java (-55 / +55 lines)
Lines 7-13 Link Here
7
 *
7
 *
8
 * Contributors:
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
9
 *     IBM Corporation - initial API and implementation
10
 *     Alex Smirnoff (alexsmr@sympatico.ca) - part of the changes to support Java-like extension 
10
 *     Alex Smirnoff (alexsmr@sympatico.ca) - part of the changes to support Java-like extension
11
 *                                                            (see https://bugs.eclipse.org/bugs/show_bug.cgi?id=71460)
11
 *                                                            (see https://bugs.eclipse.org/bugs/show_bug.cgi?id=71460)
12
 *******************************************************************************/
12
 *******************************************************************************/
13
package org.eclipse.jdt.internal.core;
13
package org.eclipse.jdt.internal.core;
Lines 39-47 Link Here
39
	 * @deprecated
39
	 * @deprecated
40
	 */
40
	 */
41
	/*package*/ static final int JLS2_INTERNAL = AST.JLS2;
41
	/*package*/ static final int JLS2_INTERNAL = AST.JLS2;
42
	
42
43
	private static final IImportDeclaration[] NO_IMPORTS = new IImportDeclaration[0];
43
	private static final IImportDeclaration[] NO_IMPORTS = new IImportDeclaration[0];
44
	
44
45
	protected String name;
45
	protected String name;
46
	public WorkingCopyOwner owner;
46
	public WorkingCopyOwner owner;
47
47
Lines 75-81 Link Here
75
		IStatus status = validateCompilationUnit(underlyingResource);
75
		IStatus status = validateCompilationUnit(underlyingResource);
76
		if (!status.isOK()) throw newJavaModelException(status);
76
		if (!status.isOK()) throw newJavaModelException(status);
77
	}
77
	}
78
	
78
79
	// prevents reopening of non-primary working copies (they are closed when they are discarded and should not be reopened)
79
	// prevents reopening of non-primary working copies (they are closed when they are discarded and should not be reopened)
80
	if (!isPrimary() && getPerWorkingCopyInfo() == null) {
80
	if (!isPrimary() && getPerWorkingCopyInfo() == null) {
81
		throw newNotPresentException();
81
		throw newNotPresentException();
Lines 117-123 Link Here
117
		statementsRecovery = false;
117
		statementsRecovery = false;
118
		problems = null;
118
		problems = null;
119
	}
119
	}
120
	
120
121
	boolean computeProblems = perWorkingCopyInfo != null && perWorkingCopyInfo.isActive() && project != null && JavaProject.hasJavaNature(project.getProject());
121
	boolean computeProblems = perWorkingCopyInfo != null && perWorkingCopyInfo.isActive() && project != null && JavaProject.hasJavaNature(project.getProject());
122
	IProblemFactory problemFactory = new DefaultProblemFactory();
122
	IProblemFactory problemFactory = new DefaultProblemFactory();
123
	Map options = project == null ? JavaCore.getOptions() : project.getOptions(true);
123
	Map options = project == null ? JavaCore.getOptions() : project.getOptions(true);
Lines 126-140 Link Here
126
		options.put(JavaCore.COMPILER_TASK_TAGS, ""); //$NON-NLS-1$
126
		options.put(JavaCore.COMPILER_TASK_TAGS, ""); //$NON-NLS-1$
127
	}
127
	}
128
	SourceElementParser parser = new SourceElementParser(
128
	SourceElementParser parser = new SourceElementParser(
129
		requestor, 
129
		requestor,
130
		problemFactory, 
130
		problemFactory,
131
		new CompilerOptions(options),
131
		new CompilerOptions(options),
132
		true/*report local declarations*/,
132
		true/*report local declarations*/,
133
		!createAST /*optimize string literals only if not creating a DOM AST*/);
133
		!createAST /*optimize string literals only if not creating a DOM AST*/);
134
	parser.reportOnlyOneSyntaxError = !computeProblems;
134
	parser.reportOnlyOneSyntaxError = !computeProblems;
135
	parser.setMethodsFullRecovery(true);
135
	parser.setMethodsFullRecovery(true);
136
	parser.setStatementsRecovery(statementsRecovery);
136
	parser.setStatementsRecovery(statementsRecovery);
137
	
137
138
	if (!computeProblems && !resolveBindings && !createAST) // disable javadoc parsing if not computing problems, not resolving and not creating ast
138
	if (!computeProblems && !resolveBindings && !createAST) // disable javadoc parsing if not computing problems, not resolving and not creating ast
139
		parser.javadocParser.checkDocComment = false;
139
		parser.javadocParser.checkDocComment = false;
140
	requestor.parser = parser;
140
	requestor.parser = parser;
Lines 152-160 Link Here
152
			public char[] getFileName() {
152
			public char[] getFileName() {
153
				return CompilationUnit.this.getFileName();
153
				return CompilationUnit.this.getFileName();
154
			}
154
			}
155
		}, 
155
		},
156
		true /*full parse to find local elements*/);
156
		true /*full parse to find local elements*/);
157
	
157
158
	// update timestamp (might be IResource.NULL_STAMP if original does not exist)
158
	// update timestamp (might be IResource.NULL_STAMP if original does not exist)
159
	if (underlyingResource == null) {
159
	if (underlyingResource == null) {
160
		underlyingResource = getResource();
160
		underlyingResource = getResource();
Lines 162-168 Link Here
162
	// underlying resource is null in the case of a working copy on a class file in a jar
162
	// underlying resource is null in the case of a working copy on a class file in a jar
163
	if (underlyingResource != null)
163
	if (underlyingResource != null)
164
		unitInfo.timestamp = ((IFile)underlyingResource).getModificationStamp();
164
		unitInfo.timestamp = ((IFile)underlyingResource).getModificationStamp();
165
	
165
166
	// compute other problems if needed
166
	// compute other problems if needed
167
	CompilationUnitDeclaration compilationUnitDeclaration = null;
167
	CompilationUnitDeclaration compilationUnitDeclaration = null;
168
	try {
168
	try {
Lines 188-205 Link Here
188
				compilationUnitDeclaration = CompilationUnitProblemFinder.process(unit, this, contents, parser, this.owner, problems, createAST, true, pm);
188
				compilationUnitDeclaration = CompilationUnitProblemFinder.process(unit, this, contents, parser, this.owner, problems, createAST, true, pm);
189
			}
189
			}
190
		}
190
		}
191
		
191
192
		if (createAST) {
192
		if (createAST) {
193
			int astLevel = ((ASTHolderCUInfo) info).astLevel;
193
			int astLevel = ((ASTHolderCUInfo) info).astLevel;
194
			org.eclipse.jdt.core.dom.CompilationUnit cu = AST.convertCompilationUnit(astLevel, unit, contents, options, computeProblems, this, pm);
194
			org.eclipse.jdt.core.dom.CompilationUnit cu = AST.convertCompilationUnit(astLevel, unit, contents, options, computeProblems, this, statementsRecovery, pm);
195
			((ASTHolderCUInfo) info).ast = cu;
195
			((ASTHolderCUInfo) info).ast = cu;
196
		}
196
		}
197
	} finally {
197
	} finally {
198
	    if (compilationUnitDeclaration != null) {
198
		if (compilationUnitDeclaration != null) {
199
	        compilationUnitDeclaration.cleanUp();
199
			compilationUnitDeclaration.cleanUp();
200
	    }
200
		}
201
	}
201
	}
202
	
202
203
	return unitInfo.isStructureKnown();
203
	return unitInfo.isStructureKnown();
204
}
204
}
205
/*
205
/*
Lines 252-258 Link Here
252
 * @deprecated - use codeComplete(int, ICompletionRequestor)
252
 * @deprecated - use codeComplete(int, ICompletionRequestor)
253
 */
253
 */
254
public void codeComplete(int offset, final ICodeCompletionRequestor requestor) throws JavaModelException {
254
public void codeComplete(int offset, final ICodeCompletionRequestor requestor) throws JavaModelException {
255
	
255
256
	if (requestor == null){
256
	if (requestor == null){
257
		codeComplete(offset, (ICompletionRequestor)null);
257
		codeComplete(offset, (ICompletionRequestor)null);
258
		return;
258
		return;
Lines 351-357 Link Here
351
 */
351
 */
352
public void copy(IJavaElement container, IJavaElement sibling, String rename, boolean force, IProgressMonitor monitor) throws JavaModelException {
352
public void copy(IJavaElement container, IJavaElement sibling, String rename, boolean force, IProgressMonitor monitor) throws JavaModelException {
353
	if (container == null) {
353
	if (container == null) {
354
		throw new IllegalArgumentException(Messages.operation_nullContainer); 
354
		throw new IllegalArgumentException(Messages.operation_nullContainer);
355
	}
355
	}
356
	IJavaElement[] elements = new IJavaElement[] {this};
356
	IJavaElement[] elements = new IJavaElement[] {this};
357
	IJavaElement[] containers = new IJavaElement[] {container};
357
	IJavaElement[] containers = new IJavaElement[] {container};
Lines 391-397 Link Here
391
 * @see ICompilationUnit#createPackageDeclaration(String, IProgressMonitor)
391
 * @see ICompilationUnit#createPackageDeclaration(String, IProgressMonitor)
392
 */
392
 */
393
public IPackageDeclaration createPackageDeclaration(String pkg, IProgressMonitor monitor) throws JavaModelException {
393
public IPackageDeclaration createPackageDeclaration(String pkg, IProgressMonitor monitor) throws JavaModelException {
394
	
394
395
	CreatePackageDeclarationOperation op= new CreatePackageDeclarationOperation(pkg, this);
395
	CreatePackageDeclarationOperation op= new CreatePackageDeclarationOperation(pkg, this);
396
	op.runOperation(monitor);
396
	op.runOperation(monitor);
397
	return getPackageDeclaration(pkg);
397
	return getPackageDeclaration(pkg);
Lines 459-466 Link Here
459
}
459
}
460
public boolean exists() {
460
public boolean exists() {
461
	// working copy always exists in the model until it is gotten rid of (even if not on classpath)
461
	// working copy always exists in the model until it is gotten rid of (even if not on classpath)
462
	if (getPerWorkingCopyInfo() != null) return true;	
462
	if (getPerWorkingCopyInfo() != null) return true;
463
	
463
464
	// if not a working copy, it exists only if it is a primary compilation unit
464
	// if not a working copy, it exists only if it is a primary compilation unit
465
	return isPrimary() && validateCompilationUnit(getResource()).isOK();
465
	return isPrimary() && validateCompilationUnit(getResource()).isOK();
466
}
466
}
Lines 512-518 Link Here
512
				currentElement = ((IType)currentElement).getMethod(child.getElementName(), ((IMethod)child).getParameterTypes());
512
				currentElement = ((IType)currentElement).getMethod(child.getElementName(), ((IMethod)child).getParameterTypes());
513
				break;
513
				break;
514
		}
514
		}
515
		
515
516
	}
516
	}
517
	if (currentElement != null && currentElement.exists()) {
517
	if (currentElement != null && currentElement.exists()) {
518
		return new IJavaElement[] {currentElement};
518
		return new IJavaElement[] {currentElement};
Lines 540-546 Link Here
540
540
541
	// if factory is null, default factory must be used
541
	// if factory is null, default factory must be used
542
	if (factory == null) factory = this.getBufferManager().getDefaultBufferFactory();
542
	if (factory == null) factory = this.getBufferManager().getDefaultBufferFactory();
543
	
543
544
	return findWorkingCopy(BufferFactoryWrapper.create(factory));
544
	return findWorkingCopy(BufferFactoryWrapper.create(factory));
545
}
545
}
546
546
Lines 580-586 Link Here
580
		for (i = 0; i < types.length; i++) {
580
		for (i = 0; i < types.length; i++) {
581
			typesToTraverse.add(types[i]);
581
			typesToTraverse.add(types[i]);
582
		}
582
		}
583
	} 
583
	}
584
	IType[] arrayOfAllTypes = new IType[allTypes.size()];
584
	IType[] arrayOfAllTypes = new IType[allTypes.size()];
585
	allTypes.toArray(arrayOfAllTypes);
585
	allTypes.toArray(arrayOfAllTypes);
586
	return arrayOfAllTypes;
586
	return arrayOfAllTypes;
Lines 708-717 Link Here
708
		else {
708
		else {
709
			open(null); // force opening of CU
709
			open(null); // force opening of CU
710
			info = manager.getInfo(container);
710
			info = manager.getInfo(container);
711
			if (info == null) 
711
			if (info == null)
712
				// after opening, if no import container, then no imports
712
				// after opening, if no import container, then no imports
713
				return NO_IMPORTS;
713
				return NO_IMPORTS;
714
		}	
714
		}
715
	}
715
	}
716
	IJavaElement[] elements = ((JavaElementInfo) info).children;
716
	IJavaElement[] elements = ((JavaElementInfo) info).children;
717
	int length = elements.length;
717
	int length = elements.length;
Lines 742-748 Link Here
742
	if (cu == null || !this.owner.equals(cu.owner)) {
742
	if (cu == null || !this.owner.equals(cu.owner)) {
743
		return null;
743
		return null;
744
	}
744
	}
745
	
745
746
	return workingCopyElement.getPrimaryElement();
746
	return workingCopyElement.getPrimaryElement();
747
}
747
}
748
/**
748
/**
Lines 752-758 Link Here
752
public IJavaElement getOriginalElement() {
752
public IJavaElement getOriginalElement() {
753
	// backward compatibility
753
	// backward compatibility
754
	if (!isWorkingCopy()) return null;
754
	if (!isWorkingCopy()) return null;
755
	
755
756
	return getPrimaryElement();
756
	return getPrimaryElement();
757
}
757
}
758
/*
758
/*
Lines 870-879 Link Here
870
 * @deprecated
870
 * @deprecated
871
 */
871
 */
872
public IJavaElement getSharedWorkingCopy(IProgressMonitor pm, IBufferFactory factory, IProblemRequestor problemRequestor) throws JavaModelException {
872
public IJavaElement getSharedWorkingCopy(IProgressMonitor pm, IBufferFactory factory, IProblemRequestor problemRequestor) throws JavaModelException {
873
	
873
874
	// if factory is null, default factory must be used
874
	// if factory is null, default factory must be used
875
	if (factory == null) factory = this.getBufferManager().getDefaultBufferFactory();
875
	if (factory == null) factory = this.getBufferManager().getDefaultBufferFactory();
876
	
876
877
	return getWorkingCopy(BufferFactoryWrapper.create(factory), problemRequestor, pm);
877
	return getWorkingCopy(BufferFactoryWrapper.create(factory), problemRequestor, pm);
878
}
878
}
879
/**
879
/**
Lines 907-917 Link Here
907
 */
907
 */
908
public ICompilationUnit getWorkingCopy(WorkingCopyOwner workingCopyOwner, IProblemRequestor problemRequestor, IProgressMonitor monitor) throws JavaModelException {
908
public ICompilationUnit getWorkingCopy(WorkingCopyOwner workingCopyOwner, IProblemRequestor problemRequestor, IProgressMonitor monitor) throws JavaModelException {
909
	if (!isPrimary()) return this;
909
	if (!isPrimary()) return this;
910
	
910
911
	JavaModelManager manager = JavaModelManager.getJavaModelManager();
911
	JavaModelManager manager = JavaModelManager.getJavaModelManager();
912
	
912
913
	CompilationUnit workingCopy = new CompilationUnit((PackageFragment)getParent(), getElementName(), workingCopyOwner);
913
	CompilationUnit workingCopy = new CompilationUnit((PackageFragment)getParent(), getElementName(), workingCopyOwner);
914
	JavaModelManager.PerWorkingCopyInfo perWorkingCopyInfo = 
914
	JavaModelManager.PerWorkingCopyInfo perWorkingCopyInfo =
915
		manager.getPerWorkingCopyInfo(workingCopy, false/*don't create*/, true/*record usage*/, null/*not used since don't create*/);
915
		manager.getPerWorkingCopyInfo(workingCopy, false/*don't create*/, true/*record usage*/, null/*not used since don't create*/);
916
	if (perWorkingCopyInfo != null) {
916
	if (perWorkingCopyInfo != null) {
917
		return perWorkingCopyInfo.getWorkingCopy(); // return existing handle instead of the one created above
917
		return perWorkingCopyInfo.getWorkingCopy(); // return existing handle instead of the one created above
Lines 931-937 Link Here
931
 */
931
 */
932
public boolean hasResourceChanged() {
932
public boolean hasResourceChanged() {
933
	if (!isWorkingCopy()) return false;
933
	if (!isWorkingCopy()) return false;
934
	
934
935
	// if resource got deleted, then #getModificationStamp() will answer IResource.NULL_STAMP, which is always different from the cached
935
	// if resource got deleted, then #getModificationStamp() will answer IResource.NULL_STAMP, which is always different from the cached
936
	// timestamp
936
	// timestamp
937
	Object info = JavaModelManager.getJavaModelManager().getInfo(this);
937
	Object info = JavaModelManager.getJavaModelManager().getInfo(this);
Lines 968-974 Link Here
968
	IPackageFragmentRoot root = getPackageFragmentRoot();
968
	IPackageFragmentRoot root = getPackageFragmentRoot();
969
	// root never null as validation is not done for working copies
969
	// root never null as validation is not done for working copies
970
	try {
970
	try {
971
		if (root.getKind() != IPackageFragmentRoot.K_SOURCE) 
971
		if (root.getKind() != IPackageFragmentRoot.K_SOURCE)
972
			return new JavaModelStatus(IJavaModelStatusConstants.INVALID_ELEMENT_TYPES, root);
972
			return new JavaModelStatus(IJavaModelStatusConstants.INVALID_ELEMENT_TYPES, root);
973
	} catch (JavaModelException e) {
973
	} catch (JavaModelException e) {
974
		return e.getJavaModelStatus();
974
		return e.getJavaModelStatus();
Lines 976-982 Link Here
976
	if (resource != null) {
976
	if (resource != null) {
977
		char[][] inclusionPatterns = ((PackageFragmentRoot)root).fullInclusionPatternChars();
977
		char[][] inclusionPatterns = ((PackageFragmentRoot)root).fullInclusionPatternChars();
978
		char[][] exclusionPatterns = ((PackageFragmentRoot)root).fullExclusionPatternChars();
978
		char[][] exclusionPatterns = ((PackageFragmentRoot)root).fullExclusionPatternChars();
979
		if (Util.isExcluded(resource, inclusionPatterns, exclusionPatterns)) 
979
		if (Util.isExcluded(resource, inclusionPatterns, exclusionPatterns))
980
			return new JavaModelStatus(IJavaModelStatusConstants.ELEMENT_NOT_ON_CLASSPATH, this);
980
			return new JavaModelStatus(IJavaModelStatusConstants.ELEMENT_NOT_ON_CLASSPATH, this);
981
		if (!resource.isAccessible())
981
		if (!resource.isAccessible())
982
			return new JavaModelStatus(IJavaModelStatusConstants.ELEMENT_DOES_NOT_EXIST, this);
982
			return new JavaModelStatus(IJavaModelStatusConstants.ELEMENT_DOES_NOT_EXIST, this);
Lines 1000-1006 Link Here
1000
}
1000
}
1001
public org.eclipse.jdt.core.dom.CompilationUnit makeConsistent(int astLevel, boolean resolveBindings, boolean statementsRecovery, HashMap problems, IProgressMonitor monitor) throws JavaModelException {
1001
public org.eclipse.jdt.core.dom.CompilationUnit makeConsistent(int astLevel, boolean resolveBindings, boolean statementsRecovery, HashMap problems, IProgressMonitor monitor) throws JavaModelException {
1002
	if (isConsistent()) return null;
1002
	if (isConsistent()) return null;
1003
		
1003
1004
	// create a new info and make it the current info
1004
	// create a new info and make it the current info
1005
	// (this will remove the info and its children just before storing the new infos)
1005
	// (this will remove the info and its children just before storing the new infos)
1006
	if (astLevel != NO_AST || problems != null) {
1006
	if (astLevel != NO_AST || problems != null) {
Lines 1023-1033 Link Here
1023
 */
1023
 */
1024
public void move(IJavaElement container, IJavaElement sibling, String rename, boolean force, IProgressMonitor monitor) throws JavaModelException {
1024
public void move(IJavaElement container, IJavaElement sibling, String rename, boolean force, IProgressMonitor monitor) throws JavaModelException {
1025
	if (container == null) {
1025
	if (container == null) {
1026
		throw new IllegalArgumentException(Messages.operation_nullContainer); 
1026
		throw new IllegalArgumentException(Messages.operation_nullContainer);
1027
	}
1027
	}
1028
	IJavaElement[] elements= new IJavaElement[] {this};
1028
	IJavaElement[] elements= new IJavaElement[] {this};
1029
	IJavaElement[] containers= new IJavaElement[] {container};
1029
	IJavaElement[] containers= new IJavaElement[] {container};
1030
	
1030
1031
	String[] renamings= null;
1031
	String[] renamings= null;
1032
	if (rename != null) {
1032
	if (rename != null) {
1033
		renamings= new String[] {rename};
1033
		renamings= new String[] {rename};
Lines 1043-1066 Link Here
1043
	// create buffer
1043
	// create buffer
1044
	BufferManager bufManager = getBufferManager();
1044
	BufferManager bufManager = getBufferManager();
1045
	boolean isWorkingCopy = isWorkingCopy();
1045
	boolean isWorkingCopy = isWorkingCopy();
1046
	IBuffer buffer = 
1046
	IBuffer buffer =
1047
		isWorkingCopy 
1047
		isWorkingCopy
1048
			? this.owner.createBuffer(this) 
1048
			? this.owner.createBuffer(this)
1049
			: BufferManager.createBuffer(this);
1049
			: BufferManager.createBuffer(this);
1050
	if (buffer == null) return null;
1050
	if (buffer == null) return null;
1051
	
1051
1052
	// synchronize to ensure that 2 threads are not putting 2 different buffers at the same time
1052
	// synchronize to ensure that 2 threads are not putting 2 different buffers at the same time
1053
	// see https://bugs.eclipse.org/bugs/show_bug.cgi?id=146331
1053
	// see https://bugs.eclipse.org/bugs/show_bug.cgi?id=146331
1054
	synchronized(bufManager) {
1054
	synchronized(bufManager) {
1055
		IBuffer existingBuffer = bufManager.getBuffer(this);
1055
		IBuffer existingBuffer = bufManager.getBuffer(this);
1056
		if (existingBuffer != null)
1056
		if (existingBuffer != null)
1057
			return existingBuffer;
1057
			return existingBuffer;
1058
		
1058
1059
		// set the buffer source
1059
		// set the buffer source
1060
		if (buffer.getCharacters() == null) {
1060
		if (buffer.getCharacters() == null) {
1061
			if (isWorkingCopy) {
1061
			if (isWorkingCopy) {
1062
				ICompilationUnit original;
1062
				ICompilationUnit original;
1063
				if (!isPrimary() 
1063
				if (!isPrimary()
1064
						&& (original = new CompilationUnit((PackageFragment)getParent(), getElementName(), DefaultWorkingCopyOwner.PRIMARY)).isOpen()) {
1064
						&& (original = new CompilationUnit((PackageFragment)getParent(), getElementName(), DefaultWorkingCopyOwner.PRIMARY)).isOpen()) {
1065
					buffer.setContents(original.getSource());
1065
					buffer.setContents(original.getSource());
1066
				} else {
1066
				} else {
Lines 1078-1092 Link Here
1078
				buffer.setContents(Util.getResourceContentsAsCharArray(file));
1078
				buffer.setContents(Util.getResourceContentsAsCharArray(file));
1079
			}
1079
			}
1080
		}
1080
		}
1081
	
1081
1082
		// add buffer to buffer cache
1082
		// add buffer to buffer cache
1083
		// note this may cause existing buffers to be removed from the buffer cache, but only primary compilation unit's buffer
1083
		// note this may cause existing buffers to be removed from the buffer cache, but only primary compilation unit's buffer
1084
		// can be closed, thus no call to a client's IBuffer#close() can be done in this synchronized block.
1084
		// can be closed, thus no call to a client's IBuffer#close() can be done in this synchronized block.
1085
		bufManager.addBuffer(buffer);
1085
		bufManager.addBuffer(buffer);
1086
				
1086
1087
		// listen to buffer changes
1087
		// listen to buffer changes
1088
		buffer.addBufferChangedListener(this);
1088
		buffer.addBufferChangedListener(this);
1089
	}	
1089
	}
1090
	return buffer;
1090
	return buffer;
1091
}
1091
}
1092
protected void openParent(Object childInfo, HashMap newElements, IProgressMonitor pm) throws JavaModelException {
1092
protected void openParent(Object childInfo, HashMap newElements, IProgressMonitor pm) throws JavaModelException {
Lines 1122-1128 Link Here
1122
	throws JavaModelException {
1122
	throws JavaModelException {
1123
	return reconcile(astLevel, forceProblemDetection, false, workingCopyOwner, monitor);
1123
	return reconcile(astLevel, forceProblemDetection, false, workingCopyOwner, monitor);
1124
}
1124
}
1125
		
1125
1126
/**
1126
/**
1127
 * @see ICompilationUnit#reconcile(int, boolean, WorkingCopyOwner, IProgressMonitor)
1127
 * @see ICompilationUnit#reconcile(int, boolean, WorkingCopyOwner, IProgressMonitor)
1128
 * @since 3.0
1128
 * @since 3.0
Lines 1134-1144 Link Here
1134
	WorkingCopyOwner workingCopyOwner,
1134
	WorkingCopyOwner workingCopyOwner,
1135
	IProgressMonitor monitor)
1135
	IProgressMonitor monitor)
1136
	throws JavaModelException {
1136
	throws JavaModelException {
1137
	
1137
1138
	if (!isWorkingCopy()) return null; // Reconciling is not supported on non working copies
1138
	if (!isWorkingCopy()) return null; // Reconciling is not supported on non working copies
1139
	if (workingCopyOwner == null) workingCopyOwner = DefaultWorkingCopyOwner.PRIMARY;
1139
	if (workingCopyOwner == null) workingCopyOwner = DefaultWorkingCopyOwner.PRIMARY;
1140
	
1140
1141
	
1141
1142
	PerformanceStats stats = null;
1142
	PerformanceStats stats = null;
1143
	if(ReconcileWorkingCopyOperation.PERF) {
1143
	if(ReconcileWorkingCopyOperation.PERF) {
1144
		stats = PerformanceStats.getStats(JavaModelManager.RECONCILE_PERF, this);
1144
		stats = PerformanceStats.getStats(JavaModelManager.RECONCILE_PERF, this);
Lines 1163-1169 Link Here
1163
 */
1163
 */
1164
public void rename(String newName, boolean force, IProgressMonitor monitor) throws JavaModelException {
1164
public void rename(String newName, boolean force, IProgressMonitor monitor) throws JavaModelException {
1165
	if (newName == null) {
1165
	if (newName == null) {
1166
		throw new IllegalArgumentException(Messages.operation_nullName); 
1166
		throw new IllegalArgumentException(Messages.operation_nullName);
1167
	}
1167
	}
1168
	IJavaElement[] elements= new IJavaElement[] {this};
1168
	IJavaElement[] elements= new IJavaElement[] {this};
1169
	IJavaElement[] dests= new IJavaElement[] {this.getParent()};
1169
	IJavaElement[] dests= new IJavaElement[] {this.getParent()};
Lines 1193-1199 Link Here
1193
		reconcile();   // not simply makeConsistent, also computes fine-grain deltas
1193
		reconcile();   // not simply makeConsistent, also computes fine-grain deltas
1194
								// in case the working copy is being reconciled already (if not it would miss
1194
								// in case the working copy is being reconciled already (if not it would miss
1195
								// one iteration of deltas).
1195
								// one iteration of deltas).
1196
	} else {		
1196
	} else {
1197
		super.save(pm, force);
1197
		super.save(pm, force);
1198
	}
1198
	}
1199
}
1199
}
(-)model/org/eclipse/jdt/internal/core/ReconcileWorkingCopyOperation.java (-34 / +35 lines)
Lines 32-42 Link Here
32
 * High level summmary of what a reconcile does:
32
 * High level summmary of what a reconcile does:
33
 * <ul>
33
 * <ul>
34
 * <li>populates the model with the new working copy contents</li>
34
 * <li>populates the model with the new working copy contents</li>
35
 * <li>fires a fine grained delta (flag F_FINE_GRAINED) describing the difference between the previous content 
35
 * <li>fires a fine grained delta (flag F_FINE_GRAINED) describing the difference between the previous content
36
 *      and the new content (which method was added/removed, which field was changed, etc.)</li>
36
 *      and the new content (which method was added/removed, which field was changed, etc.)</li>
37
 * <li>computes problems and reports them to the IProblemRequestor (begingReporting(), n x acceptProblem(...), endReporting()) iff
37
 * <li>computes problems and reports them to the IProblemRequestor (begingReporting(), n x acceptProblem(...), endReporting()) iff
38
 *     	(working copy is not consistent with its buffer || forceProblemDetection is set)
38
 *     	(working copy is not consistent with its buffer || forceProblemDetection is set)
39
 * 		&& problem requestor is active 
39
 * 		&& problem requestor is active
40
 * </li>
40
 * </li>
41
 * <li>produces a DOM AST (either JLS_2, JLS_3 or NO_AST) that is resolved if flag is set</li>
41
 * <li>produces a DOM AST (either JLS_2, JLS_3 or NO_AST) that is resolved if flag is set</li>
42
 * <li>notifies compilation participants of the reconcile allowing them to participate in this operation and report problems</li>
42
 * <li>notifies compilation participants of the reconcile allowing them to participate in this operation and report problems</li>
Lines 44-59 Link Here
44
 */
44
 */
45
public class ReconcileWorkingCopyOperation extends JavaModelOperation {
45
public class ReconcileWorkingCopyOperation extends JavaModelOperation {
46
	public static boolean PERF = false;
46
	public static boolean PERF = false;
47
	
47
48
	public int astLevel;
48
	public int astLevel;
49
	public boolean resolveBindings;
49
	public boolean resolveBindings;
50
	public HashMap problems;
50
	public HashMap problems;
51
	boolean forceProblemDetection;
51
	boolean forceProblemDetection;
52
	boolean enableStatementsRecovery;
52
	public boolean enableStatementsRecovery;
53
	WorkingCopyOwner workingCopyOwner;
53
	WorkingCopyOwner workingCopyOwner;
54
	public org.eclipse.jdt.core.dom.CompilationUnit ast;
54
	public org.eclipse.jdt.core.dom.CompilationUnit ast;
55
	public JavaElementDeltaBuilder deltaBuilder;
55
	public JavaElementDeltaBuilder deltaBuilder;
56
	
56
57
	public ReconcileWorkingCopyOperation(IJavaElement workingCopy, int astLevel, boolean forceProblemDetection, boolean enableStatementsRecovery, WorkingCopyOwner workingCopyOwner) {
57
	public ReconcileWorkingCopyOperation(IJavaElement workingCopy, int astLevel, boolean forceProblemDetection, boolean enableStatementsRecovery, WorkingCopyOwner workingCopyOwner) {
58
		super(new IJavaElement[] {workingCopy});
58
		super(new IJavaElement[] {workingCopy});
59
		this.astLevel = astLevel;
59
		this.astLevel = astLevel;
Lines 61-67 Link Here
61
		this.enableStatementsRecovery = enableStatementsRecovery;
61
		this.enableStatementsRecovery = enableStatementsRecovery;
62
		this.workingCopyOwner = workingCopyOwner;
62
		this.workingCopyOwner = workingCopyOwner;
63
	}
63
	}
64
	
64
65
	/**
65
	/**
66
	 * @exception JavaModelException if setting the source
66
	 * @exception JavaModelException if setting the source
67
	 * 	of the original compilation unit fails
67
	 * 	of the original compilation unit fails
Lines 69-94 Link Here
69
	protected void executeOperation() throws JavaModelException {
69
	protected void executeOperation() throws JavaModelException {
70
		checkCanceled();
70
		checkCanceled();
71
		try {
71
		try {
72
			beginTask(Messages.element_reconciling, 2); 
72
			beginTask(Messages.element_reconciling, 2);
73
	
73
74
			CompilationUnit workingCopy = getWorkingCopy();
74
			CompilationUnit workingCopy = getWorkingCopy();
75
			boolean wasConsistent = workingCopy.isConsistent();
75
			boolean wasConsistent = workingCopy.isConsistent();
76
			IProblemRequestor problemRequestor = workingCopy.getPerWorkingCopyInfo();
76
			IProblemRequestor problemRequestor = workingCopy.getPerWorkingCopyInfo();
77
			this.resolveBindings |= problemRequestor != null && problemRequestor.isActive();
77
			this.resolveBindings |= problemRequestor != null && problemRequestor.isActive();
78
			
78
79
			// create the delta builder (this remembers the current content of the cu)
79
			// create the delta builder (this remembers the current content of the cu)
80
			this.deltaBuilder = new JavaElementDeltaBuilder(workingCopy);
80
			this.deltaBuilder = new JavaElementDeltaBuilder(workingCopy);
81
			
81
82
			// make working copy consistent if needed and compute AST if needed
82
			// make working copy consistent if needed and compute AST if needed
83
			makeConsistent(workingCopy, problemRequestor);
83
			makeConsistent(workingCopy, problemRequestor);
84
			
84
85
			// notify reconcile participants
85
			// notify reconcile participants
86
			notifyParticipants(workingCopy);
86
			notifyParticipants(workingCopy);
87
			
87
88
			// recreate ast if needed
88
			// recreate ast if needed
89
			if (this.ast == null && (this.astLevel > ICompilationUnit.NO_AST || this.resolveBindings))
89
			if (this.ast == null && (this.astLevel > ICompilationUnit.NO_AST || this.resolveBindings))
90
				makeConsistent(workingCopy, problemRequestor);
90
				makeConsistent(workingCopy, problemRequestor);
91
		
91
92
			// report problems
92
			// report problems
93
			if (this.problems != null && (this.forceProblemDetection || !wasConsistent)) {
93
			if (this.problems != null && (this.forceProblemDetection || !wasConsistent)) {
94
				try {
94
				try {
Lines 109-115 Link Here
109
					problemRequestor.endReporting();
109
					problemRequestor.endReporting();
110
				}
110
				}
111
			}
111
			}
112
			
112
113
			// report delta
113
			// report delta
114
			JavaElementDelta delta = this.deltaBuilder.delta;
114
			JavaElementDelta delta = this.deltaBuilder.delta;
115
			if (delta != null) {
115
			if (delta != null) {
Lines 144-150 Link Here
144
			if (this.ast != null && this.deltaBuilder.delta != null)
144
			if (this.ast != null && this.deltaBuilder.delta != null)
145
				this.deltaBuilder.delta.changedAST(this.ast);
145
				this.deltaBuilder.delta.changedAST(this.ast);
146
			return this.ast;
146
			return this.ast;
147
		} 
147
		}
148
		if (this.ast != null) return this.ast; // no need to recompute AST if known already
148
		if (this.ast != null) return this.ast; // no need to recompute AST if known already
149
		if (this.forceProblemDetection || this.resolveBindings) {
149
		if (this.forceProblemDetection || this.resolveBindings) {
150
			if (JavaProject.hasJavaNature(workingCopy.getJavaProject().getProject())) {
150
			if (JavaProject.hasJavaNature(workingCopy.getJavaProject().getProject())) {
Lines 155-186 Link Here
155
						this.problems = problemMap;
155
						this.problems = problemMap;
156
				} else
156
				} else
157
					problemMap = this.problems;
157
					problemMap = this.problems;
158
			    CompilationUnitDeclaration unit = null;
158
				CompilationUnitDeclaration unit = null;
159
			    try {
159
				try {
160
			    	// find problems
160
					// find problems
161
					char[] contents = workingCopy.getContents();
161
					char[] contents = workingCopy.getContents();
162
					unit = 
162
					unit =
163
						CompilationUnitProblemFinder.process(
163
						CompilationUnitProblemFinder.process(
164
							workingCopy, 
164
							workingCopy,
165
							contents, 
165
							contents,
166
							this.workingCopyOwner, 
166
							this.workingCopyOwner,
167
							problemMap, 
167
							problemMap,
168
							this.astLevel != ICompilationUnit.NO_AST/*creating AST if level is not NO_AST */, 
168
							this.astLevel != ICompilationUnit.NO_AST/*creating AST if level is not NO_AST */,
169
							this.enableStatementsRecovery,
169
							this.enableStatementsRecovery,
170
							this.progressMonitor);
170
							this.progressMonitor);
171
					if (this.progressMonitor != null) this.progressMonitor.worked(1);
171
					if (this.progressMonitor != null) this.progressMonitor.worked(1);
172
					
172
173
					// create AST if needed
173
					// create AST if needed
174
					if (this.astLevel != ICompilationUnit.NO_AST && unit != null) {
174
					if (this.astLevel != ICompilationUnit.NO_AST && unit != null) {
175
						Map options = workingCopy.getJavaProject().getOptions(true);
175
						Map options = workingCopy.getJavaProject().getOptions(true);
176
						this.ast = 
176
						this.ast =
177
							AST.convertCompilationUnit(
177
							AST.convertCompilationUnit(
178
								this.astLevel, 
178
								this.astLevel,
179
								unit, 
179
								unit,
180
								contents, 
180
								contents,
181
								options, 
181
								options,
182
								true/*isResolved*/, 
182
								true/*isResolved*/,
183
								workingCopy, 
183
								workingCopy,
184
								this.enableStatementsRecovery,
184
								this.progressMonitor);
185
								this.progressMonitor);
185
						if (this.ast != null) {
186
						if (this.ast != null) {
186
							this.deltaBuilder.delta = new JavaElementDelta(workingCopy);
187
							this.deltaBuilder.delta = new JavaElementDelta(workingCopy);
Lines 200-211 Link Here
200
			    }
201
			    }
201
			} // else working copy not in a Java project
202
			} // else working copy not in a Java project
202
			return this.ast;
203
			return this.ast;
203
		} 
204
		}
204
		return null;
205
		return null;
205
	}
206
	}
206
	private void notifyParticipants(final CompilationUnit workingCopy) {
207
	private void notifyParticipants(final CompilationUnit workingCopy) {
207
		IJavaProject javaProject = getWorkingCopy().getJavaProject();
208
		IJavaProject javaProject = getWorkingCopy().getJavaProject();
208
		CompilationParticipant[] participants = JavaModelManager.getJavaModelManager().compilationParticipants.getCompilationParticipants(javaProject);	
209
		CompilationParticipant[] participants = JavaModelManager.getJavaModelManager().compilationParticipants.getCompilationParticipants(javaProject);
209
		if (participants == null) return;
210
		if (participants == null) return;
210
211
211
		final ReconcileContext context = new ReconcileContext(this, workingCopy);
212
		final ReconcileContext context = new ReconcileContext(this, workingCopy);
(-)dom/org/eclipse/jdt/core/dom/CompilationUnitResolver.java (-96 / +104 lines)
Lines 58-64 Link Here
58
import org.eclipse.jdt.internal.core.util.DOMFinder;
58
import org.eclipse.jdt.internal.core.util.DOMFinder;
59
59
60
class CompilationUnitResolver extends Compiler {
60
class CompilationUnitResolver extends Compiler {
61
	
61
62
	/* A list of int */
62
	/* A list of int */
63
	static class IntArrayList {
63
	static class IntArrayList {
64
		public int[] list = new int[5];
64
		public int[] list = new int[5];
Lines 70-92 Link Here
70
				this.list[this.length++] = i;
70
				this.list[this.length++] = i;
71
			}
71
			}
72
		}
72
		}
73
		
73
74
	/*
74
	/*
75
	 * The sources that were requested.
75
	 * The sources that were requested.
76
	 * Map from file name (char[]) to ICompilationUnit.
76
	 * Map from file name (char[]) to ICompilationUnit.
77
	 */
77
	 */
78
	HashtableOfObject requestedSources;
78
	HashtableOfObject requestedSources;
79
	
79
80
	/*
80
	/*
81
	 * The binding keys that were requested.
81
	 * The binding keys that were requested.
82
	 * Map from file name (char[]) to BindingKey (or ArrayList if multiple keys in the same file).
82
	 * Map from file name (char[]) to BindingKey (or ArrayList if multiple keys in the same file).
83
	 */
83
	 */
84
	HashtableOfObject requestedKeys;
84
	HashtableOfObject requestedKeys;
85
	
85
86
	DefaultBindingResolver.BindingTables bindingTables;
86
	DefaultBindingResolver.BindingTables bindingTables;
87
	
87
88
	boolean hasCompilationAborted;
88
	boolean hasCompilationAborted;
89
	
89
90
	private IProgressMonitor monitor;
90
	private IProgressMonitor monitor;
91
91
92
	/**
92
	/**
Lines 108-119 Link Here
108
	 *      them all) and at the same time perform some actions such as opening a dialog
108
	 *      them all) and at the same time perform some actions such as opening a dialog
109
	 *      in UI when compiling interactively.
109
	 *      in UI when compiling interactively.
110
	 *      @see org.eclipse.jdt.internal.compiler.DefaultErrorHandlingPolicies
110
	 *      @see org.eclipse.jdt.internal.compiler.DefaultErrorHandlingPolicies
111
	 * 
111
	 *
112
	 *	@param compilerOptions The compiler options to use for the resolution.
112
	 *	@param compilerOptions The compiler options to use for the resolution.
113
	 *      
113
	 *
114
	 *  @param requestor org.eclipse.jdt.internal.compiler.api.ICompilerRequestor
114
	 *  @param requestor org.eclipse.jdt.internal.compiler.api.ICompilerRequestor
115
	 *      Component which will receive and persist all compilation results and is intended
115
	 *      Component which will receive and persist all compilation results and is intended
116
	 *      to consume them as they are produced. Typically, in a batch compiler, it is 
116
	 *      to consume them as they are produced. Typically, in a batch compiler, it is
117
	 *      responsible for writing out the actual .class files to the file system.
117
	 *      responsible for writing out the actual .class files to the file system.
118
	 *      @see org.eclipse.jdt.internal.compiler.CompilationResult
118
	 *      @see org.eclipse.jdt.internal.compiler.CompilationResult
119
	 *
119
	 *
Lines 136-142 Link Here
136
		this.hasCompilationAborted = false;
136
		this.hasCompilationAborted = false;
137
		this.monitor =monitor;
137
		this.monitor =monitor;
138
	}
138
	}
139
	
139
140
	/*
140
	/*
141
	 * Add additional source types
141
	 * Add additional source types
142
	 */
142
	 */
Lines 197-203 Link Here
197
		for (int i = 0; i < keyLength; i++) {
197
		for (int i = 0; i < keyLength; i++) {
198
			BindingKeyResolver resolver = new BindingKeyResolver(bindingKeys[i], this, this.lookupEnvironment);
198
			BindingKeyResolver resolver = new BindingKeyResolver(bindingKeys[i], this, this.lookupEnvironment);
199
			resolver.parse(true/*pause after fully qualified name*/);
199
			resolver.parse(true/*pause after fully qualified name*/);
200
			// 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. 
200
			// 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.
201
			// Skipping it will speed up performance because the call will open jars. (theodora)
201
			// Skipping it will speed up performance because the call will open jars. (theodora)
202
			CompilationUnitDeclaration parsedUnit = resolver.hasTypeName() ? resolver.getCompilationUnitDeclaration() : null;
202
			CompilationUnitDeclaration parsedUnit = resolver.hasTypeName() ? resolver.getCompilationUnitDeclaration() : null;
203
			if (parsedUnit != null) {
203
			if (parsedUnit != null) {
Lines 212-232 Link Here
212
					list.add(existing);
212
					list.add(existing);
213
					list.add(resolver);
213
					list.add(resolver);
214
					this.requestedKeys.put(fileName, list);
214
					this.requestedKeys.put(fileName, list);
215
				} 
215
				}
216
					
216
217
			} else {
217
			} else {
218
				char[] key = resolver.hasTypeName() 
218
				char[] key = resolver.hasTypeName()
219
					? resolver.getKey().toCharArray() // binary binding
219
					? resolver.getKey().toCharArray() // binary binding
220
					: CharOperation.concatWith(resolver.compoundName(), '.'); // package binding or base type binding
220
					: CharOperation.concatWith(resolver.compoundName(), '.'); // package binding or base type binding
221
				this.requestedKeys.put(key, resolver);
221
				this.requestedKeys.put(key, resolver);
222
			}
222
			}
223
			worked(1);
223
			worked(1);
224
		}
224
		}
225
		
225
226
		// binding resolution
226
		// binding resolution
227
		lookupEnvironment.completeTypeBindings();
227
		lookupEnvironment.completeTypeBindings();
228
	}
228
	}
229
	
229
230
	IBinding createBinding(String key) {
230
	IBinding createBinding(String key) {
231
		if (this.bindingTables == null)
231
		if (this.bindingTables == null)
232
			throw new RuntimeException("Cannot be called outside ASTParser#createASTs(...)"); //$NON-NLS-1$
232
			throw new RuntimeException("Cannot be called outside ASTParser#createASTs(...)"); //$NON-NLS-1$
Lines 236-249 Link Here
236
		DefaultBindingResolver resolver = new DefaultBindingResolver(this.lookupEnvironment, null/*no owner*/, this.bindingTables);
236
		DefaultBindingResolver resolver = new DefaultBindingResolver(this.lookupEnvironment, null/*no owner*/, this.bindingTables);
237
		return resolver.getBinding(compilerBinding);
237
		return resolver.getBinding(compilerBinding);
238
	}
238
	}
239
	
239
240
	public static CompilationUnit convert(CompilationUnitDeclaration compilationUnitDeclaration, char[] source, int apiLevel, Map options, boolean needToResolveBindings, WorkingCopyOwner owner, DefaultBindingResolver.BindingTables bindingTables, IProgressMonitor monitor) {
240
	public static CompilationUnit convert(CompilationUnitDeclaration compilationUnitDeclaration, char[] source, int apiLevel, Map options, boolean needToResolveBindings, WorkingCopyOwner owner, DefaultBindingResolver.BindingTables bindingTables, boolean statementRecovery, IProgressMonitor monitor) {
241
		BindingResolver resolver = null;
241
		BindingResolver resolver = null;
242
		AST ast = AST.newAST(apiLevel);
242
		AST ast = AST.newAST(apiLevel);
243
		if (statementRecovery) {
244
			ast.setFlag(AST.STATEMENT_RECOVERY);
245
		}
243
		ast.setDefaultNodeFlag(ASTNode.ORIGINAL);
246
		ast.setDefaultNodeFlag(ASTNode.ORIGINAL);
244
		CompilationUnit compilationUnit = null;
247
		CompilationUnit compilationUnit = null;
245
		ASTConverter converter = new ASTConverter(options, needToResolveBindings, monitor);
248
		ASTConverter converter = new ASTConverter(options, needToResolveBindings, monitor);
246
		if (needToResolveBindings) {
249
		if (needToResolveBindings) {
250
			ast.setFlag(AST.RESOLVED_BINDINGS);
247
			resolver = new DefaultBindingResolver(compilationUnitDeclaration.scope, owner, bindingTables);
251
			resolver = new DefaultBindingResolver(compilationUnitDeclaration.scope, owner, bindingTables);
248
		} else {
252
		} else {
249
			resolver = new BindingResolver();
253
			resolver = new BindingResolver();
Lines 256-262 Link Here
256
		ast.setOriginalModificationCount(ast.modificationCount());
260
		ast.setOriginalModificationCount(ast.modificationCount());
257
		return compilationUnit;
261
		return compilationUnit;
258
	}
262
	}
259
	
263
260
	protected static CompilerOptions getCompilerOptions(Map options, boolean statementsRecovery) {
264
	protected static CompilerOptions getCompilerOptions(Map options, boolean statementsRecovery) {
261
		CompilerOptions compilerOptions = new CompilerOptions(options);
265
		CompilerOptions compilerOptions = new CompilerOptions(options);
262
		compilerOptions.performMethodsFullRecovery = statementsRecovery;
266
		compilerOptions.performMethodsFullRecovery = statementsRecovery;
Lines 270-282 Link Here
270
	 */
274
	 */
271
	protected static IErrorHandlingPolicy getHandlingPolicy() {
275
	protected static IErrorHandlingPolicy getHandlingPolicy() {
272
276
273
		// passes the initial set of files to the batch oracle (to avoid finding more than once the same units when case insensitive match)	
277
		// passes the initial set of files to the batch oracle (to avoid finding more than once the same units when case insensitive match)
274
		return new IErrorHandlingPolicy() {
278
		return new IErrorHandlingPolicy() {
275
			public boolean stopOnFirstError() {
279
			public boolean stopOnFirstError() {
276
				return false;
280
				return false;
277
			}
281
			}
278
			public boolean proceedOnErrors() {
282
			public boolean proceedOnErrors() {
279
				return false; // stop if there are some errors 
283
				return false; // stop if there are some errors
280
			}
284
			}
281
		};
285
		};
282
	}
286
	}
Lines 316-322 Link Here
316
			removeUnresolvedBindings(unit);
320
			removeUnresolvedBindings(unit);
317
		}
321
		}
318
	}
322
	}
319
	
323
320
	/*
324
	/*
321
	 * Compiler recovery in case of internal AbortCompilation event
325
	 * Compiler recovery in case of internal AbortCompilation event
322
	 */
326
	 */
Lines 328-342 Link Here
328
			removeUnresolvedBindings(unit);
332
			removeUnresolvedBindings(unit);
329
		}
333
		}
330
		this.hasCompilationAborted = true;
334
		this.hasCompilationAborted = true;
331
	}	
335
	}
332
	
336
333
	public static void parse(ICompilationUnit[] compilationUnits, ASTRequestor astRequestor, int apiLevel, Map options, IProgressMonitor monitor) {
337
	public static void parse(ICompilationUnit[] compilationUnits, ASTRequestor astRequestor, int apiLevel, Map options, boolean statementRecovery, IProgressMonitor monitor) {
334
		try {
338
		try {
335
			CompilerOptions compilerOptions = new CompilerOptions(options);
339
			CompilerOptions compilerOptions = new CompilerOptions(options);
336
			Parser parser = new CommentRecorderParser(
340
			Parser parser = new CommentRecorderParser(
337
				new ProblemReporter(
341
				new ProblemReporter(
338
						DefaultErrorHandlingPolicies.proceedWithAllProblems(), 
342
						DefaultErrorHandlingPolicies.proceedWithAllProblems(),
339
						compilerOptions, 
343
						compilerOptions,
340
						new DefaultProblemFactory()),
344
						new DefaultProblemFactory()),
341
				false);
345
				false);
342
			int length = compilationUnits.length;
346
			int length = compilationUnits.length;
Lines 345-357 Link Here
345
				org.eclipse.jdt.internal.compiler.env.ICompilationUnit sourceUnit = (org.eclipse.jdt.internal.compiler.env.ICompilationUnit) compilationUnits[i];
349
				org.eclipse.jdt.internal.compiler.env.ICompilationUnit sourceUnit = (org.eclipse.jdt.internal.compiler.env.ICompilationUnit) compilationUnits[i];
346
				CompilationResult compilationResult = new CompilationResult(sourceUnit, 0, 0, compilerOptions.maxProblemsPerUnit);
350
				CompilationResult compilationResult = new CompilationResult(sourceUnit, 0, 0, compilerOptions.maxProblemsPerUnit);
347
				CompilationUnitDeclaration compilationUnitDeclaration = parser.dietParse(sourceUnit, compilationResult);
351
				CompilationUnitDeclaration compilationUnitDeclaration = parser.dietParse(sourceUnit, compilationResult);
348
				
352
349
				if (compilationUnitDeclaration.ignoreMethodBodies) {
353
				if (compilationUnitDeclaration.ignoreMethodBodies) {
350
					compilationUnitDeclaration.ignoreFurtherInvestigation = true;
354
					compilationUnitDeclaration.ignoreFurtherInvestigation = true;
351
					// if initial diet parse did not work, no need to dig into method bodies.
355
					// if initial diet parse did not work, no need to dig into method bodies.
352
					continue; 
356
					continue;
353
				}
357
				}
354
				
358
355
				//fill the methods bodies in order for the code to be generated
359
				//fill the methods bodies in order for the code to be generated
356
				//real parse of the method....
360
				//real parse of the method....
357
				org.eclipse.jdt.internal.compiler.ast.TypeDeclaration[] types = compilationUnitDeclaration.types;
361
				org.eclipse.jdt.internal.compiler.ast.TypeDeclaration[] types = compilationUnitDeclaration.types;
Lines 359-379 Link Here
359
					for (int j = types.length; --j >= 0;)
363
					for (int j = types.length; --j >= 0;)
360
						types[j].parseMethod(parser, compilationUnitDeclaration);
364
						types[j].parseMethod(parser, compilationUnitDeclaration);
361
				}
365
				}
362
				
366
363
				// convert AST
367
				// convert AST
364
				CompilationUnit node = convert(compilationUnitDeclaration, parser.scanner.getSource(), apiLevel, options, false/*don't resolve binding*/, null/*no owner needed*/, null/*no binding table needed*/, monitor);
368
				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);
365
				node.setTypeRoot(compilationUnits[i]);
369
				node.setTypeRoot(compilationUnits[i]);
366
				
370
367
				// accept AST
371
				// accept AST
368
				astRequestor.acceptAST(compilationUnits[i], node);
372
				astRequestor.acceptAST(compilationUnits[i], node);
369
				
373
370
				if (monitor != null) monitor.worked(1);
374
				if (monitor != null) monitor.worked(1);
371
			}
375
			}
372
		} finally {
376
		} finally {
373
			if (monitor != null) monitor.done();
377
			if (monitor != null) monitor.done();
374
		}
378
		}
375
	}
379
	}
376
	
380
377
	public static CompilationUnitDeclaration parse(org.eclipse.jdt.internal.compiler.env.ICompilationUnit sourceUnit, NodeSearcher nodeSearcher, Map settings, boolean statementsRecovery) {
381
	public static CompilationUnitDeclaration parse(org.eclipse.jdt.internal.compiler.env.ICompilationUnit sourceUnit, NodeSearcher nodeSearcher, Map settings, boolean statementsRecovery) {
378
		if (sourceUnit == null) {
382
		if (sourceUnit == null) {
379
			throw new IllegalStateException();
383
			throw new IllegalStateException();
Lines 383-401 Link Here
383
		compilerOptions.performStatementsRecovery = statementsRecovery;
387
		compilerOptions.performStatementsRecovery = statementsRecovery;
384
		Parser parser = new CommentRecorderParser(
388
		Parser parser = new CommentRecorderParser(
385
			new ProblemReporter(
389
			new ProblemReporter(
386
					DefaultErrorHandlingPolicies.proceedWithAllProblems(), 
390
					DefaultErrorHandlingPolicies.proceedWithAllProblems(),
387
					compilerOptions, 
391
					compilerOptions,
388
					new DefaultProblemFactory()),
392
					new DefaultProblemFactory()),
389
			false);
393
			false);
390
		CompilationResult compilationResult = new CompilationResult(sourceUnit, 0, 0, compilerOptions.maxProblemsPerUnit);
394
		CompilationResult compilationResult = new CompilationResult(sourceUnit, 0, 0, compilerOptions.maxProblemsPerUnit);
391
		CompilationUnitDeclaration compilationUnitDeclaration = parser.dietParse(sourceUnit, compilationResult);
395
		CompilationUnitDeclaration compilationUnitDeclaration = parser.dietParse(sourceUnit, compilationResult);
392
		
396
393
		if (compilationUnitDeclaration.ignoreMethodBodies) {
397
		if (compilationUnitDeclaration.ignoreMethodBodies) {
394
			compilationUnitDeclaration.ignoreFurtherInvestigation = true;
398
			compilationUnitDeclaration.ignoreFurtherInvestigation = true;
395
			// if initial diet parse did not work, no need to dig into method bodies.
399
			// if initial diet parse did not work, no need to dig into method bodies.
396
			return null; 
400
			return null;
397
		}
401
		}
398
		
402
399
		if (nodeSearcher != null) {
403
		if (nodeSearcher != null) {
400
			char[] source = parser.scanner.getSource();
404
			char[] source = parser.scanner.getSource();
401
			int searchPosition = nodeSearcher.position;
405
			int searchPosition = nodeSearcher.position;
Lines 403-426 Link Here
403
				// the position is out of range. There is no need to search for a node.
407
				// the position is out of range. There is no need to search for a node.
404
	 			return compilationUnitDeclaration;
408
	 			return compilationUnitDeclaration;
405
			}
409
			}
406
		
410
407
			compilationUnitDeclaration.traverse(nodeSearcher, compilationUnitDeclaration.scope);
411
			compilationUnitDeclaration.traverse(nodeSearcher, compilationUnitDeclaration.scope);
408
			
412
409
			org.eclipse.jdt.internal.compiler.ast.ASTNode node = nodeSearcher.found;
413
			org.eclipse.jdt.internal.compiler.ast.ASTNode node = nodeSearcher.found;
410
	 		if (node == null) {
414
	 		if (node == null) {
411
	 			return compilationUnitDeclaration;
415
	 			return compilationUnitDeclaration;
412
	 		}
416
	 		}
413
	 		
417
414
	 		org.eclipse.jdt.internal.compiler.ast.TypeDeclaration enclosingTypeDeclaration = nodeSearcher.enclosingType;
418
	 		org.eclipse.jdt.internal.compiler.ast.TypeDeclaration enclosingTypeDeclaration = nodeSearcher.enclosingType;
415
	 		
419
416
			if (node instanceof AbstractMethodDeclaration) {
420
			if (node instanceof AbstractMethodDeclaration) {
417
				((AbstractMethodDeclaration)node).parseStatements(parser, compilationUnitDeclaration);
421
				((AbstractMethodDeclaration)node).parseStatements(parser, compilationUnitDeclaration);
418
			} else if (enclosingTypeDeclaration != null) {
422
			} else if (enclosingTypeDeclaration != null) {
419
				if (node instanceof org.eclipse.jdt.internal.compiler.ast.Initializer) {
423
				if (node instanceof org.eclipse.jdt.internal.compiler.ast.Initializer) {
420
					((org.eclipse.jdt.internal.compiler.ast.Initializer) node).parseStatements(parser, enclosingTypeDeclaration, compilationUnitDeclaration);
424
					((org.eclipse.jdt.internal.compiler.ast.Initializer) node).parseStatements(parser, enclosingTypeDeclaration, compilationUnitDeclaration);
421
				} else {  					
425
				} else {
422
					((org.eclipse.jdt.internal.compiler.ast.TypeDeclaration)node).parseMethod(parser, compilationUnitDeclaration);
426
					((org.eclipse.jdt.internal.compiler.ast.TypeDeclaration)node).parseMethod(parser, compilationUnitDeclaration);
423
				} 				
427
				}
424
			}
428
			}
425
		} else {
429
		} else {
426
			//fill the methods bodies in order for the code to be generated
430
			//fill the methods bodies in order for the code to be generated
Lines 444-450 Link Here
444
		WorkingCopyOwner owner,
448
		WorkingCopyOwner owner,
445
		boolean statementsRecovery,
449
		boolean statementsRecovery,
446
		IProgressMonitor monitor) {
450
		IProgressMonitor monitor) {
447
	
451
448
		CancelableNameEnvironment environment = null;
452
		CancelableNameEnvironment environment = null;
449
		CancelableProblemFactory problemFactory = null;
453
		CancelableProblemFactory problemFactory = null;
450
		try {
454
		try {
Lines 460-476 Link Here
460
					getHandlingPolicy(),
464
					getHandlingPolicy(),
461
					getCompilerOptions(options, statementsRecovery),
465
					getCompilerOptions(options, statementsRecovery),
462
					getRequestor(),
466
					getRequestor(),
463
					problemFactory, 
467
					problemFactory,
464
					monitor);
468
					monitor);
465
469
466
			resolver.resolve(compilationUnits, bindingKeys, requestor, apiLevel, options, owner);
470
			resolver.resolve(compilationUnits, bindingKeys, requestor, apiLevel, options, owner, statementsRecovery);
467
			if (NameLookup.VERBOSE) {
471
			if (NameLookup.VERBOSE) {
468
				System.out.println(Thread.currentThread() + " TIME SPENT in NameLoopkup#seekTypesInSourcePackage: " + environment.nameLookup.timeSpentInSeekTypesInSourcePackage + "ms");  //$NON-NLS-1$ //$NON-NLS-2$
472
				System.out.println(Thread.currentThread() + " TIME SPENT in NameLoopkup#seekTypesInSourcePackage: " + environment.nameLookup.timeSpentInSeekTypesInSourcePackage + "ms");  //$NON-NLS-1$ //$NON-NLS-2$
469
				System.out.println(Thread.currentThread() + " TIME SPENT in NameLoopkup#seekTypesInBinaryPackage: " + environment.nameLookup.timeSpentInSeekTypesInBinaryPackage + "ms");  //$NON-NLS-1$ //$NON-NLS-2$
473
				System.out.println(Thread.currentThread() + " TIME SPENT in NameLoopkup#seekTypesInBinaryPackage: " + environment.nameLookup.timeSpentInSeekTypesInBinaryPackage + "ms");  //$NON-NLS-1$ //$NON-NLS-2$
470
			}
474
			}
471
		} catch (JavaModelException e) {
475
		} catch (JavaModelException e) {
472
			// project doesn't exist -> simple parse without resolving
476
			// project doesn't exist -> simple parse without resolving
473
			parse(compilationUnits, requestor, apiLevel, options, monitor);
477
			parse(compilationUnits, requestor, apiLevel, options, statementsRecovery, monitor);
474
		} finally {
478
		} finally {
475
			if (monitor != null) monitor.done();
479
			if (monitor != null) monitor.done();
476
			if (environment != null) {
480
			if (environment != null) {
Lines 489-495 Link Here
489
		WorkingCopyOwner owner,
493
		WorkingCopyOwner owner,
490
		boolean statementsRecovery,
494
		boolean statementsRecovery,
491
		IProgressMonitor monitor) throws JavaModelException {
495
		IProgressMonitor monitor) throws JavaModelException {
492
	
496
493
		CompilationUnitDeclaration unit = null;
497
		CompilationUnitDeclaration unit = null;
494
		CancelableNameEnvironment environment = null;
498
		CancelableNameEnvironment environment = null;
495
		CancelableProblemFactory problemFactory = null;
499
		CancelableProblemFactory problemFactory = null;
Lines 506-512 Link Here
506
					problemFactory,
510
					problemFactory,
507
					monitor);
511
					monitor);
508
512
509
			unit = 
513
			unit =
510
				resolver.resolve(
514
				resolver.resolve(
511
					null, // no existing compilation unit declaration
515
					null, // no existing compilation unit declaration
512
					sourceUnit,
516
					sourceUnit,
Lines 529-535 Link Here
529
			if (NameLookup.VERBOSE) {
533
			if (NameLookup.VERBOSE) {
530
				System.out.println(Thread.currentThread() + " TIME SPENT in NameLoopkup#seekTypesInSourcePackage: " + environment.nameLookup.timeSpentInSeekTypesInSourcePackage + "ms");  //$NON-NLS-1$ //$NON-NLS-2$
534
				System.out.println(Thread.currentThread() + " TIME SPENT in NameLoopkup#seekTypesInSourcePackage: " + environment.nameLookup.timeSpentInSeekTypesInSourcePackage + "ms");  //$NON-NLS-1$ //$NON-NLS-2$
531
				System.out.println(Thread.currentThread() + " TIME SPENT in NameLoopkup#seekTypesInBinaryPackage: " + environment.nameLookup.timeSpentInSeekTypesInBinaryPackage + "ms");  //$NON-NLS-1$ //$NON-NLS-2$
535
				System.out.println(Thread.currentThread() + " TIME SPENT in NameLoopkup#seekTypesInBinaryPackage: " + environment.nameLookup.timeSpentInSeekTypesInBinaryPackage + "ms");  //$NON-NLS-1$ //$NON-NLS-2$
532
			}	
536
			}
533
			return unit;
537
			return unit;
534
		} finally {
538
		} finally {
535
			if (environment != null) {
539
			if (environment != null) {
Lines 542-548 Link Here
542
//			if (resolver != null) {
546
//			if (resolver != null) {
543
//				for (int i = 1; i <  resolver.totalUnits; i++) { // could be more requested units
547
//				for (int i = 1; i <  resolver.totalUnits; i++) { // could be more requested units
544
//					CompilationUnitDeclaration parsedUnit = resolver.unitsToProcess[i];
548
//					CompilationUnitDeclaration parsedUnit = resolver.unitsToProcess[i];
545
//					if (parsedUnit.scope != null) 
549
//					if (parsedUnit.scope != null)
546
//						parsedUnit.scope.faultInTypes(); // force resolution of signatures, so clients can query DOM AST
550
//						parsedUnit.scope.faultInTypes(); // force resolution of signatures, so clients can query DOM AST
547
//					parsedUnit.cleanUp();
551
//					parsedUnit.cleanUp();
548
//				}
552
//				}
Lines 583-597 Link Here
583
				} catch (JavaModelException e) {
587
				} catch (JavaModelException e) {
584
					throw new IllegalArgumentException(element + " does not exist"); //$NON-NLS-1$
588
					throw new IllegalArgumentException(element + " does not exist"); //$NON-NLS-1$
585
				}
589
				}
586
			}	
590
			}
587
		}
591
		}
588
		ICompilationUnit[] cus = new ICompilationUnit[cuNumber];
592
		ICompilationUnit[] cus = new ICompilationUnit[cuNumber];
589
		sourceElementPositions.keySet().toArray(cus);
593
		sourceElementPositions.keySet().toArray(cus);
590
		
594
591
		int bindingKeyNumber = binaryElementPositions.size();
595
		int bindingKeyNumber = binaryElementPositions.size();
592
		String[] bindingKeys = new String[bindingKeyNumber];
596
		String[] bindingKeys = new String[bindingKeyNumber];
593
		binaryElementPositions.keysToArray(bindingKeys);
597
		binaryElementPositions.keysToArray(bindingKeys);
594
		
598
595
		class Requestor extends ASTRequestor {
599
		class Requestor extends ASTRequestor {
596
			IBinding[] bindings = new IBinding[length];
600
			IBinding[] bindings = new IBinding[length];
597
			public void acceptAST(ICompilationUnit source, CompilationUnit ast) {
601
			public void acceptAST(ICompilationUnit source, CompilationUnit ast) {
Lines 640-646 Link Here
640
		if (type.binding != null && (type.binding.modifiers & ExtraCompilerModifiers.AccUnresolved) != 0) {
644
		if (type.binding != null && (type.binding.modifiers & ExtraCompilerModifiers.AccUnresolved) != 0) {
641
			type.binding = null;
645
			type.binding = null;
642
		}
646
		}
643
		
647
644
		final org.eclipse.jdt.internal.compiler.ast.FieldDeclaration[] fields = type.fields;
648
		final org.eclipse.jdt.internal.compiler.ast.FieldDeclaration[] fields = type.fields;
645
		if (fields != null) {
649
		if (fields != null) {
646
			for (int i = 0, max = fields.length; i < max; i++){
650
			for (int i = 0, max = fields.length; i < max; i++){
Lines 649-655 Link Here
649
				}
653
				}
650
			}
654
			}
651
		}
655
		}
652
	
656
653
		final AbstractMethodDeclaration[] methods = type.methods;
657
		final AbstractMethodDeclaration[] methods = type.methods;
654
		if (methods != null) {
658
		if (methods != null) {
655
			for (int i = 0, max = methods.length; i < max; i++){
659
			for (int i = 0, max = methods.length; i < max; i++){
Lines 660-667 Link Here
660
		}
664
		}
661
	}
665
	}
662
666
663
	private void resolve(ICompilationUnit[] compilationUnits, String[] bindingKeys, ASTRequestor astRequestor, int apiLevel, Map compilerOptions, WorkingCopyOwner owner) {
667
	private void resolve(ICompilationUnit[] compilationUnits, String[] bindingKeys, ASTRequestor astRequestor, int apiLevel, Map compilerOptions, WorkingCopyOwner owner, boolean statementRecovery) {
664
	
668
665
		// temporararily connect ourselves to the ASTResolver - must disconnect when done
669
		// temporararily connect ourselves to the ASTResolver - must disconnect when done
666
		astRequestor.compilationUnitResolver = this;
670
		astRequestor.compilationUnitResolver = this;
667
		this.bindingTables = new DefaultBindingResolver.BindingTables();
671
		this.bindingTables = new DefaultBindingResolver.BindingTables();
Lines 689-695 Link Here
689
					super.process(unit, i); // this.process(...) is optimized to not process already known units
693
					super.process(unit, i); // this.process(...) is optimized to not process already known units
690
694
691
					// requested AST
695
					// requested AST
692
					char[] fileName = unit.compilationResult.getFileName();					
696
					char[] fileName = unit.compilationResult.getFileName();
693
					ICompilationUnit source = (ICompilationUnit) this.requestedSources.get(fileName);
697
					ICompilationUnit source = (ICompilationUnit) this.requestedSources.get(fileName);
694
					if (source != null) {
698
					if (source != null) {
695
						// convert AST
699
						// convert AST
Lines 697-702 Link Here
697
						org.eclipse.jdt.internal.compiler.env.ICompilationUnit sourceUnit = compilationResult.compilationUnit;
701
						org.eclipse.jdt.internal.compiler.env.ICompilationUnit sourceUnit = compilationResult.compilationUnit;
698
						char[] contents = sourceUnit.getContents();
702
						char[] contents = sourceUnit.getContents();
699
						AST ast = AST.newAST(apiLevel);
703
						AST ast = AST.newAST(apiLevel);
704
						if (statementRecovery) {
705
							ast.setFlag(AST.STATEMENT_RECOVERY);
706
						}
707
						ast.setFlag(AST.RESOLVED_BINDINGS);
700
						ast.setDefaultNodeFlag(ASTNode.ORIGINAL);
708
						ast.setDefaultNodeFlag(ASTNode.ORIGINAL);
701
						ASTConverter converter = new ASTConverter(compilerOptions, true/*need to resolve bindings*/, this.monitor);
709
						ASTConverter converter = new ASTConverter(compilerOptions, true/*need to resolve bindings*/, this.monitor);
702
						BindingResolver resolver = new DefaultBindingResolver(unit.scope, owner, this.bindingTables);
710
						BindingResolver resolver = new DefaultBindingResolver(unit.scope, owner, this.bindingTables);
Lines 707-719 Link Here
707
						compilationUnit.setLineEndTable(compilationResult.getLineSeparatorPositions());
715
						compilationUnit.setLineEndTable(compilationResult.getLineSeparatorPositions());
708
						ast.setDefaultNodeFlag(0);
716
						ast.setDefaultNodeFlag(0);
709
						ast.setOriginalModificationCount(ast.modificationCount());
717
						ast.setOriginalModificationCount(ast.modificationCount());
710
						
718
711
						// pass it to requestor
719
						// pass it to requestor
712
						astRequestor.acceptAST(source, compilationUnit);
720
						astRequestor.acceptAST(source, compilationUnit);
713
						
721
714
						worked(1);
722
						worked(1);
715
					} 
723
					}
716
					
724
717
					// requested binding
725
					// requested binding
718
					Object key = this.requestedKeys.get(fileName);
726
					Object key = this.requestedKeys.get(fileName);
719
					if (key instanceof BindingKeyResolver) {
727
					if (key instanceof BindingKeyResolver) {
Lines 726-736 Link Here
726
							worked(1);
734
							worked(1);
727
						}
735
						}
728
					}
736
					}
729
					
737
730
					// 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
738
					// 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
731
					this.requestedSources.removeKey(fileName);
739
					this.requestedSources.removeKey(fileName);
732
					this.requestedKeys.removeKey(fileName);
740
					this.requestedKeys.removeKey(fileName);
733
						
741
734
/*	Code used to fault in types and resolve which is no longer necessary as all questions asked to forward references are
742
/*	Code used to fault in types and resolve which is no longer necessary as all questions asked to forward references are
735
 * lazily resolved.
743
 * lazily resolved.
736
 * Code used to be:
744
 * Code used to be:
Lines 740-751 Link Here
740
748
741
						if (unit.scope != null)
749
						if (unit.scope != null)
742
							unit.scope.faultInTypes();// still force resolution of signatures, so clients can query DOM AST
750
							unit.scope.faultInTypes();// still force resolution of signatures, so clients can query DOM AST
743
				
751
744
						// the following ensures that all type, method and field bindings are correctly initialized
752
						// the following ensures that all type, method and field bindings are correctly initialized
745
						// as they may be needed by further units
753
						// as they may be needed by further units
746
						// (see https://bugs.eclipse.org/bugs/show_bug.cgi?id=111822)
754
						// (see https://bugs.eclipse.org/bugs/show_bug.cgi?id=111822)
747
						unit.resolve();
755
						unit.resolve();
748
						
756
749
						// note that if this has a performance penalty on clients, the above code should be removed
757
						// note that if this has a performance penalty on clients, the above code should be removed
750
						// the following patch would workaround bug 111822:
758
						// the following patch would workaround bug 111822:
751
759
Lines 757-763 Link Here
757
--- FieldReference.java	24 Sep 2005 15:23:46 -0000	1.87
765
--- FieldReference.java	24 Sep 2005 15:23:46 -0000	1.87
758
+++ FieldReference.java	7 Oct 2005 13:46:12 -0000
766
+++ FieldReference.java	7 Oct 2005 13:46:12 -0000
759
@@ -407,7 +407,14 @@
767
@@ -407,7 +407,14 @@
760
 
768
761
 		FieldBinding originalField = binding.original();
769
 		FieldBinding originalField = binding.original();
762
 		SourceTypeBinding sourceType = (SourceTypeBinding) originalField.declaringClass;
770
 		SourceTypeBinding sourceType = (SourceTypeBinding) originalField.declaringClass;
763
-		TypeDeclaration typeDecl = sourceType.scope.referenceContext;
771
-		TypeDeclaration typeDecl = sourceType.scope.referenceContext;
Lines 770-778 Link Here
770
+		}
778
+		}
771
+		TypeDeclaration typeDecl = classScope.referenceContext;
779
+		TypeDeclaration typeDecl = classScope.referenceContext;
772
 		FieldDeclaration fieldDecl = typeDecl.declarationOf(originalField);
780
 		FieldDeclaration fieldDecl = typeDecl.declarationOf(originalField);
773
 
781
774
 		fieldDecl.resolve(originalField.isStatic() //side effect on binding 
782
 		fieldDecl.resolve(originalField.isStatic() //side effect on binding
775
*/					
783
*/
776
				} finally {
784
				} finally {
777
					// cleanup compilation unit result
785
					// cleanup compilation unit result
778
					unit.cleanUp();
786
					unit.cleanUp();
Lines 780-786 Link Here
780
				this.unitsToProcess[i] = null; // release reference to processed unit declaration
788
				this.unitsToProcess[i] = null; // release reference to processed unit declaration
781
				this.requestor.acceptResult(unit.compilationResult.tagAsAccepted());
789
				this.requestor.acceptResult(unit.compilationResult.tagAsAccepted());
782
			}
790
			}
783
			
791
784
			// remaining binding keys
792
			// remaining binding keys
785
			DefaultBindingResolver resolver = new DefaultBindingResolver(this.lookupEnvironment, owner, this.bindingTables);
793
			DefaultBindingResolver resolver = new DefaultBindingResolver(this.lookupEnvironment, owner, this.bindingTables);
786
			Object[] keys = this.requestedKeys.valueTable;
794
			Object[] keys = this.requestedKeys.valueTable;
Lines 819-825 Link Here
819
				astRequestor.acceptBinding(keyResolver.getKey(), binding);
827
				astRequestor.acceptBinding(keyResolver.getKey(), binding);
820
		}
828
		}
821
	}
829
	}
822
	
830
823
	private CompilationUnitDeclaration resolve(
831
	private CompilationUnitDeclaration resolve(
824
			CompilationUnitDeclaration unit,
832
			CompilationUnitDeclaration unit,
825
			org.eclipse.jdt.internal.compiler.env.ICompilationUnit sourceUnit,
833
			org.eclipse.jdt.internal.compiler.env.ICompilationUnit sourceUnit,
Lines 852-862 Link Here
852
				int length = source.length;
860
				int length = source.length;
853
				if (searchPosition >= 0 && searchPosition <= length) {
861
				if (searchPosition >= 0 && searchPosition <= length) {
854
					unit.traverse(nodeSearcher, unit.scope);
862
					unit.traverse(nodeSearcher, unit.scope);
855
					
863
856
					org.eclipse.jdt.internal.compiler.ast.ASTNode node = nodeSearcher.found;
864
					org.eclipse.jdt.internal.compiler.ast.ASTNode node = nodeSearcher.found;
857
					
865
858
					this.parser.scanner.setSource(source, unit.compilationResult);
866
					this.parser.scanner.setSource(source, unit.compilationResult);
859
					
867
860
		 			if (node != null) {
868
		 			if (node != null) {
861
						org.eclipse.jdt.internal.compiler.ast.TypeDeclaration enclosingTypeDeclaration = nodeSearcher.enclosingType;
869
						org.eclipse.jdt.internal.compiler.ast.TypeDeclaration enclosingTypeDeclaration = nodeSearcher.enclosingType;
862
		  				if (node instanceof AbstractMethodDeclaration) {
870
		  				if (node instanceof AbstractMethodDeclaration) {
Lines 864-877 Link Here
864
		 				} else if (enclosingTypeDeclaration != null) {
872
		 				} else if (enclosingTypeDeclaration != null) {
865
							if (node instanceof org.eclipse.jdt.internal.compiler.ast.Initializer) {
873
							if (node instanceof org.eclipse.jdt.internal.compiler.ast.Initializer) {
866
			 					((org.eclipse.jdt.internal.compiler.ast.Initializer) node).parseStatements(this.parser, enclosingTypeDeclaration, unit);
874
			 					((org.eclipse.jdt.internal.compiler.ast.Initializer) node).parseStatements(this.parser, enclosingTypeDeclaration, unit);
867
		 					} else if (node instanceof org.eclipse.jdt.internal.compiler.ast.TypeDeclaration) {  					
875
		 					} else if (node instanceof org.eclipse.jdt.internal.compiler.ast.TypeDeclaration) {
868
								((org.eclipse.jdt.internal.compiler.ast.TypeDeclaration)node).parseMethod(this.parser, unit);
876
								((org.eclipse.jdt.internal.compiler.ast.TypeDeclaration)node).parseMethod(this.parser, unit);
869
							} 				
877
							}
870
		 				}
878
		 				}
871
		 			}
879
		 			}
872
				}
880
				}
873
			}
881
			}
874
			
882
875
			if (unit.scope != null) {
883
			if (unit.scope != null) {
876
				// fault in fields & methods
884
				// fault in fields & methods
877
				unit.scope.faultInTypes();
885
				unit.scope.faultInTypes();
Lines 881-891 Link Here
881
					unit.scope.verifyMethods(this.lookupEnvironment.methodVerifier());
889
					unit.scope.verifyMethods(this.lookupEnvironment.methodVerifier());
882
				}
890
				}
883
				// type checking
891
				// type checking
884
				unit.resolve();		
892
				unit.resolve();
885
893
886
				// flow analysis
894
				// flow analysis
887
				if (analyzeCode) unit.analyseCode();
895
				if (analyzeCode) unit.analyseCode();
888
		
896
889
				// code generation
897
				// code generation
890
				if (generateCode) unit.generateCode();
898
				if (generateCode) unit.generateCode();
891
			}
899
			}
Lines 915-929 Link Here
915
	 * Internal API used to resolve a given compilation unit. Can run a subset of the compilation process
923
	 * Internal API used to resolve a given compilation unit. Can run a subset of the compilation process
916
	 */
924
	 */
917
	public CompilationUnitDeclaration resolve(
925
	public CompilationUnitDeclaration resolve(
918
			org.eclipse.jdt.internal.compiler.env.ICompilationUnit sourceUnit, 
926
			org.eclipse.jdt.internal.compiler.env.ICompilationUnit sourceUnit,
919
			boolean verifyMethods,
927
			boolean verifyMethods,
920
			boolean analyzeCode,
928
			boolean analyzeCode,
921
			boolean generateCode) {
929
			boolean generateCode) {
922
				
930
923
		return resolve(
931
		return resolve(
924
			null, /* no existing compilation unit declaration*/
932
			null, /* no existing compilation unit declaration*/
925
			sourceUnit,
933
			sourceUnit,
926
			null/*no node searcher*/, 
934
			null/*no node searcher*/,
927
			verifyMethods,
935
			verifyMethods,
928
			analyzeCode,
936
			analyzeCode,
929
			generateCode);
937
			generateCode);
Lines 933-953 Link Here
933
	 * Internal API used to resolve a given compilation unit. Can run a subset of the compilation process
941
	 * Internal API used to resolve a given compilation unit. Can run a subset of the compilation process
934
	 */
942
	 */
935
	public CompilationUnitDeclaration resolve(
943
	public CompilationUnitDeclaration resolve(
936
			CompilationUnitDeclaration unit, 
944
			CompilationUnitDeclaration unit,
937
			org.eclipse.jdt.internal.compiler.env.ICompilationUnit sourceUnit, 
945
			org.eclipse.jdt.internal.compiler.env.ICompilationUnit sourceUnit,
938
			boolean verifyMethods,
946
			boolean verifyMethods,
939
			boolean analyzeCode,
947
			boolean analyzeCode,
940
			boolean generateCode) {
948
			boolean generateCode) {
941
		
949
942
		return resolve(
950
		return resolve(
943
			unit, 
951
			unit,
944
			sourceUnit, 
952
			sourceUnit,
945
			null/*no node searcher*/, 
953
			null/*no node searcher*/,
946
			verifyMethods, 
954
			verifyMethods,
947
			analyzeCode, 
955
			analyzeCode,
948
			generateCode);
956
			generateCode);
949
	}
957
	}
950
	
958
951
	private void worked(int work) {
959
	private void worked(int work) {
952
		if (this.monitor != null) {
960
		if (this.monitor != null) {
953
			if (this.monitor.isCanceled())
961
			if (this.monitor.isCanceled())
(-)dom/org/eclipse/jdt/core/dom/ASTParser.java (-1 / +5 lines)
Lines 704-710 Link Here
704
					throw new IllegalStateException("project not specified"); //$NON-NLS-1$
704
					throw new IllegalStateException("project not specified"); //$NON-NLS-1$
705
				CompilationUnitResolver.resolve(compilationUnits, bindingKeys, requestor, this.apiLevel, this.compilerOptions, this.project, this.workingCopyOwner, this.statementsRecovery, monitor);
705
				CompilationUnitResolver.resolve(compilationUnits, bindingKeys, requestor, this.apiLevel, this.compilerOptions, this.project, this.workingCopyOwner, this.statementsRecovery, monitor);
706
			} else {
706
			} else {
707
				CompilationUnitResolver.parse(compilationUnits, requestor, this.apiLevel, this.compilerOptions, monitor);
707
				CompilationUnitResolver.parse(compilationUnits, requestor, this.apiLevel, this.compilerOptions, this.statementsRecovery, monitor);
708
			}
708
			}
709
		} finally {
709
		} finally {
710
	   	   // re-init defaults to allow reuse (and avoid leaking)
710
	   	   // re-init defaults to allow reuse (and avoid leaking)
Lines 864-869 Link Here
864
						needToResolveBindings,
864
						needToResolveBindings,
865
						wcOwner,
865
						wcOwner,
866
						needToResolveBindings ? new DefaultBindingResolver.BindingTables() : null,
866
						needToResolveBindings ? new DefaultBindingResolver.BindingTables() : null,
867
						this.statementsRecovery,
867
						monitor);
868
						monitor);
868
					result.setTypeRoot(this.typeRoot);
869
					result.setTypeRoot(this.typeRoot);
869
					return result;
870
					return result;
Lines 953-958 Link Here
953
		converter.scanner.setSource(this.rawSource);
954
		converter.scanner.setSource(this.rawSource);
954
955
955
		AST ast = AST.newAST(this.apiLevel);
956
		AST ast = AST.newAST(this.apiLevel);
957
		if (this.statementsRecovery) {
958
			ast.setFlag(AST.STATEMENT_RECOVERY);
959
		}
956
		ast.setDefaultNodeFlag(ASTNode.ORIGINAL);
960
		ast.setDefaultNodeFlag(ASTNode.ORIGINAL);
957
		ast.setBindingResolver(new BindingResolver());
961
		ast.setBindingResolver(new BindingResolver());
958
		converter.setAST(ast);
962
		converter.setAST(ast);
(-)dom/org/eclipse/jdt/core/dom/AST.java (-357 / +397 lines)
Lines 32-43 Link Here
32
/**
32
/**
33
 * Umbrella owner and abstract syntax tree node factory.
33
 * Umbrella owner and abstract syntax tree node factory.
34
 * An <code>AST</code> instance serves as the common owner of any number of
34
 * An <code>AST</code> instance serves as the common owner of any number of
35
 * AST nodes, and as the factory for creating new AST nodes owned by that 
35
 * AST nodes, and as the factory for creating new AST nodes owned by that
36
 * instance.
36
 * instance.
37
 * <p>
37
 * <p>
38
 * Abstract syntax trees may be hand constructed by clients, using the
38
 * Abstract syntax trees may be hand constructed by clients, using the
39
 * <code>new<i>TYPE</i></code> factory methods to create new nodes, and the
39
 * <code>new<i>TYPE</i></code> factory methods to create new nodes, and the
40
 * various <code>set<i>CHILD</i></code> methods 
40
 * various <code>set<i>CHILD</i></code> methods
41
 * (see {@link org.eclipse.jdt.core.dom.ASTNode ASTNode} and its subclasses)
41
 * (see {@link org.eclipse.jdt.core.dom.ASTNode ASTNode} and its subclasses)
42
 * to connect them together.
42
 * to connect them together.
43
 * </p>
43
 * </p>
Lines 84-98 Link Here
84
 * read-only AST.
84
 * read-only AST.
85
 * </p>
85
 * </p>
86
 * <p>
86
 * <p>
87
 * Clients may create instances of this class using {@link #newAST(int)}, 
87
 * Clients may create instances of this class using {@link #newAST(int)},
88
 * but this class is not intended to be subclassed.
88
 * but this class is not intended to be subclassed.
89
 * </p>
89
 * </p>
90
 * 
90
 *
91
 * @see ASTParser
91
 * @see ASTParser
92
 * @see ASTNode
92
 * @see ASTNode
93
 * @since 2.0
93
 * @since 2.0
94
 */
94
 */
95
public final class AST {
95
public final class AST {
96
97
	static final int RESOLVED_BINDINGS = 0x01;
98
	static final int STATEMENT_RECOVERY = 0x02;
96
	/**
99
	/**
97
	 * Constant for indicating the AST API that handles JLS2.
100
	 * Constant for indicating the AST API that handles JLS2.
98
	 * This API is capable of handling all constructs
101
	 * This API is capable of handling all constructs
Lines 107-113 Link Here
107
	 * @deprecated Clients should use the {@link #JLS3} AST API instead.
110
	 * @deprecated Clients should use the {@link #JLS3} AST API instead.
108
	 */
111
	 */
109
	public static final int JLS2 = 2;
112
	public static final int JLS2 = 2;
110
	
113
111
	/**
114
	/**
112
	 * Internal synonym for {@link #JLS2}. Use to alleviate
115
	 * Internal synonym for {@link #JLS2}. Use to alleviate
113
	 * deprecation warnings.
116
	 * deprecation warnings.
Lines 123-159 Link Here
123
     * JLS3 is a superset of all earlier versions of the
126
     * JLS3 is a superset of all earlier versions of the
124
     * Java language, and the JLS3 API can be used to manipulate
127
     * Java language, and the JLS3 API can be used to manipulate
125
     * programs written in all versions of the Java language
128
     * programs written in all versions of the Java language
126
     * up to and including J2SE 5 (aka JDK 1.5). 
129
     * up to and including J2SE 5 (aka JDK 1.5).
127
     *
130
     *
128
	 * @since 3.1
131
	 * @since 3.1
129
	 */
132
	 */
130
	public static final int JLS3 = 3;
133
	public static final int JLS3 = 3;
131
	
134
132
	/**
135
	/**
133
	 * The binding resolver for this AST. Initially a binding resolver that
136
	 * The binding resolver for this AST. Initially a binding resolver that
134
	 * does not resolve names at all.
137
	 * does not resolve names at all.
135
	 */
138
	 */
136
	private BindingResolver resolver = new BindingResolver();
139
	private BindingResolver resolver = new BindingResolver();
137
	
140
138
	/**
141
	/**
139
	 * The event handler for this AST. 
142
	 * The event handler for this AST.
140
	 * Initially an event handler that does not nothing.
143
	 * Initially an event handler that does not nothing.
141
	 * @since 3.0
144
	 * @since 3.0
142
	 */
145
	 */
143
	private NodeEventHandler eventHandler = new NodeEventHandler();
146
	private NodeEventHandler eventHandler = new NodeEventHandler();
144
	
147
145
	/**
148
	/**
146
	 * Level of AST API supported by this AST.
149
	 * Level of AST API supported by this AST.
147
	 * @since 3.0
150
	 * @since 3.0
148
	 */
151
	 */
149
	int apiLevel;
152
	int apiLevel;
150
	
153
151
	/**
154
	/**
152
	 * Internal modification count; initially 0; increases monotonically
155
	 * Internal modification count; initially 0; increases monotonically
153
	 * <b>by one or more</b> as the AST is successively modified.
156
	 * <b>by one or more</b> as the AST is successively modified.
154
	 */
157
	 */
155
	private long modificationCount = 0;
158
	private long modificationCount = 0;
156
	
159
157
	/**
160
	/**
158
	 * Internal original modification count; value is equals to <code>
161
	 * Internal original modification count; value is equals to <code>
159
	 * modificationCount</code> at the end of the parse (<code>ASTParser
162
	 * modificationCount</code> at the end of the parse (<code>ASTParser
Lines 173-179 Link Here
173
	 * @since 3.0
176
	 * @since 3.0
174
	 */
177
	 */
175
	private int disableEvents = 0;
178
	private int disableEvents = 0;
176
	
179
177
	/**
180
	/**
178
	 * Internal object unique to the AST instance. Readers must synchronize on
181
	 * Internal object unique to the AST instance. Readers must synchronize on
179
	 * this object when the modifying instance fields.
182
	 * this object when the modifying instance fields.
Lines 186-206 Link Here
186
	 * like CharacterLiteral, NumberLiteral, StringLiteral or SimpleName.
189
	 * like CharacterLiteral, NumberLiteral, StringLiteral or SimpleName.
187
	 */
190
	 */
188
	Scanner scanner;
191
	Scanner scanner;
189
	
192
190
	/**
193
	/**
191
	 * Internal ast rewriter used to record ast modification when record mode is enabled.
194
	 * Internal ast rewriter used to record ast modification when record mode is enabled.
192
	 */
195
	 */
193
	InternalASTRewrite rewriter;
196
	InternalASTRewrite rewriter;
194
	
197
195
	/**
198
	/**
196
	 * Default value of <code>flag<code> when a new node is created.
199
	 * Default value of <code>flag<code> when a new node is created.
197
	 */
200
	 */
198
	private int defaultNodeFlag = 0;
201
	private int defaultNodeFlag = 0;
199
	
202
203
	/**
204
	 * Tag bit value. This represents internal state of the tree.
205
	 */
206
	private int bits;
207
200
	/**
208
	/**
201
	 * Creates a new Java abstract syntax tree
209
	 * Creates a new Java abstract syntax tree
202
     * (AST) following the specified set of API rules. 
210
     * (AST) following the specified set of API rules.
203
     * 
211
     *
204
 	 * @param level the API level; one of the LEVEL constants
212
 	 * @param level the API level; one of the LEVEL constants
205
     * @since 3.0
213
     * @since 3.0
206
	 */
214
	 */
Lines 212-230 Link Here
212
		this.apiLevel = level;
220
		this.apiLevel = level;
213
		// initialize a scanner
221
		// initialize a scanner
214
		this.scanner = new Scanner(
222
		this.scanner = new Scanner(
215
				true /*comment*/, 
223
				true /*comment*/,
216
				true /*whitespace*/, 
224
				true /*whitespace*/,
217
				false /*nls*/, 
225
				false /*nls*/,
218
				ClassFileConstants.JDK1_3 /*sourceLevel*/, 
226
				ClassFileConstants.JDK1_3 /*sourceLevel*/,
219
				ClassFileConstants.JDK1_5 /*complianceLevel*/, 
227
				ClassFileConstants.JDK1_5 /*complianceLevel*/,
220
				null/*taskTag*/, 
228
				null/*taskTag*/,
221
				null/*taskPriorities*/,
229
				null/*taskPriorities*/,
222
				true/*taskCaseSensitive*/);
230
				true/*taskCaseSensitive*/);
223
	}
231
	}
224
232
225
	/**
233
	/**
226
	 * Creates a new, empty abstract syntax tree using default options.
234
	 * Creates a new, empty abstract syntax tree using default options.
227
	 * 
235
	 *
228
	 * @see JavaCore#getDefaultOptions()
236
	 * @see JavaCore#getDefaultOptions()
229
	 * @deprecated Clients should port their code to use the new JLS3 AST API and call
237
	 * @deprecated Clients should port their code to use the new JLS3 AST API and call
230
	 *    {@link #newAST(int) AST.newAST(AST.JLS3)} instead of using this constructor.
238
	 *    {@link #newAST(int) AST.newAST(AST.JLS3)} instead of using this constructor.
Lines 239-245 Link Here
239
	 * This method converts the given internal compiler AST for the given source string
247
	 * This method converts the given internal compiler AST for the given source string
240
	 * into a compilation unit. This method is not intended to be called by clients.
248
	 * into a compilation unit. This method is not intended to be called by clients.
241
	 * </p>
249
	 * </p>
242
	 * 
250
	 *
243
 	 * @param level the API level; one of the LEVEL constants
251
 	 * @param level the API level; one of the LEVEL constants
244
	 * @param compilationUnitDeclaration an internal AST node for a compilation unit declaration
252
	 * @param compilationUnitDeclaration an internal AST node for a compilation unit declaration
245
	 * @param source the string of the Java compilation unit
253
	 * @param source the string of the Java compilation unit
Lines 257-272 Link Here
257
		Map options,
265
		Map options,
258
		boolean isResolved,
266
		boolean isResolved,
259
		org.eclipse.jdt.internal.core.CompilationUnit workingCopy,
267
		org.eclipse.jdt.internal.core.CompilationUnit workingCopy,
268
		boolean statementRecovery,
260
		IProgressMonitor monitor) {
269
		IProgressMonitor monitor) {
261
		
270
262
		ASTConverter converter = new ASTConverter(options, isResolved, monitor);
271
		ASTConverter converter = new ASTConverter(options, isResolved, monitor);
263
		AST ast = AST.newAST(level);
272
		AST ast = AST.newAST(level);
273
		if (statementRecovery) {
274
			ast.setFlag(AST.STATEMENT_RECOVERY);
275
		}
264
		int savedDefaultNodeFlag = ast.getDefaultNodeFlag();
276
		int savedDefaultNodeFlag = ast.getDefaultNodeFlag();
265
		ast.setDefaultNodeFlag(ASTNode.ORIGINAL);
277
		ast.setDefaultNodeFlag(ASTNode.ORIGINAL);
266
		BindingResolver resolver = isResolved ? new DefaultBindingResolver(compilationUnitDeclaration.scope, workingCopy.owner, new DefaultBindingResolver.BindingTables()) : new BindingResolver();
278
		BindingResolver resolver = null;
279
		if (isResolved) {
280
			ast.setFlag(AST.RESOLVED_BINDINGS);
281
			resolver = new DefaultBindingResolver(compilationUnitDeclaration.scope, workingCopy.owner, new DefaultBindingResolver.BindingTables());
282
		} else {
283
			resolver = new BindingResolver();
284
		}
267
		ast.setBindingResolver(resolver);
285
		ast.setBindingResolver(resolver);
268
		converter.setAST(ast);
286
		converter.setAST(ast);
269
	
287
270
		CompilationUnit unit = converter.convert(compilationUnitDeclaration, source);
288
		CompilationUnit unit = converter.convert(compilationUnitDeclaration, source);
271
		unit.setLineEndTable(compilationUnitDeclaration.compilationResult.getLineSeparatorPositions());
289
		unit.setLineEndTable(compilationUnitDeclaration.compilationResult.getLineSeparatorPositions());
272
		unit.setTypeRoot(workingCopy);
290
		unit.setTypeRoot(workingCopy);
Lines 279-285 Link Here
279
	 * <p>
297
	 * <p>
280
	 * Following option keys are significant:
298
	 * Following option keys are significant:
281
	 * <ul>
299
	 * <ul>
282
	 * <li><code>"org.eclipse.jdt.core.compiler.source"</code> - 
300
	 * <li><code>"org.eclipse.jdt.core.compiler.source"</code> -
283
	 *    indicates source compatibility mode (as per <code>JavaCore</code>);
301
	 *    indicates source compatibility mode (as per <code>JavaCore</code>);
284
	 *    <code>"1.3"</code> means the source code is as per JDK 1.3;
302
	 *    <code>"1.3"</code> means the source code is as per JDK 1.3;
285
	 *    <code>"1.4"</code> means the source code is as per JDK 1.4
303
	 *    <code>"1.4"</code> means the source code is as per JDK 1.4
Lines 290-296 Link Here
290
	 * </ul>
308
	 * </ul>
291
	 * Options other than the above are ignored.
309
	 * Options other than the above are ignored.
292
	 * </p>
310
	 * </p>
293
	 * 
311
	 *
294
	 * @param options the table of options (key type: <code>String</code>;
312
	 * @param options the table of options (key type: <code>String</code>;
295
	 *    value type: <code>String</code>)
313
	 *    value type: <code>String</code>)
296
	 * @see JavaCore#getDefaultOptions()
314
	 * @see JavaCore#getDefaultOptions()
Lines 315-338 Link Here
315
		}
333
		}
316
		// override scanner if 1.4 or 1.5 asked for
334
		// override scanner if 1.4 or 1.5 asked for
317
		this.scanner = new Scanner(
335
		this.scanner = new Scanner(
318
			true /*comment*/, 
336
			true /*comment*/,
319
			true /*whitespace*/, 
337
			true /*whitespace*/,
320
			false /*nls*/, 
338
			false /*nls*/,
321
			sourceLevel /*sourceLevel*/,
339
			sourceLevel /*sourceLevel*/,
322
			complianceLevel /*complianceLevel*/,
340
			complianceLevel /*complianceLevel*/,
323
			null/*taskTag*/, 
341
			null/*taskTag*/,
324
			null/*taskPriorities*/,
342
			null/*taskPriorities*/,
325
			true/*taskCaseSensitive*/);
343
			true/*taskCaseSensitive*/);
326
	}
344
	}
327
		
345
328
	/**
346
	/**
329
	 * Creates a new Java abstract syntax tree
347
	 * Creates a new Java abstract syntax tree
330
     * (AST) following the specified set of API rules. 
348
     * (AST) following the specified set of API rules.
331
     * <p>
349
     * <p>
332
     * Clients should use this method specifing {@link #JLS3} as the
350
     * Clients should use this method specifing {@link #JLS3} as the
333
     * AST level in all cases, even when dealing with JDK 1.3 or 1.4..
351
     * AST level in all cases, even when dealing with JDK 1.3 or 1.4..
334
     * </p>
352
     * </p>
335
     * 
353
     *
336
 	 * @param level the API level; one of the LEVEL constants
354
 	 * @param level the API level; one of the LEVEL constants
337
	 * @return new AST instance following the specified set of API rules.
355
	 * @return new AST instance following the specified set of API rules.
338
	 * @exception IllegalArgumentException if:
356
	 * @exception IllegalArgumentException if:
Lines 367-376 Link Here
367
	 * <p>
385
	 * <p>
368
	 * N.B. This method may be called several times in the course
386
	 * N.B. This method may be called several times in the course
369
	 * of a single client operation. The only promise is that the modification
387
	 * of a single client operation. The only promise is that the modification
370
	 * count increases monotonically as the AST or its nodes change; there is 
388
	 * count increases monotonically as the AST or its nodes change; there is
371
	 * no promise that a modifying operation increases the count by exactly 1.
389
	 * no promise that a modifying operation increases the count by exactly 1.
372
	 * </p>
390
	 * </p>
373
	 * 
391
	 *
374
	 * @return the current value (non-negative) of the modification counter of
392
	 * @return the current value (non-negative) of the modification counter of
375
	 *    this AST
393
	 *    this AST
376
	 */
394
	 */
Lines 380-392 Link Here
380
398
381
	/**
399
	/**
382
	 * Return the API level supported by this AST.
400
	 * Return the API level supported by this AST.
383
	 * 
401
	 *
384
	 * @return level the API level; one of the <code>JLS*</code>LEVEL
402
	 * @return level the API level; one of the <code>JLS*</code>LEVEL
385
     * declared on <code>AST</code>; assume this set is open-ended
403
     * declared on <code>AST</code>; assume this set is open-ended
386
     * @since 3.0
404
     * @since 3.0
387
	 */
405
	 */
388
	public int apiLevel() {
406
	public int apiLevel() {
389
		return this.apiLevel;	
407
		return this.apiLevel;
390
	}
408
	}
391
409
392
	/**
410
	/**
Lines 403-409 Link Here
403
	 * <p>
421
	 * <p>
404
	 * N.B. This method may be called several times in the course
422
	 * N.B. This method may be called several times in the course
405
	 * of a single client operation.
423
	 * of a single client operation.
406
	 * </p> 
424
	 * </p>
407
	 */
425
	 */
408
	void modifying() {
426
	void modifying() {
409
		// when this method is called during lazy init, events are disabled
427
		// when this method is called during lazy init, events are disabled
Lines 418-424 Link Here
418
	/**
436
	/**
419
     * Disable events.
437
     * Disable events.
420
	 * This method is thread-safe for AST readers.
438
	 * This method is thread-safe for AST readers.
421
	 * 
439
	 *
422
	 * @see #reenableEvents()
440
	 * @see #reenableEvents()
423
     * @since 3.0
441
     * @since 3.0
424
     */
442
     */
Lines 429-439 Link Here
429
		}
447
		}
430
		// while disableEvents > 0 no events will be reported, and mod count will stay fixed
448
		// while disableEvents > 0 no events will be reported, and mod count will stay fixed
431
	}
449
	}
432
	
450
433
	/**
451
	/**
434
     * Reenable events.
452
     * Reenable events.
435
	 * This method is thread-safe for AST readers.
453
	 * This method is thread-safe for AST readers.
436
	 * 
454
	 *
437
	 * @see #disableEvents()
455
	 * @see #disableEvents()
438
     * @since 3.0
456
     * @since 3.0
439
     */
457
     */
Lines 443-452 Link Here
443
			this.disableEvents--;
461
			this.disableEvents--;
444
		}
462
		}
445
	}
463
	}
446
	
464
447
	/**
465
	/**
448
	 * Reports that the given node is about to lose a child.
466
	 * Reports that the given node is about to lose a child.
449
	 * 
467
	 *
450
	 * @param node the node about to be modified
468
	 * @param node the node about to be modified
451
	 * @param child the node about to be removed
469
	 * @param child the node about to be removed
452
	 * @param property the child or child list property descriptor
470
	 * @param property the child or child list property descriptor
Lines 472-481 Link Here
472
			reenableEvents();
490
			reenableEvents();
473
		}
491
		}
474
	}
492
	}
475
	
493
476
	/**
494
	/**
477
	 * Reports that the given node jsut lost a child.
495
	 * Reports that the given node jsut lost a child.
478
	 * 
496
	 *
479
	 * @param node the node that was modified
497
	 * @param node the node that was modified
480
	 * @param child the child node that was removed
498
	 * @param child the child node that was removed
481
	 * @param property the child or child list property descriptor
499
	 * @param property the child or child list property descriptor
Lines 501-510 Link Here
501
			reenableEvents();
519
			reenableEvents();
502
		}
520
		}
503
	}
521
	}
504
	
522
505
	/**
523
	/**
506
	 * Reports that the given node is about have a child replaced.
524
	 * Reports that the given node is about have a child replaced.
507
	 * 
525
	 *
508
	 * @param node the node about to be modified
526
	 * @param node the node about to be modified
509
	 * @param child the child node about to be removed
527
	 * @param child the child node about to be removed
510
	 * @param newChild the replacement child
528
	 * @param newChild the replacement child
Lines 531-540 Link Here
531
			reenableEvents();
549
			reenableEvents();
532
		}
550
		}
533
	}
551
	}
534
	
552
535
	/**
553
	/**
536
	 * Reports that the given node has just had a child replaced.
554
	 * Reports that the given node has just had a child replaced.
537
	 * 
555
	 *
538
	 * @param node the node modified
556
	 * @param node the node modified
539
	 * @param child the child removed
557
	 * @param child the child removed
540
	 * @param newChild the replacement child
558
	 * @param newChild the replacement child
Lines 561-570 Link Here
561
			reenableEvents();
579
			reenableEvents();
562
		}
580
		}
563
	}
581
	}
564
	
582
565
	/**
583
	/**
566
	 * Reports that the given node is about to gain a child.
584
	 * Reports that the given node is about to gain a child.
567
	 * 
585
	 *
568
	 * @param node the node that to be modified
586
	 * @param node the node that to be modified
569
	 * @param child the node that to be added as a child
587
	 * @param child the node that to be added as a child
570
	 * @param property the child or child list property descriptor
588
	 * @param property the child or child list property descriptor
Lines 590-599 Link Here
590
			reenableEvents();
608
			reenableEvents();
591
		}
609
		}
592
	}
610
	}
593
	
611
594
	/**
612
	/**
595
	 * Reports that the given node has just gained a child.
613
	 * Reports that the given node has just gained a child.
596
	 * 
614
	 *
597
	 * @param node the node that was modified
615
	 * @param node the node that was modified
598
	 * @param child the node that was added as a child
616
	 * @param child the node that was added as a child
599
	 * @param property the child or child list property descriptor
617
	 * @param property the child or child list property descriptor
Lines 619-629 Link Here
619
			reenableEvents();
637
			reenableEvents();
620
		}
638
		}
621
	}
639
	}
622
	
640
623
	/**
641
	/**
624
	 * Reports that the given node is about to change the value of a
642
	 * Reports that the given node is about to change the value of a
625
	 * non-child property.
643
	 * non-child property.
626
	 * 
644
	 *
627
	 * @param node the node to be modified
645
	 * @param node the node to be modified
628
	 * @param property the property descriptor
646
	 * @param property the property descriptor
629
	 * @since 3.0
647
	 * @since 3.0
Lines 648-658 Link Here
648
			reenableEvents();
666
			reenableEvents();
649
		}
667
		}
650
	}
668
	}
651
	
669
652
	/**
670
	/**
653
	 * Reports that the given node has just changed the value of a
671
	 * Reports that the given node has just changed the value of a
654
	 * non-child property.
672
	 * non-child property.
655
	 * 
673
	 *
656
	 * @param node the node that was modified
674
	 * @param node the node that was modified
657
	 * @param property the property descriptor
675
	 * @param property the property descriptor
658
	 * @since 3.0
676
	 * @since 3.0
Lines 677-686 Link Here
677
			reenableEvents();
695
			reenableEvents();
678
		}
696
		}
679
	}
697
	}
680
	
698
681
	/**
699
	/**
682
	 * Reports that the given node is about to be cloned.
700
	 * Reports that the given node is about to be cloned.
683
	 * 
701
	 *
684
	 * @param node the node to be cloned
702
	 * @param node the node to be cloned
685
	 * @since 3.0
703
	 * @since 3.0
686
	 */
704
	 */
Lines 703-712 Link Here
703
			reenableEvents();
721
			reenableEvents();
704
		}
722
		}
705
	}
723
	}
706
	
724
707
	/**
725
	/**
708
	 * Reports that the given node has just been cloned.
726
	 * Reports that the given node has just been cloned.
709
	 * 
727
	 *
710
	 * @param node the node that was cloned
728
	 * @param node the node that was cloned
711
	 * @param clone the clone of <code>node</code>
729
	 * @param clone the clone of <code>node</code>
712
	 * @since 3.0
730
	 * @since 3.0
Lines 730-739 Link Here
730
			reenableEvents();
748
			reenableEvents();
731
		}
749
		}
732
	}
750
	}
733
	
751
734
	/**
752
	/**
735
	 * Parses the source string of the given Java model compilation unit element
753
	 * Parses the source string of the given Java model compilation unit element
736
	 * and creates and returns a corresponding abstract syntax tree. The source 
754
	 * and creates and returns a corresponding abstract syntax tree. The source
737
	 * string is obtained from the Java model element using
755
	 * string is obtained from the Java model element using
738
	 * <code>ICompilationUnit.getSource()</code>.
756
	 * <code>ICompilationUnit.getSource()</code>.
739
	 * <p>
757
	 * <p>
Lines 741-747 Link Here
741
	 * Each node in the subtree carries source range(s) information relating back
759
	 * Each node in the subtree carries source range(s) information relating back
742
	 * to positions in the source string (the source string is not remembered
760
	 * to positions in the source string (the source string is not remembered
743
	 * with the AST).
761
	 * with the AST).
744
	 * The source range usually begins at the first character of the first token 
762
	 * The source range usually begins at the first character of the first token
745
	 * corresponding to the node; leading whitespace and comments are <b>not</b>
763
	 * corresponding to the node; leading whitespace and comments are <b>not</b>
746
	 * included. The source range usually extends through the last character of
764
	 * included. The source range usually extends through the last character of
747
	 * the last token corresponding to the node; trailing whitespace and
765
	 * the last token corresponding to the node; trailing whitespace and
Lines 757-768 Link Here
757
	 * <p>
775
	 * <p>
758
	 * If <code>resolveBindings</code> is <code>true</code>, the various names
776
	 * If <code>resolveBindings</code> is <code>true</code>, the various names
759
	 * and types appearing in the compilation unit can be resolved to "bindings"
777
	 * and types appearing in the compilation unit can be resolved to "bindings"
760
	 * by calling the <code>resolveBinding</code> methods. These bindings 
778
	 * by calling the <code>resolveBinding</code> methods. These bindings
761
	 * draw connections between the different parts of a program, and 
779
	 * draw connections between the different parts of a program, and
762
	 * generally afford a more powerful vantage point for clients who wish to
780
	 * generally afford a more powerful vantage point for clients who wish to
763
	 * analyze a program's structure more deeply. These bindings come at a 
781
	 * analyze a program's structure more deeply. These bindings come at a
764
	 * considerable cost in both time and space, however, and should not be
782
	 * considerable cost in both time and space, however, and should not be
765
	 * requested frivolously. The additional space is not reclaimed until the 
783
	 * requested frivolously. The additional space is not reclaimed until the
766
	 * AST, all its nodes, and all its bindings become garbage. So it is very
784
	 * AST, all its nodes, and all its bindings become garbage. So it is very
767
	 * important to not retain any of these objects longer than absolutely
785
	 * important to not retain any of these objects longer than absolutely
768
	 * necessary. Bindings are resolved at the time the AST is created. Subsequent
786
	 * necessary. Bindings are resolved at the time the AST is created. Subsequent
Lines 770-786 Link Here
770
	 * <code>resolveBinding</code> methods in any way; these methods return the
788
	 * <code>resolveBinding</code> methods in any way; these methods return the
771
	 * same binding as before the AST was modified (including modifications
789
	 * same binding as before the AST was modified (including modifications
772
	 * that rearrange subtrees by reparenting nodes).
790
	 * that rearrange subtrees by reparenting nodes).
773
	 * If <code>resolveBindings</code> is <code>false</code>, the analysis 
791
	 * If <code>resolveBindings</code> is <code>false</code>, the analysis
774
	 * does not go beyond parsing and building the tree, and all 
792
	 * does not go beyond parsing and building the tree, and all
775
	 * <code>resolveBinding</code> methods return <code>null</code> from the 
793
	 * <code>resolveBinding</code> methods return <code>null</code> from the
776
	 * outset.
794
	 * outset.
777
	 * </p>
795
	 * </p>
778
	 * 
796
	 *
779
	 * @param unit the Java model compilation unit whose source code is to be parsed
797
	 * @param unit the Java model compilation unit whose source code is to be parsed
780
	 * @param resolveBindings <code>true</code> if bindings are wanted, 
798
	 * @param resolveBindings <code>true</code> if bindings are wanted,
781
	 *   and <code>false</code> if bindings are not of interest
799
	 *   and <code>false</code> if bindings are not of interest
782
	 * @return the compilation unit node
800
	 * @return the compilation unit node
783
	 * @exception IllegalArgumentException if the given Java element does not 
801
	 * @exception IllegalArgumentException if the given Java element does not
784
	 * exist or if its source string cannot be obtained
802
	 * exist or if its source string cannot be obtained
785
	 * @see ASTNode#getFlags()
803
	 * @see ASTNode#getFlags()
786
	 * @see ASTNode#MALFORMED
804
	 * @see ASTNode#MALFORMED
Lines 804-810 Link Here
804
			throw new IllegalArgumentException();
822
			throw new IllegalArgumentException();
805
		}
823
		}
806
	}
824
	}
807
	
825
808
	/**
826
	/**
809
	 * Parses the source string corresponding to the given Java class file
827
	 * Parses the source string corresponding to the given Java class file
810
	 * element and creates and returns a corresponding abstract syntax tree.
828
	 * element and creates and returns a corresponding abstract syntax tree.
Lines 816-822 Link Here
816
	 * Each node in the subtree carries source range(s) information relating back
834
	 * Each node in the subtree carries source range(s) information relating back
817
	 * to positions in the source string (the source string is not remembered
835
	 * to positions in the source string (the source string is not remembered
818
	 * with the AST).
836
	 * with the AST).
819
	 * The source range usually begins at the first character of the first token 
837
	 * The source range usually begins at the first character of the first token
820
	 * corresponding to the node; leading whitespace and comments are <b>not</b>
838
	 * corresponding to the node; leading whitespace and comments are <b>not</b>
821
	 * included. The source range usually extends through the last character of
839
	 * included. The source range usually extends through the last character of
822
	 * the last token corresponding to the node; trailing whitespace and
840
	 * the last token corresponding to the node; trailing whitespace and
Lines 832-843 Link Here
832
	 * <p>
850
	 * <p>
833
	 * If <code>resolveBindings</code> is <code>true</code>, the various names
851
	 * If <code>resolveBindings</code> is <code>true</code>, the various names
834
	 * and types appearing in the compilation unit can be resolved to "bindings"
852
	 * and types appearing in the compilation unit can be resolved to "bindings"
835
	 * by calling the <code>resolveBinding</code> methods. These bindings 
853
	 * by calling the <code>resolveBinding</code> methods. These bindings
836
	 * draw connections between the different parts of a program, and 
854
	 * draw connections between the different parts of a program, and
837
	 * generally afford a more powerful vantage point for clients who wish to
855
	 * generally afford a more powerful vantage point for clients who wish to
838
	 * analyze a program's structure more deeply. These bindings come at a 
856
	 * analyze a program's structure more deeply. These bindings come at a
839
	 * considerable cost in both time and space, however, and should not be
857
	 * considerable cost in both time and space, however, and should not be
840
	 * requested frivolously. The additional space is not reclaimed until the 
858
	 * requested frivolously. The additional space is not reclaimed until the
841
	 * AST, all its nodes, and all its bindings become garbage. So it is very
859
	 * AST, all its nodes, and all its bindings become garbage. So it is very
842
	 * important to not retain any of these objects longer than absolutely
860
	 * important to not retain any of these objects longer than absolutely
843
	 * necessary. Bindings are resolved at the time the AST is created. Subsequent
861
	 * necessary. Bindings are resolved at the time the AST is created. Subsequent
Lines 845-861 Link Here
845
	 * <code>resolveBinding</code> methods in any way; these methods return the
863
	 * <code>resolveBinding</code> methods in any way; these methods return the
846
	 * same binding as before the AST was modified (including modifications
864
	 * same binding as before the AST was modified (including modifications
847
	 * that rearrange subtrees by reparenting nodes).
865
	 * that rearrange subtrees by reparenting nodes).
848
	 * If <code>resolveBindings</code> is <code>false</code>, the analysis 
866
	 * If <code>resolveBindings</code> is <code>false</code>, the analysis
849
	 * does not go beyond parsing and building the tree, and all 
867
	 * does not go beyond parsing and building the tree, and all
850
	 * <code>resolveBinding</code> methods return <code>null</code> from the 
868
	 * <code>resolveBinding</code> methods return <code>null</code> from the
851
	 * outset.
869
	 * outset.
852
	 * </p>
870
	 * </p>
853
	 * 
871
	 *
854
	 * @param classFile the Java model class file whose corresponding source code is to be parsed
872
	 * @param classFile the Java model class file whose corresponding source code is to be parsed
855
	 * @param resolveBindings <code>true</code> if bindings are wanted, 
873
	 * @param resolveBindings <code>true</code> if bindings are wanted,
856
	 *   and <code>false</code> if bindings are not of interest
874
	 *   and <code>false</code> if bindings are not of interest
857
	 * @return the compilation unit node
875
	 * @return the compilation unit node
858
	 * @exception IllegalArgumentException if the given Java element does not 
876
	 * @exception IllegalArgumentException if the given Java element does not
859
	 * exist or if its source string cannot be obtained
877
	 * exist or if its source string cannot be obtained
860
	 * @see ASTNode#getFlags()
878
	 * @see ASTNode#getFlags()
861
	 * @see ASTNode#MALFORMED
879
	 * @see ASTNode#MALFORMED
Lines 882-888 Link Here
882
			throw new IllegalArgumentException();
900
			throw new IllegalArgumentException();
883
		}
901
		}
884
	}
902
	}
885
	
903
886
	/**
904
	/**
887
	 * Parses the given string as the hypothetical contents of the named
905
	 * Parses the given string as the hypothetical contents of the named
888
	 * compilation unit and creates and returns a corresponding abstract syntax tree.
906
	 * compilation unit and creates and returns a corresponding abstract syntax tree.
Lines 891-897 Link Here
891
	 * Each node in the subtree carries source range(s) information relating back
909
	 * Each node in the subtree carries source range(s) information relating back
892
	 * to positions in the given source string (the given source string itself
910
	 * to positions in the given source string (the given source string itself
893
	 * is not remembered with the AST).
911
	 * is not remembered with the AST).
894
	 * The source range usually begins at the first character of the first token 
912
	 * The source range usually begins at the first character of the first token
895
	 * corresponding to the node; leading whitespace and comments are <b>not</b>
913
	 * corresponding to the node; leading whitespace and comments are <b>not</b>
896
	 * included. The source range usually extends through the last character of
914
	 * included. The source range usually extends through the last character of
897
	 * the last token corresponding to the node; trailing whitespace and
915
	 * the last token corresponding to the node; trailing whitespace and
Lines 907-918 Link Here
907
	 * <p>
925
	 * <p>
908
	 * If the given project is not <code>null</code>, the various names
926
	 * If the given project is not <code>null</code>, the various names
909
	 * and types appearing in the compilation unit can be resolved to "bindings"
927
	 * and types appearing in the compilation unit can be resolved to "bindings"
910
	 * by calling the <code>resolveBinding</code> methods. These bindings 
928
	 * by calling the <code>resolveBinding</code> methods. These bindings
911
	 * draw connections between the different parts of a program, and 
929
	 * draw connections between the different parts of a program, and
912
	 * generally afford a more powerful vantage point for clients who wish to
930
	 * generally afford a more powerful vantage point for clients who wish to
913
	 * analyze a program's structure more deeply. These bindings come at a 
931
	 * analyze a program's structure more deeply. These bindings come at a
914
	 * considerable cost in both time and space, however, and should not be
932
	 * considerable cost in both time and space, however, and should not be
915
	 * requested frivolously. The additional space is not reclaimed until the 
933
	 * requested frivolously. The additional space is not reclaimed until the
916
	 * AST, all its nodes, and all its bindings become garbage. So it is very
934
	 * AST, all its nodes, and all its bindings become garbage. So it is very
917
	 * important to not retain any of these objects longer than absolutely
935
	 * important to not retain any of these objects longer than absolutely
918
	 * necessary. Bindings are resolved at the time the AST is created. Subsequent
936
	 * necessary. Bindings are resolved at the time the AST is created. Subsequent
Lines 920-934 Link Here
920
	 * <code>resolveBinding</code> methods in any way; these methods return the
938
	 * <code>resolveBinding</code> methods in any way; these methods return the
921
	 * same binding as before the AST was modified (including modifications
939
	 * same binding as before the AST was modified (including modifications
922
	 * that rearrange subtrees by reparenting nodes).
940
	 * that rearrange subtrees by reparenting nodes).
923
	 * If the given project is <code>null</code>, the analysis 
941
	 * If the given project is <code>null</code>, the analysis
924
	 * does not go beyond parsing and building the tree, and all 
942
	 * does not go beyond parsing and building the tree, and all
925
	 * <code>resolveBinding</code> methods return <code>null</code> from the 
943
	 * <code>resolveBinding</code> methods return <code>null</code> from the
926
	 * outset.
944
	 * outset.
927
	 * </p>
945
	 * </p>
928
	 * <p>
946
	 * <p>
929
	 * The name of the compilation unit must be supplied for resolving bindings.
947
	 * The name of the compilation unit must be supplied for resolving bindings.
930
	 * This name should be suffixed by a dot ('.') followed by one of the 
948
	 * This name should be suffixed by a dot ('.') followed by one of the
931
	 * {@link JavaCore#getJavaLikeExtensions() Java-like extensions} 
949
	 * {@link JavaCore#getJavaLikeExtensions() Java-like extensions}
932
	 * and match the name of the main
950
	 * and match the name of the main
933
	 * (public) class or interface declared in the source. For example, if the source
951
	 * (public) class or interface declared in the source. For example, if the source
934
	 * declares a public class named "Foo", the name of the compilation can be
952
	 * declares a public class named "Foo", the name of the compilation can be
Lines 936-946 Link Here
936
	 * source string hide types by the same name available through the classpath
954
	 * source string hide types by the same name available through the classpath
937
	 * of the given project.
955
	 * of the given project.
938
	 * </p>
956
	 * </p>
939
	 * 
957
	 *
940
	 * @param source the string to be parsed as a Java compilation unit
958
	 * @param source the string to be parsed as a Java compilation unit
941
	 * @param unitName the name of the compilation unit that would contain the source
959
	 * @param unitName the name of the compilation unit that would contain the source
942
	 *    string, or <code>null</code> if <code>javaProject</code> is also <code>null</code>
960
	 *    string, or <code>null</code> if <code>javaProject</code> is also <code>null</code>
943
	 * @param project the Java project used to resolve names, or 
961
	 * @param project the Java project used to resolve names, or
944
	 *    <code>null</code> if bindings are not resolved
962
	 *    <code>null</code> if bindings are not resolved
945
	 * @return the compilation unit node
963
	 * @return the compilation unit node
946
	 * @see ASTNode#getFlags()
964
	 * @see ASTNode#getFlags()
Lines 966-981 Link Here
966
		ASTNode result = astParser.createAST(null);
984
		ASTNode result = astParser.createAST(null);
967
		return (CompilationUnit) result;
985
		return (CompilationUnit) result;
968
	}
986
	}
969
				
987
970
	/**
988
	/**
971
	 * Parses the given string as a Java compilation unit and creates and 
989
	 * Parses the given string as a Java compilation unit and creates and
972
	 * returns a corresponding abstract syntax tree.
990
	 * returns a corresponding abstract syntax tree.
973
	 * <p>
991
	 * <p>
974
	 * The returned compilation unit node is the root node of a new AST.
992
	 * The returned compilation unit node is the root node of a new AST.
975
	 * Each node in the subtree carries source range(s) information relating back
993
	 * Each node in the subtree carries source range(s) information relating back
976
	 * to positions in the given source string (the given source string itself
994
	 * to positions in the given source string (the given source string itself
977
	 * is not remembered with the AST). 
995
	 * is not remembered with the AST).
978
	 * The source range usually begins at the first character of the first token 
996
	 * The source range usually begins at the first character of the first token
979
	 * corresponding to the node; leading whitespace and comments are <b>not</b>
997
	 * corresponding to the node; leading whitespace and comments are <b>not</b>
980
	 * included. The source range usually extends through the last character of
998
	 * included. The source range usually extends through the last character of
981
	 * the last token corresponding to the node; trailing whitespace and
999
	 * the last token corresponding to the node; trailing whitespace and
Lines 992-998 Link Here
992
	 * This method does not compute binding information; all <code>resolveBinding</code>
1010
	 * This method does not compute binding information; all <code>resolveBinding</code>
993
	 * methods applied to nodes of the resulting AST return <code>null</code>.
1011
	 * methods applied to nodes of the resulting AST return <code>null</code>.
994
	 * </p>
1012
	 * </p>
995
	 * 
1013
	 *
996
	 * @param source the string to be parsed as a Java compilation unit
1014
	 * @param source the string to be parsed as a Java compilation unit
997
	 * @return the compilation unit node
1015
	 * @return the compilation unit node
998
	 * @see ASTNode#getFlags()
1016
	 * @see ASTNode#getFlags()
Lines 1014-1020 Link Here
1014
1032
1015
	/**
1033
	/**
1016
	 * Returns the binding resolver for this AST.
1034
	 * Returns the binding resolver for this AST.
1017
	 * 
1035
	 *
1018
	 * @return the binding resolver for this AST
1036
	 * @return the binding resolver for this AST
1019
	 */
1037
	 */
1020
	BindingResolver getBindingResolver() {
1038
	BindingResolver getBindingResolver() {
Lines 1023-1029 Link Here
1023
1041
1024
	/**
1042
	/**
1025
	 * Returns the event handler for this AST.
1043
	 * Returns the event handler for this AST.
1026
	 * 
1044
	 *
1027
	 * @return the event handler for this AST
1045
	 * @return the event handler for this AST
1028
	 * @since 3.0
1046
	 * @since 3.0
1029
	 */
1047
	 */
Lines 1033-1039 Link Here
1033
1051
1034
	/**
1052
	/**
1035
	 * Sets the event handler for this AST.
1053
	 * Sets the event handler for this AST.
1036
	 * 
1054
	 *
1037
	 * @param eventHandler the event handler for this AST
1055
	 * @param eventHandler the event handler for this AST
1038
	 * @since 3.0
1056
	 * @since 3.0
1039
	 */
1057
	 */
Lines 1043-1079 Link Here
1043
		}
1061
		}
1044
		this.eventHandler = eventHandler;
1062
		this.eventHandler = eventHandler;
1045
	}
1063
	}
1046
	
1064
1047
	/**
1065
	/**
1048
	 * Returns default node flags of new nodes of this AST.
1066
	 * Returns default node flags of new nodes of this AST.
1049
	 * 
1067
	 *
1050
	 * @return the default node flags of new nodes of this AST
1068
	 * @return the default node flags of new nodes of this AST
1051
	 * @since 3.0
1069
	 * @since 3.0
1052
	 */
1070
	 */
1053
	int getDefaultNodeFlag() {
1071
	int getDefaultNodeFlag() {
1054
		return this.defaultNodeFlag;
1072
		return this.defaultNodeFlag;
1055
	}
1073
	}
1056
	
1074
1057
	/**
1075
	/**
1058
	 * Sets default node flags of new nodes of this AST.
1076
	 * Sets default node flags of new nodes of this AST.
1059
	 * 
1077
	 *
1060
	 * @param flag node flags of new nodes of this AST
1078
	 * @param flag node flags of new nodes of this AST
1061
	 * @since 3.0
1079
	 * @since 3.0
1062
	 */
1080
	 */
1063
	void setDefaultNodeFlag(int flag) {
1081
	void setDefaultNodeFlag(int flag) {
1064
		this.defaultNodeFlag = flag;
1082
		this.defaultNodeFlag = flag;
1065
	}
1083
	}
1066
	
1084
1067
	/**
1085
	/**
1068
	 * Set <code>originalModificationCount</code> to the current modification count
1086
	 * Set <code>originalModificationCount</code> to the current modification count
1069
	 * 
1087
	 *
1070
	 * @since 3.0
1088
	 * @since 3.0
1071
	 */
1089
	 */
1072
	void setOriginalModificationCount(long count) {
1090
	void setOriginalModificationCount(long count) {
1073
		this.originalModificationCount = count;
1091
		this.originalModificationCount = count;
1074
	}
1092
	}
1075
1093
1076
	/** 
1094
	/**
1077
	 * Returns the type binding for a "well known" type.
1095
	 * Returns the type binding for a "well known" type.
1078
	 * <p>
1096
	 * <p>
1079
	 * Note that bindings are generally unavailable unless requested when the
1097
	 * Note that bindings are generally unavailable unless requested when the
Lines 1112-1120 Link Here
1112
	 * <li><code>"java.io.Serializable"</code></li>
1130
	 * <li><code>"java.io.Serializable"</code></li>
1113
	 * </ul>
1131
	 * </ul>
1114
	 * </p>
1132
	 * </p>
1115
	 * 
1133
	 *
1116
	 * @param name the name of a well known type
1134
	 * @param name the name of a well known type
1117
	 * @return the corresponding type binding, or <code>null</code> if the 
1135
	 * @return the corresponding type binding, or <code>null</code> if the
1118
	 *   named type is not considered well known or if no binding can be found
1136
	 *   named type is not considered well known or if no binding can be found
1119
	 *   for it
1137
	 *   for it
1120
	 */
1138
	 */
Lines 1124-1133 Link Here
1124
		}
1142
		}
1125
		return getBindingResolver().resolveWellKnownType(name);
1143
		return getBindingResolver().resolveWellKnownType(name);
1126
	}
1144
	}
1127
		
1145
1128
	/**
1146
	/**
1129
	 * Sets the binding resolver for this AST.
1147
	 * Sets the binding resolver for this AST.
1130
	 * 
1148
	 *
1131
	 * @param resolver the new binding resolver for this AST
1149
	 * @param resolver the new binding resolver for this AST
1132
	 */
1150
	 */
1133
	void setBindingResolver(BindingResolver resolver) {
1151
	void setBindingResolver(BindingResolver resolver) {
Lines 1174-1187 Link Here
1174
	 * @since 3.0
1192
	 * @since 3.0
1175
	 */
1193
	 */
1176
	private final Object[] THIS_AST= new Object[] {this};
1194
	private final Object[] THIS_AST= new Object[] {this};
1177
	
1195
1178
	/**
1196
	/**
1179
	 * Creates an unparented node of the given node class
1197
	 * Creates an unparented node of the given node class
1180
	 * (non-abstract subclass of {@link ASTNode}). 
1198
	 * (non-abstract subclass of {@link ASTNode}).
1181
	 * 
1199
	 *
1182
	 * @param nodeClass AST node class
1200
	 * @param nodeClass AST node class
1183
	 * @return a new unparented node owned by this AST
1201
	 * @return a new unparented node owned by this AST
1184
	 * @exception IllegalArgumentException if <code>nodeClass</code> is 
1202
	 * @exception IllegalArgumentException if <code>nodeClass</code> is
1185
	 * <code>null</code> or is not a concrete node type class
1203
	 * <code>null</code> or is not a concrete node type class
1186
	 * @since 3.0
1204
	 * @since 3.0
1187
	 */
1205
	 */
Lines 1210-1216 Link Here
1210
			// concrete AST node classes do not die in the constructor
1228
			// concrete AST node classes do not die in the constructor
1211
			// therefore nodeClass is not legit
1229
			// therefore nodeClass is not legit
1212
			throw new IllegalArgumentException();
1230
			throw new IllegalArgumentException();
1213
		}		
1231
		}
1214
	}
1232
	}
1215
1233
1216
	/**
1234
	/**
Lines 1219-1229 Link Here
1219
	 * <pre>
1237
	 * <pre>
1220
	 * createInstance(ASTNode.nodeClassForType(nodeType))
1238
	 * createInstance(ASTNode.nodeClassForType(nodeType))
1221
	 * </pre>
1239
	 * </pre>
1222
	 * 
1240
	 *
1223
	 * @param nodeType AST node type, one of the node type
1241
	 * @param nodeType AST node type, one of the node type
1224
	 * constants declared on {@link ASTNode}
1242
	 * constants declared on {@link ASTNode}
1225
	 * @return a new unparented node owned by this AST
1243
	 * @return a new unparented node owned by this AST
1226
	 * @exception IllegalArgumentException if <code>nodeType</code> is 
1244
	 * @exception IllegalArgumentException if <code>nodeType</code> is
1227
	 * not a legal AST node type
1245
	 * not a legal AST node type
1228
	 * @since 3.0
1246
	 * @since 3.0
1229
	 */
1247
	 */
Lines 1233-1244 Link Here
1233
		return createInstance(nodeClass);
1251
		return createInstance(nodeClass);
1234
	}
1252
	}
1235
1253
1254
	/**
1255
	 * Returns true if the ast tree was created with bindings, false otherwise
1256
	 *
1257
	 * @return true if the ast tree was created with bindings, false otherwise
1258
	 */
1259
	public boolean hasResolvedBindings() {
1260
		return (this.bits & RESOLVED_BINDINGS) != 0;
1261
	}
1262
1263
	/**
1264
	 * Returns true if the ast tree was created with statement recovery, false otherwise
1265
	 *
1266
	 * @return true if the ast tree was created with statement recovery, false otherwise
1267
	 */
1268
	public boolean hasStatementRecovery() {
1269
		return (this.bits & STATEMENT_RECOVERY) != 0;
1270
	}
1271
1236
	//=============================== NAMES ===========================
1272
	//=============================== NAMES ===========================
1237
	/**
1273
	/**
1238
	 * Creates and returns a new unparented simple name node for the given
1274
	 * Creates and returns a new unparented simple name node for the given
1239
	 * identifier. The identifier should be a legal Java identifier, but not
1275
	 * identifier. The identifier should be a legal Java identifier, but not
1240
	 * a keyword, boolean literal ("true", "false") or null literal ("null").
1276
	 * a keyword, boolean literal ("true", "false") or null literal ("null").
1241
	 * 
1277
	 *
1242
	 * @param identifier the identifier
1278
	 * @param identifier the identifier
1243
	 * @return a new unparented simple name node
1279
	 * @return a new unparented simple name node
1244
	 * @exception IllegalArgumentException if the identifier is invalid
1280
	 * @exception IllegalArgumentException if the identifier is invalid
Lines 1253-1261 Link Here
1253
	}
1289
	}
1254
1290
1255
	/**
1291
	/**
1256
	 * Creates and returns a new unparented qualified name node for the given 
1292
	 * Creates and returns a new unparented qualified name node for the given
1257
	 * qualifier and simple name child node.
1293
	 * qualifier and simple name child node.
1258
	 * 
1294
	 *
1259
	 * @param qualifier the qualifier name node
1295
	 * @param qualifier the qualifier name node
1260
	 * @param name the simple name being qualified
1296
	 * @param name the simple name being qualified
1261
	 * @return a new unparented qualified name node
1297
	 * @return a new unparented qualified name node
Lines 1272-1287 Link Here
1272
		result.setQualifier(qualifier);
1308
		result.setQualifier(qualifier);
1273
		result.setName(name);
1309
		result.setName(name);
1274
		return result;
1310
		return result;
1275
		
1311
1276
	}
1312
	}
1277
	
1313
1278
	/**
1314
	/**
1279
	 * Creates and returns a new unparented name node for the given name 
1315
	 * Creates and returns a new unparented name node for the given name
1280
	 * segments. Returns a simple name if there is only one name segment, and
1316
	 * segments. Returns a simple name if there is only one name segment, and
1281
	 * a qualified name if there are multiple name segments. Each of the name
1317
	 * a qualified name if there are multiple name segments. Each of the name
1282
	 * segments should be legal Java identifiers (this constraint may or may 
1318
	 * segments should be legal Java identifiers (this constraint may or may
1283
	 * not be enforced), and there must be at least one name segment.
1319
	 * not be enforced), and there must be at least one name segment.
1284
	 * 
1320
	 *
1285
	 * @param identifiers a list of 1 or more name segments, each of which
1321
	 * @param identifiers a list of 1 or more name segments, each of which
1286
	 *    is a legal Java identifier
1322
	 *    is a legal Java identifier
1287
	 * @return a new unparented name node
1323
	 * @return a new unparented name node
Lines 1304-1310 Link Here
1304
		}
1340
		}
1305
		return result;
1341
		return result;
1306
	}
1342
	}
1307
	
1343
1308
	/* (omit javadoc for this method)
1344
	/* (omit javadoc for this method)
1309
	 * This method is a copy of setName(String[]) that doesn't do any validation.
1345
	 * This method is a copy of setName(String[]) that doesn't do any validation.
1310
	 */
1346
	 */
Lines 1326-1340 Link Here
1326
1362
1327
	/**
1363
	/**
1328
	 * Creates and returns a new unparented name node for the given name.
1364
	 * Creates and returns a new unparented name node for the given name.
1329
	 * The name string must consist of 1 or more name segments separated 
1365
	 * The name string must consist of 1 or more name segments separated
1330
	 * by single dots '.'. Returns a {@link QualifiedName} if the name has
1366
	 * by single dots '.'. Returns a {@link QualifiedName} if the name has
1331
	 * dots, and a {@link SimpleName} otherwise. Each of the name
1367
	 * dots, and a {@link SimpleName} otherwise. Each of the name
1332
	 * segments should be legal Java identifiers (this constraint may or may 
1368
	 * segments should be legal Java identifiers (this constraint may or may
1333
	 * not be enforced), and there must be at least one name segment.
1369
	 * not be enforced), and there must be at least one name segment.
1334
	 * The string must not contains white space, '&lt;', '&gt;',
1370
	 * The string must not contains white space, '&lt;', '&gt;',
1335
	 * '[', ']', or other any other characters that are not
1371
	 * '[', ']', or other any other characters that are not
1336
	 * part of the Java identifiers or separating '.'s.
1372
	 * part of the Java identifiers or separating '.'s.
1337
	 * 
1373
	 *
1338
	 * @param qualifiedName string consisting of 1 or more name segments,
1374
	 * @param qualifiedName string consisting of 1 or more name segments,
1339
	 * each of which is a legal Java identifier, separated  by single dots '.'
1375
	 * each of which is a legal Java identifier, separated  by single dots '.'
1340
	 * @return a new unparented name node
1376
	 * @return a new unparented name node
Lines 1390-1396 Link Here
1390
	 * This method can be used to convert a name (<code>Name</code>) into a
1426
	 * This method can be used to convert a name (<code>Name</code>) into a
1391
	 * type (<code>Type</code>) by wrapping it.
1427
	 * type (<code>Type</code>) by wrapping it.
1392
	 * </p>
1428
	 * </p>
1393
	 * 
1429
	 *
1394
	 * @param typeName the name of the class or interface
1430
	 * @param typeName the name of the class or interface
1395
	 * @return a new unparented simple type node
1431
	 * @return a new unparented simple type node
1396
	 * @exception IllegalArgumentException if:
1432
	 * @exception IllegalArgumentException if:
Lines 1408-1414 Link Here
1408
	/**
1444
	/**
1409
	 * Creates and returns a new unparented array type node with the given
1445
	 * Creates and returns a new unparented array type node with the given
1410
	 * component type, which may be another array type.
1446
	 * component type, which may be another array type.
1411
	 * 
1447
	 *
1412
	 * @param componentType the component type (possibly another array type)
1448
	 * @param componentType the component type (possibly another array type)
1413
	 * @return a new unparented array type node
1449
	 * @return a new unparented array type node
1414
	 * @exception IllegalArgumentException if:
1450
	 * @exception IllegalArgumentException if:
Lines 1426-1437 Link Here
1426
1462
1427
	/**
1463
	/**
1428
	 * Creates and returns a new unparented array type node with the given
1464
	 * Creates and returns a new unparented array type node with the given
1429
	 * element type and number of dimensions. 
1465
	 * element type and number of dimensions.
1430
	 * <p>
1466
	 * <p>
1431
	 * Note that if the element type passed in is an array type, the
1467
	 * Note that if the element type passed in is an array type, the
1432
	 * element type of the result will not be the same as what was passed in.
1468
	 * element type of the result will not be the same as what was passed in.
1433
	 * </p>
1469
	 * </p>
1434
	 * 
1470
	 *
1435
	 * @param elementType the element type (never an array type)
1471
	 * @param elementType the element type (never an array type)
1436
	 * @param dimensions the number of dimensions, a positive number
1472
	 * @param dimensions the number of dimensions, a positive number
1437
	 * @return a new unparented array type node
1473
	 * @return a new unparented array type node
Lines 1460-1473 Link Here
1460
			result = newArrayType(result);
1496
			result = newArrayType(result);
1461
		}
1497
		}
1462
		return result;
1498
		return result;
1463
		
1499
1464
	}
1500
	}
1465
1501
1466
	/**
1502
	/**
1467
	 * Creates and returns a new unparented primitive type node with the given
1503
	 * Creates and returns a new unparented primitive type node with the given
1468
	 * type code.
1504
	 * type code.
1469
	 * 
1505
	 *
1470
	 * @param typeCode one of the primitive type code constants declared in 
1506
	 * @param typeCode one of the primitive type code constants declared in
1471
	 *    <code>PrimitiveType</code>
1507
	 *    <code>PrimitiveType</code>
1472
	 * @return a new unparented primitive type node
1508
	 * @return a new unparented primitive type node
1473
	 * @exception IllegalArgumentException if the primitive type code is invalid
1509
	 * @exception IllegalArgumentException if the primitive type code is invalid
Lines 1481-1487 Link Here
1481
	/**
1517
	/**
1482
	 * Creates and returns a new unparented parameterized type node with the
1518
	 * Creates and returns a new unparented parameterized type node with the
1483
	 * given type and an empty list of type arguments.
1519
	 * given type and an empty list of type arguments.
1484
	 * 
1520
	 *
1485
	 * @param type the type that is parameterized
1521
	 * @param type the type that is parameterized
1486
	 * @return a new unparented parameterized type node
1522
	 * @return a new unparented parameterized type node
1487
	 * @exception IllegalArgumentException if:
1523
	 * @exception IllegalArgumentException if:
Lines 1500-1508 Link Here
1500
	}
1536
	}
1501
1537
1502
	/**
1538
	/**
1503
	 * Creates and returns a new unparented qualified type node with 
1539
	 * Creates and returns a new unparented qualified type node with
1504
	 * the given qualifier type and name.
1540
	 * the given qualifier type and name.
1505
	 * 
1541
	 *
1506
	 * @param qualifier the qualifier type node
1542
	 * @param qualifier the qualifier type node
1507
	 * @param name the simple name being qualified
1543
	 * @param name the simple name being qualified
1508
	 * @return a new unparented qualified type node
1544
	 * @return a new unparented qualified type node
Lines 1521-1531 Link Here
1521
		result.setName(name);
1557
		result.setName(name);
1522
		return result;
1558
		return result;
1523
	}
1559
	}
1524
	
1560
1525
	/**
1561
	/**
1526
	 * Creates and returns a new unparented wildcard type node with no 
1562
	 * Creates and returns a new unparented wildcard type node with no
1527
	 * type bound.
1563
	 * type bound.
1528
	 * 
1564
	 *
1529
	 * @return a new unparented wildcard type node
1565
	 * @return a new unparented wildcard type node
1530
	 * @exception UnsupportedOperationException if this operation is used in
1566
	 * @exception UnsupportedOperationException if this operation is used in
1531
	 * a JLS2 AST
1567
	 * a JLS2 AST
Lines 1541-1581 Link Here
1541
	 * Creates an unparented compilation unit node owned by this AST.
1577
	 * Creates an unparented compilation unit node owned by this AST.
1542
	 * The compilation unit initially has no package declaration, no
1578
	 * The compilation unit initially has no package declaration, no
1543
	 * import declarations, and no type declarations.
1579
	 * import declarations, and no type declarations.
1544
	 * 
1580
	 *
1545
	 * @return the new unparented compilation unit node
1581
	 * @return the new unparented compilation unit node
1546
	 */
1582
	 */
1547
	public CompilationUnit newCompilationUnit() {
1583
	public CompilationUnit newCompilationUnit() {
1548
		return new CompilationUnit(this);
1584
		return new CompilationUnit(this);
1549
	}
1585
	}
1550
	
1586
1551
	/**
1587
	/**
1552
	 * Creates an unparented package declaration node owned by this AST.
1588
	 * Creates an unparented package declaration node owned by this AST.
1553
	 * The package declaration initially declares a package with an
1589
	 * The package declaration initially declares a package with an
1554
	 * unspecified name.
1590
	 * unspecified name.
1555
	 * 
1591
	 *
1556
	 * @return the new unparented package declaration node
1592
	 * @return the new unparented package declaration node
1557
	 */
1593
	 */
1558
	public PackageDeclaration newPackageDeclaration() {
1594
	public PackageDeclaration newPackageDeclaration() {
1559
		PackageDeclaration result = new PackageDeclaration(this);
1595
		PackageDeclaration result = new PackageDeclaration(this);
1560
		return result;
1596
		return result;
1561
	}
1597
	}
1562
	
1598
1563
	/**
1599
	/**
1564
	 * Creates an unparented import declaration node owned by this AST.
1600
	 * Creates an unparented import declaration node owned by this AST.
1565
	 * The import declaration initially contains a single-type import
1601
	 * The import declaration initially contains a single-type import
1566
	 * of a type with an unspecified name.
1602
	 * of a type with an unspecified name.
1567
	 * 
1603
	 *
1568
	 * @return the new unparented import declaration node
1604
	 * @return the new unparented import declaration node
1569
	 */
1605
	 */
1570
	public ImportDeclaration newImportDeclaration() {
1606
	public ImportDeclaration newImportDeclaration() {
1571
		ImportDeclaration result = new ImportDeclaration(this);
1607
		ImportDeclaration result = new ImportDeclaration(this);
1572
		return result;
1608
		return result;
1573
	}
1609
	}
1574
	
1610
1575
	/**
1611
	/**
1576
	 * Creates an unparented class declaration node owned by this AST.
1612
	 * Creates an unparented class declaration node owned by this AST.
1577
	 * The name of the class is an unspecified, but legal, name; 
1613
	 * The name of the class is an unspecified, but legal, name;
1578
	 * no modifiers; no doc comment; no superclass or superinterfaces; 
1614
	 * no modifiers; no doc comment; no superclass or superinterfaces;
1579
	 * and an empty class body.
1615
	 * and an empty class body.
1580
	 * <p>
1616
	 * <p>
1581
	 * To create an interface, use this method and then call
1617
	 * To create an interface, use this method and then call
Lines 1585-1591 Link Here
1585
	 * To create an enum declaration, use this method and then call
1621
	 * To create an enum declaration, use this method and then call
1586
	 * <code>TypeDeclaration.setEnumeration(true)</code>.
1622
	 * <code>TypeDeclaration.setEnumeration(true)</code>.
1587
	 * </p>
1623
	 * </p>
1588
	 * 
1624
	 *
1589
	 * @return a new unparented type declaration node
1625
	 * @return a new unparented type declaration node
1590
	 */
1626
	 */
1591
	public TypeDeclaration newTypeDeclaration() {
1627
	public TypeDeclaration newTypeDeclaration() {
Lines 1593-1602 Link Here
1593
		result.setInterface(false);
1629
		result.setInterface(false);
1594
		return result;
1630
		return result;
1595
	}
1631
	}
1596
	
1632
1597
	/**
1633
	/**
1598
	 * Creates an unparented method declaration node owned by this AST.
1634
	 * Creates an unparented method declaration node owned by this AST.
1599
	 * By default, the declaration is for a method of an unspecified, but 
1635
	 * By default, the declaration is for a method of an unspecified, but
1600
	 * legal, name; no modifiers; no doc comment; no parameters; return
1636
	 * legal, name; no modifiers; no doc comment; no parameters; return
1601
	 * type void; no extra array dimensions; no thrown exceptions; and no
1637
	 * type void; no extra array dimensions; no thrown exceptions; and no
1602
	 * body (as opposed to an empty body).
1638
	 * body (as opposed to an empty body).
Lines 1605-1611 Link Here
1605
	 * <code>MethodDeclaration.setConstructor(true)</code> and
1641
	 * <code>MethodDeclaration.setConstructor(true)</code> and
1606
	 * <code>MethodDeclaration.setName(className)</code>.
1642
	 * <code>MethodDeclaration.setName(className)</code>.
1607
	 * </p>
1643
	 * </p>
1608
	 * 
1644
	 *
1609
	 * @return a new unparented method declaration node
1645
	 * @return a new unparented method declaration node
1610
	 */
1646
	 */
1611
	public MethodDeclaration newMethodDeclaration() {
1647
	public MethodDeclaration newMethodDeclaration() {
Lines 1613-1649 Link Here
1613
		result.setConstructor(false);
1649
		result.setConstructor(false);
1614
		return result;
1650
		return result;
1615
	}
1651
	}
1616
	
1652
1617
	/**
1653
	/**
1618
	 * Creates an unparented single variable declaration node owned by this AST.
1654
	 * Creates an unparented single variable declaration node owned by this AST.
1619
	 * By default, the declaration is for a variable with an unspecified, but 
1655
	 * By default, the declaration is for a variable with an unspecified, but
1620
	 * legal, name and type; no modifiers; no array dimensions after the
1656
	 * legal, name and type; no modifiers; no array dimensions after the
1621
	 * variable; no initializer; not variable arity.
1657
	 * variable; no initializer; not variable arity.
1622
	 * 
1658
	 *
1623
	 * @return a new unparented single variable declaration node
1659
	 * @return a new unparented single variable declaration node
1624
	 */
1660
	 */
1625
	public SingleVariableDeclaration newSingleVariableDeclaration() {
1661
	public SingleVariableDeclaration newSingleVariableDeclaration() {
1626
		SingleVariableDeclaration result = new SingleVariableDeclaration(this);
1662
		SingleVariableDeclaration result = new SingleVariableDeclaration(this);
1627
		return result;
1663
		return result;
1628
	}
1664
	}
1629
	
1665
1630
	/**
1666
	/**
1631
	 * Creates an unparented variable declaration fragment node owned by this 
1667
	 * Creates an unparented variable declaration fragment node owned by this
1632
	 * AST. By default, the fragment is for a variable with an unspecified, but 
1668
	 * AST. By default, the fragment is for a variable with an unspecified, but
1633
	 * legal, name; no extra array dimensions; and no initializer.
1669
	 * legal, name; no extra array dimensions; and no initializer.
1634
	 * 
1670
	 *
1635
	 * @return a new unparented variable declaration fragment node
1671
	 * @return a new unparented variable declaration fragment node
1636
	 */
1672
	 */
1637
	public VariableDeclarationFragment newVariableDeclarationFragment() {
1673
	public VariableDeclarationFragment newVariableDeclarationFragment() {
1638
		VariableDeclarationFragment result = new VariableDeclarationFragment(this);
1674
		VariableDeclarationFragment result = new VariableDeclarationFragment(this);
1639
		return result;
1675
		return result;
1640
	}
1676
	}
1641
	
1677
1642
	/**
1678
	/**
1643
	 * Creates an unparented initializer node owned by this AST, with an 
1679
	 * Creates an unparented initializer node owned by this AST, with an
1644
	 * empty block. By default, the initializer has no modifiers and 
1680
	 * empty block. By default, the initializer has no modifiers and
1645
	 * an empty block.
1681
	 * an empty block.
1646
	 * 
1682
	 *
1647
	 * @return a new unparented initializer node
1683
	 * @return a new unparented initializer node
1648
	 */
1684
	 */
1649
	public Initializer newInitializer() {
1685
	public Initializer newInitializer() {
Lines 1653-1662 Link Here
1653
1689
1654
	/**
1690
	/**
1655
	 * Creates an unparented enum constant declaration node owned by this AST.
1691
	 * Creates an unparented enum constant declaration node owned by this AST.
1656
	 * The name of the constant is an unspecified, but legal, name; 
1692
	 * The name of the constant is an unspecified, but legal, name;
1657
	 * no doc comment; no modifiers or annotations; no arguments; 
1693
	 * no doc comment; no modifiers or annotations; no arguments;
1658
	 * and does not declare an anonymous class.
1694
	 * and does not declare an anonymous class.
1659
	 * 
1695
	 *
1660
	 * @return a new unparented enum constant declaration node
1696
	 * @return a new unparented enum constant declaration node
1661
	 * @exception UnsupportedOperationException if this operation is used in
1697
	 * @exception UnsupportedOperationException if this operation is used in
1662
	 * a JLS2 AST
1698
	 * a JLS2 AST
Lines 1666-1679 Link Here
1666
		EnumConstantDeclaration result = new EnumConstantDeclaration(this);
1702
		EnumConstantDeclaration result = new EnumConstantDeclaration(this);
1667
		return result;
1703
		return result;
1668
	}
1704
	}
1669
	
1705
1670
	/**
1706
	/**
1671
	 * Creates an unparented enum declaration node owned by this AST.
1707
	 * Creates an unparented enum declaration node owned by this AST.
1672
	 * The name of the enum is an unspecified, but legal, name; 
1708
	 * The name of the enum is an unspecified, but legal, name;
1673
	 * no doc comment; no modifiers or annotations; 
1709
	 * no doc comment; no modifiers or annotations;
1674
	 * no superinterfaces; and empty lists of enum constants
1710
	 * no superinterfaces; and empty lists of enum constants
1675
	 * and body declarations.
1711
	 * and body declarations.
1676
	 * 
1712
	 *
1677
	 * @return a new unparented enum declaration node
1713
	 * @return a new unparented enum declaration node
1678
	 * @exception UnsupportedOperationException if this operation is used in
1714
	 * @exception UnsupportedOperationException if this operation is used in
1679
	 * a JLS2 AST
1715
	 * a JLS2 AST
Lines 1683-1693 Link Here
1683
		EnumDeclaration result = new EnumDeclaration(this);
1719
		EnumDeclaration result = new EnumDeclaration(this);
1684
		return result;
1720
		return result;
1685
	}
1721
	}
1686
	
1722
1687
	/**
1723
	/**
1688
	 * Creates and returns a new unparented type parameter type node with an
1724
	 * Creates and returns a new unparented type parameter type node with an
1689
	 * unspecified type variable name and an empty list of type bounds.
1725
	 * unspecified type variable name and an empty list of type bounds.
1690
	 * 
1726
	 *
1691
	 * @return a new unparented type parameter node
1727
	 * @return a new unparented type parameter node
1692
	 * @exception UnsupportedOperationException if this operation is used in
1728
	 * @exception UnsupportedOperationException if this operation is used in
1693
	 * a JLS2 AST
1729
	 * a JLS2 AST
Lines 1700-1708 Link Here
1700
1736
1701
	/**
1737
	/**
1702
	 * Creates and returns a new unparented annotation type declaration
1738
	 * Creates and returns a new unparented annotation type declaration
1703
	 * node for an unspecified, but legal, name; no modifiers; no javadoc; 
1739
	 * node for an unspecified, but legal, name; no modifiers; no javadoc;
1704
	 * and an empty list of member declarations.
1740
	 * and an empty list of member declarations.
1705
	 * 
1741
	 *
1706
	 * @return a new unparented annotation type declaration node
1742
	 * @return a new unparented annotation type declaration node
1707
	 * @exception UnsupportedOperationException if this operation is used in
1743
	 * @exception UnsupportedOperationException if this operation is used in
1708
	 * a JLS2 AST
1744
	 * a JLS2 AST
Lines 1712-1724 Link Here
1712
		AnnotationTypeDeclaration result = new AnnotationTypeDeclaration(this);
1748
		AnnotationTypeDeclaration result = new AnnotationTypeDeclaration(this);
1713
		return result;
1749
		return result;
1714
	}
1750
	}
1715
	
1751
1716
	/**
1752
	/**
1717
	 * Creates and returns a new unparented annotation type 
1753
	 * Creates and returns a new unparented annotation type
1718
	 * member declaration node for an unspecified, but legal, 
1754
	 * member declaration node for an unspecified, but legal,
1719
	 * member name and type; no modifiers; no javadoc; 
1755
	 * member name and type; no modifiers; no javadoc;
1720
	 * and no default value.
1756
	 * and no default value.
1721
	 * 
1757
	 *
1722
	 * @return a new unparented annotation type member declaration node
1758
	 * @return a new unparented annotation type member declaration node
1723
	 * @exception UnsupportedOperationException if this operation is used in
1759
	 * @exception UnsupportedOperationException if this operation is used in
1724
	 * a JLS2 AST
1760
	 * a JLS2 AST
Lines 1728-1738 Link Here
1728
		AnnotationTypeMemberDeclaration result = new AnnotationTypeMemberDeclaration(this);
1764
		AnnotationTypeMemberDeclaration result = new AnnotationTypeMemberDeclaration(this);
1729
		return result;
1765
		return result;
1730
	}
1766
	}
1731
	
1767
1732
	/**
1768
	/**
1733
	 * Creates and returns a new unparented modifier node for the given
1769
	 * Creates and returns a new unparented modifier node for the given
1734
	 * modifier.
1770
	 * modifier.
1735
	 * 
1771
	 *
1736
	 * @param keyword one of the modifier keyword constants
1772
	 * @param keyword one of the modifier keyword constants
1737
	 * @return a new unparented modifier node
1773
	 * @return a new unparented modifier node
1738
	 * @exception IllegalArgumentException if the primitive type code is invalid
1774
	 * @exception IllegalArgumentException if the primitive type code is invalid
Lines 1747-1759 Link Here
1747
	}
1783
	}
1748
1784
1749
	/**
1785
	/**
1750
	 * Creates and returns a list of new unparented modifier nodes 
1786
	 * Creates and returns a list of new unparented modifier nodes
1751
	 * for the given modifier flags. When multiple modifiers are 
1787
	 * for the given modifier flags. When multiple modifiers are
1752
	 * requested the modifiers nodes will appear in the following order:
1788
	 * requested the modifiers nodes will appear in the following order:
1753
	 * public, protected, private, abstract, static, final, synchronized,
1789
	 * public, protected, private, abstract, static, final, synchronized,
1754
	 * native, strictfp, transient, volatile. This order is consistent
1790
	 * native, strictfp, transient, volatile. This order is consistent
1755
	 * with the recommendations in JLS2 8.1.1, 8.3.1, and 8.4.3.
1791
	 * with the recommendations in JLS2 8.1.1, 8.3.1, and 8.4.3.
1756
	 * 
1792
	 *
1757
	 * @param flags bitwise or of modifier flags declared on {@link Modifier}
1793
	 * @param flags bitwise or of modifier flags declared on {@link Modifier}
1758
	 * @return a possibly empty list of new unparented modifier nodes
1794
	 * @return a possibly empty list of new unparented modifier nodes
1759
	 *   (element type <code>Modifier</code>)
1795
	 *   (element type <code>Modifier</code>)
Lines 1809-1819 Link Here
1809
	 * <p>
1845
	 * <p>
1810
	 * Note that this node type is used to recording the source
1846
	 * Note that this node type is used to recording the source
1811
	 * range where a comment was found in the source string.
1847
	 * range where a comment was found in the source string.
1812
	 * These comment nodes are normally found (only) in 
1848
	 * These comment nodes are normally found (only) in
1813
	 * {@linkplain CompilationUnit#getCommentList() 
1849
	 * {@linkplain CompilationUnit#getCommentList()
1814
	 * the comment table} for parsed compilation units.
1850
	 * the comment table} for parsed compilation units.
1815
	 * </p>
1851
	 * </p>
1816
	 * 
1852
	 *
1817
	 * @return a new unparented block comment node
1853
	 * @return a new unparented block comment node
1818
	 * @since 3.0
1854
	 * @since 3.0
1819
	 */
1855
	 */
Lines 1821-1837 Link Here
1821
		BlockComment result = new BlockComment(this);
1857
		BlockComment result = new BlockComment(this);
1822
		return result;
1858
		return result;
1823
	}
1859
	}
1824
	
1860
1825
	/**
1861
	/**
1826
	 * Creates and returns a new line comment placeholder node.
1862
	 * Creates and returns a new line comment placeholder node.
1827
	 * <p>
1863
	 * <p>
1828
	 * Note that this node type is used to recording the source
1864
	 * Note that this node type is used to recording the source
1829
	 * range where a comment was found in the source string.
1865
	 * range where a comment was found in the source string.
1830
	 * These comment nodes are normally found (only) in 
1866
	 * These comment nodes are normally found (only) in
1831
	 * {@linkplain CompilationUnit#getCommentList() 
1867
	 * {@linkplain CompilationUnit#getCommentList()
1832
	 * the comment table} for parsed compilation units.
1868
	 * the comment table} for parsed compilation units.
1833
	 * </p>
1869
	 * </p>
1834
	 * 
1870
	 *
1835
	 * @return a new unparented line comment node
1871
	 * @return a new unparented line comment node
1836
	 * @since 3.0
1872
	 * @since 3.0
1837
	 */
1873
	 */
Lines 1839-1858 Link Here
1839
		LineComment result = new LineComment(this);
1875
		LineComment result = new LineComment(this);
1840
		return result;
1876
		return result;
1841
	}
1877
	}
1842
	
1878
1843
	/**
1879
	/**
1844
	 * Creates and returns a new doc comment node.
1880
	 * Creates and returns a new doc comment node.
1845
	 * Initially the new node has an empty list of tag elements
1881
	 * Initially the new node has an empty list of tag elements
1846
	 * (and, for backwards compatability, an unspecified, but legal,
1882
	 * (and, for backwards compatability, an unspecified, but legal,
1847
	 * doc comment string)
1883
	 * doc comment string)
1848
	 * 
1884
	 *
1849
	 * @return a new unparented doc comment node
1885
	 * @return a new unparented doc comment node
1850
	 */
1886
	 */
1851
	public Javadoc newJavadoc() {
1887
	public Javadoc newJavadoc() {
1852
		Javadoc result = new Javadoc(this);
1888
		Javadoc result = new Javadoc(this);
1853
		return result;
1889
		return result;
1854
	}
1890
	}
1855
	
1891
1856
	/**
1892
	/**
1857
	 * Creates and returns a new tag element node.
1893
	 * Creates and returns a new tag element node.
1858
	 * Initially the new node has no tag name and an empty list of fragments.
1894
	 * Initially the new node has no tag name and an empty list of fragments.
Lines 1860-1866 Link Here
1860
	 * Note that this node type is used only inside doc comments
1896
	 * Note that this node type is used only inside doc comments
1861
	 * ({@link Javadoc}).
1897
	 * ({@link Javadoc}).
1862
	 * </p>
1898
	 * </p>
1863
	 * 
1899
	 *
1864
	 * @return a new unparented tag element node
1900
	 * @return a new unparented tag element node
1865
	 * @since 3.0
1901
	 * @since 3.0
1866
	 */
1902
	 */
Lines 1868-1874 Link Here
1868
		TagElement result = new TagElement(this);
1904
		TagElement result = new TagElement(this);
1869
		return result;
1905
		return result;
1870
	}
1906
	}
1871
	
1907
1872
	/**
1908
	/**
1873
	 * Creates and returns a new text element node.
1909
	 * Creates and returns a new text element node.
1874
	 * Initially the new node has an empty text string.
1910
	 * Initially the new node has an empty text string.
Lines 1876-1882 Link Here
1876
	 * Note that this node type is used only inside doc comments
1912
	 * Note that this node type is used only inside doc comments
1877
	 * ({@link Javadoc Javadoc}).
1913
	 * ({@link Javadoc Javadoc}).
1878
	 * </p>
1914
	 * </p>
1879
	 * 
1915
	 *
1880
	 * @return a new unparented text element node
1916
	 * @return a new unparented text element node
1881
	 * @since 3.0
1917
	 * @since 3.0
1882
	 */
1918
	 */
Lines 1884-1899 Link Here
1884
		TextElement result = new TextElement(this);
1920
		TextElement result = new TextElement(this);
1885
		return result;
1921
		return result;
1886
	}
1922
	}
1887
	
1923
1888
	/**
1924
	/**
1889
	 * Creates and returns a new member reference node.
1925
	 * Creates and returns a new member reference node.
1890
	 * Initially the new node has no qualifier name and 
1926
	 * Initially the new node has no qualifier name and
1891
	 * an unspecified, but legal, member name.
1927
	 * an unspecified, but legal, member name.
1892
	 * <p>
1928
	 * <p>
1893
	 * Note that this node type is used only inside doc comments
1929
	 * Note that this node type is used only inside doc comments
1894
	 * ({@link Javadoc}).
1930
	 * ({@link Javadoc}).
1895
	 * </p>
1931
	 * </p>
1896
	 * 
1932
	 *
1897
	 * @return a new unparented member reference node
1933
	 * @return a new unparented member reference node
1898
	 * @since 3.0
1934
	 * @since 3.0
1899
	 */
1935
	 */
Lines 1901-1917 Link Here
1901
		MemberRef result = new MemberRef(this);
1937
		MemberRef result = new MemberRef(this);
1902
		return result;
1938
		return result;
1903
	}
1939
	}
1904
	
1940
1905
	/**
1941
	/**
1906
	 * Creates and returns a new method reference node.
1942
	 * Creates and returns a new method reference node.
1907
	 * Initially the new node has no qualifier name, 
1943
	 * Initially the new node has no qualifier name,
1908
	 * an unspecified, but legal, method name, and an
1944
	 * an unspecified, but legal, method name, and an
1909
	 * empty parameter list. 
1945
	 * empty parameter list.
1910
	 * <p>
1946
	 * <p>
1911
	 * Note that this node type is used only inside doc comments
1947
	 * Note that this node type is used only inside doc comments
1912
	 * ({@link Javadoc Javadoc}).
1948
	 * ({@link Javadoc Javadoc}).
1913
	 * </p>
1949
	 * </p>
1914
	 * 
1950
	 *
1915
	 * @return a new unparented method reference node
1951
	 * @return a new unparented method reference node
1916
	 * @since 3.0
1952
	 * @since 3.0
1917
	 */
1953
	 */
Lines 1919-1934 Link Here
1919
		MethodRef result = new MethodRef(this);
1955
		MethodRef result = new MethodRef(this);
1920
		return result;
1956
		return result;
1921
	}
1957
	}
1922
	
1958
1923
	/**
1959
	/**
1924
	 * Creates and returns a new method reference node.
1960
	 * Creates and returns a new method reference node.
1925
	 * Initially the new node has an unspecified, but legal,
1961
	 * Initially the new node has an unspecified, but legal,
1926
	 * type, not variable arity, and no parameter name. 
1962
	 * type, not variable arity, and no parameter name.
1927
	 * <p>
1963
	 * <p>
1928
	 * Note that this node type is used only inside doc comments
1964
	 * Note that this node type is used only inside doc comments
1929
	 * ({@link Javadoc}).
1965
	 * ({@link Javadoc}).
1930
	 * </p>
1966
	 * </p>
1931
	 * 
1967
	 *
1932
	 * @return a new unparented method reference parameter node
1968
	 * @return a new unparented method reference parameter node
1933
	 * @since 3.0
1969
	 * @since 3.0
1934
	 */
1970
	 */
Lines 1936-1946 Link Here
1936
		MethodRefParameter result = new MethodRefParameter(this);
1972
		MethodRefParameter result = new MethodRefParameter(this);
1937
		return result;
1973
		return result;
1938
	}
1974
	}
1939
	
1975
1940
	//=============================== STATEMENTS ===========================
1976
	//=============================== STATEMENTS ===========================
1941
	/**
1977
	/**
1942
	 * Creates a new unparented local variable declaration statement node 
1978
	 * Creates a new unparented local variable declaration statement node
1943
	 * owned by this AST, for the given variable declaration fragment. 
1979
	 * owned by this AST, for the given variable declaration fragment.
1944
	 * By default, there are no modifiers and the base type is unspecified
1980
	 * By default, there are no modifiers and the base type is unspecified
1945
	 * (but legal).
1981
	 * (but legal).
1946
	 * <p>
1982
	 * <p>
Lines 1949-1955 Link Here
1949
	 * (<code>Statement</code>) by wrapping it. Additional variable
1985
	 * (<code>Statement</code>) by wrapping it. Additional variable
1950
	 * declaration fragments can be added afterwards.
1986
	 * declaration fragments can be added afterwards.
1951
	 * </p>
1987
	 * </p>
1952
	 * 
1988
	 *
1953
	 * @param fragment the variable declaration fragment
1989
	 * @param fragment the variable declaration fragment
1954
	 * @return a new unparented variable declaration statement node
1990
	 * @return a new unparented variable declaration statement node
1955
	 * @exception IllegalArgumentException if:
1991
	 * @exception IllegalArgumentException if:
Lines 1970-1985 Link Here
1970
		result.fragments().add(fragment);
2006
		result.fragments().add(fragment);
1971
		return result;
2007
		return result;
1972
	}
2008
	}
1973
	
2009
1974
	/**
2010
	/**
1975
	 * Creates a new unparented local type declaration statement node 
2011
	 * Creates a new unparented local type declaration statement node
1976
	 * owned by this AST, for the given type declaration.
2012
	 * owned by this AST, for the given type declaration.
1977
	 * <p>
2013
	 * <p>
1978
	 * This method can be used to convert a type declaration
2014
	 * This method can be used to convert a type declaration
1979
	 * (<code>TypeDeclaration</code>) into a statement
2015
	 * (<code>TypeDeclaration</code>) into a statement
1980
	 * (<code>Statement</code>) by wrapping it.
2016
	 * (<code>Statement</code>) by wrapping it.
1981
	 * </p>
2017
	 * </p>
1982
	 * 
2018
	 *
1983
	 * @param decl the type declaration
2019
	 * @param decl the type declaration
1984
	 * @return a new unparented local type declaration statement node
2020
	 * @return a new unparented local type declaration statement node
1985
	 * @exception IllegalArgumentException if:
2021
	 * @exception IllegalArgumentException if:
Lines 1989-2010 Link Here
1989
	 * <li>a cycle in would be created</li>
2025
	 * <li>a cycle in would be created</li>
1990
	 * </ul>
2026
	 * </ul>
1991
	 */
2027
	 */
1992
	public TypeDeclarationStatement 
2028
	public TypeDeclarationStatement
1993
			newTypeDeclarationStatement(TypeDeclaration decl) {
2029
			newTypeDeclarationStatement(TypeDeclaration decl) {
1994
		TypeDeclarationStatement result = new TypeDeclarationStatement(this);
2030
		TypeDeclarationStatement result = new TypeDeclarationStatement(this);
1995
		result.setDeclaration(decl);
2031
		result.setDeclaration(decl);
1996
		return result;
2032
		return result;
1997
	}
2033
	}
1998
	
2034
1999
	/**
2035
	/**
2000
	 * Creates a new unparented local type declaration statement node 
2036
	 * Creates a new unparented local type declaration statement node
2001
	 * owned by this AST, for the given type declaration.
2037
	 * owned by this AST, for the given type declaration.
2002
	 * <p>
2038
	 * <p>
2003
	 * This method can be used to convert any kind of type declaration
2039
	 * This method can be used to convert any kind of type declaration
2004
	 * (<code>AbstractTypeDeclaration</code>) into a statement
2040
	 * (<code>AbstractTypeDeclaration</code>) into a statement
2005
	 * (<code>Statement</code>) by wrapping it.
2041
	 * (<code>Statement</code>) by wrapping it.
2006
	 * </p>
2042
	 * </p>
2007
	 * 
2043
	 *
2008
	 * @param decl the type declaration
2044
	 * @param decl the type declaration
2009
	 * @return a new unparented local type declaration statement node
2045
	 * @return a new unparented local type declaration statement node
2010
	 * @exception IllegalArgumentException if:
2046
	 * @exception IllegalArgumentException if:
Lines 2015-2021 Link Here
2015
	 * </ul>
2051
	 * </ul>
2016
	 * @since 3.0
2052
	 * @since 3.0
2017
	 */
2053
	 */
2018
	public TypeDeclarationStatement 
2054
	public TypeDeclarationStatement
2019
			newTypeDeclarationStatement(AbstractTypeDeclaration decl) {
2055
			newTypeDeclarationStatement(AbstractTypeDeclaration decl) {
2020
		TypeDeclarationStatement result = new TypeDeclarationStatement(this);
2056
		TypeDeclarationStatement result = new TypeDeclarationStatement(this);
2021
		if (this.apiLevel == AST.JLS2) {
2057
		if (this.apiLevel == AST.JLS2) {
Lines 2026-2073 Link Here
2026
		}
2062
		}
2027
		return result;
2063
		return result;
2028
	}
2064
	}
2029
	
2065
2030
	/**
2066
	/**
2031
	 * Creates an unparented block node owned by this AST, for an empty list 
2067
	 * Creates an unparented block node owned by this AST, for an empty list
2032
	 * of statements.
2068
	 * of statements.
2033
	 * 
2069
	 *
2034
	 * @return a new unparented, empty block node
2070
	 * @return a new unparented, empty block node
2035
	 */
2071
	 */
2036
	public Block newBlock() {
2072
	public Block newBlock() {
2037
		return new Block(this);
2073
		return new Block(this);
2038
	}
2074
	}
2039
	
2075
2040
	/**
2076
	/**
2041
	 * Creates an unparented continue statement node owned by this AST.
2077
	 * Creates an unparented continue statement node owned by this AST.
2042
	 * The continue statement has no label.
2078
	 * The continue statement has no label.
2043
	 * 
2079
	 *
2044
	 * @return a new unparented continue statement node
2080
	 * @return a new unparented continue statement node
2045
	 */
2081
	 */
2046
	public ContinueStatement newContinueStatement() {
2082
	public ContinueStatement newContinueStatement() {
2047
		return new ContinueStatement(this);
2083
		return new ContinueStatement(this);
2048
	}
2084
	}
2049
	
2085
2050
	/**
2086
	/**
2051
	 * Creates an unparented break statement node owned by this AST.
2087
	 * Creates an unparented break statement node owned by this AST.
2052
	 * The break statement has no label.
2088
	 * The break statement has no label.
2053
	 * 
2089
	 *
2054
	 * @return a new unparented break statement node
2090
	 * @return a new unparented break statement node
2055
	 */
2091
	 */
2056
	public BreakStatement newBreakStatement() {
2092
	public BreakStatement newBreakStatement() {
2057
		return new BreakStatement(this);
2093
		return new BreakStatement(this);
2058
	}
2094
	}
2059
	
2095
2060
	/**
2096
	/**
2061
	 * Creates a new unparented expression statement node owned by this AST,
2097
	 * Creates a new unparented expression statement node owned by this AST,
2062
	 * for the given expression.
2098
	 * for the given expression.
2063
	 * <p>
2099
	 * <p>
2064
	 * This method can be used to convert an expression 
2100
	 * This method can be used to convert an expression
2065
	 * (<code>Expression</code>) into a statement (<code>Type</code>) 
2101
	 * (<code>Expression</code>) into a statement (<code>Type</code>)
2066
	 * by wrapping it. Note, however, that the result is only legal for 
2102
	 * by wrapping it. Note, however, that the result is only legal for
2067
	 * limited expression types, including method invocations, assignments,
2103
	 * limited expression types, including method invocations, assignments,
2068
	 * and increment/decrement operations.
2104
	 * and increment/decrement operations.
2069
	 * </p>
2105
	 * </p>
2070
	 * 
2106
	 *
2071
	 * @param expression the expression
2107
	 * @param expression the expression
2072
	 * @return a new unparented statement node
2108
	 * @return a new unparented statement node
2073
	 * @exception IllegalArgumentException if:
2109
	 * @exception IllegalArgumentException if:
Lines 2082-2093 Link Here
2082
		result.setExpression(expression);
2118
		result.setExpression(expression);
2083
		return result;
2119
		return result;
2084
	}
2120
	}
2085
	
2121
2086
	/**
2122
	/**
2087
	 * Creates a new unparented if statement node owned by this AST.
2123
	 * Creates a new unparented if statement node owned by this AST.
2088
	 * By default, the expression is unspecified (but legal), 
2124
	 * By default, the expression is unspecified (but legal),
2089
	 * the then statement is an empty block, and there is no else statement.
2125
	 * the then statement is an empty block, and there is no else statement.
2090
	 * 
2126
	 *
2091
	 * @return a new unparented if statement node
2127
	 * @return a new unparented if statement node
2092
	 */
2128
	 */
2093
	public IfStatement newIfStatement() {
2129
	public IfStatement newIfStatement() {
Lines 2098-2104 Link Here
2098
	 * Creates a new unparented while statement node owned by this AST.
2134
	 * Creates a new unparented while statement node owned by this AST.
2099
	 * By default, the expression is unspecified (but legal), and
2135
	 * By default, the expression is unspecified (but legal), and
2100
	 * the body statement is an empty block.
2136
	 * the body statement is an empty block.
2101
	 * 
2137
	 *
2102
	 * @return a new unparented while statement node
2138
	 * @return a new unparented while statement node
2103
	 */
2139
	 */
2104
	public WhileStatement newWhileStatement() {
2140
	public WhileStatement newWhileStatement() {
Lines 2109-2115 Link Here
2109
	 * Creates a new unparented do statement node owned by this AST.
2145
	 * Creates a new unparented do statement node owned by this AST.
2110
	 * By default, the expression is unspecified (but legal), and
2146
	 * By default, the expression is unspecified (but legal), and
2111
	 * the body statement is an empty block.
2147
	 * the body statement is an empty block.
2112
	 * 
2148
	 *
2113
	 * @return a new unparented do statement node
2149
	 * @return a new unparented do statement node
2114
	 */
2150
	 */
2115
	public DoStatement newDoStatement() {
2151
	public DoStatement newDoStatement() {
Lines 2120-2126 Link Here
2120
	 * Creates a new unparented try statement node owned by this AST.
2156
	 * Creates a new unparented try statement node owned by this AST.
2121
	 * By default, the try statement has an empty block, no catch
2157
	 * By default, the try statement has an empty block, no catch
2122
	 * clauses, and no finally block.
2158
	 * clauses, and no finally block.
2123
	 * 
2159
	 *
2124
	 * @return a new unparented try statement node
2160
	 * @return a new unparented try statement node
2125
	 */
2161
	 */
2126
	public TryStatement newTryStatement() {
2162
	public TryStatement newTryStatement() {
Lines 2129-2137 Link Here
2129
2165
2130
	/**
2166
	/**
2131
	 * Creates a new unparented catch clause node owned by this AST.
2167
	 * Creates a new unparented catch clause node owned by this AST.
2132
	 * By default, the catch clause declares an unspecified, but legal, 
2168
	 * By default, the catch clause declares an unspecified, but legal,
2133
	 * exception declaration and has an empty block.
2169
	 * exception declaration and has an empty block.
2134
	 * 
2170
	 *
2135
	 * @return a new unparented catch clause node
2171
	 * @return a new unparented catch clause node
2136
	 */
2172
	 */
2137
	public CatchClause newCatchClause() {
2173
	public CatchClause newCatchClause() {
Lines 2141-2147 Link Here
2141
	/**
2177
	/**
2142
	 * Creates a new unparented return statement node owned by this AST.
2178
	 * Creates a new unparented return statement node owned by this AST.
2143
	 * By default, the return statement has no expression.
2179
	 * By default, the return statement has no expression.
2144
	 * 
2180
	 *
2145
	 * @return a new unparented return statement node
2181
	 * @return a new unparented return statement node
2146
	 */
2182
	 */
2147
	public ReturnStatement newReturnStatement() {
2183
	public ReturnStatement newReturnStatement() {
Lines 2151-2157 Link Here
2151
	/**
2187
	/**
2152
	 * Creates a new unparented throw statement node owned by this AST.
2188
	 * Creates a new unparented throw statement node owned by this AST.
2153
	 * By default, the expression is unspecified, but legal.
2189
	 * By default, the expression is unspecified, but legal.
2154
	 * 
2190
	 *
2155
	 * @return a new unparented throw statement node
2191
	 * @return a new unparented throw statement node
2156
	 */
2192
	 */
2157
	public ThrowStatement newThrowStatement() {
2193
	public ThrowStatement newThrowStatement() {
Lines 2162-2168 Link Here
2162
	 * Creates a new unparented assert statement node owned by this AST.
2198
	 * Creates a new unparented assert statement node owned by this AST.
2163
	 * By default, the first expression is unspecified, but legal, and has no
2199
	 * By default, the first expression is unspecified, but legal, and has no
2164
	 * message expression.
2200
	 * message expression.
2165
	 * 
2201
	 *
2166
	 * @return a new unparented assert statement node
2202
	 * @return a new unparented assert statement node
2167
	 */
2203
	 */
2168
	public AssertStatement newAssertStatement() {
2204
	public AssertStatement newAssertStatement() {
Lines 2171-2177 Link Here
2171
2207
2172
	/**
2208
	/**
2173
	 * Creates a new unparented empty statement node owned by this AST.
2209
	 * Creates a new unparented empty statement node owned by this AST.
2174
	 * 
2210
	 *
2175
	 * @return a new unparented empty statement node
2211
	 * @return a new unparented empty statement node
2176
	 */
2212
	 */
2177
	public EmptyStatement newEmptyStatement() {
2213
	public EmptyStatement newEmptyStatement() {
Lines 2181-2187 Link Here
2181
	/**
2217
	/**
2182
	 * Creates a new unparented labeled statement node owned by this AST.
2218
	 * Creates a new unparented labeled statement node owned by this AST.
2183
	 * By default, the label and statement are both unspecified, but legal.
2219
	 * By default, the label and statement are both unspecified, but legal.
2184
	 * 
2220
	 *
2185
	 * @return a new unparented labeled statement node
2221
	 * @return a new unparented labeled statement node
2186
	 */
2222
	 */
2187
	public LabeledStatement newLabeledStatement() {
2223
	public LabeledStatement newLabeledStatement() {
Lines 2192-2198 Link Here
2192
	 * Creates a new unparented switch statement node owned by this AST.
2228
	 * Creates a new unparented switch statement node owned by this AST.
2193
	 * By default, the expression is unspecified, but legal, and there are
2229
	 * By default, the expression is unspecified, but legal, and there are
2194
	 * no statements or switch cases.
2230
	 * no statements or switch cases.
2195
	 * 
2231
	 *
2196
	 * @return a new unparented labeled statement node
2232
	 * @return a new unparented labeled statement node
2197
	 */
2233
	 */
2198
	public SwitchStatement newSwitchStatement() {
2234
	public SwitchStatement newSwitchStatement() {
Lines 2200-2208 Link Here
2200
	}
2236
	}
2201
2237
2202
	/**
2238
	/**
2203
	 * Creates a new unparented switch case statement node owned by 
2239
	 * Creates a new unparented switch case statement node owned by
2204
	 * this AST. By default, the expression is unspecified, but legal.
2240
	 * this AST. By default, the expression is unspecified, but legal.
2205
	 * 
2241
	 *
2206
	 * @return a new unparented switch case node
2242
	 * @return a new unparented switch case node
2207
	 */
2243
	 */
2208
	public SwitchCase newSwitchCase() {
2244
	public SwitchCase newSwitchCase() {
Lines 2213-2219 Link Here
2213
	 * Creates a new unparented synchronized statement node owned by this AST.
2249
	 * Creates a new unparented synchronized statement node owned by this AST.
2214
	 * By default, the expression is unspecified, but legal, and the body is
2250
	 * By default, the expression is unspecified, but legal, and the body is
2215
	 * an empty block.
2251
	 * an empty block.
2216
	 * 
2252
	 *
2217
	 * @return a new unparented synchronized statement node
2253
	 * @return a new unparented synchronized statement node
2218
	 */
2254
	 */
2219
	public SynchronizedStatement newSynchronizedStatement() {
2255
	public SynchronizedStatement newSynchronizedStatement() {
Lines 2222-2230 Link Here
2222
2258
2223
	/**
2259
	/**
2224
	 * Creates a new unparented for statement node owned by this AST.
2260
	 * Creates a new unparented for statement node owned by this AST.
2225
	 * By default, there are no initializers, no condition expression, 
2261
	 * By default, there are no initializers, no condition expression,
2226
	 * no updaters, and the body is an empty block.
2262
	 * no updaters, and the body is an empty block.
2227
	 * 
2263
	 *
2228
	 * @return a new unparented for statement node
2264
	 * @return a new unparented for statement node
2229
	 */
2265
	 */
2230
	public ForStatement newForStatement() {
2266
	public ForStatement newForStatement() {
Lines 2235-2241 Link Here
2235
	 * Creates a new unparented enhanced for statement node owned by this AST.
2271
	 * Creates a new unparented enhanced for statement node owned by this AST.
2236
	 * By default, the paramter and expression are unspecified
2272
	 * By default, the paramter and expression are unspecified
2237
	 * but legal subtrees, and the body is an empty block.
2273
	 * but legal subtrees, and the body is an empty block.
2238
	 * 
2274
	 *
2239
	 * @return a new unparented throw statement node
2275
	 * @return a new unparented throw statement node
2240
	 * @exception UnsupportedOperationException if this operation is used in
2276
	 * @exception UnsupportedOperationException if this operation is used in
2241
	 * a JLS2 AST
2277
	 * a JLS2 AST
Lines 2247-2266 Link Here
2247
2283
2248
	//=============================== EXPRESSIONS ===========================
2284
	//=============================== EXPRESSIONS ===========================
2249
	/**
2285
	/**
2250
	 * Creates and returns a new unparented string literal node for 
2286
	 * Creates and returns a new unparented string literal node for
2251
	 * the empty string literal.
2287
	 * the empty string literal.
2252
	 * 
2288
	 *
2253
	 * @return a new unparented string literal node
2289
	 * @return a new unparented string literal node
2254
	 */
2290
	 */
2255
	public StringLiteral newStringLiteral() {
2291
	public StringLiteral newStringLiteral() {
2256
		return new StringLiteral(this);
2292
		return new StringLiteral(this);
2257
	}
2293
	}
2258
	
2294
2259
2295
2260
	/**
2296
	/**
2261
	 * Creates and returns a new unparented character literal node.
2297
	 * Creates and returns a new unparented character literal node.
2262
	 * Initially the node has an unspecified character literal.
2298
	 * Initially the node has an unspecified character literal.
2263
	 * 
2299
	 *
2264
	 * @return a new unparented character literal node
2300
	 * @return a new unparented character literal node
2265
	 */
2301
	 */
2266
	public CharacterLiteral newCharacterLiteral() {
2302
	public CharacterLiteral newCharacterLiteral() {
Lines 2269-2276 Link Here
2269
2305
2270
	/**
2306
	/**
2271
	 * Creates and returns a new unparented number literal node.
2307
	 * Creates and returns a new unparented number literal node.
2272
	 * 
2308
	 *
2273
	 * @param literal the token for the numeric literal as it would 
2309
	 * @param literal the token for the numeric literal as it would
2274
	 *    appear in Java source code
2310
	 *    appear in Java source code
2275
	 * @return a new unparented number literal node
2311
	 * @return a new unparented number literal node
2276
	 * @exception IllegalArgumentException if the literal is null
2312
	 * @exception IllegalArgumentException if the literal is null
Lines 2283-2309 Link Here
2283
		result.setToken(literal);
2319
		result.setToken(literal);
2284
		return result;
2320
		return result;
2285
	}
2321
	}
2286
	
2322
2287
	/**
2323
	/**
2288
	 * Creates and returns a new unparented number literal node.
2324
	 * Creates and returns a new unparented number literal node.
2289
	 * Initially the number literal token is <code>"0"</code>.
2325
	 * Initially the number literal token is <code>"0"</code>.
2290
	 * 
2326
	 *
2291
	 * @return a new unparented number literal node
2327
	 * @return a new unparented number literal node
2292
	 */
2328
	 */
2293
	public NumberLiteral newNumberLiteral() {
2329
	public NumberLiteral newNumberLiteral() {
2294
		NumberLiteral result = new NumberLiteral(this);
2330
		NumberLiteral result = new NumberLiteral(this);
2295
		return result;
2331
		return result;
2296
	}
2332
	}
2297
	
2333
2298
	/**
2334
	/**
2299
	 * Creates and returns a new unparented null literal node.
2335
	 * Creates and returns a new unparented null literal node.
2300
	 * 
2336
	 *
2301
	 * @return a new unparented null literal node
2337
	 * @return a new unparented null literal node
2302
	 */
2338
	 */
2303
	public NullLiteral newNullLiteral() {
2339
	public NullLiteral newNullLiteral() {
2304
		return new NullLiteral(this);
2340
		return new NullLiteral(this);
2305
	}
2341
	}
2306
	
2342
2307
	/**
2343
	/**
2308
	 * Creates and returns a new unparented boolean literal node.
2344
	 * Creates and returns a new unparented boolean literal node.
2309
	 * <p>
2345
	 * <p>
Lines 2317-2323 Link Here
2317
	 * </pre>
2353
	 * </pre>
2318
	 * </code>
2354
	 * </code>
2319
	 * </p>
2355
	 * </p>
2320
	 * 
2356
	 *
2321
	 * @param value the boolean value
2357
	 * @param value the boolean value
2322
	 * @return a new unparented boolean literal node
2358
	 * @return a new unparented boolean literal node
2323
	 */
2359
	 */
Lines 2326-2398 Link Here
2326
		result.setBooleanValue(value);
2362
		result.setBooleanValue(value);
2327
		return result;
2363
		return result;
2328
	}
2364
	}
2329
	
2365
2330
	/**
2366
	/**
2331
	 * Creates and returns a new unparented assignment expression node 
2367
	 * Creates and returns a new unparented assignment expression node
2332
	 * owned by this AST. By default, the assignment operator is "=" and
2368
	 * owned by this AST. By default, the assignment operator is "=" and
2333
	 * the left and right hand side expressions are unspecified, but 
2369
	 * the left and right hand side expressions are unspecified, but
2334
	 * legal, names.
2370
	 * legal, names.
2335
	 * 
2371
	 *
2336
	 * @return a new unparented assignment expression node
2372
	 * @return a new unparented assignment expression node
2337
	 */
2373
	 */
2338
	public Assignment newAssignment() {
2374
	public Assignment newAssignment() {
2339
		Assignment result = new Assignment(this);
2375
		Assignment result = new Assignment(this);
2340
		return result;
2376
		return result;
2341
	}
2377
	}
2342
	
2378
2343
	/**
2379
	/**
2344
	 * Creates an unparented method invocation expression node owned by this 
2380
	 * Creates an unparented method invocation expression node owned by this
2345
	 * AST. By default, the name of the method is unspecified (but legal) 
2381
	 * AST. By default, the name of the method is unspecified (but legal)
2346
	 * there is no receiver expression, no type arguments, and the list of
2382
	 * there is no receiver expression, no type arguments, and the list of
2347
	 * arguments is empty.
2383
	 * arguments is empty.
2348
	 * 
2384
	 *
2349
	 * @return a new unparented method invocation expression node
2385
	 * @return a new unparented method invocation expression node
2350
	 */
2386
	 */
2351
	public MethodInvocation newMethodInvocation() {
2387
	public MethodInvocation newMethodInvocation() {
2352
		MethodInvocation result = new MethodInvocation(this);
2388
		MethodInvocation result = new MethodInvocation(this);
2353
		return result;
2389
		return result;
2354
	}
2390
	}
2355
	
2391
2356
	/**
2392
	/**
2357
	 * Creates an unparented "super" method invocation expression node owned by 
2393
	 * Creates an unparented "super" method invocation expression node owned by
2358
	 * this AST. By default, the name of the method is unspecified (but legal) 
2394
	 * this AST. By default, the name of the method is unspecified (but legal)
2359
	 * there is no qualifier, no type arguments, and the list of arguments is empty.
2395
	 * there is no qualifier, no type arguments, and the list of arguments is empty.
2360
	 * 
2396
	 *
2361
	 * @return a new unparented  "super" method invocation 
2397
	 * @return a new unparented  "super" method invocation
2362
	 *    expression node
2398
	 *    expression node
2363
	 */
2399
	 */
2364
	public SuperMethodInvocation newSuperMethodInvocation() {
2400
	public SuperMethodInvocation newSuperMethodInvocation() {
2365
		SuperMethodInvocation result = new SuperMethodInvocation(this);
2401
		SuperMethodInvocation result = new SuperMethodInvocation(this);
2366
		return result;
2402
		return result;
2367
	}
2403
	}
2368
	
2404
2369
	/**
2405
	/**
2370
	 * Creates an unparented alternate constructor ("this(...);") invocation 
2406
	 * Creates an unparented alternate constructor ("this(...);") invocation
2371
	 * statement node owned by this AST. By default, the lists of arguments
2407
	 * statement node owned by this AST. By default, the lists of arguments
2372
	 * and type arguments are both empty.
2408
	 * and type arguments are both empty.
2373
	 * <p>
2409
	 * <p>
2374
	 * Note that this type of node is a Statement, whereas a regular
2410
	 * Note that this type of node is a Statement, whereas a regular
2375
	 * method invocation is an Expression. The only valid use of these 
2411
	 * method invocation is an Expression. The only valid use of these
2376
	 * statements are as the first statement of a constructor body.
2412
	 * statements are as the first statement of a constructor body.
2377
	 * </p>
2413
	 * </p>
2378
	 * 
2414
	 *
2379
	 * @return a new unparented alternate constructor invocation statement node
2415
	 * @return a new unparented alternate constructor invocation statement node
2380
	 */
2416
	 */
2381
	public ConstructorInvocation newConstructorInvocation() {
2417
	public ConstructorInvocation newConstructorInvocation() {
2382
		ConstructorInvocation result = new ConstructorInvocation(this);
2418
		ConstructorInvocation result = new ConstructorInvocation(this);
2383
		return result;
2419
		return result;
2384
	}
2420
	}
2385
	
2421
2386
	/**
2422
	/**
2387
	 * Creates an unparented alternate super constructor ("super(...);") 
2423
	 * Creates an unparented alternate super constructor ("super(...);")
2388
	 * invocation statement node owned by this AST. By default, there is no
2424
	 * invocation statement node owned by this AST. By default, there is no
2389
	 * qualifier, no type arguments, and the list of arguments is empty.
2425
	 * qualifier, no type arguments, and the list of arguments is empty.
2390
	 * <p>
2426
	 * <p>
2391
	 * Note that this type of node is a Statement, whereas a regular
2427
	 * Note that this type of node is a Statement, whereas a regular
2392
	 * super method invocation is an Expression. The only valid use of these 
2428
	 * super method invocation is an Expression. The only valid use of these
2393
	 * statements are as the first statement of a constructor body.
2429
	 * statements are as the first statement of a constructor body.
2394
	 * </p>
2430
	 * </p>
2395
	 * 
2431
	 *
2396
	 * @return a new unparented super constructor invocation statement node
2432
	 * @return a new unparented super constructor invocation statement node
2397
	 */
2433
	 */
2398
	public SuperConstructorInvocation newSuperConstructorInvocation() {
2434
	public SuperConstructorInvocation newSuperConstructorInvocation() {
Lines 2400-2409 Link Here
2400
			new SuperConstructorInvocation(this);
2436
			new SuperConstructorInvocation(this);
2401
		return result;
2437
		return result;
2402
	}
2438
	}
2403
		
2439
2404
	/**
2440
	/**
2405
	 * Creates a new unparented local variable declaration expression node 
2441
	 * Creates a new unparented local variable declaration expression node
2406
	 * owned by this AST, for the given variable declaration fragment. By 
2442
	 * owned by this AST, for the given variable declaration fragment. By
2407
	 * default, there are no modifiers and the base type is unspecified
2443
	 * default, there are no modifiers and the base type is unspecified
2408
	 * (but legal).
2444
	 * (but legal).
2409
	 * <p>
2445
	 * <p>
Lines 2412-2418 Link Here
2412
	 * (<code>Expression</code>) by wrapping it. Additional variable
2448
	 * (<code>Expression</code>) by wrapping it. Additional variable
2413
	 * declaration fragments can be added afterwards.
2449
	 * declaration fragments can be added afterwards.
2414
	 * </p>
2450
	 * </p>
2415
	 * 
2451
	 *
2416
	 * @param fragment the first variable declaration fragment
2452
	 * @param fragment the first variable declaration fragment
2417
	 * @return a new unparented variable declaration expression node
2453
	 * @return a new unparented variable declaration expression node
2418
	 * @exception IllegalArgumentException if:
2454
	 * @exception IllegalArgumentException if:
Lines 2434-2444 Link Here
2434
		result.fragments().add(fragment);
2470
		result.fragments().add(fragment);
2435
		return result;
2471
		return result;
2436
	}
2472
	}
2437
	
2473
2438
	/**
2474
	/**
2439
	 * Creates a new unparented field declaration node owned by this AST, 
2475
	 * Creates a new unparented field declaration node owned by this AST,
2440
	 * for the given variable declaration fragment. By default, there are no
2476
	 * for the given variable declaration fragment. By default, there are no
2441
	 * modifiers, no doc comment, and the base type is unspecified 
2477
	 * modifiers, no doc comment, and the base type is unspecified
2442
	 * (but legal).
2478
	 * (but legal).
2443
	 * <p>
2479
	 * <p>
2444
	 * This method can be used to wrap a variable declaration fragment
2480
	 * This method can be used to wrap a variable declaration fragment
Lines 2447-2453 Link Here
2447
	 * (<code>FieldDeclaration</code> implements <code>BodyDeclaration</code>).
2483
	 * (<code>FieldDeclaration</code> implements <code>BodyDeclaration</code>).
2448
	 * Additional variable declaration fragments can be added afterwards.
2484
	 * Additional variable declaration fragments can be added afterwards.
2449
	 * </p>
2485
	 * </p>
2450
	 * 
2486
	 *
2451
	 * @param fragment the variable declaration fragment
2487
	 * @param fragment the variable declaration fragment
2452
	 * @return a new unparented field declaration node
2488
	 * @return a new unparented field declaration node
2453
	 * @exception IllegalArgumentException if:
2489
	 * @exception IllegalArgumentException if:
Lines 2466-2476 Link Here
2466
		result.fragments().add(fragment);
2502
		result.fragments().add(fragment);
2467
		return result;
2503
		return result;
2468
	}
2504
	}
2469
	
2505
2470
	/**
2506
	/**
2471
	 * Creates and returns a new unparented "this" expression node 
2507
	 * Creates and returns a new unparented "this" expression node
2472
	 * owned by this AST. By default, there is no qualifier.
2508
	 * owned by this AST. By default, there is no qualifier.
2473
	 * 
2509
	 *
2474
	 * @return a new unparented "this" expression node
2510
	 * @return a new unparented "this" expression node
2475
	 */
2511
	 */
2476
	public ThisExpression newThisExpression() {
2512
	public ThisExpression newThisExpression() {
Lines 2479-2488 Link Here
2479
	}
2515
	}
2480
2516
2481
	/**
2517
	/**
2482
	 * Creates and returns a new unparented field access expression node 
2518
	 * Creates and returns a new unparented field access expression node
2483
	 * owned by this AST. By default, the expression and field are both
2519
	 * owned by this AST. By default, the expression and field are both
2484
	 * unspecified, but legal, names.
2520
	 * unspecified, but legal, names.
2485
	 * 
2521
	 *
2486
	 * @return a new unparented field access expression node
2522
	 * @return a new unparented field access expression node
2487
	 */
2523
	 */
2488
	public FieldAccess newFieldAccess() {
2524
	public FieldAccess newFieldAccess() {
Lines 2491-2500 Link Here
2491
	}
2527
	}
2492
2528
2493
	/**
2529
	/**
2494
	 * Creates and returns a new unparented super field access expression node 
2530
	 * Creates and returns a new unparented super field access expression node
2495
	 * owned by this AST. By default, the expression and field are both
2531
	 * owned by this AST. By default, the expression and field are both
2496
	 * unspecified, but legal, names.
2532
	 * unspecified, but legal, names.
2497
	 * 
2533
	 *
2498
	 * @return a new unparented super field access expression node
2534
	 * @return a new unparented super field access expression node
2499
	 */
2535
	 */
2500
	public SuperFieldAccess newSuperFieldAccess() {
2536
	public SuperFieldAccess newSuperFieldAccess() {
Lines 2503-2511 Link Here
2503
	}
2539
	}
2504
2540
2505
	/**
2541
	/**
2506
	 * Creates and returns a new unparented type literal expression node 
2542
	 * Creates and returns a new unparented type literal expression node
2507
	 * owned by this AST. By default, the type is unspecified (but legal).
2543
	 * owned by this AST. By default, the type is unspecified (but legal).
2508
	 * 
2544
	 *
2509
	 * @return a new unparented type literal node
2545
	 * @return a new unparented type literal node
2510
	 */
2546
	 */
2511
	public TypeLiteral newTypeLiteral() {
2547
	public TypeLiteral newTypeLiteral() {
Lines 2514-2523 Link Here
2514
	}
2550
	}
2515
2551
2516
	/**
2552
	/**
2517
	 * Creates and returns a new unparented cast expression node 
2553
	 * Creates and returns a new unparented cast expression node
2518
	 * owned by this AST. By default, the type and expression are unspecified
2554
	 * owned by this AST. By default, the type and expression are unspecified
2519
	 * (but legal).
2555
	 * (but legal).
2520
	 * 
2556
	 *
2521
	 * @return a new unparented cast expression node
2557
	 * @return a new unparented cast expression node
2522
	 */
2558
	 */
2523
	public CastExpression newCastExpression() {
2559
	public CastExpression newCastExpression() {
Lines 2526-2534 Link Here
2526
	}
2562
	}
2527
2563
2528
	/**
2564
	/**
2529
	 * Creates and returns a new unparented parenthesized expression node 
2565
	 * Creates and returns a new unparented parenthesized expression node
2530
	 * owned by this AST. By default, the expression is unspecified (but legal).
2566
	 * owned by this AST. By default, the expression is unspecified (but legal).
2531
	 * 
2567
	 *
2532
	 * @return a new unparented parenthesized expression node
2568
	 * @return a new unparented parenthesized expression node
2533
	 */
2569
	 */
2534
	public ParenthesizedExpression newParenthesizedExpression() {
2570
	public ParenthesizedExpression newParenthesizedExpression() {
Lines 2537-2547 Link Here
2537
	}
2573
	}
2538
2574
2539
	/**
2575
	/**
2540
	 * Creates and returns a new unparented infix expression node 
2576
	 * Creates and returns a new unparented infix expression node
2541
	 * owned by this AST. By default, the operator and left and right
2577
	 * owned by this AST. By default, the operator and left and right
2542
	 * operand are unspecified (but legal), and there are no extended
2578
	 * operand are unspecified (but legal), and there are no extended
2543
	 * operands.
2579
	 * operands.
2544
	 * 
2580
	 *
2545
	 * @return a new unparented infix expression node
2581
	 * @return a new unparented infix expression node
2546
	 */
2582
	 */
2547
	public InfixExpression newInfixExpression() {
2583
	public InfixExpression newInfixExpression() {
Lines 2550-2559 Link Here
2550
	}
2586
	}
2551
2587
2552
	/**
2588
	/**
2553
	 * Creates and returns a new unparented instanceof expression node 
2589
	 * Creates and returns a new unparented instanceof expression node
2554
	 * owned by this AST. By default, the operator and left and right
2590
	 * owned by this AST. By default, the operator and left and right
2555
	 * operand are unspecified (but legal).
2591
	 * operand are unspecified (but legal).
2556
	 * 
2592
	 *
2557
	 * @return a new unparented instanceof expression node
2593
	 * @return a new unparented instanceof expression node
2558
	 */
2594
	 */
2559
	public InstanceofExpression newInstanceofExpression() {
2595
	public InstanceofExpression newInstanceofExpression() {
Lines 2562-2571 Link Here
2562
	}
2598
	}
2563
2599
2564
	/**
2600
	/**
2565
	 * Creates and returns a new unparented postfix expression node 
2601
	 * Creates and returns a new unparented postfix expression node
2566
	 * owned by this AST. By default, the operator and operand are 
2602
	 * owned by this AST. By default, the operator and operand are
2567
	 * unspecified (but legal).
2603
	 * unspecified (but legal).
2568
	 * 
2604
	 *
2569
	 * @return a new unparented postfix expression node
2605
	 * @return a new unparented postfix expression node
2570
	 */
2606
	 */
2571
	public PostfixExpression newPostfixExpression() {
2607
	public PostfixExpression newPostfixExpression() {
Lines 2574-2583 Link Here
2574
	}
2610
	}
2575
2611
2576
	/**
2612
	/**
2577
	 * Creates and returns a new unparented prefix expression node 
2613
	 * Creates and returns a new unparented prefix expression node
2578
	 * owned by this AST. By default, the operator and operand are 
2614
	 * owned by this AST. By default, the operator and operand are
2579
	 * unspecified (but legal).
2615
	 * unspecified (but legal).
2580
	 * 
2616
	 *
2581
	 * @return a new unparented prefix expression node
2617
	 * @return a new unparented prefix expression node
2582
	 */
2618
	 */
2583
	public PrefixExpression newPrefixExpression() {
2619
	public PrefixExpression newPrefixExpression() {
Lines 2586-2595 Link Here
2586
	}
2622
	}
2587
2623
2588
	/**
2624
	/**
2589
	 * Creates and returns a new unparented array access expression node 
2625
	 * Creates and returns a new unparented array access expression node
2590
	 * owned by this AST. By default, the array and index expression are 
2626
	 * owned by this AST. By default, the array and index expression are
2591
	 * both unspecified (but legal).
2627
	 * both unspecified (but legal).
2592
	 * 
2628
	 *
2593
	 * @return a new unparented array access expression node
2629
	 * @return a new unparented array access expression node
2594
	 */
2630
	 */
2595
	public ArrayAccess newArrayAccess() {
2631
	public ArrayAccess newArrayAccess() {
Lines 2598-2604 Link Here
2598
	}
2634
	}
2599
2635
2600
	/**
2636
	/**
2601
	 * Creates and returns a new unparented array creation expression node 
2637
	 * Creates and returns a new unparented array creation expression node
2602
	 * owned by this AST. By default, the array type is an unspecified
2638
	 * owned by this AST. By default, the array type is an unspecified
2603
	 * 1-dimensional array, the list of dimensions is empty, and there is no
2639
	 * 1-dimensional array, the list of dimensions is empty, and there is no
2604
	 * array initializer.
2640
	 * array initializer.
Lines 2633-2639 Link Here
2633
	 * </pre>
2669
	 * </pre>
2634
	 * </code>
2670
	 * </code>
2635
	 * </p>
2671
	 * </p>
2636
	 * 
2672
	 *
2637
	 * @return a new unparented array creation expression node
2673
	 * @return a new unparented array creation expression node
2638
	 */
2674
	 */
2639
	public ArrayCreation newArrayCreation() {
2675
	public ArrayCreation newArrayCreation() {
Lines 2642-2653 Link Here
2642
	}
2678
	}
2643
2679
2644
	/**
2680
	/**
2645
	 * Creates and returns a new unparented class instance creation 
2681
	 * Creates and returns a new unparented class instance creation
2646
	 * ("new") expression node owned by this AST. By default, 
2682
	 * ("new") expression node owned by this AST. By default,
2647
	 * there is no qualifying expression, no type parameters,
2683
	 * there is no qualifying expression, no type parameters,
2648
	 * an unspecified (but legal) type name, an empty list of
2684
	 * an unspecified (but legal) type name, an empty list of
2649
	 * arguments, and does not declare an anonymous class declaration.
2685
	 * arguments, and does not declare an anonymous class declaration.
2650
	 * 
2686
	 *
2651
	 * @return a new unparented class instance creation expression node
2687
	 * @return a new unparented class instance creation expression node
2652
	 */
2688
	 */
2653
	public ClassInstanceCreation newClassInstanceCreation() {
2689
	public ClassInstanceCreation newClassInstanceCreation() {
Lines 2658-2664 Link Here
2658
	/**
2694
	/**
2659
	 * Creates and returns a new unparented anonymous class declaration
2695
	 * Creates and returns a new unparented anonymous class declaration
2660
	 * node owned by this AST. By default, the body declaration list is empty.
2696
	 * node owned by this AST. By default, the body declaration list is empty.
2661
	 * 
2697
	 *
2662
	 * @return a new unparented anonymous class declaration node
2698
	 * @return a new unparented anonymous class declaration node
2663
	 */
2699
	 */
2664
	public AnonymousClassDeclaration newAnonymousClassDeclaration() {
2700
	public AnonymousClassDeclaration newAnonymousClassDeclaration() {
Lines 2667-2675 Link Here
2667
	}
2703
	}
2668
2704
2669
	/**
2705
	/**
2670
	 * Creates and returns a new unparented array initializer node 
2706
	 * Creates and returns a new unparented array initializer node
2671
	 * owned by this AST. By default, the initializer has no expressions.
2707
	 * owned by this AST. By default, the initializer has no expressions.
2672
	 * 
2708
	 *
2673
	 * @return a new unparented array initializer node
2709
	 * @return a new unparented array initializer node
2674
	 */
2710
	 */
2675
	public ArrayInitializer newArrayInitializer() {
2711
	public ArrayInitializer newArrayInitializer() {
Lines 2678-2701 Link Here
2678
	}
2714
	}
2679
2715
2680
	/**
2716
	/**
2681
	 * Creates and returns a new unparented conditional expression node 
2717
	 * Creates and returns a new unparented conditional expression node
2682
	 * owned by this AST. By default, the condition and both expressions
2718
	 * owned by this AST. By default, the condition and both expressions
2683
	 * are unspecified (but legal).
2719
	 * are unspecified (but legal).
2684
	 * 
2720
	 *
2685
	 * @return a new unparented array conditional expression node
2721
	 * @return a new unparented array conditional expression node
2686
	 */
2722
	 */
2687
	public ConditionalExpression newConditionalExpression() {
2723
	public ConditionalExpression newConditionalExpression() {
2688
		ConditionalExpression result = new ConditionalExpression(this);
2724
		ConditionalExpression result = new ConditionalExpression(this);
2689
		return result;
2725
		return result;
2690
	}
2726
	}
2691
	
2727
2692
	//=============================== ANNOTATIONS ====================
2728
	//=============================== ANNOTATIONS ====================
2693
	
2729
2694
	/**
2730
	/**
2695
	 * Creates and returns a new unparented normal annotation node with
2731
	 * Creates and returns a new unparented normal annotation node with
2696
	 * an unspecified type name and an empty list of member value
2732
	 * an unspecified type name and an empty list of member value
2697
	 * pairs.
2733
	 * pairs.
2698
	 * 
2734
	 *
2699
	 * @return a new unparented normal annotation node
2735
	 * @return a new unparented normal annotation node
2700
	 * @exception UnsupportedOperationException if this operation is used in
2736
	 * @exception UnsupportedOperationException if this operation is used in
2701
	 * a JLS2 AST
2737
	 * a JLS2 AST
Lines 2705-2715 Link Here
2705
		NormalAnnotation result = new NormalAnnotation(this);
2741
		NormalAnnotation result = new NormalAnnotation(this);
2706
		return result;
2742
		return result;
2707
	}
2743
	}
2708
	
2744
2709
	/**
2745
	/**
2710
	 * Creates and returns a new unparented marker annotation node with
2746
	 * Creates and returns a new unparented marker annotation node with
2711
	 * an unspecified type name.
2747
	 * an unspecified type name.
2712
	 * 
2748
	 *
2713
	 * @return a new unparented marker annotation node
2749
	 * @return a new unparented marker annotation node
2714
	 * @exception UnsupportedOperationException if this operation is used in
2750
	 * @exception UnsupportedOperationException if this operation is used in
2715
	 * a JLS2 AST
2751
	 * a JLS2 AST
Lines 2719-2729 Link Here
2719
		MarkerAnnotation result = new MarkerAnnotation(this);
2755
		MarkerAnnotation result = new MarkerAnnotation(this);
2720
		return result;
2756
		return result;
2721
	}
2757
	}
2722
	
2758
2723
	/**
2759
	/**
2724
	 * Creates and returns a new unparented single member annotation node with
2760
	 * Creates and returns a new unparented single member annotation node with
2725
	 * an unspecified type name and value.
2761
	 * an unspecified type name and value.
2726
	 * 
2762
	 *
2727
	 * @return a new unparented single member annotation node
2763
	 * @return a new unparented single member annotation node
2728
	 * @exception UnsupportedOperationException if this operation is used in
2764
	 * @exception UnsupportedOperationException if this operation is used in
2729
	 * a JLS2 AST
2765
	 * a JLS2 AST
Lines 2733-2743 Link Here
2733
		SingleMemberAnnotation result = new SingleMemberAnnotation(this);
2769
		SingleMemberAnnotation result = new SingleMemberAnnotation(this);
2734
		return result;
2770
		return result;
2735
	}
2771
	}
2736
	
2772
2737
	/**
2773
	/**
2738
	 * Creates and returns a new unparented member value pair node with
2774
	 * Creates and returns a new unparented member value pair node with
2739
	 * an unspecified member name and value.
2775
	 * an unspecified member name and value.
2740
	 * 
2776
	 *
2741
	 * @return a new unparented member value pair node
2777
	 * @return a new unparented member value pair node
2742
	 * @exception UnsupportedOperationException if this operation is used in
2778
	 * @exception UnsupportedOperationException if this operation is used in
2743
	 * a JLS2 AST
2779
	 * a JLS2 AST
Lines 2747-2753 Link Here
2747
		MemberValuePair result = new MemberValuePair(this);
2783
		MemberValuePair result = new MemberValuePair(this);
2748
		return result;
2784
		return result;
2749
	}
2785
	}
2750
	
2786
2751
	/**
2787
	/**
2752
	 * Enables the recording of changes to the given compilation
2788
	 * Enables the recording of changes to the given compilation
2753
	 * unit and its descendents. The compilation unit must have
2789
	 * unit and its descendents. The compilation unit must have
Lines 2756-2766 Link Here
2756
	 * arbitrary changes to the subtree rooted at the compilation
2792
	 * arbitrary changes to the subtree rooted at the compilation
2757
	 * unit are recorded internally. Once the modification has
2793
	 * unit are recorded internally. Once the modification has
2758
	 * been completed, call <code>rewrite</code> to get an object
2794
	 * been completed, call <code>rewrite</code> to get an object
2759
	 * representing the corresponding edits to the original 
2795
	 * representing the corresponding edits to the original
2760
	 * source code string.
2796
	 * source code string.
2761
	 *
2797
	 *
2762
	 * @exception IllegalArgumentException if this compilation unit is
2798
	 * @exception IllegalArgumentException if this compilation unit is
2763
	 * marked as unmodifiable, or if this compilation unit has already 
2799
	 * marked as unmodifiable, or if this compilation unit has already
2764
	 * been tampered with, or if recording has already been enabled,
2800
	 * been tampered with, or if recording has already been enabled,
2765
	 * or if <code>root</code> is not owned by this AST
2801
	 * or if <code>root</code> is not owned by this AST
2766
	 * @see CompilationUnit#recordModifications()
2802
	 * @see CompilationUnit#recordModifications()
Lines 2776-2782 Link Here
2776
		} else if(root.getAST() != this) {
2812
		} else if(root.getAST() != this) {
2777
			throw new IllegalArgumentException("Root node is not owned by this ast"); //$NON-NLS-1$
2813
			throw new IllegalArgumentException("Root node is not owned by this ast"); //$NON-NLS-1$
2778
		}
2814
		}
2779
		
2815
2780
		this.rewriter = new InternalASTRewrite(root);
2816
		this.rewriter = new InternalASTRewrite(root);
2781
		this.setEventHandler(this.rewriter);
2817
		this.setEventHandler(this.rewriter);
2782
	}
2818
	}
Lines 2787-2793 Link Here
2787
	 * given document containing the original source
2823
	 * given document containing the original source
2788
	 * code for the compilation unit that gave rise to
2824
	 * code for the compilation unit that gave rise to
2789
	 * this AST.
2825
	 * this AST.
2790
	 * 
2826
	 *
2791
	 * @param document original document containing source code
2827
	 * @param document original document containing source code
2792
	 * for the compilation unit
2828
	 * for the compilation unit
2793
	 * @param options the table of formatter options
2829
	 * @param options the table of formatter options
Lines 2812-2816 Link Here
2812
		}
2848
		}
2813
		return this.rewriter.rewriteAST(document, options);
2849
		return this.rewriter.rewriteAST(document, options);
2814
	}
2850
	}
2851
2852
	void setFlag(int newValue) {
2853
		this.bits |= newValue;
2854
	}
2815
}
2855
}
2816
2856
(-)model/org/eclipse/jdt/core/compiler/ReconcileContext.java (-25 / +26 lines)
Lines 9-15 Link Here
9
 *    mkaufman@bea.com - initial API and implementation
9
 *    mkaufman@bea.com - initial API and implementation
10
 *    IBM - renamed from PreReconcileCompilationResult to ReconcileContext
10
 *    IBM - renamed from PreReconcileCompilationResult to ReconcileContext
11
 *    IBM - rewrote spec
11
 *    IBM - rewrote spec
12
 *    
12
 *
13
 *******************************************************************************/
13
 *******************************************************************************/
14
14
15
package org.eclipse.jdt.core.compiler;
15
package org.eclipse.jdt.core.compiler;
Lines 27-53 Link Here
27
import org.eclipse.jdt.internal.core.ReconcileWorkingCopyOperation;
27
import org.eclipse.jdt.internal.core.ReconcileWorkingCopyOperation;
28
28
29
/**
29
/**
30
 * The context of a reconcile event that is notified to interested compilation 
30
 * The context of a reconcile event that is notified to interested compilation
31
 * participants while a reconcile operation is running.
31
 * participants while a reconcile operation is running.
32
 * <p>
32
 * <p>
33
 * A reconcile participant can get the AST for the reconcile-operation using
33
 * A reconcile participant can get the AST for the reconcile-operation using
34
 * {@link #getAST3()}. If the participant modifies in any way the AST 
34
 * {@link #getAST3()}. If the participant modifies in any way the AST
35
 * (either by modifying the source of the working copy, or modifying another entity 
35
 * (either by modifying the source of the working copy, or modifying another entity
36
 * that would result in different bindings for the AST), it is expected to reset the 
36
 * that would result in different bindings for the AST), it is expected to reset the
37
 * AST in the context using {@link #resetAST()}.
37
 * AST in the context using {@link #resetAST()}.
38
 * </p><p>
38
 * </p><p>
39
 * A reconcile participant can also create and return problems using 
39
 * A reconcile participant can also create and return problems using
40
 * {@link #putProblems(String, CategorizedProblem[])}. These problems are then reported 
40
 * {@link #putProblems(String, CategorizedProblem[])}. These problems are then reported
41
 * to the problem requestor of the reconcile operation.
41
 * to the problem requestor of the reconcile operation.
42
 * </p><p>
42
 * </p><p>
43
 * This class is not intended to be instanciated or subclassed by clients.
43
 * This class is not intended to be instanciated or subclassed by clients.
44
 * </p>
44
 * </p>
45
 * 
45
 *
46
 * @see CompilationParticipant#reconcile(ReconcileContext)
46
 * @see CompilationParticipant#reconcile(ReconcileContext)
47
 * @since 3.2
47
 * @since 3.2
48
 */
48
 */
49
public class ReconcileContext {
49
public class ReconcileContext {
50
	
50
51
	private ReconcileWorkingCopyOperation operation;
51
	private ReconcileWorkingCopyOperation operation;
52
	private CompilationUnit workingCopy;
52
	private CompilationUnit workingCopy;
53
53
Lines 56-62 Link Here
56
 * <p>
56
 * <p>
57
 * This constructor is not intended to be called by clients.
57
 * This constructor is not intended to be called by clients.
58
 * </p>
58
 * </p>
59
 * 
59
 *
60
 * @param operation the reconcile operation
60
 * @param operation the reconcile operation
61
 */
61
 */
62
public ReconcileContext(ReconcileWorkingCopyOperation operation, CompilationUnit workingCopy) {
62
public ReconcileContext(ReconcileWorkingCopyOperation operation, CompilationUnit workingCopy) {
Lines 69-83 Link Here
69
 * It is created from the current state of the working copy.
69
 * It is created from the current state of the working copy.
70
 * Creates one if none exists yet.
70
 * Creates one if none exists yet.
71
 * Returns <code>null</code> if the current state of the working copy
71
 * Returns <code>null</code> if the current state of the working copy
72
 * doesn't allow the AST to be created (e.g. if the working copy's content 
72
 * doesn't allow the AST to be created (e.g. if the working copy's content
73
 * cannot be parsed).
73
 * cannot be parsed).
74
 * <p>
74
 * <p>
75
 * If the AST level requested during reconciling is not {@link AST#JLS3}
75
 * If the AST level requested during reconciling is not {@link AST#JLS3}
76
 * or if binding resolutions was not requested, then a different AST is created. 
76
 * or if binding resolutions was not requested, then a different AST is created.
77
 * Note that this AST does not become the current AST and it is only valid for 
77
 * Note that this AST does not become the current AST and it is only valid for
78
 * the requestor.
78
 * the requestor.
79
 * </p>
79
 * </p>
80
 * 
80
 *
81
 * @return the AST created from the current state of the working copy,
81
 * @return the AST created from the current state of the working copy,
82
 *   or <code>null</code> if none could be created
82
 *   or <code>null</code> if none could be created
83
 * @exception JavaModelException  if the contents of the working copy
83
 * @exception JavaModelException  if the contents of the working copy
Lines 94-100 Link Here
94
		if (JavaProject.hasJavaNature(workingCopy.getJavaProject().getProject()))
94
		if (JavaProject.hasJavaNature(workingCopy.getJavaProject().getProject()))
95
			parser.setResolveBindings(true);
95
			parser.setResolveBindings(true);
96
		parser.setSource(workingCopy);
96
		parser.setSource(workingCopy);
97
		return (org.eclipse.jdt.core.dom.CompilationUnit) parser.createAST(this.operation.progressMonitor);		
97
		parser.setStatementsRecovery(this.operation.enableStatementsRecovery);
98
		return (org.eclipse.jdt.core.dom.CompilationUnit) parser.createAST(this.operation.progressMonitor);
98
	}
99
	}
99
	return this.operation.makeConsistent(this.workingCopy, null/*don't report problems to the working copy's problem requestor*/);
100
	return this.operation.makeConsistent(this.workingCopy, null/*don't report problems to the working copy's problem requestor*/);
100
}
101
}
Lines 102-108 Link Here
102
/**
103
/**
103
 * Returns the AST level requested by the reconcile operation.
104
 * Returns the AST level requested by the reconcile operation.
104
 * It is either {@link ICompilationUnit#NO_AST}, or one of the JLS constants defined on {@link AST}.
105
 * It is either {@link ICompilationUnit#NO_AST}, or one of the JLS constants defined on {@link AST}.
105
 * 
106
 *
106
 * @return the AST level requested by the reconcile operation
107
 * @return the AST level requested by the reconcile operation
107
 */
108
 */
108
public int getASTLevel() {
109
public int getASTLevel() {
Lines 111-117 Link Here
111
112
112
/**
113
/**
113
 * Returns whether the reconcile operation is resolving bindings.
114
 * Returns whether the reconcile operation is resolving bindings.
114
 * 
115
 *
115
 * @return whether the reconcile operation is resolving bindings
116
 * @return whether the reconcile operation is resolving bindings
116
 */
117
 */
117
public boolean isResolvingBindings() {
118
public boolean isResolvingBindings() {
Lines 134-140 Link Here
134
 * Returns the problems to be reported to the problem requestor of the reconcile operation
135
 * Returns the problems to be reported to the problem requestor of the reconcile operation
135
 * for the given marker type.
136
 * for the given marker type.
136
 * Returns <code>null</code> if no problems need to be reported for this marker type.
137
 * Returns <code>null</code> if no problems need to be reported for this marker type.
137
 * 
138
 *
138
 * @param markerType the given marker type
139
 * @param markerType the given marker type
139
 * @return problems to be reported to the problem requesto
140
 * @return problems to be reported to the problem requesto
140
 */
141
 */
Lines 145-151 Link Here
145
146
146
/**
147
/**
147
 * Returns the working copy this context refers to.
148
 * Returns the working copy this context refers to.
148
 * 
149
 *
149
 * @return the working copy this context refers to
150
 * @return the working copy this context refers to
150
 */
151
 */
151
public ICompilationUnit getWorkingCopy() {
152
public ICompilationUnit getWorkingCopy() {
Lines 154-166 Link Here
154
155
155
/**
156
/**
156
 * Resets the AST carried by this context.
157
 * Resets the AST carried by this context.
157
 * A compilation participant that modifies the environment that would result in different 
158
 * A compilation participant that modifies the environment that would result in different
158
 * bindings for the AST is expected to reset the AST on this context, so that other 
159
 * bindings for the AST is expected to reset the AST on this context, so that other
159
 * participants don't get a stale AST.
160
 * participants don't get a stale AST.
160
 * <p>
161
 * <p>
161
 * Note that resetting the AST will not restart the reconcile process. Only further 
162
 * Note that resetting the AST will not restart the reconcile process. Only further
162
 * participants will see the new AST. Thus participants running before the one that
163
 * participants will see the new AST. Thus participants running before the one that
163
 * resets the AST will have a stale view of the AST and its problems. Use 
164
 * resets the AST will have a stale view of the AST and its problems. Use
164
 * the compilation participant extension point to order the participants.
165
 * the compilation participant extension point to order the participants.
165
 * </p>
166
 * </p>
166
 */
167
 */
Lines 175-184 Link Here
175
 * for the given marker type.
176
 * for the given marker type.
176
 * <code>null</code> indicates that no problems need to be reported.
177
 * <code>null</code> indicates that no problems need to be reported.
177
 * <p>
178
 * <p>
178
 * Using this functionality, a participant that resolves problems for a given marker type 
179
 * Using this functionality, a participant that resolves problems for a given marker type
179
 * can hide those problems since they don't exist any longer.
180
 * can hide those problems since they don't exist any longer.
180
 * </p>
181
 * </p>
181
 * 
182
 *
182
 * @param markerType the marker type of the given problems
183
 * @param markerType the marker type of the given problems
183
 * @param problems  the problems to be reported to the problem requestor of the reconcile operation,
184
 * @param problems  the problems to be reported to the problem requestor of the reconcile operation,
184
 *   or <code>null</code> if none
185
 *   or <code>null</code> if none

Return to bug 130001