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

(-)compiler/org/eclipse/jdt/internal/compiler/ast/Annotation.java (-1 / +3 lines)
Lines 288-294 Link Here
288
					}
288
					}
289
				}
289
				}
290
			}
290
			}
291
			if (!foundValue && (method.modifiers & ClassFileConstants.AccAnnotationDefault) == 0) {
291
			if (!foundValue &&
292
					(method.modifiers & ClassFileConstants.AccAnnotationDefault) == 0 &&
293
					(this.bits & IsRecovered) == 0) {
292
				scope.problemReporter().missingValueForAnnotationMember(this, selector);
294
				scope.problemReporter().missingValueForAnnotationMember(this, selector);
293
			}
295
			}
294
		}
296
		}
(-)compiler/org/eclipse/jdt/internal/compiler/ast/ASTNode.java (-1 / +4 lines)
Lines 28-34 Link Here
28
	public final static int Bit3 = 0x4;					// return type (operator) | name reference kind (name ref) | implicit this (this ref)
28
	public final static int Bit3 = 0x4;					// return type (operator) | name reference kind (name ref) | implicit this (this ref)
29
	public final static int Bit4 = 0x8;					// return type (operator) | first assignment to local (name ref,local decl) | undocumented empty block (block, type and method decl)
29
	public final static int Bit4 = 0x8;					// return type (operator) | first assignment to local (name ref,local decl) | undocumented empty block (block, type and method decl)
30
	public final static int Bit5 = 0x10;				// value for return (expression) | has all method bodies (unit) | supertype ref (type ref) | resolved (field decl)
30
	public final static int Bit5 = 0x10;				// value for return (expression) | has all method bodies (unit) | supertype ref (type ref) | resolved (field decl)
31
	public final static int Bit6 = 0x20;				// depth (name ref, msg) | ignore need cast check (cast expression) | error in signature (method declaration/ initializer)
31
	public final static int Bit6 = 0x20;				// depth (name ref, msg) | ignore need cast check (cast expression) | error in signature (method declaration/ initializer) | is recovered (annotation reference)
32
	public final static int Bit7 = 0x40;				// depth (name ref, msg) | operator (operator) | need runtime checkcast (cast expression) | label used (labelStatement) | needFreeReturn (AbstractMethodDeclaration)
32
	public final static int Bit7 = 0x40;				// depth (name ref, msg) | operator (operator) | need runtime checkcast (cast expression) | label used (labelStatement) | needFreeReturn (AbstractMethodDeclaration)
33
	public final static int Bit8 = 0x80;				// depth (name ref, msg) | operator (operator) | unsafe cast (cast expression) | is default constructor (constructor declaration)
33
	public final static int Bit8 = 0x80;				// depth (name ref, msg) | operator (operator) | unsafe cast (cast expression) | is default constructor (constructor declaration)
34
	public final static int Bit9 = 0x100;				// depth (name ref, msg) | operator (operator) | is local type (type decl)
34
	public final static int Bit9 = 0x100;				// depth (name ref, msg) | operator (operator) | is local type (type decl)
Lines 217-222 Link Here
217
	// for synchronized statement
217
	// for synchronized statement
218
	public static final int BlockExit = Bit30;
218
	public static final int BlockExit = Bit30;
219
	
219
	
220
	// for annotation reference
221
	public static final int IsRecovered = Bit6;
222
	
220
	// constants used when checking invocation arguments
223
	// constants used when checking invocation arguments
221
	public static final int INVOCATION_ARGUMENT_OK = 0;
224
	public static final int INVOCATION_ARGUMENT_OK = 0;
222
	public static final int INVOCATION_ARGUMENT_UNCHECKED = 1;
225
	public static final int INVOCATION_ARGUMENT_UNCHECKED = 1;
(-)compiler/org/eclipse/jdt/internal/compiler/parser/Parser.java (-8 / +62 lines)
Lines 182-192 Link Here
182
	public boolean reportOnlyOneSyntaxError = false;
182
	public boolean reportOnlyOneSyntaxError = false;
183
	public boolean reportSyntaxErrorIsRequired = true;
183
	public boolean reportSyntaxErrorIsRequired = true;
184
	protected boolean restartRecovery;
184
	protected boolean restartRecovery;
185
	protected boolean annotationRecoveryActivated = true;
185
	
186
	
186
	protected int lastPosistion;
187
	protected int lastPosistion;
187
	
188
	
188
	// statement recovery
189
	// statement recovery
189
//	public boolean statementRecoveryEnabled = true;
190
	public boolean methodRecoveryActivated = false;
190
	public boolean methodRecoveryActivated = false;
191
	protected boolean statementRecoveryActivated = false;
191
	protected boolean statementRecoveryActivated = false;
192
	protected TypeDeclaration[] recoveredTypes;
192
	protected TypeDeclaration[] recoveredTypes;
Lines 888-894 Link Here
888
	this.javadocParser = createJavadocParser();
888
	this.javadocParser = createJavadocParser();
889
}
889
}
890
protected void annotationRecoveryCheckPoint(int start, int end) {
890
protected void annotationRecoveryCheckPoint(int start, int end) {
891
	if(this.lastCheckPoint > start && this.lastCheckPoint < end) {
891
	if(this.lastCheckPoint < end) {
892
		this.lastCheckPoint = end + 1;
892
		this.lastCheckPoint = end + 1;
893
	}
893
	}
894
}
894
}
Lines 1092-1097 Link Here
1092
	this.modifiers |= flag;
1092
	this.modifiers |= flag;
1093
			
1093
			
1094
	if (this.modifiersSourceStart < 0) this.modifiersSourceStart = this.scanner.startPosition;
1094
	if (this.modifiersSourceStart < 0) this.modifiersSourceStart = this.scanner.startPosition;
1095
	
1096
	if (currentElement != null && this.annotationRecoveryActivated) {
1097
		currentElement.addModifier(flag, this.modifiersSourceStart);
1098
	}
1095
}
1099
}
1096
public void checkComment() {
1100
public void checkComment() {
1097
1101
Lines 1263-1268 Link Here
1263
		int start = this.intStack[this.intPtr];
1267
		int start = this.intStack[this.intPtr];
1264
		int end = (int) (this.identifierPositionStack[this.identifierPtr] & 0x00000000FFFFFFFFL);
1268
		int end = (int) (this.identifierPositionStack[this.identifierPtr] & 0x00000000FFFFFFFFL);
1265
		annotationRecoveryCheckPoint(start, end);
1269
		annotationRecoveryCheckPoint(start, end);
1270
	
1271
		if (this.annotationRecoveryActivated) {
1272
			this.currentElement = this.currentElement.addAnnotationName(this.identifierPtr, this.identifierLengthPtr, start, 0);
1273
		}
1266
	}
1274
	}
1267
	this.recordStringLiterals = false;
1275
	this.recordStringLiterals = false;
1268
}
1276
}
Lines 3021-3027 Link Here
3021
	if (this.currentElement != null){ 
3029
	if (this.currentElement != null){ 
3022
		this.lastCheckPoint = anonymousType.bodyStart;		
3030
		this.lastCheckPoint = anonymousType.bodyStart;		
3023
		this.currentElement = this.currentElement.add(anonymousType, 0);
3031
		this.currentElement = this.currentElement.add(anonymousType, 0);
3024
		this.currentToken = 0; // opening brace already taken into account
3032
		if (!(this.currentElement instanceof RecoveredAnnotation)) {
3033
			this.currentToken = 0; // opening brace already taken into account
3034
		} else {
3035
			this.ignoreNextOpeningBrace = true;
3036
			this.currentElement.bracketBalance++;
3037
		}
3025
		this.lastIgnoredToken = -1;
3038
		this.lastIgnoredToken = -1;
3026
	}	
3039
	}	
3027
}
3040
}
Lines 4220-4225 Link Here
4220
protected void consumeMarkerAnnotation() {
4233
protected void consumeMarkerAnnotation() {
4221
	// MarkerAnnotation ::= '@' Name
4234
	// MarkerAnnotation ::= '@' Name
4222
	MarkerAnnotation markerAnnotation = null;
4235
	MarkerAnnotation markerAnnotation = null;
4236
	
4237
	int oldIndex = this.identifierPtr;
4238
	
4223
	TypeReference typeReference = this.getAnnotationType();
4239
	TypeReference typeReference = this.getAnnotationType();
4224
	markerAnnotation = new MarkerAnnotation(typeReference, this.intStack[this.intPtr--]);
4240
	markerAnnotation = new MarkerAnnotation(typeReference, this.intStack[this.intPtr--]);
4225
	markerAnnotation.declarationSourceEnd = markerAnnotation.sourceEnd;
4241
	markerAnnotation.declarationSourceEnd = markerAnnotation.sourceEnd;
Lines 4230-4235 Link Here
4230
		this.problemReporter().invalidUsageOfAnnotation(markerAnnotation);
4246
		this.problemReporter().invalidUsageOfAnnotation(markerAnnotation);
4231
	}
4247
	}
4232
	this.recordStringLiterals = true;
4248
	this.recordStringLiterals = true;
4249
	
4250
	if (this.currentElement != null && this.currentElement instanceof RecoveredAnnotation) {
4251
		this.currentElement = ((RecoveredAnnotation)this.currentElement).addAnnotation(markerAnnotation, oldIndex);
4252
	}
4233
}
4253
}
4234
protected void consumeMemberValueArrayInitializer() {
4254
protected void consumeMemberValueArrayInitializer() {
4235
	// MemberValueArrayInitializer ::= '{' MemberValues ',' '}'
4255
	// MemberValueArrayInitializer ::= '{' MemberValues ',' '}'
Lines 4250-4255 Link Here
4250
	this.expressionLengthPtr--;
4270
	this.expressionLengthPtr--;
4251
	MemberValuePair memberValuePair = new MemberValuePair(simpleName, start, end, value);
4271
	MemberValuePair memberValuePair = new MemberValuePair(simpleName, start, end, value);
4252
	pushOnAstStack(memberValuePair);
4272
	pushOnAstStack(memberValuePair);
4273
	
4274
	if (this.currentElement != null && this.currentElement instanceof RecoveredAnnotation) {
4275
		RecoveredAnnotation recoveredAnnotation = (RecoveredAnnotation) this.currentElement;
4276
		
4277
		recoveredAnnotation.setKind(RecoveredAnnotation.NORMAL);
4278
	}
4253
}
4279
}
4254
protected void consumeMemberValuePairs() {
4280
protected void consumeMemberValuePairs() {
4255
	// MemberValuePairs ::= MemberValuePairs ',' MemberValuePair
4281
	// MemberValuePairs ::= MemberValuePairs ',' MemberValuePair
Lines 4725-4730 Link Here
4725
protected void consumeNormalAnnotation() {
4751
protected void consumeNormalAnnotation() {
4726
	// NormalAnnotation ::= '@' Name '(' MemberValuePairsopt ')'
4752
	// NormalAnnotation ::= '@' Name '(' MemberValuePairsopt ')'
4727
	NormalAnnotation normalAnnotation = null;
4753
	NormalAnnotation normalAnnotation = null;
4754
	
4755
	int oldIndex = this.identifierPtr;
4756
	
4728
	TypeReference typeReference = this.getAnnotationType();
4757
	TypeReference typeReference = this.getAnnotationType();
4729
	normalAnnotation = new NormalAnnotation(typeReference, this.intStack[this.intPtr--]);
4758
	normalAnnotation = new NormalAnnotation(typeReference, this.intStack[this.intPtr--]);
4730
	int length;
4759
	int length;
Lines 4741-4746 Link Here
4741
	
4770
	
4742
	if(this.currentElement != null) {
4771
	if(this.currentElement != null) {
4743
		annotationRecoveryCheckPoint(normalAnnotation.sourceStart, normalAnnotation.declarationSourceEnd);
4772
		annotationRecoveryCheckPoint(normalAnnotation.sourceStart, normalAnnotation.declarationSourceEnd);
4773
		
4774
		if (currentElement instanceof RecoveredAnnotation) {
4775
			this.currentElement = ((RecoveredAnnotation)this.currentElement).addAnnotation(normalAnnotation, oldIndex);
4776
		}
4744
	}
4777
	}
4745
	
4778
	
4746
	if(!this.statementRecoveryActivated &&
4779
	if(!this.statementRecoveryActivated &&
Lines 6738-6760 Link Here
6738
		    consumeMarkerAnnotation() ;  
6771
		    consumeMarkerAnnotation() ;  
6739
			break;
6772
			break;
6740
 
6773
 
6741
    case 695 : if (DEBUG) { System.out.println("SingleMemberAnnotation ::= AnnotationName LPAREN..."); }  //$NON-NLS-1$
6774
    case 695 : if (DEBUG) { System.out.println("SingleMemberAnnotationMemberValue ::= MemberValue"); }  //$NON-NLS-1$
6775
		    consumeSingleMemberAnnotationMemberValue() ;  
6776
			break;
6777
 
6778
    case 696 : if (DEBUG) { System.out.println("SingleMemberAnnotation ::= AnnotationName LPAREN..."); }  //$NON-NLS-1$
6742
		    consumeSingleMemberAnnotation() ;  
6779
		    consumeSingleMemberAnnotation() ;  
6743
			break;
6780
			break;
6744
 
6781
 
6745
    case 696 : if (DEBUG) { System.out.println("RecoveryMethodHeaderName ::= Modifiersopt TypeParameters"); }  //$NON-NLS-1$
6782
    case 697 : if (DEBUG) { System.out.println("RecoveryMethodHeaderName ::= Modifiersopt TypeParameters"); }  //$NON-NLS-1$
6746
		    consumeRecoveryMethodHeaderNameWithTypeParameters();  
6783
		    consumeRecoveryMethodHeaderNameWithTypeParameters();  
6747
			break;
6784
			break;
6748
 
6785
 
6749
    case 697 : if (DEBUG) { System.out.println("RecoveryMethodHeaderName ::= Modifiersopt Type..."); }  //$NON-NLS-1$
6786
    case 698 : if (DEBUG) { System.out.println("RecoveryMethodHeaderName ::= Modifiersopt Type..."); }  //$NON-NLS-1$
6750
		    consumeRecoveryMethodHeaderName();  
6787
		    consumeRecoveryMethodHeaderName();  
6751
			break;
6788
			break;
6752
 
6789
 
6753
    case 698 : if (DEBUG) { System.out.println("RecoveryMethodHeader ::= RecoveryMethodHeaderName..."); }  //$NON-NLS-1$
6790
    case 699 : if (DEBUG) { System.out.println("RecoveryMethodHeader ::= RecoveryMethodHeaderName..."); }  //$NON-NLS-1$
6754
		    consumeMethodHeader();  
6791
		    consumeMethodHeader();  
6755
			break;
6792
			break;
6756
 
6793
 
6757
    case 699 : if (DEBUG) { System.out.println("RecoveryMethodHeader ::= RecoveryMethodHeaderName..."); }  //$NON-NLS-1$
6794
    case 700 : if (DEBUG) { System.out.println("RecoveryMethodHeader ::= RecoveryMethodHeaderName..."); }  //$NON-NLS-1$
6758
		    consumeMethodHeader();  
6795
		    consumeMethodHeader();  
6759
			break;
6796
			break;
6760
 
6797
 
Lines 6768-6773 Link Here
6768
protected void consumeSingleMemberAnnotation() {
6805
protected void consumeSingleMemberAnnotation() {
6769
	// SingleMemberAnnotation ::= '@' Name '(' MemberValue ')'
6806
	// SingleMemberAnnotation ::= '@' Name '(' MemberValue ')'
6770
	SingleMemberAnnotation singleMemberAnnotation = null;
6807
	SingleMemberAnnotation singleMemberAnnotation = null;
6808
	
6809
	int oldIndex = this.identifierPtr;
6810
	
6771
	TypeReference typeReference = this.getAnnotationType();
6811
	TypeReference typeReference = this.getAnnotationType();
6772
	singleMemberAnnotation = new SingleMemberAnnotation(typeReference, this.intStack[this.intPtr--]);
6812
	singleMemberAnnotation = new SingleMemberAnnotation(typeReference, this.intStack[this.intPtr--]);
6773
	singleMemberAnnotation.memberValue = this.expressionStack[this.expressionPtr--];
6813
	singleMemberAnnotation.memberValue = this.expressionStack[this.expressionPtr--];
Lines 6778-6783 Link Here
6778
	
6818
	
6779
	if(this.currentElement != null) {
6819
	if(this.currentElement != null) {
6780
		annotationRecoveryCheckPoint(singleMemberAnnotation.sourceStart, singleMemberAnnotation.declarationSourceEnd);
6820
		annotationRecoveryCheckPoint(singleMemberAnnotation.sourceStart, singleMemberAnnotation.declarationSourceEnd);
6821
		
6822
		if (currentElement instanceof RecoveredAnnotation) {
6823
			this.currentElement = ((RecoveredAnnotation)this.currentElement).addAnnotation(singleMemberAnnotation, oldIndex);
6824
		}
6781
	}
6825
	}
6782
	
6826
	
6783
	if(!this.statementRecoveryActivated &&
6827
	if(!this.statementRecoveryActivated &&
Lines 6787-6792 Link Here
6787
	}
6831
	}
6788
	this.recordStringLiterals = true;
6832
	this.recordStringLiterals = true;
6789
}
6833
}
6834
6835
protected void consumeSingleMemberAnnotationMemberValue() {
6836
	// this rule is used for syntax recovery only
6837
	if (this.currentElement != null && this.currentElement instanceof RecoveredAnnotation) {
6838
		RecoveredAnnotation recoveredAnnotation = (RecoveredAnnotation) this.currentElement;
6839
		
6840
		recoveredAnnotation.setKind(RecoveredAnnotation.SINGLE_MEMBER);
6841
	}
6842
6843
}
6790
protected void consumeSingleStaticImportDeclarationName() {
6844
protected void consumeSingleStaticImportDeclarationName() {
6791
	// SingleTypeImportDeclarationName ::= 'import' 'static' Name
6845
	// SingleTypeImportDeclarationName ::= 'import' 'static' Name
6792
	/* push an ImportRef build from the last name 
6846
	/* push an ImportRef build from the last name 
(-)compiler/org/eclipse/jdt/internal/compiler/parser/parser19.rsc (-1 / +2 lines)
Line 1 Link Here
1
ggFFFEEhAAA!FfAeAIEJJE!EEbGG_!H!Ab!!!!55
1
ggFFFEEhAAA!FfAeAIE
2
JJE!EEbGG_!H!Ab!!!!55
(-)compiler/org/eclipse/jdt/internal/compiler/parser/TerminalTokens.java (-8 / +8 lines)
Lines 60-66 Link Here
60
		TokenNameif = 79,
60
		TokenNameif = 79,
61
		TokenNameimplements = 106,
61
		TokenNameimplements = 106,
62
		TokenNameimport = 100,
62
		TokenNameimport = 100,
63
		TokenNameinstanceof = 15,
63
		TokenNameinstanceof = 12,
64
		TokenNameint = 37,
64
		TokenNameint = 37,
65
		TokenNameinterface = 95,
65
		TokenNameinterface = 95,
66
		TokenNamelong = 38,
66
		TokenNamelong = 38,
Lines 93-106 Link Here
93
		TokenNameDoubleLiteral = 50,
93
		TokenNameDoubleLiteral = 50,
94
		TokenNameCharacterLiteral = 51,
94
		TokenNameCharacterLiteral = 51,
95
		TokenNameStringLiteral = 52,
95
		TokenNameStringLiteral = 52,
96
		TokenNamePLUS_PLUS = 9,
96
		TokenNamePLUS_PLUS = 8,
97
		TokenNameMINUS_MINUS = 10,
97
		TokenNameMINUS_MINUS = 9,
98
		TokenNameEQUAL_EQUAL = 18,
98
		TokenNameEQUAL_EQUAL = 18,
99
		TokenNameLESS_EQUAL = 16,
99
		TokenNameLESS_EQUAL = 15,
100
		TokenNameGREATER_EQUAL = 17,
100
		TokenNameGREATER_EQUAL = 16,
101
		TokenNameNOT_EQUAL = 19,
101
		TokenNameNOT_EQUAL = 19,
102
		TokenNameLEFT_SHIFT = 13,
102
		TokenNameLEFT_SHIFT = 17,
103
		TokenNameRIGHT_SHIFT = 8,
103
		TokenNameRIGHT_SHIFT = 10,
104
		TokenNameUNSIGNED_RIGHT_SHIFT = 11,
104
		TokenNameUNSIGNED_RIGHT_SHIFT = 11,
105
		TokenNamePLUS_EQUAL = 84,
105
		TokenNamePLUS_EQUAL = 84,
106
		TokenNameMINUS_EQUAL = 85,
106
		TokenNameMINUS_EQUAL = 85,
Lines 125-131 Link Here
125
		TokenNameOR = 22,
125
		TokenNameOR = 22,
126
		TokenNameTWIDDLE = 67,
126
		TokenNameTWIDDLE = 67,
127
		TokenNameDIVIDE = 6,
127
		TokenNameDIVIDE = 6,
128
		TokenNameGREATER = 12,
128
		TokenNameGREATER = 13,
129
		TokenNameLESS = 7,
129
		TokenNameLESS = 7,
130
		TokenNameLPAREN = 28,
130
		TokenNameLPAREN = 28,
131
		TokenNameRPAREN = 29,
131
		TokenNameRPAREN = 29,
(-)compiler/org/eclipse/jdt/internal/compiler/parser/RecoveredMethod.java (-5 / +122 lines)
Lines 12-17 Link Here
12
12
13
import org.eclipse.jdt.core.compiler.*;
13
import org.eclipse.jdt.core.compiler.*;
14
import org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration;
14
import org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration;
15
import org.eclipse.jdt.internal.compiler.ast.Annotation;
15
import org.eclipse.jdt.internal.compiler.ast.Argument;
16
import org.eclipse.jdt.internal.compiler.ast.Argument;
16
import org.eclipse.jdt.internal.compiler.ast.ASTNode;
17
import org.eclipse.jdt.internal.compiler.ast.ASTNode;
17
import org.eclipse.jdt.internal.compiler.ast.Block;
18
import org.eclipse.jdt.internal.compiler.ast.Block;
Lines 37-48 Link Here
37
public class RecoveredMethod extends RecoveredElement implements TerminalTokens {
38
public class RecoveredMethod extends RecoveredElement implements TerminalTokens {
38
39
39
	public AbstractMethodDeclaration methodDeclaration;
40
	public AbstractMethodDeclaration methodDeclaration;
41
	
42
	public RecoveredAnnotation[] annotations;
43
	public int annotationCount;
44
	
45
	public int modifiers;
46
	public int modifiersStart;
40
47
41
	public RecoveredType[] localTypes;
48
	public RecoveredType[] localTypes;
42
	public int localTypeCount;
49
	public int localTypeCount;
43
50
44
	public RecoveredBlock methodBody;
51
	public RecoveredBlock methodBody;
45
	public boolean discardBody = true;
52
	public boolean discardBody = true;
53
	
54
	int pendingModifiers;
55
	int pendingModifersSourceStart = -1;
56
	RecoveredAnnotation[] pendingAnnotations;
57
	int pendingAnnotationCount;
46
58
47
public RecoveredMethod(AbstractMethodDeclaration methodDeclaration, RecoveredElement parent, int bracketBalance, Parser parser){
59
public RecoveredMethod(AbstractMethodDeclaration methodDeclaration, RecoveredElement parent, int bracketBalance, Parser parser){
48
	super(parent, bracketBalance, parser);
60
	super(parent, bracketBalance, parser);
Lines 56-62 Link Here
56
 * Record a nested block declaration
68
 * Record a nested block declaration
57
 */
69
 */
58
public RecoveredElement add(Block nestedBlockDeclaration, int bracketBalanceValue) {
70
public RecoveredElement add(Block nestedBlockDeclaration, int bracketBalanceValue) {
59
60
	/* default behavior is to delegate recording to parent if any,
71
	/* default behavior is to delegate recording to parent if any,
61
	do not consider elements passed the known end (if set)
72
	do not consider elements passed the known end (if set)
62
	it must be belonging to an enclosing element 
73
	it must be belonging to an enclosing element 
Lines 64-69 Link Here
64
	if (methodDeclaration.declarationSourceEnd > 0
75
	if (methodDeclaration.declarationSourceEnd > 0
65
		&& nestedBlockDeclaration.sourceStart
76
		&& nestedBlockDeclaration.sourceStart
66
			> methodDeclaration.declarationSourceEnd){
77
			> methodDeclaration.declarationSourceEnd){
78
				resetPendingModifiers();
67
				if (this.parent == null){
79
				if (this.parent == null){
68
					return this; // ignore
80
					return this; // ignore
69
				} else {
81
				} else {
Lines 84-89 Link Here
84
 * Record a field declaration
96
 * Record a field declaration
85
 */
97
 */
86
public RecoveredElement add(FieldDeclaration fieldDeclaration, int bracketBalanceValue) {
98
public RecoveredElement add(FieldDeclaration fieldDeclaration, int bracketBalanceValue) {
99
	this.resetPendingModifiers();
87
100
88
	/* local variables inside method can only be final and non void */
101
	/* local variables inside method can only be final and non void */
89
	char[][] fieldTypeName; 
102
	char[][] fieldTypeName; 
Lines 91-97 Link Here
91
		|| (fieldDeclaration.type == null) // initializer
104
		|| (fieldDeclaration.type == null) // initializer
92
		|| ((fieldTypeName = fieldDeclaration.type.getTypeName()).length == 1 // non void
105
		|| ((fieldTypeName = fieldDeclaration.type.getTypeName()).length == 1 // non void
93
			&& CharOperation.equals(fieldTypeName[0], TypeBinding.VOID.sourceName()))){ 
106
			&& CharOperation.equals(fieldTypeName[0], TypeBinding.VOID.sourceName()))){ 
94
95
		if (this.parent == null){
107
		if (this.parent == null){
96
			return this; // ignore
108
			return this; // ignore
97
		} else {
109
		} else {
Lines 124-129 Link Here
124
 * Record a local declaration - regular method should have been created a block body
136
 * Record a local declaration - regular method should have been created a block body
125
 */
137
 */
126
public RecoveredElement add(LocalDeclaration localDeclaration, int bracketBalanceValue) {
138
public RecoveredElement add(LocalDeclaration localDeclaration, int bracketBalanceValue) {
139
	this.resetPendingModifiers();
127
140
128
	/* local variables inside method can only be final and non void */
141
	/* local variables inside method can only be final and non void */
129
/*	
142
/*	
Lines 170-175 Link Here
170
 * Record a statement - regular method should have been created a block body
183
 * Record a statement - regular method should have been created a block body
171
 */
184
 */
172
public RecoveredElement add(Statement statement, int bracketBalanceValue) {
185
public RecoveredElement add(Statement statement, int bracketBalanceValue) {
186
	this.resetPendingModifiers();
173
187
174
	/* do not consider a type starting passed the type end (if set)
188
	/* do not consider a type starting passed the type end (if set)
175
		it must be belonging to an enclosing type */
189
		it must be belonging to an enclosing type */
Lines 214-224 Link Here
214
			block.sourceStart = methodDeclaration.bodyStart;
228
			block.sourceStart = methodDeclaration.bodyStart;
215
			this.add(block, 1);
229
			this.add(block, 1);
216
		}
230
		}
231
		methodBody.attachPendingModifiers(
232
				this.pendingAnnotations,
233
				this.pendingAnnotationCount,
234
				this.pendingModifiers,
235
				this.pendingModifersSourceStart);
236
		this.resetPendingModifiers();
217
		return methodBody.add(typeDeclaration, bracketBalanceValue, true);	
237
		return methodBody.add(typeDeclaration, bracketBalanceValue, true);	
218
	}
238
	}
219
	switch (TypeDeclaration.kind(typeDeclaration.modifiers)) {
239
	switch (TypeDeclaration.kind(typeDeclaration.modifiers)) {
220
		case TypeDeclaration.INTERFACE_DECL :
240
		case TypeDeclaration.INTERFACE_DECL :
221
		case TypeDeclaration.ANNOTATION_TYPE_DECL :
241
		case TypeDeclaration.ANNOTATION_TYPE_DECL :
242
			resetPendingModifiers();
222
			this.updateSourceEndIfNecessary(this.previousAvailableLineEnd(typeDeclaration.declarationSourceStart - 1));
243
			this.updateSourceEndIfNecessary(this.previousAvailableLineEnd(typeDeclaration.declarationSourceStart - 1));
223
			if (this.parent == null) {
244
			if (this.parent == null) {
224
				return this; // ignore
245
				return this; // ignore
Lines 242-247 Link Here
242
	RecoveredType element = new RecoveredType(typeDeclaration, this, bracketBalanceValue);
263
	RecoveredType element = new RecoveredType(typeDeclaration, this, bracketBalanceValue);
243
	localTypes[localTypeCount++] = element;
264
	localTypes[localTypeCount++] = element;
244
265
266
	if(this.pendingAnnotationCount > 0) {
267
		element.attach(
268
				pendingAnnotations,
269
				pendingAnnotationCount,
270
				pendingModifiers,
271
				pendingModifersSourceStart);
272
		this.resetPendingModifiers();
273
	}
274
	
245
	/* consider that if the opening brace was not found, it is there */
275
	/* consider that if the opening brace was not found, it is there */
246
	if (!foundOpeningBrace){
276
	if (!foundOpeningBrace){
247
		foundOpeningBrace = true;
277
		foundOpeningBrace = true;
Lines 258-263 Link Here
258
public ASTNode parseTree(){
288
public ASTNode parseTree(){
259
	return methodDeclaration;
289
	return methodDeclaration;
260
}
290
}
291
public void resetPendingModifiers() {
292
	this.pendingAnnotations = null;
293
	this.pendingAnnotationCount = 0;
294
	this.pendingModifiers = 0;
295
	this.pendingModifersSourceStart = -1;
296
}
261
/*
297
/*
262
 * Answer the very source end of the corresponding parse node
298
 * Answer the very source end of the corresponding parse node
263
 */
299
 */
Lines 268-273 Link Here
268
	StringBuffer result = new StringBuffer(tabString(tab));
304
	StringBuffer result = new StringBuffer(tabString(tab));
269
	result.append("Recovered method:\n"); //$NON-NLS-1$
305
	result.append("Recovered method:\n"); //$NON-NLS-1$
270
	this.methodDeclaration.print(tab + 1, result);
306
	this.methodDeclaration.print(tab + 1, result);
307
	if (this.annotations != null) {
308
		for (int i = 0; i < this.annotationCount; i++) {
309
			result.append("\n"); //$NON-NLS-1$
310
			result.append(this.annotations[i].toString(tab + 1));
311
		}
312
	}
271
	if (this.localTypes != null) {
313
	if (this.localTypes != null) {
272
		for (int i = 0; i < this.localTypeCount; i++) {
314
		for (int i = 0; i < this.localTypeCount; i++) {
273
			result.append("\n"); //$NON-NLS-1$
315
			result.append("\n"); //$NON-NLS-1$
Lines 288-294 Link Here
288
	this.methodDeclaration.bodyStart = bodyStart;
330
	this.methodDeclaration.bodyStart = bodyStart;
289
}
331
}
290
public AbstractMethodDeclaration updatedMethodDeclaration(){
332
public AbstractMethodDeclaration updatedMethodDeclaration(){
291
333
	/* update annotations */
334
	if (modifiers != 0) {
335
		this.methodDeclaration.modifiers |= modifiers;
336
		if (this.modifiersStart < this.methodDeclaration.declarationSourceStart) {
337
			this.methodDeclaration.declarationSourceStart = modifiersStart;
338
		}
339
	}
340
	/* update annotations */
341
	if (annotationCount > 0){
342
		int existingCount = methodDeclaration.annotations == null ? 0 : methodDeclaration.annotations.length;
343
		Annotation[] annotationReferences = new Annotation[existingCount + annotationCount];
344
		if (existingCount > 0){
345
			System.arraycopy(methodDeclaration.annotations, 0, annotationReferences, annotationCount, existingCount);
346
		}
347
		for (int i = 0; i < annotationCount; i++){
348
			annotationReferences[i] = annotations[i].updatedAnnotationReference();
349
		}
350
		methodDeclaration.annotations = annotationReferences;
351
		
352
		int start = this.annotations[0].annotation.sourceStart;
353
		if (start < this.methodDeclaration.declarationSourceStart) {
354
			this.methodDeclaration.declarationSourceStart = start;
355
		}
356
	}
357
	
292
	if (methodBody != null){
358
	if (methodBody != null){
293
		Block block = methodBody.updatedBlock();
359
		Block block = methodBody.updatedBlock();
294
		if (block != null){
360
		if (block != null){
Lines 452-459 Link Here
452
		return this;
518
		return this;
453
	}
519
	}
454
	if(this.parent != null && this.parent instanceof RecoveredType) {
520
	if(this.parent != null && this.parent instanceof RecoveredType) {
455
		int modifiers = ((RecoveredType)this.parent).typeDeclaration.modifiers;
521
		int mods = ((RecoveredType)this.parent).typeDeclaration.modifiers;
456
		if (TypeDeclaration.kind(modifiers) == TypeDeclaration.INTERFACE_DECL) {
522
		if (TypeDeclaration.kind(mods) == TypeDeclaration.INTERFACE_DECL) {
457
			if (!this.foundOpeningBrace) {
523
			if (!this.foundOpeningBrace) {
458
				this.updateSourceEndIfNecessary(braceStart - 1, braceStart - 1);
524
				this.updateSourceEndIfNecessary(braceStart - 1, braceStart - 1);
459
				return this.parent.updateOnClosingBrace(braceStart, braceEnd);
525
				return this.parent.updateOnClosingBrace(braceStart, braceEnd);
Lines 502-507 Link Here
502
		}
568
		}
503
	}
569
	}
504
}
570
}
571
public RecoveredElement addAnnotationName(int identifierPtr, int identifierLengthPtr, int annotationStart, int bracketBalanceValue) {
572
	if (pendingAnnotations == null) {
573
		pendingAnnotations = new RecoveredAnnotation[5];
574
		pendingAnnotationCount = 0;
575
	} else {
576
		if (pendingAnnotationCount == pendingAnnotations.length) {
577
			System.arraycopy(
578
				pendingAnnotations, 
579
				0, 
580
				(pendingAnnotations = new RecoveredAnnotation[2 * pendingAnnotationCount]), 
581
				0, 
582
				pendingAnnotationCount); 
583
		}
584
	}
585
	
586
	RecoveredAnnotation element = new RecoveredAnnotation(identifierPtr, identifierLengthPtr, annotationStart, this, bracketBalanceValue);
587
	
588
	pendingAnnotations[pendingAnnotationCount++] = element;
589
	
590
	return element;
591
}
592
public void addModifier(int flag, int modifiersSourceStart) {
593
	this.pendingModifiers |= flag;
594
	
595
	if (this.pendingModifersSourceStart < 0) {
596
		this.pendingModifersSourceStart = modifiersSourceStart;
597
	}
598
}
505
void attach(TypeParameter[] parameters, int startPos) {
599
void attach(TypeParameter[] parameters, int startPos) {
506
	if(methodDeclaration.modifiers != ClassFileConstants.AccDefault) return;
600
	if(methodDeclaration.modifiers != ClassFileConstants.AccDefault) return;
507
	
601
	
Lines 523-526 Link Here
523
		this.methodDeclaration.declarationSourceStart = startPos;
617
		this.methodDeclaration.declarationSourceStart = startPos;
524
	}
618
	}
525
}
619
}
620
public void attach(RecoveredAnnotation[] annots, int annotCount, int mods, int modsSourceStart) {
621
	if (annotCount > 0) {
622
		Annotation[] existingAnnotations = this.methodDeclaration.annotations;
623
		if (existingAnnotations != null) {
624
			this.annotations = new RecoveredAnnotation[annotCount];
625
			this.annotationCount = 0;
626
			next : for (int i = 0; i < annotCount; i++) {
627
				for (int j = 0; j < existingAnnotations.length; j++) {
628
					if (annots[i].annotation == existingAnnotations[j]) continue next;
629
				}
630
				this.annotations[this.annotationCount++] = annots[i];
631
			}
632
		} else {
633
			this.annotations = annots;
634
			this.annotationCount = annotCount;
635
		}
636
	}
637
	
638
	if (mods != 0) {
639
		this.modifiers = mods;
640
		this.modifiersStart = modsSourceStart;
641
	}
642
}
526
}
643
}
(-)compiler/org/eclipse/jdt/internal/compiler/parser/RecoveredElement.java (+21 lines)
Lines 37-48 Link Here
37
	this.bracketBalance = bracketBalance;
37
	this.bracketBalance = bracketBalance;
38
	this.recoveringParser = parser;
38
	this.recoveringParser = parser;
39
}
39
}
40
public RecoveredElement addAnnotationName(int identifierPtr, int identifierLengthPtr, int annotationStart, int bracketBalanceValue) {
41
	/* default behavior is to delegate recording to parent if any */
42
	this.resetPendingModifiers();
43
	if (this.parent == null) return this; // ignore
44
	this.updateSourceEndIfNecessary(this.previousAvailableLineEnd(annotationStart - 1));	
45
	return this.parent.addAnnotationName(identifierPtr, identifierLengthPtr, annotationStart, bracketBalanceValue);
46
}
40
/*
47
/*
41
 *	Record a method declaration
48
 *	Record a method declaration
42
 */
49
 */
43
public RecoveredElement add(AbstractMethodDeclaration methodDeclaration, int bracketBalanceValue) {
50
public RecoveredElement add(AbstractMethodDeclaration methodDeclaration, int bracketBalanceValue) {
44
51
45
	/* default behavior is to delegate recording to parent if any */
52
	/* default behavior is to delegate recording to parent if any */
53
	this.resetPendingModifiers();
46
	if (this.parent == null) return this; // ignore
54
	if (this.parent == null) return this; // ignore
47
	this.updateSourceEndIfNecessary(this.previousAvailableLineEnd(methodDeclaration.declarationSourceStart - 1));	
55
	this.updateSourceEndIfNecessary(this.previousAvailableLineEnd(methodDeclaration.declarationSourceStart - 1));	
48
	return this.parent.add(methodDeclaration, bracketBalanceValue);
56
	return this.parent.add(methodDeclaration, bracketBalanceValue);
Lines 53-58 Link Here
53
public RecoveredElement add(Block nestedBlockDeclaration, int bracketBalanceValue) {
61
public RecoveredElement add(Block nestedBlockDeclaration, int bracketBalanceValue) {
54
62
55
	/* default behavior is to delegate recording to parent if any */
63
	/* default behavior is to delegate recording to parent if any */
64
	this.resetPendingModifiers();
56
	if (this.parent == null) return this; // ignore
65
	if (this.parent == null) return this; // ignore
57
	this.updateSourceEndIfNecessary(this.previousAvailableLineEnd(nestedBlockDeclaration.sourceStart - 1));	
66
	this.updateSourceEndIfNecessary(this.previousAvailableLineEnd(nestedBlockDeclaration.sourceStart - 1));	
58
	return this.parent.add(nestedBlockDeclaration, bracketBalanceValue);
67
	return this.parent.add(nestedBlockDeclaration, bracketBalanceValue);
Lines 63-68 Link Here
63
public RecoveredElement add(FieldDeclaration fieldDeclaration, int bracketBalanceValue) {
72
public RecoveredElement add(FieldDeclaration fieldDeclaration, int bracketBalanceValue) {
64
73
65
	/* default behavior is to delegate recording to parent if any */
74
	/* default behavior is to delegate recording to parent if any */
75
	this.resetPendingModifiers();
66
	if (this.parent == null) return this; // ignore
76
	if (this.parent == null) return this; // ignore
67
	this.updateSourceEndIfNecessary(this.previousAvailableLineEnd(fieldDeclaration.declarationSourceStart - 1));	
77
	this.updateSourceEndIfNecessary(this.previousAvailableLineEnd(fieldDeclaration.declarationSourceStart - 1));	
68
	return this.parent.add(fieldDeclaration, bracketBalanceValue);
78
	return this.parent.add(fieldDeclaration, bracketBalanceValue);
Lines 73-78 Link Here
73
public RecoveredElement add(ImportReference importReference, int bracketBalanceValue){
83
public RecoveredElement add(ImportReference importReference, int bracketBalanceValue){
74
84
75
	/* default behavior is to delegate recording to parent if any */
85
	/* default behavior is to delegate recording to parent if any */
86
	this.resetPendingModifiers();
76
	if (this.parent == null) return this; // ignore
87
	if (this.parent == null) return this; // ignore
77
	this.updateSourceEndIfNecessary(this.previousAvailableLineEnd(importReference.declarationSourceStart - 1));	
88
	this.updateSourceEndIfNecessary(this.previousAvailableLineEnd(importReference.declarationSourceStart - 1));	
78
	return this.parent.add(importReference, bracketBalanceValue);
89
	return this.parent.add(importReference, bracketBalanceValue);
Lines 83-88 Link Here
83
public RecoveredElement add(LocalDeclaration localDeclaration, int bracketBalanceValue) {
94
public RecoveredElement add(LocalDeclaration localDeclaration, int bracketBalanceValue) {
84
95
85
	/* default behavior is to delegate recording to parent if any */
96
	/* default behavior is to delegate recording to parent if any */
97
	this.resetPendingModifiers();
86
	if (this.parent == null) return this; // ignore
98
	if (this.parent == null) return this; // ignore
87
	this.updateSourceEndIfNecessary(this.previousAvailableLineEnd(localDeclaration.declarationSourceStart - 1));	
99
	this.updateSourceEndIfNecessary(this.previousAvailableLineEnd(localDeclaration.declarationSourceStart - 1));	
88
	return this.parent.add(localDeclaration, bracketBalanceValue);
100
	return this.parent.add(localDeclaration, bracketBalanceValue);
Lines 93-98 Link Here
93
public RecoveredElement add(Statement statement, int bracketBalanceValue) {
105
public RecoveredElement add(Statement statement, int bracketBalanceValue) {
94
106
95
	/* default behavior is to delegate recording to parent if any */
107
	/* default behavior is to delegate recording to parent if any */
108
	this.resetPendingModifiers();
96
	if (this.parent == null) return this; // ignore
109
	if (this.parent == null) return this; // ignore
97
	this.updateSourceEndIfNecessary(this.previousAvailableLineEnd(statement.sourceStart - 1));	
110
	this.updateSourceEndIfNecessary(this.previousAvailableLineEnd(statement.sourceStart - 1));	
98
	return this.parent.add(statement, bracketBalanceValue);
111
	return this.parent.add(statement, bracketBalanceValue);
Lines 103-108 Link Here
103
public RecoveredElement add(TypeDeclaration typeDeclaration, int bracketBalanceValue){
116
public RecoveredElement add(TypeDeclaration typeDeclaration, int bracketBalanceValue){
104
117
105
	/* default behavior is to delegate recording to parent if any */
118
	/* default behavior is to delegate recording to parent if any */
119
	this.resetPendingModifiers();
106
	if (this.parent == null) return this; // ignore
120
	if (this.parent == null) return this; // ignore
107
	this.updateSourceEndIfNecessary(this.previousAvailableLineEnd(typeDeclaration.declarationSourceStart - 1));	
121
	this.updateSourceEndIfNecessary(this.previousAvailableLineEnd(typeDeclaration.declarationSourceStart - 1));	
108
	return this.parent.add(typeDeclaration, bracketBalanceValue);
122
	return this.parent.add(typeDeclaration, bracketBalanceValue);
Lines 116-121 Link Here
116
		}
130
		}
117
	}
131
	}
118
}
132
}
133
public void addModifier(int flag, int modifiersSourceStart) {
134
	// default implementation: do nothing
135
}
119
/*
136
/*
120
 * Answer the depth of this element, considering the parent link.
137
 * Answer the depth of this element, considering the parent link.
121
 */
138
 */
Lines 183-188 Link Here
183
public ASTNode parseTree(){
200
public ASTNode parseTree(){
184
	return null;
201
	return null;
185
}
202
}
203
public void resetPendingModifiers() {
204
	// default implementation: do nothing
205
	// recovered elements which have pending modifiers must override this method
206
}
186
/*
207
/*
187
 * Iterate the enclosing blocks and tag them so as to preserve their content
208
 * Iterate the enclosing blocks and tag them so as to preserve their content
188
 */
209
 */
(-)compiler/org/eclipse/jdt/internal/compiler/parser/RecoveredLocalVariable.java (-1 / +55 lines)
Lines 13-18 Link Here
13
/**
13
/**
14
 * Internal local variable structure for parsing recovery 
14
 * Internal local variable structure for parsing recovery 
15
 */
15
 */
16
import org.eclipse.jdt.internal.compiler.ast.Annotation;
16
import org.eclipse.jdt.internal.compiler.ast.ArrayQualifiedTypeReference;
17
import org.eclipse.jdt.internal.compiler.ast.ArrayQualifiedTypeReference;
17
import org.eclipse.jdt.internal.compiler.ast.ArrayTypeReference;
18
import org.eclipse.jdt.internal.compiler.ast.ArrayTypeReference;
18
import org.eclipse.jdt.internal.compiler.ast.ASTNode;
19
import org.eclipse.jdt.internal.compiler.ast.ASTNode;
Lines 22-27 Link Here
22
23
23
public class RecoveredLocalVariable extends RecoveredStatement {
24
public class RecoveredLocalVariable extends RecoveredStatement {
24
25
26
	public RecoveredAnnotation[] annotations;
27
	public int annotationCount;
28
	
29
	public int modifiers;
30
	public int modifiersStart;
31
	
25
	public LocalDeclaration localDeclaration;
32
	public LocalDeclaration localDeclaration;
26
	boolean alreadyCompletedLocalInitialization;
33
	boolean alreadyCompletedLocalInitialization;
27
public RecoveredLocalVariable(LocalDeclaration localDeclaration, RecoveredElement parent, int bracketBalance){
34
public RecoveredLocalVariable(LocalDeclaration localDeclaration, RecoveredElement parent, int bracketBalance){
Lines 44-49 Link Here
44
		return this;
51
		return this;
45
	}
52
	}
46
}
53
}
54
public void attach(RecoveredAnnotation[] annots, int annotCount, int mods, int modsSourceStart) {
55
	if (annotCount > 0) {
56
		Annotation[] existingAnnotations = this.localDeclaration.annotations;
57
		if (existingAnnotations != null) {
58
			this.annotations = new RecoveredAnnotation[annotCount];
59
			this.annotationCount = 0;
60
			next : for (int i = 0; i < annotCount; i++) {
61
				for (int j = 0; j < existingAnnotations.length; j++) {
62
					if (annots[i].annotation == existingAnnotations[j]) continue next;
63
				}
64
				this.annotations[this.annotationCount++] = annots[i];
65
			}
66
		} else {
67
			this.annotations = annots;
68
			this.annotationCount = annotCount;
69
		}
70
	}
71
	
72
	if (mods != 0) {
73
		this.modifiers = mods;
74
		this.modifiersStart = modsSourceStart;
75
	}
76
}
47
/* 
77
/* 
48
 * Answer the associated parsed structure
78
 * Answer the associated parsed structure
49
 */
79
 */
Lines 56-65 Link Here
56
public int sourceEnd(){
86
public int sourceEnd(){
57
	return this.localDeclaration.declarationSourceEnd;
87
	return this.localDeclaration.declarationSourceEnd;
58
}
88
}
59
public String toString(int tab) {
89
public String toString(int tab) {	
60
	return tabString(tab) + "Recovered local variable:\n" + localDeclaration.print(tab + 1, new StringBuffer(10)); //$NON-NLS-1$
90
	return tabString(tab) + "Recovered local variable:\n" + localDeclaration.print(tab + 1, new StringBuffer(10)); //$NON-NLS-1$
61
}
91
}
62
public Statement updatedStatement(){
92
public Statement updatedStatement(){
93
	/* update annotations */
94
	if (modifiers != 0) {
95
		this.localDeclaration.modifiers |= modifiers;
96
		if (this.modifiersStart < this.localDeclaration.declarationSourceStart) {
97
			this.localDeclaration.declarationSourceStart = modifiersStart;
98
		}
99
	}
100
	/* update annotations */
101
	if (annotationCount > 0){
102
		int existingCount = localDeclaration.annotations == null ? 0 : localDeclaration.annotations.length;
103
		Annotation[] annotationReferences = new Annotation[existingCount + annotationCount];
104
		if (existingCount > 0){
105
			System.arraycopy(localDeclaration.annotations, 0, annotationReferences, annotationCount, existingCount);
106
		}
107
		for (int i = 0; i < annotationCount; i++){
108
			annotationReferences[i] = annotations[i].updatedAnnotationReference();
109
		}
110
		localDeclaration.annotations = annotationReferences;
111
		
112
		int start = this.annotations[0].annotation.sourceStart;
113
		if (start < this.localDeclaration.declarationSourceStart) {
114
			this.localDeclaration.declarationSourceStart = start;
115
		}
116
	}
63
	return localDeclaration;
117
	return localDeclaration;
64
}
118
}
65
/*
119
/*
(-)compiler/org/eclipse/jdt/internal/compiler/parser/RecoveredBlock.java (-1 / +69 lines)
Lines 30-35 Link Here
30
	public boolean preserveContent = false;
30
	public boolean preserveContent = false;
31
	public RecoveredLocalVariable pendingArgument;
31
	public RecoveredLocalVariable pendingArgument;
32
	
32
	
33
	int pendingModifiers;
34
	int pendingModifersSourceStart = -1;
35
	RecoveredAnnotation[] pendingAnnotations;
36
	int pendingAnnotationCount;
37
	
33
public RecoveredBlock(Block block, RecoveredElement parent, int bracketBalance){
38
public RecoveredBlock(Block block, RecoveredElement parent, int bracketBalance){
34
	super(block, parent, bracketBalance);
39
	super(block, parent, bracketBalance);
35
	this.blockDeclaration = block;
40
	this.blockDeclaration = block;
Lines 41-46 Link Here
41
	if (this.parent != null && this.parent instanceof RecoveredMethod) {
46
	if (this.parent != null && this.parent instanceof RecoveredMethod) {
42
		RecoveredMethod enclosingRecoveredMethod = (RecoveredMethod) this.parent;
47
		RecoveredMethod enclosingRecoveredMethod = (RecoveredMethod) this.parent;
43
		if (enclosingRecoveredMethod.methodBody == this && enclosingRecoveredMethod.parent == null) {
48
		if (enclosingRecoveredMethod.methodBody == this && enclosingRecoveredMethod.parent == null) {
49
			this.resetPendingModifiers();
44
			// the element cannot be added because we are in the body of a top level method
50
			// the element cannot be added because we are in the body of a top level method
45
			return this; // ignore this element
51
			return this; // ignore this element
46
		}
52
		}
Lines 51-56 Link Here
51
 * Record a nested block declaration 
57
 * Record a nested block declaration 
52
 */
58
 */
53
public RecoveredElement add(Block nestedBlockDeclaration, int bracketBalanceValue) {
59
public RecoveredElement add(Block nestedBlockDeclaration, int bracketBalanceValue) {
60
	this.resetPendingModifiers();
54
61
55
	/* do not consider a nested block starting passed the block end (if set)
62
	/* do not consider a nested block starting passed the block end (if set)
56
		it must be belonging to an enclosing block */
63
		it must be belonging to an enclosing block */
Lines 104-114 Link Here
104
		it must be belonging to an enclosing block */
111
		it must be belonging to an enclosing block */
105
	if (this.blockDeclaration.sourceEnd != 0 
112
	if (this.blockDeclaration.sourceEnd != 0 
106
			&& localDeclaration.declarationSourceStart > this.blockDeclaration.sourceEnd){
113
			&& localDeclaration.declarationSourceStart > this.blockDeclaration.sourceEnd){
114
		resetPendingModifiers();
107
		if (delegatedByParent) return this; //ignore
115
		if (delegatedByParent) return this; //ignore
108
		return this.parent.add(localDeclaration, bracketBalanceValue);
116
		return this.parent.add(localDeclaration, bracketBalanceValue);
109
	}
117
	}
110
118
111
	RecoveredLocalVariable element = new RecoveredLocalVariable(localDeclaration, this, bracketBalanceValue);
119
	RecoveredLocalVariable element = new RecoveredLocalVariable(localDeclaration, this, bracketBalanceValue);
120
	
121
	if(this.pendingAnnotationCount > 0) {
122
		element.attach(
123
				pendingAnnotations,
124
				pendingAnnotationCount,
125
				pendingModifiers,
126
				pendingModifersSourceStart);
127
		this.resetPendingModifiers();
128
	}
112
129
113
	if (localDeclaration instanceof Argument){
130
	if (localDeclaration instanceof Argument){
114
		this.pendingArgument = element;
131
		this.pendingArgument = element;
Lines 130-135 Link Here
130
 * Record a statement declaration 
147
 * Record a statement declaration 
131
 */
148
 */
132
public RecoveredElement add(Statement stmt, int bracketBalanceValue, boolean delegatedByParent) {
149
public RecoveredElement add(Statement stmt, int bracketBalanceValue, boolean delegatedByParent) {
150
	this.resetPendingModifiers();
133
151
134
	/* do not consider a nested block starting passed the block end (if set)
152
	/* do not consider a nested block starting passed the block end (if set)
135
		it must be belonging to an enclosing block */
153
		it must be belonging to an enclosing block */
Lines 159-173 Link Here
159
		it must be belonging to an enclosing block */
177
		it must be belonging to an enclosing block */
160
	if (this.blockDeclaration.sourceEnd != 0 
178
	if (this.blockDeclaration.sourceEnd != 0 
161
			&& typeDeclaration.declarationSourceStart > this.blockDeclaration.sourceEnd){
179
			&& typeDeclaration.declarationSourceStart > this.blockDeclaration.sourceEnd){
180
		resetPendingModifiers();
162
		if (delegatedByParent) return this; //ignore
181
		if (delegatedByParent) return this; //ignore
163
		return this.parent.add(typeDeclaration, bracketBalanceValue);
182
		return this.parent.add(typeDeclaration, bracketBalanceValue);
164
	}
183
	}
165
			
184
			
166
	RecoveredStatement element = new RecoveredType(typeDeclaration, this, bracketBalanceValue);
185
	RecoveredType element = new RecoveredType(typeDeclaration, this, bracketBalanceValue);
186
	if(this.pendingAnnotationCount > 0) {
187
		element.attach(
188
				pendingAnnotations,
189
				pendingAnnotationCount,
190
				pendingModifiers,
191
				pendingModifersSourceStart);
192
		this.resetPendingModifiers();
193
	}
167
	this.attach(element);
194
	this.attach(element);
168
	if (typeDeclaration.declarationSourceEnd == 0) return element;
195
	if (typeDeclaration.declarationSourceEnd == 0) return element;
169
	return this;
196
	return this;
170
}
197
}
198
public RecoveredElement addAnnotationName(int identifierPtr, int identifierLengthPtr, int annotationStart, int bracketBalanceValue) {
199
	if (pendingAnnotations == null) {
200
		pendingAnnotations = new RecoveredAnnotation[5];
201
		pendingAnnotationCount = 0;
202
	} else {
203
		if (pendingAnnotationCount == pendingAnnotations.length) {
204
			System.arraycopy(
205
				pendingAnnotations, 
206
				0, 
207
				(pendingAnnotations = new RecoveredAnnotation[2 * pendingAnnotationCount]), 
208
				0, 
209
				pendingAnnotationCount); 
210
		}
211
	}
212
	
213
	RecoveredAnnotation element = new RecoveredAnnotation(identifierPtr, identifierLengthPtr, annotationStart, this, bracketBalanceValue);
214
	
215
	pendingAnnotations[pendingAnnotationCount++] = element;
216
	
217
	return element;
218
}
219
public void addModifier(int flag, int modifiersSourceStart) {
220
	this.pendingModifiers |= flag;
221
	
222
	if (this.pendingModifersSourceStart < 0) {
223
		this.pendingModifersSourceStart = modifiersSourceStart;
224
	}
225
}
171
/*
226
/*
172
 * Attach a recovered statement
227
 * Attach a recovered statement
173
 */
228
 */
Lines 188-199 Link Here
188
	}
243
	}
189
	this.statements[this.statementCount++] = recoveredStatement;
244
	this.statements[this.statementCount++] = recoveredStatement;
190
}
245
}
246
void attachPendingModifiers(RecoveredAnnotation[] pendingAnnots, int pendingAnnotCount, int pendingMods, int pendingModsSourceStart) {
247
	this.pendingAnnotations = pendingAnnots;
248
	this.pendingAnnotationCount = pendingAnnotCount;
249
	this.pendingModifiers = pendingMods;
250
	this.pendingModifersSourceStart = pendingModsSourceStart;
251
}
191
/* 
252
/* 
192
 * Answer the associated parsed structure
253
 * Answer the associated parsed structure
193
 */
254
 */
194
public ASTNode parseTree(){
255
public ASTNode parseTree(){
195
	return this.blockDeclaration;
256
	return this.blockDeclaration;
196
}
257
}
258
public void resetPendingModifiers() {
259
	this.pendingAnnotations = null;
260
	this.pendingAnnotationCount = 0;
261
	this.pendingModifiers = 0;
262
	this.pendingModifersSourceStart = -1;
263
}
197
public String toString(int tab) {
264
public String toString(int tab) {
198
	StringBuffer result = new StringBuffer(tabString(tab));
265
	StringBuffer result = new StringBuffer(tabString(tab));
199
	result.append("Recovered block:\n"); //$NON-NLS-1$
266
	result.append("Recovered block:\n"); //$NON-NLS-1$
Lines 377-382 Link Here
377
 * Record a field declaration 
444
 * Record a field declaration 
378
 */
445
 */
379
public RecoveredElement add(FieldDeclaration fieldDeclaration, int bracketBalanceValue) {
446
public RecoveredElement add(FieldDeclaration fieldDeclaration, int bracketBalanceValue) {
447
	this.resetPendingModifiers();
380
448
381
	/* local variables inside method can only be final and non void */
449
	/* local variables inside method can only be final and non void */
382
	char[][] fieldTypeName; 
450
	char[][] fieldTypeName; 
(-)compiler/org/eclipse/jdt/internal/compiler/parser/RecoveredType.java (-3 / +141 lines)
Lines 13-18 Link Here
13
import org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration;
13
import org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration;
14
import org.eclipse.jdt.internal.compiler.ast.ASTNode;
14
import org.eclipse.jdt.internal.compiler.ast.ASTNode;
15
import org.eclipse.jdt.internal.compiler.ast.AbstractVariableDeclaration;
15
import org.eclipse.jdt.internal.compiler.ast.AbstractVariableDeclaration;
16
import org.eclipse.jdt.internal.compiler.ast.Annotation;
16
import org.eclipse.jdt.internal.compiler.ast.Block;
17
import org.eclipse.jdt.internal.compiler.ast.Block;
17
import org.eclipse.jdt.internal.compiler.ast.FieldDeclaration;
18
import org.eclipse.jdt.internal.compiler.ast.FieldDeclaration;
18
import org.eclipse.jdt.internal.compiler.ast.Initializer;
19
import org.eclipse.jdt.internal.compiler.ast.Initializer;
Lines 29-34 Link Here
29
30
30
public class RecoveredType extends RecoveredStatement implements TerminalTokens {
31
public class RecoveredType extends RecoveredStatement implements TerminalTokens {
31
	public TypeDeclaration typeDeclaration;
32
	public TypeDeclaration typeDeclaration;
33
	
34
	public RecoveredAnnotation[] annotations;
35
	public int annotationCount;
36
	
37
	public int modifiers;
38
	public int modifiersStart;
32
39
33
	public RecoveredType[] memberTypes;
40
	public RecoveredType[] memberTypes;
34
	public int memberTypeCount;
41
	public int memberTypeCount;
Lines 45-50 Link Here
45
	public TypeParameter[] pendingTypeParameters;
52
	public TypeParameter[] pendingTypeParameters;
46
	public int pendingTypeParametersStart;
53
	public int pendingTypeParametersStart;
47
	
54
	
55
	int pendingModifiers;
56
	int pendingModifersSourceStart = -1;
57
	RecoveredAnnotation[] pendingAnnotations;
58
	int pendingAnnotationCount;
59
	
48
public RecoveredType(TypeDeclaration typeDeclaration, RecoveredElement parent, int bracketBalance){
60
public RecoveredType(TypeDeclaration typeDeclaration, RecoveredElement parent, int bracketBalance){
49
	super(typeDeclaration, parent, bracketBalance);
61
	super(typeDeclaration, parent, bracketBalance);
50
	this.typeDeclaration = typeDeclaration;
62
	this.typeDeclaration = typeDeclaration;
Lines 68-73 Link Here
68
	if (typeDeclaration.declarationSourceEnd != 0 
80
	if (typeDeclaration.declarationSourceEnd != 0 
69
		&& methodDeclaration.declarationSourceStart > typeDeclaration.declarationSourceEnd){
81
		&& methodDeclaration.declarationSourceStart > typeDeclaration.declarationSourceEnd){
70
		this.pendingTypeParameters = null;
82
		this.pendingTypeParameters = null;
83
		this.resetPendingModifiers();
84
		
71
		return this.parent.add(methodDeclaration, bracketBalanceValue);
85
		return this.parent.add(methodDeclaration, bracketBalanceValue);
72
	}
86
	}
73
87
Lines 92-97 Link Here
92
		this.pendingTypeParameters = null;
106
		this.pendingTypeParameters = null;
93
	}
107
	}
94
	
108
	
109
	if(this.pendingAnnotationCount > 0) {
110
		element.attach(
111
				pendingAnnotations,
112
				pendingAnnotationCount,
113
				pendingModifiers,
114
				pendingModifersSourceStart);
115
		this.resetPendingModifiers();
116
	}
117
	
95
	this.insideEnumConstantPart = false;
118
	this.insideEnumConstantPart = false;
96
119
97
	/* consider that if the opening brace was not found, it is there */
120
	/* consider that if the opening brace was not found, it is there */
Lines 105-116 Link Here
105
}
128
}
106
public RecoveredElement add(Block nestedBlockDeclaration,int bracketBalanceValue) {
129
public RecoveredElement add(Block nestedBlockDeclaration,int bracketBalanceValue) {
107
	this.pendingTypeParameters = null;
130
	this.pendingTypeParameters = null;
131
	this.resetPendingModifiers();
108
	
132
	
109
	int modifiers = ClassFileConstants.AccDefault;
133
	int mods = ClassFileConstants.AccDefault;
110
	if(this.parser().recoveredStaticInitializerStart != 0) {
134
	if(this.parser().recoveredStaticInitializerStart != 0) {
111
		modifiers = ClassFileConstants.AccStatic;
135
		mods = ClassFileConstants.AccStatic;
112
	}
136
	}
113
	return this.add(new Initializer(nestedBlockDeclaration, modifiers), bracketBalanceValue);
137
	return this.add(new Initializer(nestedBlockDeclaration, mods), bracketBalanceValue);
114
}
138
}
115
public RecoveredElement add(FieldDeclaration fieldDeclaration, int bracketBalanceValue) {
139
public RecoveredElement add(FieldDeclaration fieldDeclaration, int bracketBalanceValue) {
116
	this.pendingTypeParameters = null;
140
	this.pendingTypeParameters = null;
Lines 119-124 Link Here
119
	it must be belonging to an enclosing type */
143
	it must be belonging to an enclosing type */
120
	if (typeDeclaration.declarationSourceEnd != 0
144
	if (typeDeclaration.declarationSourceEnd != 0
121
		&& fieldDeclaration.declarationSourceStart > typeDeclaration.declarationSourceEnd) {
145
		&& fieldDeclaration.declarationSourceStart > typeDeclaration.declarationSourceEnd) {
146
		
147
		this.resetPendingModifiers();
148
		
122
		return this.parent.add(fieldDeclaration, bracketBalanceValue);
149
		return this.parent.add(fieldDeclaration, bracketBalanceValue);
123
	}
150
	}
124
	if (fields == null) {
151
	if (fields == null) {
Lines 148-153 Link Here
148
			return this;
175
			return this;
149
	}
176
	}
150
	fields[fieldCount++] = element;
177
	fields[fieldCount++] = element;
178
	
179
	if(this.pendingAnnotationCount > 0) {
180
		element.attach(
181
				pendingAnnotations,
182
				pendingAnnotationCount,
183
				pendingModifiers,
184
				pendingModifersSourceStart);
185
		this.resetPendingModifiers();
186
	}
151
187
152
	/* consider that if the opening brace was not found, it is there */
188
	/* consider that if the opening brace was not found, it is there */
153
	if (!foundOpeningBrace){
189
	if (!foundOpeningBrace){
Lines 165-170 Link Here
165
		it must be belonging to an enclosing type */
201
		it must be belonging to an enclosing type */
166
	if (typeDeclaration.declarationSourceEnd != 0 
202
	if (typeDeclaration.declarationSourceEnd != 0 
167
		&& memberTypeDeclaration.declarationSourceStart > typeDeclaration.declarationSourceEnd){
203
		&& memberTypeDeclaration.declarationSourceStart > typeDeclaration.declarationSourceEnd){
204
		
205
		this.resetPendingModifiers();
206
		
168
		return this.parent.add(memberTypeDeclaration, bracketBalanceValue);
207
		return this.parent.add(memberTypeDeclaration, bracketBalanceValue);
169
	}
208
	}
170
	
209
	
Lines 177-182 Link Here
177
			lastMethod.methodDeclaration.bodyEnd = 0; // reopen method
216
			lastMethod.methodDeclaration.bodyEnd = 0; // reopen method
178
			lastMethod.methodDeclaration.declarationSourceEnd = 0; // reopen method
217
			lastMethod.methodDeclaration.declarationSourceEnd = 0; // reopen method
179
			lastMethod.bracketBalance++; // expect one closing brace
218
			lastMethod.bracketBalance++; // expect one closing brace
219
			
220
			this.resetPendingModifiers();
221
			
180
			return lastMethod.add(memberTypeDeclaration, bracketBalanceValue);
222
			return lastMethod.add(memberTypeDeclaration, bracketBalanceValue);
181
		} else {
223
		} else {
182
			// ignore
224
			// ignore
Lines 199-204 Link Here
199
	}
241
	}
200
	RecoveredType element = new RecoveredType(memberTypeDeclaration, this, bracketBalanceValue);
242
	RecoveredType element = new RecoveredType(memberTypeDeclaration, this, bracketBalanceValue);
201
	memberTypes[memberTypeCount++] = element;
243
	memberTypes[memberTypeCount++] = element;
244
	
245
	if(this.pendingAnnotationCount > 0) {
246
		element.attach(
247
				pendingAnnotations,
248
				pendingAnnotationCount,
249
				pendingModifiers,
250
				pendingModifersSourceStart);
251
		this.resetPendingModifiers();
252
	}
202
253
203
	/* consider that if the opening brace was not found, it is there */
254
	/* consider that if the opening brace was not found, it is there */
204
	if (!foundOpeningBrace){
255
	if (!foundOpeningBrace){
Lines 213-218 Link Here
213
	this.pendingTypeParameters = parameters;
264
	this.pendingTypeParameters = parameters;
214
	this.pendingTypeParametersStart = startPos;
265
	this.pendingTypeParametersStart = startPos;
215
}
266
}
267
public RecoveredElement addAnnotationName(int identifierPtr, int identifierLengthPtr, int annotationStart, int bracketBalanceValue) {
268
	if (pendingAnnotations == null) {
269
		pendingAnnotations = new RecoveredAnnotation[5];
270
		pendingAnnotationCount = 0;
271
	} else {
272
		if (pendingAnnotationCount == pendingAnnotations.length) {
273
			System.arraycopy(
274
				pendingAnnotations, 
275
				0, 
276
				(pendingAnnotations = new RecoveredAnnotation[2 * pendingAnnotationCount]), 
277
				0, 
278
				pendingAnnotationCount); 
279
		}
280
	}
281
	
282
	RecoveredAnnotation element = new RecoveredAnnotation(identifierPtr, identifierLengthPtr, annotationStart, this, bracketBalanceValue);
283
	
284
	pendingAnnotations[pendingAnnotationCount++] = element;
285
	
286
	return element;
287
}
288
public void addModifier(int flag, int modifiersSourceStart) {
289
	this.pendingModifiers |= flag;
290
	
291
	if (this.pendingModifersSourceStart < 0) {
292
		this.pendingModifersSourceStart = modifiersSourceStart;
293
	}
294
}
295
public void attach(RecoveredAnnotation[] annots, int annotCount, int mods, int modsSourceStart) {
296
	if (annotCount > 0) {
297
		Annotation[] existingAnnotations = this.typeDeclaration.annotations;
298
		if (existingAnnotations != null) {
299
			this.annotations = new RecoveredAnnotation[annotCount];
300
			this.annotationCount = 0;
301
			next : for (int i = 0; i < annotCount; i++) {
302
				for (int j = 0; j < existingAnnotations.length; j++) {
303
					if (annots[i].annotation == existingAnnotations[j]) continue next;
304
				}
305
				this.annotations[this.annotationCount++] = annots[i];
306
			}
307
		} else {
308
			this.annotations = annots;
309
			this.annotationCount = annotCount;
310
		}
311
	}
312
	
313
	if (mods != 0) {
314
		this.modifiers = mods;
315
		this.modifiersStart = modsSourceStart;
316
	}
317
}
216
/*
318
/*
217
 * Answer the body end of the corresponding parse node
319
 * Answer the body end of the corresponding parse node
218
 */
320
 */
Lines 258-263 Link Here
258
public ASTNode parseTree(){
360
public ASTNode parseTree(){
259
	return typeDeclaration;
361
	return typeDeclaration;
260
}
362
}
363
public void resetPendingModifiers() {
364
	this.pendingAnnotations = null;
365
	this.pendingAnnotationCount = 0;
366
	this.pendingModifiers = 0;
367
	this.pendingModifersSourceStart = -1;
368
}
261
/*
369
/*
262
 * Answer the very source end of the corresponding parse node
370
 * Answer the very source end of the corresponding parse node
263
 */
371
 */
Lines 272-277 Link Here
272
		result.append(" "); //$NON-NLS-1$
380
		result.append(" "); //$NON-NLS-1$
273
	}
381
	}
274
	typeDeclaration.print(tab + 1, result);
382
	typeDeclaration.print(tab + 1, result);
383
	if (this.annotations != null) {
384
		for (int i = 0; i < this.annotationCount; i++) {
385
			result.append("\n"); //$NON-NLS-1$
386
			result.append(this.annotations[i].toString(tab + 1));
387
		}
388
	}
275
	if (this.memberTypes != null) {
389
	if (this.memberTypes != null) {
276
		for (int i = 0; i < this.memberTypeCount; i++) {
390
		for (int i = 0; i < this.memberTypeCount; i++) {
277
			result.append("\n"); //$NON-NLS-1$
391
			result.append("\n"); //$NON-NLS-1$
Lines 320-325 Link Here
320
}
434
}
321
public TypeDeclaration updatedTypeDeclaration(){
435
public TypeDeclaration updatedTypeDeclaration(){
322
	int lastEnd = typeDeclaration.bodyStart;
436
	int lastEnd = typeDeclaration.bodyStart;
437
	/* update annotations */
438
	if (modifiers != 0) {
439
		this.typeDeclaration.modifiers |= modifiers;
440
		if (this.modifiersStart < this.typeDeclaration.declarationSourceStart) {
441
			this.typeDeclaration.declarationSourceStart = modifiersStart;
442
		}
443
	}
444
	/* update annotations */
445
	if (annotationCount > 0){
446
		int existingCount = typeDeclaration.annotations == null ? 0 : typeDeclaration.annotations.length;
447
		Annotation[] annotationReferences = new Annotation[existingCount + annotationCount];
448
		if (existingCount > 0){
449
			System.arraycopy(typeDeclaration.annotations, 0, annotationReferences, annotationCount, existingCount);
450
		}
451
		for (int i = 0; i < annotationCount; i++){
452
			annotationReferences[i] = annotations[i].updatedAnnotationReference();
453
		}
454
		typeDeclaration.annotations = annotationReferences;
455
		
456
		int start = this.annotations[0].annotation.sourceStart;
457
		if (start < this.typeDeclaration.declarationSourceStart) {
458
			this.typeDeclaration.declarationSourceStart = start;
459
		}
460
	}
323
	/* update member types */
461
	/* update member types */
324
	if (memberTypeCount > 0){
462
	if (memberTypeCount > 0){
325
		int existingCount = typeDeclaration.memberTypes == null ? 0 : typeDeclaration.memberTypes.length;
463
		int existingCount = typeDeclaration.memberTypes == null ? 0 : typeDeclaration.memberTypes.length;
(-)compiler/org/eclipse/jdt/internal/compiler/parser/ParserBasicInformation.java (-8 / +8 lines)
Lines 16-35 Link Here
16
16
17
	int ERROR_SYMBOL = 110,
17
	int ERROR_SYMBOL = 110,
18
		MAX_NAME_LENGTH = 41,
18
		MAX_NAME_LENGTH = 41,
19
		NUM_STATES = 961,
19
		NUM_STATES = 969,
20
20
21
		NT_OFFSET = 110,
21
		NT_OFFSET = 110,
22
		SCOPE_UBOUND = 133,
22
		SCOPE_UBOUND = 133,
23
		SCOPE_SIZE = 134,
23
		SCOPE_SIZE = 134,
24
		LA_STATE_OFFSET = 12766,
24
		LA_STATE_OFFSET = 12828,
25
		MAX_LA = 1,
25
		MAX_LA = 1,
26
		NUM_RULES = 699,
26
		NUM_RULES = 700,
27
		NUM_TERMINALS = 110,
27
		NUM_TERMINALS = 110,
28
		NUM_NON_TERMINALS = 310,
28
		NUM_NON_TERMINALS = 311,
29
		NUM_SYMBOLS = 420,
29
		NUM_SYMBOLS = 421,
30
		START_STATE = 730,
30
		START_STATE = 731,
31
		EOFT_SYMBOL = 68,
31
		EOFT_SYMBOL = 68,
32
		EOLT_SYMBOL = 68,
32
		EOLT_SYMBOL = 68,
33
		ACCEPT_ACTION = 12765,
33
		ACCEPT_ACTION = 12827,
34
		ERROR_ACTION = 12766;
34
		ERROR_ACTION = 12828;
35
}
35
}
(-)compiler/org/eclipse/jdt/internal/compiler/parser/readableNames.properties (+1 lines)
Lines 245-250 Link Here
245
ShiftExpression_NotName=Expression
245
ShiftExpression_NotName=Expression
246
SimpleName=SimpleName
246
SimpleName=SimpleName
247
SingleMemberAnnotation=SingleMemberAnnotation
247
SingleMemberAnnotation=SingleMemberAnnotation
248
SingleMemberAnnotationMemberValue=MemberValue
248
SingleStaticImportDeclaration=SingleStaticImportDeclaration
249
SingleStaticImportDeclaration=SingleStaticImportDeclaration
249
SingleStaticImportDeclarationName=SingleStaticImportDeclarationName
250
SingleStaticImportDeclarationName=SingleStaticImportDeclarationName
250
SingleTypeImportDeclaration=SingleTypeImportDeclaration
251
SingleTypeImportDeclaration=SingleTypeImportDeclaration
(-)compiler/org/eclipse/jdt/internal/compiler/parser/RecoveredField.java (-1 / +61 lines)
Lines 14-19 Link Here
14
 * Internal field structure for parsing recovery 
14
 * Internal field structure for parsing recovery 
15
 */
15
 */
16
import org.eclipse.jdt.internal.compiler.ast.AbstractVariableDeclaration;
16
import org.eclipse.jdt.internal.compiler.ast.AbstractVariableDeclaration;
17
import org.eclipse.jdt.internal.compiler.ast.Annotation;
17
import org.eclipse.jdt.internal.compiler.ast.ArrayQualifiedTypeReference;
18
import org.eclipse.jdt.internal.compiler.ast.ArrayQualifiedTypeReference;
18
import org.eclipse.jdt.internal.compiler.ast.ArrayTypeReference;
19
import org.eclipse.jdt.internal.compiler.ast.ArrayTypeReference;
19
import org.eclipse.jdt.internal.compiler.ast.ASTNode;
20
import org.eclipse.jdt.internal.compiler.ast.ASTNode;
Lines 27-32 Link Here
27
	public FieldDeclaration fieldDeclaration;
28
	public FieldDeclaration fieldDeclaration;
28
	boolean alreadyCompletedFieldInitialization;
29
	boolean alreadyCompletedFieldInitialization;
29
	
30
	
31
	public RecoveredAnnotation[] annotations;
32
	public int annotationCount;
33
	
34
	public int modifiers;
35
	public int modifiersStart;
36
	
30
	public RecoveredType[] anonymousTypes;
37
	public RecoveredType[] anonymousTypes;
31
	public int anonymousTypeCount;
38
	public int anonymousTypeCount;
32
public RecoveredField(FieldDeclaration fieldDeclaration, RecoveredElement parent, int bracketBalance){
39
public RecoveredField(FieldDeclaration fieldDeclaration, RecoveredElement parent, int bracketBalance){
Lines 85-90 Link Here
85
		return element;
92
		return element;
86
	}
93
	}
87
}
94
}
95
public void attach(RecoveredAnnotation[] annots, int annotCount, int mods, int modsSourceStart) {
96
	if (annotCount > 0) {
97
		Annotation[] existingAnnotations = this.fieldDeclaration.annotations;
98
		if (existingAnnotations != null) {
99
			this.annotations = new RecoveredAnnotation[annotCount];
100
			this.annotationCount = 0;
101
			next : for (int i = 0; i < annotCount; i++) {
102
				for (int j = 0; j < existingAnnotations.length; j++) {
103
					if (annots[i].annotation == existingAnnotations[j]) continue next;
104
				}
105
				this.annotations[this.annotationCount++] = annots[i];
106
			}
107
		} else {
108
			this.annotations = annots;
109
			this.annotationCount = annotCount;
110
		}
111
	}
112
	
113
	if (mods != 0) {
114
		this.modifiers = mods;
115
		this.modifiersStart = modsSourceStart;
116
	}
117
}
88
/* 
118
/* 
89
 * Answer the associated parsed structure
119
 * Answer the associated parsed structure
90
 */
120
 */
Lines 101-106 Link Here
101
	StringBuffer buffer = new StringBuffer(tabString(tab));
131
	StringBuffer buffer = new StringBuffer(tabString(tab));
102
	buffer.append("Recovered field:\n"); //$NON-NLS-1$
132
	buffer.append("Recovered field:\n"); //$NON-NLS-1$
103
	fieldDeclaration.print(tab + 1, buffer);
133
	fieldDeclaration.print(tab + 1, buffer);
134
	if (this.annotations != null) {
135
		for (int i = 0; i < this.annotationCount; i++) {
136
			buffer.append("\n"); //$NON-NLS-1$
137
			buffer.append(this.annotations[i].toString(tab + 1));
138
		}
139
	}
104
	if (this.anonymousTypes != null) {
140
	if (this.anonymousTypes != null) {
105
		for (int i = 0; i < this.anonymousTypeCount; i++){
141
		for (int i = 0; i < this.anonymousTypeCount; i++){
106
			buffer.append("\n"); //$NON-NLS-1$
142
			buffer.append("\n"); //$NON-NLS-1$
Lines 110-116 Link Here
110
	return buffer.toString();
146
	return buffer.toString();
111
}
147
}
112
public FieldDeclaration updatedFieldDeclaration(){
148
public FieldDeclaration updatedFieldDeclaration(){
113
149
	/* update annotations */
150
	if (modifiers != 0) {
151
		this.fieldDeclaration.modifiers |= modifiers;
152
		if (this.modifiersStart < this.fieldDeclaration.declarationSourceStart) {
153
			this.fieldDeclaration.declarationSourceStart = modifiersStart;
154
		}
155
	}
156
	/* update annotations */
157
	if (annotationCount > 0){
158
		int existingCount = fieldDeclaration.annotations == null ? 0 : fieldDeclaration.annotations.length;
159
		Annotation[] annotationReferences = new Annotation[existingCount + annotationCount];
160
		if (existingCount > 0){
161
			System.arraycopy(fieldDeclaration.annotations, 0, annotationReferences, annotationCount, existingCount);
162
		}
163
		for (int i = 0; i < annotationCount; i++){
164
			annotationReferences[i] = annotations[i].updatedAnnotationReference();
165
		}
166
		fieldDeclaration.annotations = annotationReferences;
167
		
168
		int start = this.annotations[0].annotation.sourceStart;
169
		if (start < this.fieldDeclaration.declarationSourceStart) {
170
			this.fieldDeclaration.declarationSourceStart = start;
171
		}
172
	}
173
	
114
	if (this.anonymousTypes != null) {
174
	if (this.anonymousTypes != null) {
115
		if(fieldDeclaration.initialization == null) {
175
		if(fieldDeclaration.initialization == null) {
116
			for (int i = 0; i < this.anonymousTypeCount; i++){
176
			for (int i = 0; i < this.anonymousTypeCount; i++){
(-)compiler/org/eclipse/jdt/internal/compiler/parser/RecoveredUnit.java (+59 lines)
Lines 30-39 Link Here
30
	public int importCount;
30
	public int importCount;
31
	public RecoveredType[] types;
31
	public RecoveredType[] types;
32
	public int typeCount;
32
	public int typeCount;
33
	
34
	int pendingModifiers;
35
	int pendingModifersSourceStart = -1;
36
	RecoveredAnnotation[] pendingAnnotations;
37
	int pendingAnnotationCount;
38
	
33
public RecoveredUnit(CompilationUnitDeclaration unitDeclaration, int bracketBalance, Parser parser){
39
public RecoveredUnit(CompilationUnitDeclaration unitDeclaration, int bracketBalance, Parser parser){
34
	super(null, bracketBalance, parser);
40
	super(null, bracketBalance, parser);
35
	this.unitDeclaration = unitDeclaration;
41
	this.unitDeclaration = unitDeclaration;
36
}
42
}
43
public RecoveredElement addAnnotationName(int identifierPtr, int identifierLengthPtr, int annotationStart, int bracketBalanceValue) {
44
	if (pendingAnnotations == null) {
45
		pendingAnnotations = new RecoveredAnnotation[5];
46
		pendingAnnotationCount = 0;
47
	} else {
48
		if (pendingAnnotationCount == pendingAnnotations.length) {
49
			System.arraycopy(
50
				pendingAnnotations, 
51
				0, 
52
				(pendingAnnotations = new RecoveredAnnotation[2 * pendingAnnotationCount]), 
53
				0, 
54
				pendingAnnotationCount); 
55
		}
56
	}
57
	
58
	RecoveredAnnotation element = new RecoveredAnnotation(identifierPtr, identifierLengthPtr, annotationStart, this, bracketBalanceValue);
59
	
60
	pendingAnnotations[pendingAnnotationCount++] = element;
61
	
62
	return element;
63
}
64
public void addModifier(int flag, int modifiersSourceStart) {
65
	this.pendingModifiers |= flag;
66
	
67
	if (this.pendingModifersSourceStart < 0) {
68
		this.pendingModifersSourceStart = modifiersSourceStart;
69
	}
70
}
37
/*
71
/*
38
 *	Record a method declaration: should be attached to last type
72
 *	Record a method declaration: should be attached to last type
39
 */
73
 */
Lines 64-69 Link Here
64
			type.add(initializer, bracketBalanceValue);
98
			type.add(initializer, bracketBalanceValue);
65
		}
99
		}
66
		
100
		
101
		this.resetPendingModifiers();
102
		
67
		return type.add(methodDeclaration, bracketBalanceValue);
103
		return type.add(methodDeclaration, bracketBalanceValue);
68
	}
104
	}
69
	return this; // ignore
105
	return this; // ignore
Lines 79-89 Link Here
79
		type.bodyEnd = 0; // reset position
115
		type.bodyEnd = 0; // reset position
80
		type.typeDeclaration.declarationSourceEnd = 0; // reset position
116
		type.typeDeclaration.declarationSourceEnd = 0; // reset position
81
		type.typeDeclaration.bodyEnd = 0;
117
		type.typeDeclaration.bodyEnd = 0;
118
		
119
		this.resetPendingModifiers();
120
		
82
		return type.add(fieldDeclaration, bracketBalanceValue);
121
		return type.add(fieldDeclaration, bracketBalanceValue);
83
	}
122
	}
84
	return this; // ignore
123
	return this; // ignore
85
}
124
}
86
public RecoveredElement add(ImportReference importReference, int bracketBalanceValue) {
125
public RecoveredElement add(ImportReference importReference, int bracketBalanceValue) {
126
	this.resetPendingModifiers();
127
		
87
	if (this.imports == null) {
128
	if (this.imports == null) {
88
		this.imports = new RecoveredImport[5];
129
		this.imports = new RecoveredImport[5];
89
		this.importCount = 0;
130
		this.importCount = 0;
Lines 114-119 Link Here
114
			lastType.typeDeclaration.bodyEnd = 0; // reopen type
155
			lastType.typeDeclaration.bodyEnd = 0; // reopen type
115
			lastType.typeDeclaration.declarationSourceEnd = 0; // reopen type
156
			lastType.typeDeclaration.declarationSourceEnd = 0; // reopen type
116
			lastType.bracketBalance++; // expect one closing brace
157
			lastType.bracketBalance++; // expect one closing brace
158
			
159
			this.resetPendingModifiers();
160
		
117
			return lastType.add(typeDeclaration, bracketBalanceValue);
161
			return lastType.add(typeDeclaration, bracketBalanceValue);
118
		}
162
		}
119
	}
163
	}
Lines 132-137 Link Here
132
	}
176
	}
133
	RecoveredType element = new RecoveredType(typeDeclaration, this, bracketBalanceValue);
177
	RecoveredType element = new RecoveredType(typeDeclaration, this, bracketBalanceValue);
134
	this.types[this.typeCount++] = element;
178
	this.types[this.typeCount++] = element;
179
	
180
	if(this.pendingAnnotationCount > 0) {
181
		element.attach(
182
				pendingAnnotations,
183
				pendingAnnotationCount,
184
				pendingModifiers,
185
				pendingModifersSourceStart);
186
		this.resetPendingModifiers();
187
	}
135
188
136
	/* if type not finished, then type becomes current */
189
	/* if type not finished, then type becomes current */
137
	if (typeDeclaration.declarationSourceEnd == 0) return element;
190
	if (typeDeclaration.declarationSourceEnd == 0) return element;
Lines 143-148 Link Here
143
public ASTNode parseTree(){
196
public ASTNode parseTree(){
144
	return this.unitDeclaration;
197
	return this.unitDeclaration;
145
}
198
}
199
public void resetPendingModifiers() {
200
	this.pendingAnnotations = null;
201
	this.pendingAnnotationCount = 0;
202
	this.pendingModifiers = 0;
203
	this.pendingModifersSourceStart = -1;
204
}
146
/*
205
/*
147
 * Answer the very source end of the corresponding parse node
206
 * Answer the very source end of the corresponding parse node
148
 */
207
 */
(-)compiler/org/eclipse/jdt/internal/compiler/parser/RecoveredInitializer.java (+85 lines)
Lines 27-32 Link Here
27
	public int localTypeCount;
27
	public int localTypeCount;
28
28
29
	public RecoveredBlock initializerBody;	
29
	public RecoveredBlock initializerBody;	
30
	
31
	int pendingModifiers;
32
	int pendingModifersSourceStart = -1;
33
	RecoveredAnnotation[] pendingAnnotations;
34
	int pendingAnnotationCount;
30
35
31
public RecoveredInitializer(FieldDeclaration fieldDeclaration, RecoveredElement parent, int bracketBalance){
36
public RecoveredInitializer(FieldDeclaration fieldDeclaration, RecoveredElement parent, int bracketBalance){
32
	this(fieldDeclaration, parent, bracketBalance, null);
37
	this(fieldDeclaration, parent, bracketBalance, null);
Lines 46-51 Link Here
46
	*/
51
	*/
47
	if (fieldDeclaration.declarationSourceEnd > 0
52
	if (fieldDeclaration.declarationSourceEnd > 0
48
			&& nestedBlockDeclaration.sourceStart > fieldDeclaration.declarationSourceEnd){
53
			&& nestedBlockDeclaration.sourceStart > fieldDeclaration.declarationSourceEnd){
54
		resetPendingModifiers();
49
		if (this.parent == null) return this; // ignore
55
		if (this.parent == null) return this; // ignore
50
		return this.parent.add(nestedBlockDeclaration, bracketBalanceValue);
56
		return this.parent.add(nestedBlockDeclaration, bracketBalanceValue);
51
	}
57
	}
Lines 62-67 Link Here
62
 * Record a field declaration (act like inside method body)
68
 * Record a field declaration (act like inside method body)
63
 */
69
 */
64
public RecoveredElement add(FieldDeclaration newFieldDeclaration, int bracketBalanceValue) {
70
public RecoveredElement add(FieldDeclaration newFieldDeclaration, int bracketBalanceValue) {
71
	this.resetPendingModifiers();
65
72
66
	/* local variables inside initializer can only be final and non void */
73
	/* local variables inside initializer can only be final and non void */
67
	char[][] fieldTypeName;
74
	char[][] fieldTypeName;
Lines 95-100 Link Here
95
		it must be belonging to an enclosing type */
102
		it must be belonging to an enclosing type */
96
	if (fieldDeclaration.declarationSourceEnd != 0 
103
	if (fieldDeclaration.declarationSourceEnd != 0 
97
			&& localDeclaration.declarationSourceStart > fieldDeclaration.declarationSourceEnd){
104
			&& localDeclaration.declarationSourceStart > fieldDeclaration.declarationSourceEnd){
105
		resetPendingModifiers();
98
		if (parent == null) return this; // ignore
106
		if (parent == null) return this; // ignore
99
		return this.parent.add(localDeclaration, bracketBalanceValue);
107
		return this.parent.add(localDeclaration, bracketBalanceValue);
100
	}
108
	}
Lines 102-107 Link Here
102
	Block block = new Block(0);
110
	Block block = new Block(0);
103
	block.sourceStart = ((Initializer)fieldDeclaration).sourceStart;
111
	block.sourceStart = ((Initializer)fieldDeclaration).sourceStart;
104
	RecoveredElement element = this.add(block, 1);
112
	RecoveredElement element = this.add(block, 1);
113
	if (initializerBody != null) {
114
		initializerBody.attachPendingModifiers(
115
				this.pendingAnnotations,
116
				this.pendingAnnotationCount,
117
				this.pendingModifiers,
118
				this.pendingModifersSourceStart);
119
	}
120
	this.resetPendingModifiers();
105
	return element.add(localDeclaration, bracketBalanceValue);	
121
	return element.add(localDeclaration, bracketBalanceValue);	
106
}
122
}
107
/*
123
/*
Lines 113-118 Link Here
113
		it must be belonging to an enclosing type */
129
		it must be belonging to an enclosing type */
114
	if (fieldDeclaration.declarationSourceEnd != 0 
130
	if (fieldDeclaration.declarationSourceEnd != 0 
115
			&& statement.sourceStart > fieldDeclaration.declarationSourceEnd){
131
			&& statement.sourceStart > fieldDeclaration.declarationSourceEnd){
132
		resetPendingModifiers();
116
		if (parent == null) return this; // ignore
133
		if (parent == null) return this; // ignore
117
		return this.parent.add(statement, bracketBalanceValue);
134
		return this.parent.add(statement, bracketBalanceValue);
118
	}
135
	}
Lines 120-125 Link Here
120
	Block block = new Block(0);
137
	Block block = new Block(0);
121
	block.sourceStart = ((Initializer)fieldDeclaration).sourceStart;
138
	block.sourceStart = ((Initializer)fieldDeclaration).sourceStart;
122
	RecoveredElement element = this.add(block, 1);
139
	RecoveredElement element = this.add(block, 1);
140
	
141
	if (initializerBody != null) {
142
		initializerBody.attachPendingModifiers(
143
				this.pendingAnnotations,
144
				this.pendingAnnotationCount,
145
				this.pendingModifiers,
146
				this.pendingModifersSourceStart);
147
	}
148
	this.resetPendingModifiers();
149
		
123
	return element.add(statement, bracketBalanceValue);	
150
	return element.add(statement, bracketBalanceValue);	
124
}
151
}
125
public RecoveredElement add(TypeDeclaration typeDeclaration, int bracketBalanceValue) {
152
public RecoveredElement add(TypeDeclaration typeDeclaration, int bracketBalanceValue) {
Lines 128-133 Link Here
128
		it must be belonging to an enclosing type */
155
		it must be belonging to an enclosing type */
129
	if (fieldDeclaration.declarationSourceEnd != 0 
156
	if (fieldDeclaration.declarationSourceEnd != 0 
130
			&& typeDeclaration.declarationSourceStart > fieldDeclaration.declarationSourceEnd){
157
			&& typeDeclaration.declarationSourceStart > fieldDeclaration.declarationSourceEnd){
158
		resetPendingModifiers();
131
		if (parent == null) return this; // ignore
159
		if (parent == null) return this; // ignore
132
		return this.parent.add(typeDeclaration, bracketBalanceValue);
160
		return this.parent.add(typeDeclaration, bracketBalanceValue);
133
	}
161
	}
Lines 136-141 Link Here
136
		Block block = new Block(0);
164
		Block block = new Block(0);
137
		block.sourceStart = ((Initializer)fieldDeclaration).sourceStart;
165
		block.sourceStart = ((Initializer)fieldDeclaration).sourceStart;
138
		RecoveredElement element = this.add(block, 1);
166
		RecoveredElement element = this.add(block, 1);
167
		if (initializerBody != null) {
168
			initializerBody.attachPendingModifiers(
169
					this.pendingAnnotations,
170
					this.pendingAnnotationCount,
171
					this.pendingModifiers,
172
					this.pendingModifersSourceStart);
173
		}
174
		this.resetPendingModifiers();
139
		return element.add(typeDeclaration, bracketBalanceValue);	
175
		return element.add(typeDeclaration, bracketBalanceValue);	
140
	}	
176
	}	
141
	if (localTypes == null) {
177
	if (localTypes == null) {
Lines 154-159 Link Here
154
	RecoveredType element = new RecoveredType(typeDeclaration, this, bracketBalanceValue);
190
	RecoveredType element = new RecoveredType(typeDeclaration, this, bracketBalanceValue);
155
	localTypes[localTypeCount++] = element;
191
	localTypes[localTypeCount++] = element;
156
	
192
	
193
	if(this.pendingAnnotationCount > 0) {
194
		element.attach(
195
				pendingAnnotations,
196
				pendingAnnotationCount,
197
				pendingModifiers,
198
				pendingModifersSourceStart);
199
		this.resetPendingModifiers();
200
	}
201
	
157
	/* consider that if the opening brace was not found, it is there */
202
	/* consider that if the opening brace was not found, it is there */
158
	if (!foundOpeningBrace){
203
	if (!foundOpeningBrace){
159
		foundOpeningBrace = true;
204
		foundOpeningBrace = true;
Lines 161-170 Link Here
161
	}
206
	}
162
	return element;
207
	return element;
163
}
208
}
209
public RecoveredElement addAnnotationName(int identifierPtr, int identifierLengthPtr, int annotationStart, int bracketBalanceValue) {
210
	if (pendingAnnotations == null) {
211
		pendingAnnotations = new RecoveredAnnotation[5];
212
		pendingAnnotationCount = 0;
213
	} else {
214
		if (pendingAnnotationCount == pendingAnnotations.length) {
215
			System.arraycopy(
216
				pendingAnnotations, 
217
				0, 
218
				(pendingAnnotations = new RecoveredAnnotation[2 * pendingAnnotationCount]), 
219
				0, 
220
				pendingAnnotationCount); 
221
		}
222
	}
223
	
224
	RecoveredAnnotation element = new RecoveredAnnotation(identifierPtr, identifierLengthPtr, annotationStart, this, bracketBalanceValue);
225
	
226
	pendingAnnotations[pendingAnnotationCount++] = element;
227
	
228
	return element;
229
}
230
public void addModifier(int flag, int modifiersSourceStart) {
231
	this.pendingModifiers |= flag;
232
	
233
	if (this.pendingModifersSourceStart < 0) {
234
		this.pendingModifersSourceStart = modifiersSourceStart;
235
	}
236
}
237
public void resetPendingModifiers() {
238
	this.pendingAnnotations = null;
239
	this.pendingAnnotationCount = 0;
240
	this.pendingModifiers = 0;
241
	this.pendingModifersSourceStart = -1;
242
}
164
public String toString(int tab) {
243
public String toString(int tab) {
165
	StringBuffer result = new StringBuffer(tabString(tab));
244
	StringBuffer result = new StringBuffer(tabString(tab));
166
	result.append("Recovered initializer:\n"); //$NON-NLS-1$
245
	result.append("Recovered initializer:\n"); //$NON-NLS-1$
167
	this.fieldDeclaration.print(tab + 1, result);
246
	this.fieldDeclaration.print(tab + 1, result);
247
	if (this.annotations != null) {
248
		for (int i = 0; i < this.annotationCount; i++) {
249
			result.append("\n"); //$NON-NLS-1$
250
			result.append(this.annotations[i].toString(tab + 1));
251
		}
252
	}
168
	if (this.initializerBody != null) {
253
	if (this.initializerBody != null) {
169
		result.append("\n"); //$NON-NLS-1$
254
		result.append("\n"); //$NON-NLS-1$
170
		result.append(this.initializerBody.toString(tab + 1));
255
		result.append(this.initializerBody.toString(tab + 1));
(-)grammar/java.g (-1 / +6 lines)
Lines 2233-2239 Link Here
2233
/:$readableName MarkerAnnotation:/
2233
/:$readableName MarkerAnnotation:/
2234
/:$compliance 1.5:/
2234
/:$compliance 1.5:/
2235
2235
2236
SingleMemberAnnotation ::= AnnotationName '(' MemberValue ')'
2236
SingleMemberAnnotationMemberValue ::= MemberValue
2237
/.$putCase consumeSingleMemberAnnotationMemberValue() ; $break ./
2238
/:$readableName MemberValue:/
2239
/:$compliance 1.5:/
2240
2241
SingleMemberAnnotation ::= AnnotationName '(' SingleMemberAnnotationMemberValue ')'
2237
/.$putCase consumeSingleMemberAnnotation() ; $break ./
2242
/.$putCase consumeSingleMemberAnnotation() ; $break ./
2238
/:$readableName SingleMemberAnnotation:/
2243
/:$readableName SingleMemberAnnotation:/
2239
/:$compliance 1.5:/
2244
/:$compliance 1.5:/
(-)codeassist/org/eclipse/jdt/internal/codeassist/impl/AssistParser.java (+1 lines)
Lines 80-85 Link Here
80
	
80
	
81
	this.setMethodsFullRecovery(false);
81
	this.setMethodsFullRecovery(false);
82
	this.setStatementsRecovery(false);
82
	this.setStatementsRecovery(false);
83
	this.annotationRecoveryActivated = false;
83
}
84
}
84
public abstract char[] assistIdentifier();
85
public abstract char[] assistIdentifier();
85
public int bodyEnd(AbstractMethodDeclaration method){
86
public int bodyEnd(AbstractMethodDeclaration method){
(-)dom/org/eclipse/jdt/core/dom/ASTRecoveryPropagator.java (-2 / +49 lines)
Lines 183-190 Link Here
183
		
183
		
184
		// is inside diet part of the ast
184
		// is inside diet part of the ast
185
		if(this.blockDepth < 1) {
185
		if(this.blockDepth < 1) {
186
			if(this.markIncludedProblems(start, end)) {
186
			switch (node.getNodeType()) {
187
				node.setFlags(node.getFlags() | ASTNode.RECOVERED);
187
				case ASTNode.ANNOTATION_TYPE_DECLARATION:
188
				case ASTNode.COMPILATION_UNIT:
189
				case ASTNode.ENUM_DECLARATION:
190
				case ASTNode.FIELD_DECLARATION:
191
				case ASTNode.IMPORT_DECLARATION:
192
				case ASTNode.INITIALIZER:
193
				case ASTNode.METHOD_DECLARATION:
194
				case ASTNode.PACKAGE_DECLARATION:
195
				case ASTNode.TYPE_DECLARATION:
196
				case ASTNode.MARKER_ANNOTATION:
197
				case ASTNode.NORMAL_ANNOTATION:
198
				case ASTNode.SINGLE_MEMBER_ANNOTATION:
199
				case ASTNode.BLOCK:
200
					if(this.markIncludedProblems(start, end)) {
201
						node.setFlags(node.getFlags() | ASTNode.RECOVERED);
202
					}
203
					break;
188
			}
204
			}
189
		} else {			
205
		} else {			
190
			this.markIncludedProblems(start, end);
206
			this.markIncludedProblems(start, end);
Lines 396-399 Link Here
396
			}
412
			}
397
		}
413
		}
398
	}
414
	}
415
	
416
	public void endVisit(NormalAnnotation node) {
417
		endVisitNode(node);
418
		// is inside diet part of the ast
419
		if(this.blockDepth < 1) {
420
			List values = node.values();
421
			int size = values.size();
422
			if (size > 0) {
423
				MemberValuePair lastMemberValuePair = (MemberValuePair)values.get(size - 1);
424
				
425
				int annotationEnd = node.getStartPosition() + node.getLength();
426
				int lastMemberValuePairEnd = lastMemberValuePair.getStartPosition() + lastMemberValuePair.getLength();
427
				if (annotationEnd == lastMemberValuePairEnd) {
428
					node.setFlags(node.getFlags() | ASTNode.RECOVERED);
429
				}
430
			}
431
		}
432
	}
433
	
434
	public void endVisit(SingleMemberAnnotation node) {
435
		endVisitNode(node);
436
		// is inside diet part of the ast
437
		if(this.blockDepth < 1) {
438
			Expression value = node.getValue();
439
			int annotationEnd = node.getStartPosition() + node.getLength();
440
			int valueEnd = value.getStartPosition() + value.getLength();
441
			if (annotationEnd == valueEnd) {
442
				node.setFlags(node.getFlags() | ASTNode.RECOVERED);
443
			}
444
		}
445
	}
399
}
446
}
(-)dom/org/eclipse/jdt/core/dom/ASTConverter.java (-11 / +12 lines)
Lines 4348-4365 Link Here
4348
4348
4349
	protected void setModifiers(AnnotationTypeDeclaration typeDecl, org.eclipse.jdt.internal.compiler.ast.TypeDeclaration typeDeclaration) {
4349
	protected void setModifiers(AnnotationTypeDeclaration typeDecl, org.eclipse.jdt.internal.compiler.ast.TypeDeclaration typeDeclaration) {
4350
		this.scanner.resetTo(typeDeclaration.declarationSourceStart, typeDeclaration.sourceStart);
4350
		this.scanner.resetTo(typeDeclaration.declarationSourceStart, typeDeclaration.sourceStart);
4351
		this.setModifiers(typeDecl, typeDeclaration.annotations);
4351
		this.setModifiers(typeDecl, typeDeclaration.annotations, typeDeclaration.sourceStart);
4352
	}
4352
	}
4353
	
4353
	
4354
	protected void setModifiers(AnnotationTypeMemberDeclaration annotationTypeMemberDecl, org.eclipse.jdt.internal.compiler.ast.AnnotationMethodDeclaration annotationTypeMemberDeclaration) {
4354
	protected void setModifiers(AnnotationTypeMemberDeclaration annotationTypeMemberDecl, org.eclipse.jdt.internal.compiler.ast.AnnotationMethodDeclaration annotationTypeMemberDeclaration) {
4355
		this.scanner.resetTo(annotationTypeMemberDeclaration.declarationSourceStart, annotationTypeMemberDeclaration.sourceStart);
4355
		this.scanner.resetTo(annotationTypeMemberDeclaration.declarationSourceStart, annotationTypeMemberDeclaration.sourceStart);
4356
		this.setModifiers(annotationTypeMemberDecl, annotationTypeMemberDeclaration.annotations);
4356
		this.setModifiers(annotationTypeMemberDecl, annotationTypeMemberDeclaration.annotations, annotationTypeMemberDeclaration.sourceStart);
4357
	}
4357
	}
4358
4358
4359
	/**
4359
	/**
4360
	 * @param bodyDeclaration
4360
	 * @param bodyDeclaration
4361
	 */
4361
	 */
4362
	protected void setModifiers(BodyDeclaration bodyDeclaration, org.eclipse.jdt.internal.compiler.ast.Annotation[] annotations) {
4362
	protected void setModifiers(BodyDeclaration bodyDeclaration, org.eclipse.jdt.internal.compiler.ast.Annotation[] annotations, int modifiersEnd) {
4363
		this.scanner.tokenizeWhiteSpace = false;
4363
		this.scanner.tokenizeWhiteSpace = false;
4364
		try {
4364
		try {
4365
			int token;
4365
			int token;
Lines 4405-4411 Link Here
4405
						if (annotations != null && indexInAnnotations < annotations.length) {
4405
						if (annotations != null && indexInAnnotations < annotations.length) {
4406
							org.eclipse.jdt.internal.compiler.ast.Annotation annotation = annotations[indexInAnnotations++];
4406
							org.eclipse.jdt.internal.compiler.ast.Annotation annotation = annotations[indexInAnnotations++];
4407
							modifier = convert(annotation);
4407
							modifier = convert(annotation);
4408
							this.scanner.resetTo(annotation.declarationSourceEnd + 1, this.compilationUnitSourceLength);
4408
							this.scanner.resetTo(annotation.declarationSourceEnd + 1, modifiersEnd);
4409
						}
4409
						}
4410
						break;
4410
						break;
4411
					case TerminalTokens.TokenNameCOMMENT_BLOCK :
4411
					case TerminalTokens.TokenNameCOMMENT_BLOCK :
Lines 4413-4419 Link Here
4413
					case TerminalTokens.TokenNameCOMMENT_JAVADOC :
4413
					case TerminalTokens.TokenNameCOMMENT_JAVADOC :
4414
						break;
4414
						break;
4415
					default :
4415
					default :
4416
						return;
4416
						// there is some syntax errors in source code
4417
						break;
4417
				}
4418
				}
4418
				if (modifier != null) {
4419
				if (modifier != null) {
4419
					bodyDeclaration.modifiers().add(modifier);
4420
					bodyDeclaration.modifiers().add(modifier);
Lines 4426-4432 Link Here
4426
4427
4427
	protected void setModifiers(EnumDeclaration enumDeclaration, org.eclipse.jdt.internal.compiler.ast.TypeDeclaration enumDeclaration2) {
4428
	protected void setModifiers(EnumDeclaration enumDeclaration, org.eclipse.jdt.internal.compiler.ast.TypeDeclaration enumDeclaration2) {
4428
		this.scanner.resetTo(enumDeclaration2.declarationSourceStart, enumDeclaration2.sourceStart);
4429
		this.scanner.resetTo(enumDeclaration2.declarationSourceStart, enumDeclaration2.sourceStart);
4429
		this.setModifiers(enumDeclaration, enumDeclaration2.annotations);
4430
		this.setModifiers(enumDeclaration, enumDeclaration2.annotations, enumDeclaration2.sourceStart);
4430
	}
4431
	}
4431
	
4432
	
4432
	protected void setModifiers(EnumConstantDeclaration enumConstantDeclaration, org.eclipse.jdt.internal.compiler.ast.FieldDeclaration fieldDeclaration) {
4433
	protected void setModifiers(EnumConstantDeclaration enumConstantDeclaration, org.eclipse.jdt.internal.compiler.ast.FieldDeclaration fieldDeclaration) {
Lines 4439-4445 Link Here
4439
				break;
4440
				break;
4440
			case AST.JLS3 :
4441
			case AST.JLS3 :
4441
				this.scanner.resetTo(fieldDeclaration.declarationSourceStart, fieldDeclaration.sourceStart);
4442
				this.scanner.resetTo(fieldDeclaration.declarationSourceStart, fieldDeclaration.sourceStart);
4442
				this.setModifiers(enumConstantDeclaration, fieldDeclaration.annotations);
4443
				this.setModifiers(enumConstantDeclaration, fieldDeclaration.annotations, fieldDeclaration.sourceStart);
4443
		}
4444
		}
4444
	}
4445
	}
4445
	
4446
	
Lines 4457-4463 Link Here
4457
				break;
4458
				break;
4458
			case AST.JLS3 :
4459
			case AST.JLS3 :
4459
				this.scanner.resetTo(fieldDecl.declarationSourceStart, fieldDecl.sourceStart);
4460
				this.scanner.resetTo(fieldDecl.declarationSourceStart, fieldDecl.sourceStart);
4460
				this.setModifiers(fieldDeclaration, fieldDecl.annotations);
4461
				this.setModifiers(fieldDeclaration, fieldDecl.annotations, fieldDecl.sourceStart);
4461
		}
4462
		}
4462
	}
4463
	}
4463
	
4464
	
Lines 4475-4481 Link Here
4475
				break;
4476
				break;
4476
			case AST.JLS3 :
4477
			case AST.JLS3 :
4477
				this.scanner.resetTo(oldInitializer.declarationSourceStart, oldInitializer.bodyStart);
4478
				this.scanner.resetTo(oldInitializer.declarationSourceStart, oldInitializer.bodyStart);
4478
				this.setModifiers(initializer, oldInitializer.annotations);
4479
				this.setModifiers(initializer, oldInitializer.annotations, oldInitializer.bodyStart);
4479
		}
4480
		}
4480
	}
4481
	}
4481
	/**
4482
	/**
Lines 4492-4498 Link Here
4492
				break;
4493
				break;
4493
			case AST.JLS3 :
4494
			case AST.JLS3 :
4494
				this.scanner.resetTo(methodDeclaration.declarationSourceStart, methodDeclaration.sourceStart);
4495
				this.scanner.resetTo(methodDeclaration.declarationSourceStart, methodDeclaration.sourceStart);
4495
				this.setModifiers(methodDecl, methodDeclaration.annotations);
4496
				this.setModifiers(methodDecl, methodDeclaration.annotations, methodDeclaration.sourceStart);
4496
		}
4497
		}
4497
	}
4498
	}
4498
4499
Lines 4667-4673 Link Here
4667
				break;
4668
				break;
4668
			case AST.JLS3 :
4669
			case AST.JLS3 :
4669
				this.scanner.resetTo(typeDeclaration.declarationSourceStart, typeDeclaration.sourceStart);
4670
				this.scanner.resetTo(typeDeclaration.declarationSourceStart, typeDeclaration.sourceStart);
4670
				this.setModifiers(typeDecl, typeDeclaration.annotations);
4671
				this.setModifiers(typeDecl, typeDeclaration.annotations, typeDeclaration.sourceStart);
4671
		}
4672
		}
4672
	}
4673
	}
4673
	
4674
	
(-)compiler/org/eclipse/jdt/internal/compiler/parser/RecoveredAnnotation.java (+191 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2008 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.jdt.internal.compiler.parser;
12
13
import org.eclipse.jdt.internal.compiler.ast.ASTNode;
14
import org.eclipse.jdt.internal.compiler.ast.Annotation;
15
import org.eclipse.jdt.internal.compiler.ast.Expression;
16
import org.eclipse.jdt.internal.compiler.ast.MarkerAnnotation;
17
import org.eclipse.jdt.internal.compiler.ast.MemberValuePair;
18
import org.eclipse.jdt.internal.compiler.ast.NormalAnnotation;
19
import org.eclipse.jdt.internal.compiler.ast.SingleMemberAnnotation;
20
import org.eclipse.jdt.internal.compiler.ast.TypeDeclaration;
21
import org.eclipse.jdt.internal.compiler.ast.TypeReference;
22
23
public class RecoveredAnnotation extends RecoveredElement {
24
	public static final int MARKER = 0;
25
	public static final int NORMAL = 1;
26
	public static final int SINGLE_MEMBER = 2;
27
	
28
	private int kind;
29
	private int identifierPtr;
30
	private int identifierLengthPtr;
31
	private int sourceStart;
32
	public Annotation annotation;
33
34
	public RecoveredAnnotation(int identifierPtr, int identifierLengthPtr, int sourceStart, RecoveredElement parent, int bracketBalance) {
35
		super(parent, bracketBalance);
36
		this.kind = MARKER;
37
		this.identifierPtr = identifierPtr;
38
		this.identifierLengthPtr = identifierLengthPtr;
39
		this.sourceStart = sourceStart;
40
	}
41
	
42
	public RecoveredElement add(TypeDeclaration typeDeclaration, int bracketBalanceValue) {
43
		if (annotation == null && (typeDeclaration.bits & ASTNode.IsAnonymousType) != 0){
44
			// ignore anonymous type in annotations when annotation isn't fully recovered
45
			return this;
46
		}
47
		return super.add(typeDeclaration, bracketBalanceValue);
48
	}
49
	
50
	public RecoveredElement addAnnotationName(int identPtr, int identLengthPtr, int annotationStart, int bracketBalanceValue) {
51
52
		RecoveredAnnotation element = new RecoveredAnnotation(identPtr, identLengthPtr, annotationStart, this, bracketBalanceValue);
53
		
54
		return element;
55
	}
56
	
57
	public RecoveredElement addAnnotation(Annotation annot, int index) {
58
		this.annotation = annot;
59
		
60
		if (parent != null) return parent;
61
		return this;
62
	}
63
	
64
	public void updateFromParserState() {
65
		Parser parser = this.parser();
66
		
67
		if (annotation == null && this.identifierPtr <= parser.identifierPtr) {
68
			Annotation annot = null;
69
			
70
			boolean needUpdateRParenPos = false;
71
			
72
			parser.identifierPtr = this.identifierPtr;
73
			parser.identifierLengthPtr = this.identifierLengthPtr;
74
			TypeReference typeReference = parser.getAnnotationType();
75
			
76
			switch (this.kind) {
77
				case NORMAL:
78
					MemberValuePair[] memberValuePairs = null;
79
					if (parser.astPtr > -1 && parser.astStack[parser.astPtr] instanceof MemberValuePair) {
80
						int argLength = parser.astLengthStack[parser.astLengthPtr];
81
						int argStart = parser.astPtr - argLength + 1;
82
						
83
						if (argLength > 0) {
84
							System.arraycopy(parser.astStack, argStart, memberValuePairs = new MemberValuePair[argLength], 0, argLength);
85
							parser.astLengthPtr--;
86
							parser.astPtr -= argLength;
87
							
88
							MemberValuePair lastMemberValuePair = memberValuePairs[memberValuePairs.length - 1];
89
							
90
							NormalAnnotation normalAnnotation = new NormalAnnotation(typeReference, this.sourceStart);
91
							normalAnnotation.memberValuePairs = memberValuePairs;
92
							normalAnnotation.declarationSourceEnd =
93
								lastMemberValuePair.value != null
94
										? lastMemberValuePair.value instanceof Annotation
95
												? ((Annotation)lastMemberValuePair.value).declarationSourceEnd
96
												: lastMemberValuePair.value.sourceEnd
97
										: lastMemberValuePair.sourceEnd;
98
							normalAnnotation.bits |= ASTNode.IsRecovered;
99
							
100
							annot = normalAnnotation;
101
							
102
							needUpdateRParenPos = true;
103
						}
104
					}
105
					
106
					
107
					break;
108
				case SINGLE_MEMBER:
109
					if (parser.expressionPtr > -1) {
110
						Expression memberValue = parser.expressionStack[parser.expressionPtr--];
111
						
112
						SingleMemberAnnotation singleMemberAnnotation = new SingleMemberAnnotation(typeReference, this.sourceStart);
113
						singleMemberAnnotation.memberValue = memberValue;
114
						singleMemberAnnotation.declarationSourceEnd = memberValue.sourceEnd;
115
						singleMemberAnnotation.bits |= ASTNode.IsRecovered;
116
						
117
						annot = singleMemberAnnotation;
118
							
119
						needUpdateRParenPos = true;
120
					}
121
					break;
122
			}
123
			
124
			if (!needUpdateRParenPos) {
125
				MarkerAnnotation markerAnnotation = new MarkerAnnotation(typeReference, this.sourceStart);
126
				markerAnnotation.declarationSourceEnd = markerAnnotation.sourceEnd;
127
				markerAnnotation.bits |= ASTNode.IsRecovered;
128
				
129
				annot = markerAnnotation;
130
			}
131
			
132
			parser.currentElement = this.addAnnotation(annot, this.identifierPtr);
133
			parser.annotationRecoveryCheckPoint(annot.sourceStart, annot.declarationSourceEnd);
134
			if (this.parent != null) {
135
136
				this.parent.updateFromParserState();
137
			}
138
		}
139
	}
140
	
141
	public ASTNode parseTree() {
142
		return this.annotation;
143
	}
144
	
145
	public void resetPendingModifiers() {
146
		if (parent != null) this.parent.resetPendingModifiers();
147
	}
148
	
149
	public void setKind(int kind) {
150
		this.kind = kind;
151
	}
152
	
153
	public int sourceEnd() {
154
		if (annotation == null) {
155
			Parser parser = parser();
156
			if (this.identifierPtr < parser.identifierPositionStack.length) {
157
				return (int) parser.identifierPositionStack[this.identifierPtr];
158
			} else {
159
				return this.sourceStart;
160
			}
161
		}
162
		return this.annotation.declarationSourceEnd;
163
	}
164
	
165
	public String toString(int tab) {	
166
		if (annotation != null) {
167
			return tabString(tab) + "Recovered annotation:\n" + annotation.print(tab + 1, new StringBuffer(10)); //$NON-NLS-1$
168
		} else {
169
			return tabString(tab) + "Recovered annotation: identiferPtr=" + this.identifierPtr + " identiferlengthPtr=" + this.identifierLengthPtr + "\n"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
170
		}
171
	}
172
	
173
	public Annotation updatedAnnotationReference() {
174
		return this.annotation;
175
	}
176
	
177
	public RecoveredElement updateOnClosingBrace(int braceStart, int braceEnd){
178
		if (bracketBalance > 0){ // was an member value array initializer
179
			bracketBalance--;
180
			return this;
181
		}
182
		if (parent != null){
183
			return parent.updateOnClosingBrace(braceStart, braceEnd);
184
		}
185
		return this;
186
	}
187
	
188
	public void updateParseTree() {
189
		this.updatedAnnotationReference();
190
	}
191
}
(-)src/org/eclipse/jdt/core/tests/compiler/parser/ComplianceDiagnoseTest.java (-3 / +23 lines)
Lines 41-47 Link Here
41
		this.runNegativeTest(testFiles, expected13ProblemLog);
41
		this.runNegativeTest(testFiles, expected13ProblemLog);
42
	} else if(this.complianceLevel == ClassFileConstants.JDK1_4) {
42
	} else if(this.complianceLevel == ClassFileConstants.JDK1_4) {
43
		this.runNegativeTest(testFiles, expected14ProblemLog);
43
		this.runNegativeTest(testFiles, expected14ProblemLog);
44
	} else if(this.complianceLevel > ClassFileConstants.JDK1_5) {
44
	} else if(this.complianceLevel >= ClassFileConstants.JDK1_5) {
45
		this.runNegativeTest(testFiles, expected15ProblemLog);
45
		this.runNegativeTest(testFiles, expected15ProblemLog);
46
	}
46
	}
47
}
47
}
Lines 1919-1925 Link Here
1919
		"5. ERROR in X.java (at line 23)\n" + 
1919
		"5. ERROR in X.java (at line 23)\n" + 
1920
		"	}\n" + 
1920
		"	}\n" + 
1921
		"	^\n" + 
1921
		"	^\n" + 
1922
		"Syntax error, insert \"}\" to complete MemberValueArrayInitializer\n" + 
1922
		"Syntax error, insert \"}\" to complete MemberValue\n" + 
1923
		"----------\n" + 
1923
		"----------\n" + 
1924
		"6. ERROR in X.java (at line 23)\n" + 
1924
		"6. ERROR in X.java (at line 23)\n" + 
1925
		"	}\n" + 
1925
		"	}\n" + 
Lines 2212-2217 Link Here
2212
		"	public @MyAnn(\"\",\"\") class Test {		\n" + 
2212
		"	public @MyAnn(\"\",\"\") class Test {		\n" + 
2213
		"	              ^^\n" + 
2213
		"	              ^^\n" + 
2214
		"Syntax error, insert \")\" to complete Modifier\n" + 
2214
		"Syntax error, insert \")\" to complete Modifier\n" + 
2215
		"----------\n" + 
2216
		"3. ERROR in X.java (at line 6)\n" + 
2217
		"	public @MyAnn(\"\",\"\") class Test {		\n" + 
2218
		"	              ^^\n" + 
2219
		"The attribute value is undefined for the annotation type MyAnn\n" + 
2220
		"----------\n" + 
2221
		"4. ERROR in X.java (at line 6)\n" + 
2222
		"	public @MyAnn(\"\",\"\") class Test {		\n" + 
2223
		"	                           ^^^^\n" + 
2224
		"The public type Test must be defined in its own file\n" + 
2215
		"----------\n";
2225
		"----------\n";
2216
	String expected14ProblemLog =
2226
	String expected14ProblemLog =
2217
		expected13ProblemLog;
2227
		expected13ProblemLog;
Lines 2220-2227 Link Here
2220
		"----------\n" + 
2230
		"----------\n" + 
2221
		"1. ERROR in X.java (at line 6)\n" + 
2231
		"1. ERROR in X.java (at line 6)\n" + 
2222
		"	public @MyAnn(\"\",\"\") class Test {		\n" + 
2232
		"	public @MyAnn(\"\",\"\") class Test {		\n" + 
2233
		"	              ^^\n" + 
2234
		"The attribute value is undefined for the annotation type MyAnn\n" + 
2235
		"----------\n" + 
2236
		"2. ERROR in X.java (at line 6)\n" + 
2237
		"	public @MyAnn(\"\",\"\") class Test {		\n" + 
2223
		"	                ^\n" + 
2238
		"	                ^\n" + 
2224
		"Syntax error on token \",\", / expected\n" + 
2239
		"Syntax error on token \",\", < expected\n" + 
2240
		"----------\n" + 
2241
		"3. ERROR in X.java (at line 6)\n" + 
2242
		"	public @MyAnn(\"\",\"\") class Test {		\n" + 
2243
		"	                           ^^^^\n" + 
2244
		"The public type Test must be defined in its own file\n" + 
2225
		"----------\n";
2245
		"----------\n";
2226
	
2246
	
2227
	runComplianceParserTest(
2247
	runComplianceParserTest(
(-)src/org/eclipse/jdt/core/tests/compiler/parser/StatementRecoveryTest_1_5.java (+349 lines)
Lines 379-382 Link Here
379
		expectedFullWithStatementRecoveryUnitToString,
379
		expectedFullWithStatementRecoveryUnitToString,
380
		testName);
380
		testName);
381
}
381
}
382
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=130778
383
public void test0003() {
384
385
	String s = 
386
		"package a;															\n"
387
			+ "public class X {												\n"
388
			+ "  void foo() {												\n"
389
			+ "    @AnAnnotation(name) #									\n"
390
			+ "    int var;													\n"
391
			+ "  }															\n"
392
			+ "}															\n";
393
394
	String expectedDietUnitToString = 
395
		"package a;\n" + 
396
		"public class X {\n" + 
397
		"  public X() {\n" + 
398
		"  }\n" + 
399
		"  void foo() {\n" + 
400
		"  }\n" + 
401
		"}\n";
402
			
403
	String expectedDietWithStatementRecoveryUnitToString =
404
		expectedDietUnitToString;
405
	
406
	String expectedDietPlusBodyUnitToString = 
407
		"package a;\n" + 
408
		"public class X {\n" + 
409
		"  public X() {\n" + 
410
		"    super();\n" + 
411
		"  }\n" + 
412
		"  void foo() {\n" + 
413
		"  }\n" + 
414
		"}\n";
415
416
	String expectedDietPlusBodyWithStatementRecoveryUnitToString = 
417
		"package a;\n" + 
418
		"public class X {\n" + 
419
		"  public X() {\n" + 
420
		"    super();\n" + 
421
		"  }\n" + 
422
		"  void foo() {\n" + 
423
		"    @AnAnnotation(name) int var;\n" + 
424
		"  }\n" + 
425
		"}\n";
426
	
427
	String expectedFullUnitToString =
428
		expectedDietUnitToString;
429
	
430
	String expectedFullWithStatementRecoveryUnitToString =
431
		expectedFullUnitToString;
432
	
433
	String testName = "<test>";
434
	checkParse(
435
		s.toCharArray(),
436
		expectedDietUnitToString,
437
		expectedDietWithStatementRecoveryUnitToString,
438
		expectedDietPlusBodyUnitToString,
439
		expectedDietPlusBodyWithStatementRecoveryUnitToString,
440
		expectedFullUnitToString,
441
		expectedFullWithStatementRecoveryUnitToString,
442
		testName);
443
}
444
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=130778
445
public void test0004() {
446
447
	String s = 
448
		"package a;															\n"
449
			+ "public class X {												\n"
450
			+ "  void foo() {												\n"
451
			+ "    @AnAnnotation(name=)										\n"
452
			+ "    int var;													\n"
453
			+ "  }															\n"
454
			+ "}															\n";
455
456
	String expectedDietUnitToString = 
457
		"package a;\n" + 
458
		"public class X {\n" + 
459
		"  public X() {\n" + 
460
		"  }\n" + 
461
		"  void foo() {\n" + 
462
		"  }\n" + 
463
		"}\n";
464
			
465
	String expectedDietWithStatementRecoveryUnitToString =
466
		expectedDietUnitToString;
467
	
468
	String expectedDietPlusBodyUnitToString = 
469
		"package a;\n" + 
470
		"public class X {\n" + 
471
		"  public X() {\n" + 
472
		"    super();\n" + 
473
		"  }\n" + 
474
		"  void foo() {\n" + 
475
		"  }\n" + 
476
		"}\n";
477
478
	String expectedDietPlusBodyWithStatementRecoveryUnitToString = 
479
		"package a;\n" + 
480
		"public class X {\n" + 
481
		"  public X() {\n" + 
482
		"    super();\n" + 
483
		"  }\n" + 
484
		"  void foo() {\n" + 
485
		"    @AnAnnotation(name = $missing$) int var;\n" + 
486
		"  }\n" + 
487
		"}\n";
488
	
489
	String expectedFullUnitToString =
490
		expectedDietUnitToString;
491
	
492
	String expectedFullWithStatementRecoveryUnitToString =
493
		expectedFullUnitToString;
494
	
495
	String testName = "<test>";
496
	checkParse(
497
		s.toCharArray(),
498
		expectedDietUnitToString,
499
		expectedDietWithStatementRecoveryUnitToString,
500
		expectedDietPlusBodyUnitToString,
501
		expectedDietPlusBodyWithStatementRecoveryUnitToString,
502
		expectedFullUnitToString,
503
		expectedFullWithStatementRecoveryUnitToString,
504
		testName);
505
}
506
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=130778
507
public void test0005() {
508
509
	String s = 
510
		"package a;															\n"
511
			+ "public class X {												\n"
512
			+ "  void foo() {												\n"
513
			+ "    foo1();													\n"
514
			+ "    @AnAnnotation(name) #									\n"
515
			+ "    class Y {}												\n"
516
			+ "    foo2();													\n"
517
			+ "  }															\n"
518
			+ "}															\n";
519
520
	String expectedDietUnitToString = 
521
		"package a;\n" + 
522
		"public class X {\n" + 
523
		"  public X() {\n" + 
524
		"  }\n" + 
525
		"  void foo() {\n" + 
526
		"  }\n" + 
527
		"}\n";
528
			
529
	String expectedDietWithStatementRecoveryUnitToString =
530
		expectedDietUnitToString;
531
	
532
	String expectedDietPlusBodyUnitToString = 
533
		"package a;\n" + 
534
		"public class X {\n" + 
535
		"  public X() {\n" + 
536
		"    super();\n" + 
537
		"  }\n" + 
538
		"  void foo() {\n" + 
539
		"    @AnAnnotation(name) class Y {\n" + 
540
		"      Y() {\n" + 
541
		"        super();\n" + 
542
		"      }\n" + 
543
		"    }\n" + 
544
		"  }\n" + 
545
		"}\n";
546
547
	String expectedDietPlusBodyWithStatementRecoveryUnitToString = 
548
		"package a;\n" + 
549
		"public class X {\n" + 
550
		"  public X() {\n" + 
551
		"    super();\n" + 
552
		"  }\n" + 
553
		"  void foo() {\n" + 
554
		"    foo1();\n" + 
555
		"    @AnAnnotation(name) class Y {\n" + 
556
		"      Y() {\n" + 
557
		"        super();\n" + 
558
		"      }\n" + 
559
		"    }\n" + 
560
		"    foo2();\n" + 
561
		"  }\n" + 
562
		"}\n";
563
	
564
	String expectedFullUnitToString =
565
		expectedDietUnitToString;
566
	
567
	String expectedFullWithStatementRecoveryUnitToString =
568
		expectedFullUnitToString;
569
	
570
	String testName = "<test>";
571
	checkParse(
572
		s.toCharArray(),
573
		expectedDietUnitToString,
574
		expectedDietWithStatementRecoveryUnitToString,
575
		expectedDietPlusBodyUnitToString,
576
		expectedDietPlusBodyWithStatementRecoveryUnitToString,
577
		expectedFullUnitToString,
578
		expectedFullWithStatementRecoveryUnitToString,
579
		testName);
580
}
581
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=130778
582
public void test0006() {
583
584
	String s = 
585
		"package a;															\n"
586
			+ "public class X {												\n"
587
			+ "  void foo() {												\n"
588
			+ "    foo1();													\n"
589
			+ "    @AnAnnotation(name=)										\n"
590
			+ "    class Y {}												\n"
591
			+ "    foo2();													\n"
592
			+ "  }															\n"
593
			+ "}															\n";
594
595
	String expectedDietUnitToString = 
596
		"package a;\n" + 
597
		"public class X {\n" + 
598
		"  public X() {\n" + 
599
		"  }\n" + 
600
		"  void foo() {\n" + 
601
		"  }\n" + 
602
		"}\n";
603
			
604
	String expectedDietWithStatementRecoveryUnitToString =
605
		expectedDietUnitToString;
606
	
607
	String expectedDietPlusBodyUnitToString = 
608
		"package a;\n" + 
609
		"public class X {\n" + 
610
		"  public X() {\n" + 
611
		"    super();\n" + 
612
		"  }\n" + 
613
		"  void foo() {\n" + 
614
		"    @AnAnnotation class Y {\n" + 
615
		"      Y() {\n" + 
616
		"        super();\n" + 
617
		"      }\n" + 
618
		"    }\n" + 
619
		"  }\n" + 
620
		"}\n";
621
622
	String expectedDietPlusBodyWithStatementRecoveryUnitToString = 
623
		"package a;\n" + 
624
		"public class X {\n" + 
625
		"  public X() {\n" + 
626
		"    super();\n" + 
627
		"  }\n" + 
628
		"  void foo() {\n" + 
629
		"    foo1();\n" + 
630
		"    @AnAnnotation class Y {\n" + 
631
		"      Y() {\n" + 
632
		"        super();\n" + 
633
		"      }\n" + 
634
		"    }\n" + 
635
		"    foo2();\n" + 
636
		"  }\n" + 
637
		"}\n";
638
			
639
	String expectedFullUnitToString =
640
		expectedDietUnitToString;
641
	
642
	String expectedFullWithStatementRecoveryUnitToString =
643
		expectedFullUnitToString;
644
	
645
	String testName = "<test>";
646
	checkParse(
647
		s.toCharArray(),
648
		expectedDietUnitToString,
649
		expectedDietWithStatementRecoveryUnitToString,
650
		expectedDietPlusBodyUnitToString,
651
		expectedDietPlusBodyWithStatementRecoveryUnitToString,
652
		expectedFullUnitToString,
653
		expectedFullWithStatementRecoveryUnitToString,
654
		testName);
655
}
656
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=130778
657
public void test0007() {
658
659
	String s = 
660
		"package a;															\n"
661
			+ "public class X {												\n"
662
			+ "  void foo() {												\n"
663
			+ "    foo1();													\n"
664
			+ "    final @AnAnnotation(name) #								\n"
665
			+ "    class Y {}												\n"
666
			+ "    foo2();													\n"
667
			+ "  }															\n"
668
			+ "}															\n";
669
670
	String expectedDietUnitToString = 
671
		"package a;\n" + 
672
		"public class X {\n" + 
673
		"  public X() {\n" + 
674
		"  }\n" + 
675
		"  void foo() {\n" + 
676
		"  }\n" + 
677
		"}\n";
678
			
679
	String expectedDietWithStatementRecoveryUnitToString =
680
		expectedDietUnitToString;
681
	
682
	String expectedDietPlusBodyUnitToString = 
683
		"package a;\n" + 
684
		"public class X {\n" + 
685
		"  public X() {\n" + 
686
		"    super();\n" + 
687
		"  }\n" + 
688
		"  void foo() {\n" + 
689
		"    final @AnAnnotation(name) class Y {\n" + 
690
		"      Y() {\n" + 
691
		"        super();\n" + 
692
		"      }\n" + 
693
		"    }\n" + 
694
		"  }\n" + 
695
		"}\n";
696
697
	String expectedDietPlusBodyWithStatementRecoveryUnitToString = 
698
		"package a;\n" + 
699
		"public class X {\n" + 
700
		"  public X() {\n" + 
701
		"    super();\n" + 
702
		"  }\n" + 
703
		"  void foo() {\n" + 
704
		"    foo1();\n" + 
705
		"    final @AnAnnotation(name) class Y {\n" + 
706
		"      Y() {\n" + 
707
		"        super();\n" + 
708
		"      }\n" + 
709
		"    }\n" + 
710
		"    foo2();\n" + 
711
		"  }\n" + 
712
		"}\n";
713
	
714
	String expectedFullUnitToString =
715
		expectedDietUnitToString;
716
	
717
	String expectedFullWithStatementRecoveryUnitToString =
718
		expectedFullUnitToString;
719
	
720
	String testName = "<test>";
721
	checkParse(
722
		s.toCharArray(),
723
		expectedDietUnitToString,
724
		expectedDietWithStatementRecoveryUnitToString,
725
		expectedDietPlusBodyUnitToString,
726
		expectedDietPlusBodyWithStatementRecoveryUnitToString,
727
		expectedFullUnitToString,
728
		expectedFullWithStatementRecoveryUnitToString,
729
		testName);
730
}
382
}
731
}
(-)src/org/eclipse/jdt/core/tests/compiler/parser/AnnotationDietRecoveryTest.java (-9 / +1010 lines)
Lines 13-18 Link Here
13
import java.util.Locale;
13
import java.util.Locale;
14
import java.util.Map;
14
import java.util.Map;
15
15
16
import junit.framework.Test;
17
16
import org.eclipse.jdt.core.tests.util.AbstractCompilerTest;
18
import org.eclipse.jdt.core.tests.util.AbstractCompilerTest;
17
import org.eclipse.jdt.core.tests.util.Util;
19
import org.eclipse.jdt.core.tests.util.Util;
18
import org.eclipse.jdt.internal.codeassist.complete.CompletionParser;
20
import org.eclipse.jdt.internal.codeassist.complete.CompletionParser;
Lines 32-44 Link Here
32
// Tests must be updated with annotation recovery improvment
34
// Tests must be updated with annotation recovery improvment
33
// TODO(david) update test suite
35
// TODO(david) update test suite
34
public class AnnotationDietRecoveryTest extends AbstractCompilerTest {
36
public class AnnotationDietRecoveryTest extends AbstractCompilerTest {
37
	private static final boolean CHECK_ALL_PARSE = true;
35
	public static boolean optimizeStringLiterals = false;
38
	public static boolean optimizeStringLiterals = false;
36
	public static long sourceLevel = ClassFileConstants.JDK1_3; //$NON-NLS-1$
39
	public static long sourceLevel = ClassFileConstants.JDK1_3; //$NON-NLS-1$
37
	
40
	
38
public AnnotationDietRecoveryTest(String testName){
41
public AnnotationDietRecoveryTest(String testName){
39
	super(testName);
42
	super(testName);
40
}
43
}
41
44
public static Test suite() {
45
	return buildMinimalComplianceTestSuite(testClass(), F_1_5);
46
}
47
public static Class testClass() {  
48
	return AnnotationDietRecoveryTest.class;
49
}
42
/*
50
/*
43
 * Toggle compiler in mode -1.5
51
 * Toggle compiler in mode -1.5
44
 */
52
 */
Lines 59-65 Link Here
59
	String testName) {
67
	String testName) {
60
68
61
	/* using regular parser in DIET mode */
69
	/* using regular parser in DIET mode */
62
	{
70
	if (CHECK_ALL_PARSE){
63
		Parser parser = 
71
		Parser parser = 
64
			new Parser(
72
			new Parser(
65
				new ProblemReporter(
73
				new ProblemReporter(
Lines 119-125 Link Here
119
			computedUnitToString);
127
			computedUnitToString);
120
	}
128
	}
121
	/* using regular parser in FULL mode */
129
	/* using regular parser in FULL mode */
122
	{
130
	if (CHECK_ALL_PARSE){
123
		Parser parser = 
131
		Parser parser = 
124
			new Parser(
132
			new Parser(
125
				new ProblemReporter(
133
				new ProblemReporter(
Lines 143-149 Link Here
143
151
144
	}
152
	}
145
	/* using source element parser in DIET mode */
153
	/* using source element parser in DIET mode */
146
	{
154
	if (CHECK_ALL_PARSE){
147
		SourceElementParser parser =
155
		SourceElementParser parser =
148
			new SourceElementParser(
156
			new SourceElementParser(
149
				new TestSourceElementRequestor(),
157
				new TestSourceElementRequestor(),
Lines 166-172 Link Here
166
			computedUnitToString);
174
			computedUnitToString);
167
	}
175
	}
168
	/* using source element parser in FULL mode */
176
	/* using source element parser in FULL mode */
169
	{
177
	if (CHECK_ALL_PARSE){
170
		SourceElementParser parser =
178
		SourceElementParser parser =
171
			new SourceElementParser(
179
			new SourceElementParser(
172
				new TestSourceElementRequestor(),
180
				new TestSourceElementRequestor(),
Lines 189-195 Link Here
189
			computedUnitToString);
197
			computedUnitToString);
190
	}	
198
	}	
191
	/* using completion parser in DIET mode */
199
	/* using completion parser in DIET mode */
192
	{
200
	if (CHECK_ALL_PARSE){
193
		CompilerOptions options = new CompilerOptions(getCompilerOptions());
201
		CompilerOptions options = new CompilerOptions(getCompilerOptions());
194
		CompletionParser parser =
202
		CompletionParser parser =
195
			new CompletionParser(
203
			new CompletionParser(
Lines 508-514 Link Here
508
	String expectedDietUnitToString = 
516
	String expectedDietUnitToString = 
509
		"package a;\n" + 
517
		"package a;\n" + 
510
		"public class X {\n" + 
518
		"public class X {\n" + 
511
		"  List<Test> l;\n" + 
519
		"  @SuppressWarnings(\"unchecked\") List<Test> l;\n" + 
512
		"  public X() {\n" + 
520
		"  public X() {\n" + 
513
		"  }\n" + 
521
		"  }\n" + 
514
		"}\n";
522
		"}\n";
Lines 516-522 Link Here
516
	String expectedDietPlusBodyUnitToString = 
524
	String expectedDietPlusBodyUnitToString = 
517
		"package a;\n" + 
525
		"package a;\n" + 
518
		"public class X {\n" + 
526
		"public class X {\n" + 
519
		"  List<Test> l;\n" + 
527
		"  @SuppressWarnings(\"unchecked\") List<Test> l;\n" + 
520
		"  public X() {\n" + 
528
		"  public X() {\n" + 
521
		"    super();\n" + 
529
		"    super();\n" + 
522
		"  }\n" + 
530
		"  }\n" + 
Lines 525-531 Link Here
525
	String expectedFullUnitToString = expectedDietUnitToString;
533
	String expectedFullUnitToString = expectedDietUnitToString;
526
	
534
	
527
	String expectedCompletionDietUnitToString = 
535
	String expectedCompletionDietUnitToString = 
528
		expectedDietUnitToString;
536
		"package a;\n" + 
537
		"public class X {\n" + 
538
		"  List<Test> l;\n" + 
539
		"  public X() {\n" + 
540
		"  }\n" + 
541
		"}\n";
529
	
542
	
530
	String testName = "<generic type recovery>";
543
	String testName = "<generic type recovery>";
531
	checkParse(
544
	checkParse(
Lines 671-674 Link Here
671
		expectedCompletionDietUnitToString,	
684
		expectedCompletionDietUnitToString,	
672
		testName);
685
		testName);
673
}
686
}
687
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=130778
688
public void test0013() {
689
690
	String s = 
691
		"package a;										\n"
692
			+ "@AnAnnotation(name)						\n"
693
			+ "@AnAnnotation2(name2)					\n"
694
			+ "public class X {							\n"
695
			+ "}										\n"; 	
696
697
	String expectedDietUnitToString = 
698
		"package a;\n" + 
699
		"public @AnAnnotation(name) @AnAnnotation2(name2) class X {\n" + 
700
		"  public X() {\n" + 
701
		"  }\n" + 
702
		"}\n";
703
	
704
	
705
	String expectedDietPlusBodyUnitToString = 
706
		"package a;\n" + 
707
		"public @AnAnnotation(name) @AnAnnotation2(name2) class X {\n" + 
708
		"  public X() {\n" + 
709
		"    super();\n" + 
710
		"  }\n" + 
711
		"}\n";
712
713
714
	String expectedFullUnitToString = 
715
		expectedDietPlusBodyUnitToString;
716
	
717
	String expectedCompletionDietUnitToString = 
718
		expectedDietUnitToString;
719
	
720
	String testName = "<generic type recovery>";
721
	checkParse(
722
		s.toCharArray(),
723
		expectedDietUnitToString,
724
		expectedDietPlusBodyUnitToString,
725
		expectedFullUnitToString,
726
		expectedCompletionDietUnitToString,	
727
		testName);
728
}
729
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=130778
730
public void test0014() {
731
732
	String s = 
733
		"package a;										\n"
734
			+ "#										\n"
735
			+ "@AnAnnotation(name)						\n"
736
			+ "@AnAnnotation2(name2)					\n"
737
			+ "public class X {							\n"
738
			+ "}										\n"; 	
739
740
	String expectedDietUnitToString = 
741
		"package a;\n" + 
742
		"public @AnAnnotation(name) @AnAnnotation2(name2) class X {\n" + 
743
		"  public X() {\n" + 
744
		"  }\n" + 
745
		"}\n";
746
	
747
	
748
	String expectedDietPlusBodyUnitToString = 
749
		"package a;\n" + 
750
		"public @AnAnnotation(name) @AnAnnotation2(name2) class X {\n" + 
751
		"  public X() {\n" + 
752
		"    super();\n" + 
753
		"  }\n" + 
754
		"}\n";
755
756
757
	String expectedFullUnitToString = 
758
		expectedDietUnitToString;
759
	
760
	String expectedCompletionDietUnitToString = 
761
		expectedDietUnitToString;
762
	
763
	String testName = "<generic type recovery>";
764
	checkParse(
765
		s.toCharArray(),
766
		expectedDietUnitToString,
767
		expectedDietPlusBodyUnitToString,
768
		expectedFullUnitToString,
769
		expectedCompletionDietUnitToString,	
770
		testName);
771
}
772
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=130778
773
public void test0015() {
774
775
	String s = 
776
		"package a;										\n"
777
			+ "@AnAnnotation(name)						\n"
778
			+ "@AnAnnotation2(name2)					\n"
779
			+ "public class X {							\n"
780
			+ "#										\n"
781
			+ "}										\n"; 	
782
783
	String expectedDietUnitToString = 
784
		"package a;\n" + 
785
		"public @AnAnnotation(name) @AnAnnotation2(name2) class X {\n" + 
786
		"  public X() {\n" + 
787
		"  }\n" + 
788
		"}\n";
789
	
790
	
791
	String expectedDietPlusBodyUnitToString = 
792
		"package a;\n" + 
793
		"public @AnAnnotation(name) @AnAnnotation2(name2) class X {\n" + 
794
		"  public X() {\n" + 
795
		"    super();\n" + 
796
		"  }\n" + 
797
		"}\n";
798
799
800
	String expectedFullUnitToString = 
801
		expectedDietUnitToString;
802
	
803
	String expectedCompletionDietUnitToString = 
804
		expectedDietUnitToString;
805
	
806
	String testName = "<generic type recovery>";
807
	checkParse(
808
		s.toCharArray(),
809
		expectedDietUnitToString,
810
		expectedDietPlusBodyUnitToString,
811
		expectedFullUnitToString,
812
		expectedCompletionDietUnitToString,	
813
		testName);
814
}
815
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=130778
816
public void test0016() {
817
818
	String s = 
819
		"package a;										\n"
820
			+ "@AnAnnotation(name)						\n"
821
			+ "@AnAnnotation2(name2)					\n"
822
			+ "#										\n"
823
			+ "public class X {							\n"
824
			+ "}										\n"; 	
825
826
	String expectedDietUnitToString = 
827
		"package a;\n" + 
828
		"public @AnAnnotation(name) @AnAnnotation2(name2) class X {\n" + 
829
		"  public X() {\n" + 
830
		"  }\n" + 
831
		"}\n";
832
	
833
	
834
	String expectedDietPlusBodyUnitToString = 
835
		"package a;\n" + 
836
		"public @AnAnnotation(name) @AnAnnotation2(name2) class X {\n" + 
837
		"  public X() {\n" + 
838
		"    super();\n" + 
839
		"  }\n" + 
840
		"}\n";
841
842
843
	String expectedFullUnitToString = 
844
		expectedDietUnitToString;
845
	
846
	String expectedCompletionDietUnitToString = 
847
		"package a;\n" + 
848
		"public class X {\n" + 
849
		"  public X() {\n" + 
850
		"  }\n" + 
851
		"}\n";
852
	
853
	String testName = "<generic type recovery>";
854
	checkParse(
855
		s.toCharArray(),
856
		expectedDietUnitToString,
857
		expectedDietPlusBodyUnitToString,
858
		expectedFullUnitToString,
859
		expectedCompletionDietUnitToString,	
860
		testName);
861
}
862
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=130778
863
public void test0017() {
864
865
	String s = 
866
		"package a;										\n"
867
			+ "@AnAnnotation(name)						\n"
868
			+ "#										\n"
869
			+ "@AnAnnotation2(name2)					\n"
870
			+ "public class X {							\n"
871
			+ "}										\n"; 	
872
873
	String expectedDietUnitToString = 
874
		"package a;\n" + 
875
		"public @AnAnnotation(name) @AnAnnotation2(name2) class X {\n" + 
876
		"  public X() {\n" + 
877
		"  }\n" + 
878
		"}\n";
879
	
880
	
881
	String expectedDietPlusBodyUnitToString = 
882
		"package a;\n" + 
883
		"public @AnAnnotation(name) @AnAnnotation2(name2) class X {\n" + 
884
		"  public X() {\n" + 
885
		"    super();\n" + 
886
		"  }\n" + 
887
		"}\n";
888
889
890
	String expectedFullUnitToString = 
891
		expectedDietUnitToString;
892
	
893
	String expectedCompletionDietUnitToString = 
894
		"package a;\n" + 
895
		"public @AnAnnotation2(name2) class X {\n" + 
896
		"  public X() {\n" + 
897
		"  }\n" + 
898
		"}\n";
899
	
900
	String testName = "<generic type recovery>";
901
	checkParse(
902
		s.toCharArray(),
903
		expectedDietUnitToString,
904
		expectedDietPlusBodyUnitToString,
905
		expectedFullUnitToString,
906
		expectedCompletionDietUnitToString,	
907
		testName);
908
}
909
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=130778
910
public void test0018() {
911
912
	String s = 
913
		"package a;										\n"
914
			+ "@AnAnnotation(name=)						\n"
915
			+ "@AnAnnotation2(name2)					\n"
916
			+ "public class X {							\n"
917
			+ "}										\n"; 	
918
919
	String expectedDietUnitToString = 
920
		"package a;\n" + 
921
		"public @AnAnnotation @AnAnnotation2(name2) class X {\n" + 
922
		"  public X() {\n" + 
923
		"  }\n" + 
924
		"}\n";
925
	
926
	
927
	String expectedDietPlusBodyUnitToString = 
928
		"package a;\n" + 
929
		"public @AnAnnotation @AnAnnotation2(name2) class X {\n" + 
930
		"  public X() {\n" + 
931
		"    super();\n" + 
932
		"  }\n" + 
933
		"}\n";
934
935
936
	String expectedFullUnitToString = 
937
		expectedDietUnitToString;
938
	
939
	String expectedCompletionDietUnitToString = 
940
		"package a;\n" + 
941
		"public @AnAnnotation2(name2) class X {\n" + 
942
		"  public X() {\n" + 
943
		"  }\n" + 
944
		"}\n";
945
	
946
	String testName = "<generic type recovery>";
947
	checkParse(
948
		s.toCharArray(),
949
		expectedDietUnitToString,
950
		expectedDietPlusBodyUnitToString,
951
		expectedFullUnitToString,
952
		expectedCompletionDietUnitToString,	
953
		testName);
954
}
955
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=130778
956
public void test0019() {
957
958
	String s = 
959
		"package a;										\n"
960
			+ "@AnAnnotation(name)						\n"
961
			+ "@AnAnnotation2(name2=)					\n"
962
			+ "public class X {							\n"
963
			+ "}										\n"; 	
964
965
	String expectedDietUnitToString = 
966
		"package a;\n" + 
967
		"public @AnAnnotation(name) @AnAnnotation2 class X {\n" + 
968
		"  public X() {\n" + 
969
		"  }\n" + 
970
		"}\n";
971
	
972
	String expectedDietPlusBodyUnitToString = 
973
		"package a;\n" + 
974
		"public @AnAnnotation(name) @AnAnnotation2 class X {\n" + 
975
		"  public X() {\n" + 
976
		"    super();\n" + 
977
		"  }\n" + 
978
		"}\n";
979
980
981
	String expectedFullUnitToString = 
982
		expectedDietUnitToString;
983
	
984
	String expectedCompletionDietUnitToString = 
985
		"package a;\n" + 
986
		"public class X {\n" + 
987
		"  public X() {\n" + 
988
		"  }\n" + 
989
		"}\n";
990
	
991
	String testName = "<generic type recovery>";
992
	checkParse(
993
		s.toCharArray(),
994
		expectedDietUnitToString,
995
		expectedDietPlusBodyUnitToString,
996
		expectedFullUnitToString,
997
		expectedCompletionDietUnitToString,	
998
		testName);
999
}
1000
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=130778
1001
public void test0020() {
1002
1003
	String s = 
1004
		"package a;										\n"
1005
			+ "public class X {							\n"
1006
			+ "  @AnAnnotation(name) #					\n"
1007
			+ "  int field;								\n"
1008
			+ "}										\n"; 	
1009
1010
	String expectedDietUnitToString = 
1011
		"package a;\n" + 
1012
		"public class X {\n" + 
1013
		"  @AnAnnotation(name) int field;\n" + 
1014
		"  public X() {\n" + 
1015
		"  }\n" + 
1016
		"}\n";
1017
	
1018
	String expectedDietPlusBodyUnitToString = 
1019
		"package a;\n" + 
1020
		"public class X {\n" + 
1021
		"  @AnAnnotation(name) int field;\n" + 
1022
		"  public X() {\n" + 
1023
		"    super();\n" + 
1024
		"  }\n" + 
1025
		"}\n";
1026
1027
1028
	String expectedFullUnitToString = 
1029
		expectedDietUnitToString;
1030
	
1031
	String expectedCompletionDietUnitToString = 
1032
		"package a;\n" + 
1033
		"public class X {\n" + 
1034
		"  int field;\n" + 
1035
		"  public X() {\n" + 
1036
		"  }\n" + 
1037
		"}\n";
1038
	
1039
	String testName = "<generic type recovery>";
1040
	checkParse(
1041
		s.toCharArray(),
1042
		expectedDietUnitToString,
1043
		expectedDietPlusBodyUnitToString,
1044
		expectedFullUnitToString,
1045
		expectedCompletionDietUnitToString,	
1046
		testName);
1047
}
1048
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=130778
1049
public void test0021() {
1050
1051
	String s = 
1052
		"package a;										\n"
1053
			+ "public class X {							\n"
1054
			+ "  @AnAnnotation(name=)					\n"
1055
			+ "  int field;								\n"
1056
			+ "}										\n"; 	
1057
1058
	String expectedDietUnitToString = 
1059
		"package a;\n" + 
1060
		"public class X {\n" + 
1061
		"  @AnAnnotation int field;\n" + 
1062
		"  public X() {\n" + 
1063
		"  }\n" + 
1064
		"}\n";
1065
	
1066
	String expectedDietPlusBodyUnitToString = 
1067
		"package a;\n" + 
1068
		"public class X {\n" + 
1069
		"  @AnAnnotation int field;\n" + 
1070
		"  public X() {\n" + 
1071
		"    super();\n" + 
1072
		"  }\n" + 
1073
		"}\n";
1074
1075
1076
	String expectedFullUnitToString = 
1077
		expectedDietUnitToString;
1078
	
1079
	String expectedCompletionDietUnitToString = 
1080
		"package a;\n" + 
1081
		"public class X {\n" + 
1082
		"  int field;\n" + 
1083
		"  public X() {\n" + 
1084
		"  }\n" + 
1085
		"}\n";
1086
	
1087
	String testName = "<generic type recovery>";
1088
	checkParse(
1089
		s.toCharArray(),
1090
		expectedDietUnitToString,
1091
		expectedDietPlusBodyUnitToString,
1092
		expectedFullUnitToString,
1093
		expectedCompletionDietUnitToString,	
1094
		testName);
1095
}
1096
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=130778
1097
public void test0022() {
1098
1099
	String s = 
1100
		"package a;										\n"
1101
			+ "public class X {							\n"
1102
			+ "  @AnAnnotation(name) #					\n"
1103
			+ "  void foo() {}							\n"
1104
			+ "}										\n"; 	
1105
1106
	String expectedDietUnitToString = 
1107
		"package a;\n" + 
1108
		"public class X {\n" + 
1109
		"  public X() {\n" + 
1110
		"  }\n" + 
1111
		"  @AnAnnotation(name) void foo() {\n" + 
1112
		"  }\n" + 
1113
		"}\n";
1114
			
1115
	String expectedDietPlusBodyUnitToString = 
1116
		"package a;\n" + 
1117
		"public class X {\n" + 
1118
		"  public X() {\n" + 
1119
		"    super();\n" + 
1120
		"  }\n" + 
1121
		"  @AnAnnotation(name) void foo() {\n" + 
1122
		"  }\n" + 
1123
		"}\n";
1124
1125
1126
	String expectedFullUnitToString = 
1127
		expectedDietUnitToString;
1128
	
1129
	String expectedCompletionDietUnitToString = 
1130
		"package a;\n" + 
1131
		"public class X {\n" + 
1132
		"  public X() {\n" + 
1133
		"  }\n" + 
1134
		"  void foo() {\n" + 
1135
		"  }\n" + 
1136
		"}\n";
1137
	
1138
	String testName = "<generic type recovery>";
1139
	checkParse(
1140
		s.toCharArray(),
1141
		expectedDietUnitToString,
1142
		expectedDietPlusBodyUnitToString,
1143
		expectedFullUnitToString,
1144
		expectedCompletionDietUnitToString,	
1145
		testName);
1146
}
1147
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=130778
1148
public void test0023() {
1149
1150
	String s = 
1151
		"package a;										\n"
1152
			+ "public class X {							\n"
1153
			+ "  @AnAnnotation(name=)					\n"
1154
			+ "  void foo() {}							\n"
1155
			+ "}										\n"; 	
1156
1157
	String expectedDietUnitToString = 
1158
		"package a;\n" + 
1159
		"public class X {\n" + 
1160
		"  public X() {\n" + 
1161
		"  }\n" + 
1162
		"  @AnAnnotation void foo() {\n" + 
1163
		"  }\n" + 
1164
		"}\n";
1165
	
1166
	String expectedDietPlusBodyUnitToString = 
1167
		"package a;\n" + 
1168
		"public class X {\n" + 
1169
		"  public X() {\n" + 
1170
		"    super();\n" + 
1171
		"  }\n" + 
1172
		"  @AnAnnotation void foo() {\n" + 
1173
		"  }\n" + 
1174
		"}\n";
1175
1176
	String expectedFullUnitToString = 
1177
		expectedDietUnitToString;
1178
	
1179
	String expectedCompletionDietUnitToString = 
1180
		"package a;\n" + 
1181
		"public class X {\n" + 
1182
		"  public X() {\n" + 
1183
		"  }\n" + 
1184
		"  void foo() {\n" + 
1185
		"  }\n" + 
1186
		"}\n";
1187
	
1188
	String testName = "<generic type recovery>";
1189
	checkParse(
1190
		s.toCharArray(),
1191
		expectedDietUnitToString,
1192
		expectedDietPlusBodyUnitToString,
1193
		expectedFullUnitToString,
1194
		expectedCompletionDietUnitToString,	
1195
		testName);
1196
}
1197
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=130778
1198
public void test0024() {
1199
1200
	String s = 
1201
		"package a;															\n"
1202
			+ "public class X {												\n"
1203
			+ "  void foo(int param1, @AnAnnotation(name) # int param2) {}	\n"
1204
			+ "}															\n"; 	
1205
1206
	String expectedDietUnitToString = 
1207
		"package a;\n" + 
1208
		"public class X {\n" + 
1209
		"  public X() {\n" + 
1210
		"  }\n" + 
1211
		"  void foo(int param1) {\n" + 
1212
		"  }\n" + 
1213
		"}\n";
1214
			
1215
	String expectedDietPlusBodyUnitToString = 
1216
		"package a;\n" + 
1217
		"public class X {\n" + 
1218
		"  public X() {\n" + 
1219
		"    super();\n" + 
1220
		"  }\n" + 
1221
		"  void foo(int param1) {\n" + 
1222
		"  }\n" + 
1223
		"}\n";
1224
1225
1226
	String expectedFullUnitToString = 
1227
		expectedDietUnitToString;
1228
	
1229
	String expectedCompletionDietUnitToString = 
1230
		expectedDietUnitToString;
1231
	
1232
	String testName = "<generic type recovery>";
1233
	checkParse(
1234
		s.toCharArray(),
1235
		expectedDietUnitToString,
1236
		expectedDietPlusBodyUnitToString,
1237
		expectedFullUnitToString,
1238
		expectedCompletionDietUnitToString,	
1239
		testName);
1240
}
1241
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=130778
1242
public void test0025() {
1243
1244
	String s = 
1245
		"package a;															\n"
1246
			+ "public class X {												\n"
1247
			+ "  void foo(int param1, @AnAnnotation(name=) int param2) {}	\n"
1248
			+ "}															\n"; 	
1249
1250
	String expectedDietUnitToString = 
1251
		"package a;\n" + 
1252
		"public class X {\n" + 
1253
		"  public X() {\n" + 
1254
		"  }\n" + 
1255
		"  void foo(int param1) {\n" + 
1256
		"  }\n" + 
1257
		"}\n";
1258
	
1259
	String expectedDietPlusBodyUnitToString = 
1260
		"package a;\n" + 
1261
		"public class X {\n" + 
1262
		"  public X() {\n" + 
1263
		"    super();\n" + 
1264
		"  }\n" + 
1265
		"  void foo(int param1) {\n" + 
1266
		"  }\n" + 
1267
		"}\n";
1268
1269
	String expectedFullUnitToString = 
1270
		expectedDietUnitToString;
1271
	
1272
	String expectedCompletionDietUnitToString = 
1273
		expectedDietUnitToString;
1274
	
1275
	String testName = "<generic type recovery>";
1276
	checkParse(
1277
		s.toCharArray(),
1278
		expectedDietUnitToString,
1279
		expectedDietPlusBodyUnitToString,
1280
		expectedFullUnitToString,
1281
		expectedCompletionDietUnitToString,	
1282
		testName);
1283
}
1284
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=130778
1285
public void test0026() {
1286
1287
	String s = 
1288
		"package a;															\n"
1289
			+ "public class X {												\n"
1290
			+ "  void foo(int param1, @AnAnnotation(@AnAnnotation1(name1=\"a\", name2=) int param2) {}	\n"
1291
			+ "}															\n"; 	
1292
1293
	String expectedDietUnitToString = 
1294
		"package a;\n" + 
1295
		"public class X {\n" + 
1296
		"  public X() {\n" + 
1297
		"  }\n" + 
1298
		"  void foo(int param1) {\n" + 
1299
		"  }\n" + 
1300
		"}\n";
1301
	
1302
	String expectedDietPlusBodyUnitToString = 
1303
		"package a;\n" + 
1304
		"public class X {\n" + 
1305
		"  public X() {\n" + 
1306
		"    super();\n" + 
1307
		"  }\n" + 
1308
		"  void foo(int param1) {\n" + 
1309
		"  }\n" + 
1310
		"}\n";
1311
1312
	String expectedFullUnitToString = 
1313
		expectedDietUnitToString;
1314
	
1315
	String expectedCompletionDietUnitToString = 
1316
		expectedDietUnitToString;
1317
	
1318
	String testName = "<generic type recovery>";
1319
	checkParse(
1320
		s.toCharArray(),
1321
		expectedDietUnitToString,
1322
		expectedDietPlusBodyUnitToString,
1323
		expectedFullUnitToString,
1324
		expectedCompletionDietUnitToString,	
1325
		testName);
1326
}
1327
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=130778
1328
public void test0027() {
1329
1330
	String s = 
1331
		"package a;																					\n"
1332
			+ "@AnAnnotation1(name1=\"a\", #)														\n"
1333
			+ "public class X {																		\n"
1334
			+ "}																					\n"; 	
1335
1336
	String expectedDietUnitToString = 
1337
		"package a;\n" + 
1338
		"public @AnAnnotation1(name1 = \"a\") class X {\n" + 
1339
		"  public X() {\n" + 
1340
		"  }\n" + 
1341
		"}\n";
1342
	
1343
	String expectedDietPlusBodyUnitToString = 
1344
		"package a;\n" + 
1345
		"public @AnAnnotation1(name1 = \"a\") class X {\n" + 
1346
		"  public X() {\n" + 
1347
		"    super();\n" + 
1348
		"  }\n" + 
1349
		"}\n";
1350
1351
	String expectedFullUnitToString = 
1352
		expectedDietUnitToString;
1353
	
1354
	String expectedCompletionDietUnitToString = 
1355
		"package a;\n" + 
1356
		"public class X {\n" + 
1357
		"  public X() {\n" + 
1358
		"  }\n" + 
1359
		"}\n";
1360
	
1361
	String testName = "<generic type recovery>";
1362
	checkParse(
1363
		s.toCharArray(),
1364
		expectedDietUnitToString,
1365
		expectedDietPlusBodyUnitToString,
1366
		expectedFullUnitToString,
1367
		expectedCompletionDietUnitToString,	
1368
		testName);
1369
}
1370
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=130778
1371
public void test0028() {
1372
1373
	String s = 
1374
		"package a;																					\n"
1375
			+ "@AnAnnotation1(name1=\"a\", name2=@AnAnnotation2(name3=\"b\"), #)					\n"
1376
			+ "public class X {																		\n"
1377
			+ "}																					\n"; 	
1378
1379
	String expectedDietUnitToString = 
1380
		"package a;\n" + 
1381
		"public @AnAnnotation1(name1 = \"a\",name2 = @AnAnnotation2(name3 = \"b\")) class X {\n" + 
1382
		"  public X() {\n" + 
1383
		"  }\n" + 
1384
		"}\n";
1385
	
1386
	String expectedDietPlusBodyUnitToString = 
1387
		"package a;\n" + 
1388
		"public @AnAnnotation1(name1 = \"a\",name2 = @AnAnnotation2(name3 = \"b\")) class X {\n" + 
1389
		"  public X() {\n" + 
1390
		"    super();\n" + 
1391
		"  }\n" + 
1392
		"}\n";
1393
1394
	String expectedFullUnitToString = 
1395
		expectedDietUnitToString;
1396
	
1397
	String expectedCompletionDietUnitToString = 
1398
		"package a;\n" + 
1399
		"public class X {\n" + 
1400
		"  public X() {\n" + 
1401
		"  }\n" + 
1402
		"}\n";
1403
	
1404
	String testName = "<generic type recovery>";
1405
	checkParse(
1406
		s.toCharArray(),
1407
		expectedDietUnitToString,
1408
		expectedDietPlusBodyUnitToString,
1409
		expectedFullUnitToString,
1410
		expectedCompletionDietUnitToString,	
1411
		testName);
1412
}
1413
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=130778
1414
public void test0030() {
1415
1416
	String s = 
1417
		"package a;																					\n"
1418
			+ "@AnAnnotation1(\"a\"#)																\n"
1419
			+ "public class X {																		\n"
1420
			+ "}																					\n"; 	
1421
1422
	String expectedDietUnitToString = 
1423
		"package a;\n" + 
1424
		"public @AnAnnotation1(\"a\") class X {\n" + 
1425
		"  public X() {\n" + 
1426
		"  }\n" + 
1427
		"}\n";
1428
	
1429
	String expectedDietPlusBodyUnitToString = 
1430
		"package a;\n" + 
1431
		"public @AnAnnotation1(\"a\") class X {\n" + 
1432
		"  public X() {\n" + 
1433
		"    super();\n" + 
1434
		"  }\n" + 
1435
		"}\n";
1436
1437
	String expectedFullUnitToString = 
1438
		expectedDietUnitToString;
1439
	
1440
	String expectedCompletionDietUnitToString = 
1441
		"package a;\n" + 
1442
		"public class X {\n" + 
1443
		"  public X() {\n" + 
1444
		"  }\n" + 
1445
		"}\n";
1446
	
1447
	String testName = "<generic type recovery>";
1448
	checkParse(
1449
		s.toCharArray(),
1450
		expectedDietUnitToString,
1451
		expectedDietPlusBodyUnitToString,
1452
		expectedFullUnitToString,
1453
		expectedCompletionDietUnitToString,	
1454
		testName);
1455
}
1456
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=130778
1457
public void test0031() {
1458
1459
	String s = 
1460
		"package a;																					\n"
1461
			+ "@AnAnnotation1(\"a\", name2=@AnAnnotation2(name3=\"b\"), #)							\n"
1462
			+ "public class X {																		\n"
1463
			+ "}																					\n"; 	
1464
1465
	String expectedDietUnitToString = 
1466
		"package a;\n" + 
1467
		"public @AnAnnotation1(\"a\") @AnAnnotation2(name3 = \"b\") class X {\n" + 
1468
		"  public X() {\n" + 
1469
		"  }\n" + 
1470
		"}\n";
1471
	
1472
	String expectedDietPlusBodyUnitToString = 
1473
		"package a;\n" + 
1474
		"public @AnAnnotation1(\"a\") @AnAnnotation2(name3 = \"b\") class X {\n" + 
1475
		"  public X() {\n" + 
1476
		"    super();\n" + 
1477
		"  }\n" + 
1478
		"}\n";
1479
1480
	String expectedFullUnitToString = 
1481
		expectedDietUnitToString;
1482
	
1483
	String expectedCompletionDietUnitToString = 
1484
		"package a;\n" + 
1485
		"public class X {\n" + 
1486
		"  public X() {\n" + 
1487
		"  }\n" + 
1488
		"}\n";
1489
	
1490
	String testName = "<generic type recovery>";
1491
	checkParse(
1492
		s.toCharArray(),
1493
		expectedDietUnitToString,
1494
		expectedDietPlusBodyUnitToString,
1495
		expectedFullUnitToString,
1496
		expectedCompletionDietUnitToString,	
1497
		testName);
1498
}
1499
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=130778
1500
public void test0032() {
1501
1502
	String s = 
1503
		"package a;																					\n"
1504
			+ "@AnAnnotation1(\"a\", name2=@AnAnnotation2(name3=\"b\"))								\n"
1505
			+ "public class X {																		\n"
1506
			+ "}																					\n"; 	
1507
1508
	String expectedDietUnitToString = 
1509
		"package a;\n" + 
1510
		"public @AnAnnotation1(\"a\") @AnAnnotation2(name3 = \"b\") class X {\n" + 
1511
		"  public X() {\n" + 
1512
		"  }\n" + 
1513
		"}\n";
1514
	
1515
	String expectedDietPlusBodyUnitToString = 
1516
		"package a;\n" + 
1517
		"public @AnAnnotation1(\"a\") @AnAnnotation2(name3 = \"b\") class X {\n" + 
1518
		"  public X() {\n" + 
1519
		"    super();\n" + 
1520
		"  }\n" + 
1521
		"}\n";
1522
1523
	String expectedFullUnitToString = 
1524
		expectedDietUnitToString;
1525
	
1526
	String expectedCompletionDietUnitToString = 
1527
		"package a;\n" + 
1528
		"public class X {\n" + 
1529
		"  public X() {\n" + 
1530
		"  }\n" + 
1531
		"}\n";
1532
	
1533
	String testName = "<generic type recovery>";
1534
	checkParse(
1535
		s.toCharArray(),
1536
		expectedDietUnitToString,
1537
		expectedDietPlusBodyUnitToString,
1538
		expectedFullUnitToString,
1539
		expectedCompletionDietUnitToString,	
1540
		testName);
1541
}
1542
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=130778
1543
public void test0033() {
1544
1545
	String s = 
1546
		"package a;																					\n"
1547
			+ "@AnAnnotation1(name=new Object() {})	#												\n"
1548
			+ "public class X {																		\n"
1549
			+ "}																					\n"; 	
1550
1551
	String expectedDietUnitToString = 
1552
		"package a;\n" + 
1553
		"public @AnAnnotation1(name = new Object() {\n" + 
1554
		"}) class X {\n" + 
1555
		"  public X() {\n" + 
1556
		"  }\n" + 
1557
		"}\n";
1558
	
1559
	String expectedDietPlusBodyUnitToString = 
1560
		"package a;\n" + 
1561
		"public @AnAnnotation1(name = new Object() {\n" + 
1562
		"}) class X {\n" + 
1563
		"  public X() {\n" + 
1564
		"    super();\n" + 
1565
		"  }\n" + 
1566
		"}\n";
1567
1568
	String expectedFullUnitToString = 
1569
		expectedDietUnitToString;
1570
	
1571
	String expectedCompletionDietUnitToString = 
1572
		"package a;\n" + 
1573
		"public class X {\n" + 
1574
		"  public X() {\n" + 
1575
		"  }\n" + 
1576
		"}\n";
1577
	
1578
	String testName = "<generic type recovery>";
1579
	checkParse(
1580
		s.toCharArray(),
1581
		expectedDietUnitToString,
1582
		expectedDietPlusBodyUnitToString,
1583
		expectedFullUnitToString,
1584
		expectedCompletionDietUnitToString,	
1585
		testName);
1586
}
1587
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=130778
1588
public void test0034() {
1589
1590
	String s = 
1591
		"package a;																					\n"
1592
			+ "@AnAnnotation1(name=new Object() {},#)												\n"
1593
			+ "public class X {																		\n"
1594
			+ "}																					\n"; 	
1595
1596
	String expectedDietUnitToString = 
1597
		"package a;\n" + 
1598
		"public @AnAnnotation1(name = new Object() {\n" + 
1599
		"}) class X {\n" + 
1600
		"  public X() {\n" + 
1601
		"  }\n" + 
1602
		"}\n";
1603
	
1604
	String expectedDietPlusBodyUnitToString = 
1605
		"package a;\n" + 
1606
		"public @AnAnnotation1(name = new Object() {\n" + 
1607
		"}) class X {\n" + 
1608
		"  public X() {\n" + 
1609
		"    super();\n" + 
1610
		"  }\n" + 
1611
		"}\n";
1612
1613
	String expectedFullUnitToString = 
1614
		expectedDietUnitToString;
1615
	
1616
	String expectedCompletionDietUnitToString = 
1617
		"package a;\n" + 
1618
		"public class X {\n" + 
1619
		"  public X() {\n" + 
1620
		"  }\n" + 
1621
		"}\n";
1622
	
1623
	String testName = "<generic type recovery>";
1624
	checkParse(
1625
		s.toCharArray(),
1626
		expectedDietUnitToString,
1627
		expectedDietPlusBodyUnitToString,
1628
		expectedFullUnitToString,
1629
		expectedCompletionDietUnitToString,	
1630
		testName);
1631
}
1632
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=130778
1633
public void test0035() {
1634
1635
	String s = 
1636
		"package a;																					\n"
1637
			+ "@AnAnnotation1(name=new Object() {#})												\n"
1638
			+ "public class X {																		\n"
1639
			+ "}																					\n"; 	
1640
1641
	String expectedDietUnitToString = 
1642
		"package a;\n" + 
1643
		"public @AnAnnotation1 class X {\n" + 
1644
		"  public X() {\n" + 
1645
		"  }\n" + 
1646
		"}\n";
1647
	
1648
	String expectedDietPlusBodyUnitToString = 
1649
		"package a;\n" + 
1650
		"public @AnAnnotation1 class X {\n" + 
1651
		"  public X() {\n" + 
1652
		"    super();\n" + 
1653
		"  }\n" + 
1654
		"}\n";
1655
1656
	String expectedFullUnitToString = 
1657
		expectedDietUnitToString;
1658
	
1659
	String expectedCompletionDietUnitToString = 
1660
		"package a;\n" + 
1661
		"public class X {\n" + 
1662
		"  public X() {\n" + 
1663
		"  }\n" + 
1664
		"}\n";
1665
	
1666
	String testName = "<generic type recovery>";
1667
	checkParse(
1668
		s.toCharArray(),
1669
		expectedDietUnitToString,
1670
		expectedDietPlusBodyUnitToString,
1671
		expectedFullUnitToString,
1672
		expectedCompletionDietUnitToString,	
1673
		testName);
1674
}
674
}
1675
}
(-)src/org/eclipse/jdt/core/tests/compiler/regression/Compliance_1_5.java (-1 / +1 lines)
Lines 2636-2642 Link Here
2636
		"5. ERROR in Hello.java (at line 23)\n" + 
2636
		"5. ERROR in Hello.java (at line 23)\n" + 
2637
		"	}\n" + 
2637
		"	}\n" + 
2638
		"	^\n" + 
2638
		"	^\n" + 
2639
		"Syntax error, insert \"}\" to complete MemberValueArrayInitializer\n" + 
2639
		"Syntax error, insert \"}\" to complete MemberValue\n" + 
2640
		"----------\n" + 
2640
		"----------\n" + 
2641
		"6. ERROR in Hello.java (at line 23)\n" + 
2641
		"6. ERROR in Hello.java (at line 23)\n" + 
2642
		"	}\n" + 
2642
		"	}\n" + 
(-)src/org/eclipse/jdt/core/tests/dom/ASTConverterBugsTestJLS3.java (+1000 lines)
Lines 15-20 Link Here
15
import junit.framework.Test;
15
import junit.framework.Test;
16
import junit.framework.TestSuite;
16
import junit.framework.TestSuite;
17
17
18
import org.eclipse.jdt.core.ICompilationUnit;
19
import org.eclipse.jdt.core.JavaModelException;
18
import org.eclipse.jdt.core.dom.AST;
20
import org.eclipse.jdt.core.dom.AST;
19
21
20
public class ASTConverterBugsTestJLS3 extends ASTConverterBugsTest {
22
public class ASTConverterBugsTestJLS3 extends ASTConverterBugsTest {
Lines 33-36 Link Here
33
	return suite;
35
	return suite;
34
}
36
}
35
37
38
/**
39
 * @bug 130778: Invalid annotation elements cause no annotation to be in the AST
40
 * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=130778"
41
 */
42
public void testBug130778a() throws JavaModelException {
43
	this.workingCopies = new ICompilationUnit[2];
44
	
45
	this.workingCopies[0] = getWorkingCopy(
46
			"/Converter15/src/a/AnAnnotation.java",
47
			"package a;\n" +
48
			"public @interface AnAnnotation {\n" +
49
			"  String value();\n" +
50
			"}\n",
51
			true/*resolve*/);
52
	
53
	this.workingCopies[1] = getWorkingCopy(
54
			"/Converter15/src/a/AnAnnotation2.java",
55
			"package a;\n" +
56
			"public @interface AnAnnotation2 {\n" +
57
			"  String value();\n" +
58
			"}\n",
59
			true/*resolve*/);
60
	
61
	ASTResult result = this.buildMarkedAST(
62
			"/Converter15/src/a/X.java",
63
			"package a;\n" +
64
			"[*1*]public[*1*]\n" +
65
			"[*2*]@AnAnnotation(\"a\")[*2*]\n" +
66
			"[*3*]final[*3*]\n" +
67
			"[*4*]@AnAnnotation2(\"b\")[*4*]\n" +
68
			"class X {\n" +
69
			"}\n");
70
	
71
	assertASTResult(
72
			"===== AST =====\n" + 
73
			"package a;\n" + 
74
			"[*1*]public[*1*] [*2*]@AnAnnotation(\"a\")[*2*] [*3*]final[*3*] [*4*]@AnAnnotation2(\"b\")[*4*] class X {\n" + 
75
			"}\n" + 
76
			"\n" + 
77
			"===== Details =====\n" + 
78
			"1:MODIFIER,[11,6],,,[N/A]\n" + 
79
			"2:SINGLE_MEMBER_ANNOTATION,[18,18],,,[ANNOTATION,La/X;@La/AnAnnotation;,]\n" + 
80
			"3:MODIFIER,[37,5],,,[N/A]\n" + 
81
			"4:SINGLE_MEMBER_ANNOTATION,[43,19],,,[ANNOTATION,La/X;@La/AnAnnotation2;,]\n" + 
82
			"===== Problems =====\n" + 
83
			"No problem",
84
			result);
85
}
86
public void testBug130778b() throws JavaModelException {
87
	this.workingCopies = new ICompilationUnit[2];
88
	
89
	this.workingCopies[0] = getWorkingCopy(
90
			"/Converter15/src/a/AnAnnotation.java",
91
			"package a;\n" +
92
			"public @interface AnAnnotation {\n" +
93
			"  String value();\n" +
94
			"}\n",
95
			true/*resolve*/);
96
	
97
	this.workingCopies[1] = getWorkingCopy(
98
			"/Converter15/src/a/AnAnnotation2.java",
99
			"package a;\n" +
100
			"public @interface AnAnnotation2 {\n" +
101
			"  String value();\n" +
102
			"}\n",
103
			true/*resolve*/);
104
	
105
	ASTResult result = this.buildMarkedAST(
106
			"/Converter15/src/a/X.java",
107
			"package a;\n" +
108
			"#\n" +
109
			"[*1*]public[*1*]\n" +
110
			"[*2*]@AnAnnotation(\"a\")[*2*]\n" +
111
			"[*3*]final[*3*]\n" +
112
			"[*4*]@AnAnnotation2(\"b\")[*4*]\n" +
113
			"class X {\n" +
114
			"}\n");
115
	
116
	assertASTResult(
117
			"===== AST =====\n" + 
118
			"package a;\n" + 
119
			"[*1*]public[*1*] [*2*]@AnAnnotation(\"a\")[*2*] [*3*]final[*3*] [*4*]@AnAnnotation2(\"b\")[*4*] class X {\n" + 
120
			"}\n" + 
121
			"\n" + 
122
			"===== Details =====\n" + 
123
			"1:MODIFIER,[13,6],,,[N/A]\n" + 
124
			"2:SINGLE_MEMBER_ANNOTATION,[20,18],,,[ANNOTATION,La/X;@La/AnAnnotation;,]\n" + 
125
			"3:MODIFIER,[39,5],,,[N/A]\n" + 
126
			"4:SINGLE_MEMBER_ANNOTATION,[45,19],,,[ANNOTATION,La/X;@La/AnAnnotation2;,]\n" + 
127
			"===== Problems =====\n" + 
128
			"1. ERROR in /Converter15/src/a/X.java (at line 2)\n" + 
129
			"	#\n" + 
130
			"	^\n" + 
131
			"Syntax error on token \"Invalid Character\", delete this token\n",
132
			result);
133
}
134
public void testBug130778c() throws JavaModelException {
135
	this.workingCopies = new ICompilationUnit[2];
136
	
137
	this.workingCopies[0] = getWorkingCopy(
138
			"/Converter15/src/a/AnAnnotation.java",
139
			"package a;\n" +
140
			"public @interface AnAnnotation {\n" +
141
			"  String value();\n" +
142
			"}\n",
143
			true/*resolve*/);
144
	
145
	this.workingCopies[1] = getWorkingCopy(
146
			"/Converter15/src/a/AnAnnotation2.java",
147
			"package a;\n" +
148
			"public @interface AnAnnotation2 {\n" +
149
			"  String value();\n" +
150
			"}\n",
151
			true/*resolve*/);
152
	
153
	ASTResult result = this.buildMarkedAST(
154
			"/Converter15/src/a/X.java",
155
			"package a;\n" +
156
			"[*1*]public[*1*]\n" +
157
			"#\n" +
158
			"[*2*]@AnAnnotation(\"a\")[*2*]\n" +
159
			"[*3*]final[*3*]\n" +
160
			"[*4*]@AnAnnotation2(\"b\")[*4*]\n" +
161
			"class X {\n" +
162
			"}\n");
163
	
164
	assertASTResult(
165
			"===== AST =====\n" + 
166
			"package a;\n" + 
167
			"[*1*]public[*1*] [*2*]@AnAnnotation(\"a\")[*2*] [*3*]final[*3*] [*4*]@AnAnnotation2(\"b\")[*4*] class X {\n" + 
168
			"}\n" + 
169
			"\n" + 
170
			"===== Details =====\n" + 
171
			"1:MODIFIER,[11,6],,,[N/A]\n" + 
172
			"2:SINGLE_MEMBER_ANNOTATION,[20,18],,,[ANNOTATION,La/X;@La/AnAnnotation;,]\n" + 
173
			"3:MODIFIER,[39,5],,,[N/A]\n" + 
174
			"4:SINGLE_MEMBER_ANNOTATION,[45,19],,,[ANNOTATION,La/X;@La/AnAnnotation2;,]\n" + 
175
			"===== Problems =====\n" + 
176
			"1. ERROR in /Converter15/src/a/X.java (at line 3)\n" + 
177
			"	#\n" + 
178
			"	^\n" + 
179
			"Syntax error on token \"Invalid Character\", delete this token\n",
180
			result);
181
}
182
public void testBug130778d() throws JavaModelException {
183
	this.workingCopies = new ICompilationUnit[2];
184
	
185
	this.workingCopies[0] = getWorkingCopy(
186
			"/Converter15/src/a/AnAnnotation.java",
187
			"package a;\n" +
188
			"public @interface AnAnnotation {\n" +
189
			"  String value();\n" +
190
			"}\n",
191
			true/*resolve*/);
192
	
193
	this.workingCopies[1] = getWorkingCopy(
194
			"/Converter15/src/a/AnAnnotation2.java",
195
			"package a;\n" +
196
			"public @interface AnAnnotation2 {\n" +
197
			"  String value();\n" +
198
			"}\n",
199
			true/*resolve*/);
200
	
201
	ASTResult result = this.buildMarkedAST(
202
			"/Converter15/src/a/X.java",
203
			"package a;\n" +
204
			"[*1*]public[*1*]\n" +
205
			"[*2*]@AnAnnotation(\"a\")[*2*]\n" +
206
			"#\n" +
207
			"[*3*]final[*3*]\n" +
208
			"[*4*]@AnAnnotation2(\"b\")[*4*]\n" +
209
			"class X {\n" +
210
			"}\n");
211
	
212
	assertASTResult(
213
			"===== AST =====\n" + 
214
			"package a;\n" + 
215
			"[*1*]public[*1*] [*2*]@AnAnnotation(\"a\")[*2*] [*3*]final[*3*] [*4*]@AnAnnotation2(\"b\")[*4*] class X {\n" + 
216
			"}\n" + 
217
			"\n" + 
218
			"===== Details =====\n" + 
219
			"1:MODIFIER,[11,6],,,[N/A]\n" + 
220
			"2:SINGLE_MEMBER_ANNOTATION,[18,18],,,[ANNOTATION,La/X;@La/AnAnnotation;,]\n" + 
221
			"3:MODIFIER,[39,5],,,[N/A]\n" + 
222
			"4:SINGLE_MEMBER_ANNOTATION,[45,19],,,[ANNOTATION,La/X;@La/AnAnnotation2;,]\n" + 
223
			"===== Problems =====\n" + 
224
			"1. ERROR in /Converter15/src/a/X.java (at line 4)\n" + 
225
			"	#\n" + 
226
			"	^\n" + 
227
			"Syntax error on token \"Invalid Character\", delete this token\n",
228
			result);
229
}
230
public void testBug130778e() throws JavaModelException {
231
	this.workingCopies = new ICompilationUnit[2];
232
	
233
	this.workingCopies[0] = getWorkingCopy(
234
			"/Converter15/src/a/AnAnnotation.java",
235
			"package a;\n" +
236
			"public @interface AnAnnotation {\n" +
237
			"  String value();\n" +
238
			"}\n",
239
			true/*resolve*/);
240
	
241
	this.workingCopies[1] = getWorkingCopy(
242
			"/Converter15/src/a/AnAnnotation2.java",
243
			"package a;\n" +
244
			"public @interface AnAnnotation2 {\n" +
245
			"  String value();\n" +
246
			"}\n",
247
			true/*resolve*/);
248
	
249
	ASTResult result = this.buildMarkedAST(
250
			"/Converter15/src/a/X.java",
251
			"package a;\n" +
252
			"[*1*]public[*1*]\n" +
253
			"[*2*]@AnAnnotation(\"a\")[*2*]\n" +
254
			"[*3*]final[*3*]\n" +
255
			"#\n" +
256
			"[*4*]@AnAnnotation2(\"b\")[*4*]\n" +
257
			"class X {\n" +
258
			"}\n");
259
	
260
	assertASTResult(
261
			"===== AST =====\n" + 
262
			"package a;\n" + 
263
			"[*1*]public[*1*] [*2*]@AnAnnotation(\"a\")[*2*] [*3*]final[*3*] [*4*]@AnAnnotation2(\"b\")[*4*] class X {\n" + 
264
			"}\n" + 
265
			"\n" + 
266
			"===== Details =====\n" + 
267
			"1:MODIFIER,[11,6],,,[N/A]\n" + 
268
			"2:SINGLE_MEMBER_ANNOTATION,[18,18],,,[ANNOTATION,La/X;@La/AnAnnotation;,]\n" + 
269
			"3:MODIFIER,[37,5],,,[N/A]\n" + 
270
			"4:SINGLE_MEMBER_ANNOTATION,[45,19],,,[ANNOTATION,La/X;@La/AnAnnotation2;,]\n" + 
271
			"===== Problems =====\n" + 
272
			"1. ERROR in /Converter15/src/a/X.java (at line 5)\n" + 
273
			"	#\n" + 
274
			"	^\n" + 
275
			"Syntax error on token \"Invalid Character\", delete this token\n",
276
			result);
277
}
278
public void testBug130778f() throws JavaModelException {
279
	this.workingCopies = new ICompilationUnit[2];
280
	
281
	this.workingCopies[0] = getWorkingCopy(
282
			"/Converter15/src/a/AnAnnotation.java",
283
			"package a;\n" +
284
			"public @interface AnAnnotation {\n" +
285
			"  String value();\n" +
286
			"}\n",
287
			true/*resolve*/);
288
	
289
	this.workingCopies[1] = getWorkingCopy(
290
			"/Converter15/src/a/AnAnnotation2.java",
291
			"package a;\n" +
292
			"public @interface AnAnnotation2 {\n" +
293
			"  String value();\n" +
294
			"}\n",
295
			true/*resolve*/);
296
	
297
	ASTResult result = this.buildMarkedAST(
298
			"/Converter15/src/a/X.java",
299
			"package a;\n" +
300
			"[*1*]public[*1*]\n" +
301
			"[*2*]@AnAnnotation(\"a\")[*2*]\n" +
302
			"[*3*]final[*3*]\n" +
303
			"[*4*]@AnAnnotation2(\"b\")[*4*]\n" +
304
			"#\n" +
305
			"class X {\n" +
306
			"}\n");
307
	
308
	assertASTResult(
309
			"===== AST =====\n" + 
310
			"package a;\n" + 
311
			"[*1*]public[*1*] [*2*]@AnAnnotation(\"a\")[*2*] [*3*]final[*3*] [*4*]@AnAnnotation2(\"b\")[*4*] class X {\n" + 
312
			"}\n" + 
313
			"\n" + 
314
			"===== Details =====\n" + 
315
			"1:MODIFIER,[11,6],,,[N/A]\n" + 
316
			"2:SINGLE_MEMBER_ANNOTATION,[18,18],,,[ANNOTATION,La/X;@La/AnAnnotation;,]\n" + 
317
			"3:MODIFIER,[37,5],,,[N/A]\n" + 
318
			"4:SINGLE_MEMBER_ANNOTATION,[43,19],,,[ANNOTATION,La/X;@La/AnAnnotation2;,]\n" + 
319
			"===== Problems =====\n" + 
320
			"1. ERROR in /Converter15/src/a/X.java (at line 6)\n" + 
321
			"	#\n" + 
322
			"	^\n" + 
323
			"Syntax error on token \"Invalid Character\", delete this token\n",
324
			result);
325
}
326
public void testBug130778g() throws JavaModelException {
327
	this.workingCopies = new ICompilationUnit[2];
328
	
329
	this.workingCopies[0] = getWorkingCopy(
330
			"/Converter15/src/a/AnAnnotation.java",
331
			"package a;\n" +
332
			"public @interface AnAnnotation {\n" +
333
			"  String value();\n" +
334
			"}\n",
335
			true/*resolve*/);
336
	
337
	this.workingCopies[1] = getWorkingCopy(
338
			"/Converter15/src/a/AnAnnotation2.java",
339
			"package a;\n" +
340
			"public @interface AnAnnotation2 {\n" +
341
			"  String value();\n" +
342
			"}\n",
343
			true/*resolve*/);
344
	
345
	ASTResult result = this.buildMarkedAST(
346
			"/Converter15/src/a/X.java",
347
			"package a;\n" +
348
			"[*1*]public[*1*]\n" +
349
			"[*2*]@AnAnnotation(\"a\")[*2*]\n" +
350
			"[*3*]final[*3*]\n" +
351
			"[*4*]@AnAnnotation2(\"b\")[*4*]\n" +
352
			"class X {\n" +
353
			"  #\n" +
354
			"}\n");
355
	
356
	assertASTResult(
357
			"===== AST =====\n" + 
358
			"package a;\n" + 
359
			"[*1*]public[*1*] [*2*]@AnAnnotation(\"a\")[*2*] [*3*]final[*3*] [*4*]@AnAnnotation2(\"b\")[*4*] class X {\n" + 
360
			"}\n" + 
361
			"\n" + 
362
			"===== Details =====\n" + 
363
			"1:MODIFIER,[11,6],,,[N/A]\n" + 
364
			"2:SINGLE_MEMBER_ANNOTATION,[18,18],,,[ANNOTATION,La/X;@La/AnAnnotation;,]\n" + 
365
			"3:MODIFIER,[37,5],,,[N/A]\n" + 
366
			"4:SINGLE_MEMBER_ANNOTATION,[43,19],,,[ANNOTATION,La/X;@La/AnAnnotation2;,]\n" + 
367
			"===== Problems =====\n" + 
368
			"1. ERROR in /Converter15/src/a/X.java (at line 7)\n" + 
369
			"	#\n" + 
370
			"	^\n" + 
371
			"Syntax error on token \"Invalid Character\", delete this token\n",
372
			result);
373
}
374
public void testBug130778h() throws JavaModelException {
375
	this.workingCopies = new ICompilationUnit[2];
376
	
377
	this.workingCopies[0] = getWorkingCopy(
378
			"/Converter15/src/a/AnAnnotation.java",
379
			"package a;\n" +
380
			"public @interface AnAnnotation {\n" +
381
			"  String value();\n" +
382
			"}\n",
383
			true/*resolve*/);
384
	
385
	this.workingCopies[1] = getWorkingCopy(
386
			"/Converter15/src/a/AnAnnotation2.java",
387
			"package a;\n" +
388
			"public @interface AnAnnotation2 {\n" +
389
			"  String value();\n" +
390
			"}\n",
391
			true/*resolve*/);
392
	
393
	ASTResult result = this.buildMarkedAST(
394
			"/Converter15/src/a/X.java",
395
			"package a;\n" +
396
			"[*1*]@AnAnnotation(value=\"a\")[*1*]\n" +
397
			"[*2*]@AnAnnotation2(value=\"b\")[*2*]\n" +
398
			"[*3*]public[*3*] class X {\n" +
399
			"}\n");
400
	
401
	assertASTResult(
402
			"===== AST =====\n" + 
403
			"package a;\n" + 
404
			"[*1*]@AnAnnotation(value=\"a\")[*1*] [*2*]@AnAnnotation2(value=\"b\")[*2*] [*3*]public[*3*] class X {\n" + 
405
			"}\n" + 
406
			"\n" + 
407
			"===== Details =====\n" + 
408
			"1:NORMAL_ANNOTATION,[11,24],,,[ANNOTATION,La/X;@La/AnAnnotation;,]\n" + 
409
			"2:NORMAL_ANNOTATION,[36,25],,,[ANNOTATION,La/X;@La/AnAnnotation2;,]\n" + 
410
			"3:MODIFIER,[62,6],,,[N/A]\n" + 
411
			"===== Problems =====\n" + 
412
			"No problem",
413
			result);
414
}
415
public void testBug130778i() throws JavaModelException {
416
	this.workingCopies = new ICompilationUnit[2];
417
	
418
	this.workingCopies[0] = getWorkingCopy(
419
			"/Converter15/src/a/AnAnnotation.java",
420
			"package a;\n" +
421
			"public @interface AnAnnotation {\n" +
422
			"  String value();\n" +
423
			"}\n",
424
			true/*resolve*/);
425
	
426
	this.workingCopies[1] = getWorkingCopy(
427
			"/Converter15/src/a/AnAnnotation2.java",
428
			"package a;\n" +
429
			"public @interface AnAnnotation2 {\n" +
430
			"  String value();\n" +
431
			"}\n",
432
			true/*resolve*/);
433
	
434
	ASTResult result = this.buildMarkedAST(
435
			"/Converter15/src/a/X.java",
436
			"package a;\n" +
437
			"[*1*]@AnAnnotation[*1*](value=)\n" +
438
			"[*2*]@AnAnnotation2(value=\"b\")[*2*]\n" +
439
			"[*3*]public[*3*] class X {\n" +
440
			"}\n");
441
	
442
	assertASTResult(
443
			"===== AST =====\n" + 
444
			"package a;\n" + 
445
			"[*1*]@AnAnnotation[*1*] [*2*]@AnAnnotation2(value=\"b\")[*2*] [*3*]public[*3*] class X {\n" + 
446
			"}\n" + 
447
			"\n" + 
448
			"===== Details =====\n" + 
449
			"1:MARKER_ANNOTATION,[11,13],,,[ANNOTATION,La/X;@La/AnAnnotation;,]\n" + 
450
			"2:NORMAL_ANNOTATION,[33,25],,,[ANNOTATION,La/X;@La/AnAnnotation2;,]\n" + 
451
			"3:MODIFIER,[59,6],,,[N/A]\n" + 
452
			"===== Problems =====\n" + 
453
			"1. ERROR in /Converter15/src/a/X.java (at line 2)\n" + 
454
			"	@AnAnnotation(value=)\n" + 
455
			"	                   ^\n" + 
456
			"Syntax error on token \"=\", MemberValue expected after this token\n",
457
			result);
458
}
459
public void testBug130778j() throws JavaModelException {
460
	this.workingCopies = new ICompilationUnit[2];
461
	
462
	this.workingCopies[0] = getWorkingCopy(
463
			"/Converter15/src/a/AnAnnotation.java",
464
			"package a;\n" +
465
			"public @interface AnAnnotation {\n" +
466
			"  String value();\n" +
467
			"}\n",
468
			true/*resolve*/);
469
	
470
	this.workingCopies[1] = getWorkingCopy(
471
			"/Converter15/src/a/AnAnnotation2.java",
472
			"package a;\n" +
473
			"public @interface AnAnnotation2 {\n" +
474
			"  String value();\n" +
475
			"}\n",
476
			true/*resolve*/);
477
	
478
	ASTResult result = this.buildMarkedAST(
479
			"/Converter15/src/a/X.java",
480
			"package a;\n" +
481
			"[*1*]@AnAnnotation(value=\"a\")[*1*]\n" +
482
			"[*2*]@AnAnnotation2[*2*](value=)\n" +
483
			"[*3*]public[*3*] class X {\n" +
484
			"}\n");
485
	
486
	assertASTResult(
487
			"===== AST =====\n" + 
488
			"package a;\n" + 
489
			"[*1*]@AnAnnotation(value=\"a\")[*1*] [*2*]@AnAnnotation2[*2*] [*3*]public[*3*] class X {\n" + 
490
			"}\n" + 
491
			"\n" + 
492
			"===== Details =====\n" + 
493
			"1:NORMAL_ANNOTATION,[11,24],,,[ANNOTATION,La/X;@La/AnAnnotation;,]\n" + 
494
			"2:MARKER_ANNOTATION,[36,14],,,[ANNOTATION,La/X;@La/AnAnnotation2;,]\n" + 
495
			"3:MODIFIER,[59,6],,,[N/A]\n" + 
496
			"===== Problems =====\n" + 
497
			"1. ERROR in /Converter15/src/a/X.java (at line 3)\n" + 
498
			"	@AnAnnotation2(value=)\n" + 
499
			"	                    ^\n" + 
500
			"Syntax error on token \"=\", MemberValue expected after this token\n",
501
			result);
502
}
503
public void testBug130778k() throws JavaModelException {
504
	this.workingCopies = new ICompilationUnit[2];
505
	
506
	this.workingCopies[0] = getWorkingCopy(
507
			"/Converter15/src/a/AnAnnotation.java",
508
			"package a;\n" +
509
			"public @interface AnAnnotation {\n" +
510
			"  String value();\n" +
511
			"}\n",
512
			true/*resolve*/);
513
	
514
	this.workingCopies[1] = getWorkingCopy(
515
			"/Converter15/src/a/AnAnnotation2.java",
516
			"package a;\n" +
517
			"public @interface AnAnnotation2 {\n" +
518
			"  String value();\n" +
519
			"}\n",
520
			true/*resolve*/);
521
	
522
	ASTResult result = this.buildMarkedAST(
523
			"/Converter15/src/a/X.java",
524
			"package a;\n" +
525
			"[*1*]@AnAnnotation[*1*](value=)\n" +
526
			"[*2*]@AnAnnotation2[*2*](value=)\n" +
527
			"[*3*]public[*3*] class X {\n" +
528
			"}\n");
529
	
530
	assertASTResult(
531
			"===== AST =====\n" + 
532
			"package a;\n" + 
533
			"[*1*]@AnAnnotation[*1*] [*2*]@AnAnnotation2[*2*] [*3*]public[*3*] class X {\n" + 
534
			"}\n" + 
535
			"\n" + 
536
			"===== Details =====\n" + 
537
			"1:MARKER_ANNOTATION,[11,13],,,[ANNOTATION,La/X;@La/AnAnnotation;,]\n" + 
538
			"2:MARKER_ANNOTATION,[33,14],,,[ANNOTATION,La/X;@La/AnAnnotation2;,]\n" + 
539
			"3:MODIFIER,[56,6],,,[N/A]\n" + 
540
			"===== Problems =====\n" + 
541
			"1. ERROR in /Converter15/src/a/X.java (at line 2)\n" + 
542
			"	@AnAnnotation(value=)\n" + 
543
			"	                    ^\n" + 
544
			"Syntax error on token \")\", delete this token\n" + 
545
			"2. ERROR in /Converter15/src/a/X.java (at line 3)\n" + 
546
			"	@AnAnnotation2(value=)\n" + 
547
			"	                    ^\n" + 
548
			"Syntax error on token \"=\", ) expected\n",
549
			result);
550
}
551
public void testBug130778l() throws JavaModelException {
552
	this.workingCopies = new ICompilationUnit[2];
553
	
554
	this.workingCopies[0] = getWorkingCopy(
555
			"/Converter15/src/a/AnAnnotation.java",
556
			"package a;\n" +
557
			"public @interface AnAnnotation {\n" +
558
			"  String value();\n" +
559
			"}\n",
560
			true/*resolve*/);
561
	
562
	this.workingCopies[1] = getWorkingCopy(
563
			"/Converter15/src/a/AnAnnotation2.java",
564
			"package a;\n" +
565
			"public @interface AnAnnotation2 {\n" +
566
			"  String value();\n" +
567
			"}\n",
568
			true/*resolve*/);
569
	
570
	ASTResult result = this.buildMarkedAST(
571
			"/Converter15/src/a/X.java",
572
			"package a;\n" +
573
			"public class X {\n" +
574
			"  public void foo(){\n" +
575
			"    [*1*]@AnAnnotation[*1*](value=)\n" +
576
			"    [*2*]@AnAnnotation2(value=\"b\")[*2*]\n" +
577
			"    class Y {}\n" +
578
			"  }\n" +
579
			"}\n");
580
	
581
	assertASTResult(
582
			"===== AST =====\n" + 
583
			"package a;\n" + 
584
			"public class X {\n" + 
585
			"  public void foo(){\n" + 
586
			"[*1*]@AnAnnotation[*1*] [*2*]@AnAnnotation2(value=\"b\")[*2*] class Y {\n" + 
587
			"    }\n" + 
588
			"  }\n" + 
589
			"}\n" + 
590
			"\n" + 
591
			"===== Details =====\n" + 
592
			"1:MARKER_ANNOTATION,[53,13],,,[ANNOTATION,La/X$115$Y;@La/AnAnnotation;,]\n" + 
593
			"2:NORMAL_ANNOTATION,[79,25],,,[ANNOTATION,La/X$115$Y;@La/AnAnnotation2;,]\n" + 
594
			"===== Problems =====\n" + 
595
			"1. ERROR in /Converter15/src/a/X.java (at line 4)\n" + 
596
			"	@AnAnnotation(value=)\n" + 
597
			"	                   ^\n" + 
598
			"Syntax error on token \"=\", MemberValue expected after this token\n",
599
			result);
600
}
601
public void testBug130778m() throws JavaModelException {
602
	this.workingCopies = new ICompilationUnit[2];
603
	
604
	this.workingCopies[0] = getWorkingCopy(
605
			"/Converter15/src/a/AnAnnotation.java",
606
			"package a;\n" +
607
			"public @interface AnAnnotation {\n" +
608
			"  String value();\n" +
609
			"}\n",
610
			true/*resolve*/);
611
	
612
	this.workingCopies[1] = getWorkingCopy(
613
			"/Converter15/src/a/AnAnnotation2.java",
614
			"package a;\n" +
615
			"public @interface AnAnnotation2 {\n" +
616
			"  String value();\n" +
617
			"}\n",
618
			true/*resolve*/);
619
	
620
	ASTResult result = this.buildMarkedAST(
621
			"/Converter15/src/a/X.java",
622
			"package a;\n" +
623
			"public class X {\n" +
624
			"  public void foo(){\n" +
625
			"    [*1*]@AnAnnotation(value=)[*1*]\n" +
626
			"    [*2*]@AnAnnotation2(value=\"b\")[*2*]\n" +
627
			"    int i;\n" +
628
			"  }\n" +
629
			"}\n");
630
	
631
	assertASTResult(
632
			"===== AST =====\n" + 
633
			"package a;\n" + 
634
			"public class X {\n" + 
635
			"  public void foo(){\n" + 
636
			"    [*1*]@AnAnnotation(value=$missing$)[*1*] [*2*]@AnAnnotation2(value=\"b\")[*2*] int i;\n" + 
637
			"  }\n" + 
638
			"}\n" + 
639
			"\n" + 
640
			"===== Details =====\n" + 
641
			"1:NORMAL_ANNOTATION,[53,21],,,[ANNOTATION,La/X;.foo()V#i@La/AnAnnotation;,]\n" + 
642
			"2:NORMAL_ANNOTATION,[79,25],,,[ANNOTATION,La/X;.foo()V#i@La/AnAnnotation2;,]\n" + 
643
			"===== Problems =====\n" + 
644
			"1. ERROR in /Converter15/src/a/X.java (at line 4)\n" + 
645
			"	@AnAnnotation(value=)\n" + 
646
			"	                   ^\n" + 
647
			"Syntax error on token \"=\", MemberValue expected after this token\n",
648
			result);
649
}
650
public void testBug130778n() throws JavaModelException {
651
	this.workingCopies = new ICompilationUnit[1];
652
	
653
	this.workingCopies[0] = getWorkingCopy(
654
			"/Converter15/src/a/AnAnnotation.java",
655
			"package a;\n" +
656
			"public @interface AnAnnotation {\n" +
657
			"  String name1();\n" +
658
			"  String name2();\n" +
659
			"}\n",
660
			true/*resolve*/);
661
	
662
	ASTResult result = this.buildMarkedAST(
663
			"/Converter15/src/a/X.java",
664
			"package a;\n" +
665
			"[*1*][*2*]@AnAnnotation([*3*]name1=\"a\"[*3*][*2*], name2)\n" +
666
			"public class X {\n" +
667
			"}[*1*]\n");
668
	
669
	assertASTResult(
670
			"===== AST =====\n" + 
671
			"package a;\n" + 
672
			"[*1*][*2*]@AnAnnotation([*3*]name1=\"a\"[*3*])[*2*] public class X {\n" + 
673
			"}[*1*]\n" + 
674
			"\n" + 
675
			"===== Details =====\n" + 
676
			"1:TYPE_DECLARATION,[11,50],,MALFORMED|RECOVERED,[TYPE,La/X;,]\n" + 
677
			"2:NORMAL_ANNOTATION,[11,23],,RECOVERED,[ANNOTATION,La/X;@La/AnAnnotation;,]\n" + 
678
			"3:MEMBER_VALUE_PAIR,[25,9],,,[N/A]\n" + 
679
			"===== Problems =====\n" + 
680
			"1. ERROR in /Converter15/src/a/X.java (at line 2)\n" + 
681
			"	@AnAnnotation(name1=\"a\", name2)\n" + 
682
			"	                       ^\n" + 
683
			"Syntax error on token \",\", . expected\n",
684
			result);
685
}
686
public void testBug130778o() throws JavaModelException {
687
	this.workingCopies = new ICompilationUnit[1];
688
	
689
	this.workingCopies[0] = getWorkingCopy(
690
			"/Converter15/src/a/AnAnnotation.java",
691
			"package a;\n" +
692
			"public @interface AnAnnotation {\n" +
693
			"  String name1();\n" +
694
			"  String name2();\n" +
695
			"}\n",
696
			true/*resolve*/);
697
	
698
	ASTResult result = this.buildMarkedAST(
699
			"/Converter15/src/a/X.java",
700
			"package a;\n" +
701
			"[*1*][*2*]@AnAnnotation[*2*]([*3*]name1=[*3*])\n" +
702
			"public class X {\n" +
703
			"}[*1*]\n");
704
	
705
	assertASTResult(
706
			"===== AST =====\n" + 
707
			"package a;\n" + 
708
			"[*1*][*2*]@AnAnnotation[*2*] public class X {\n" + 
709
			"}[*1*]\n" + 
710
			"\n" + 
711
			"===== Details =====\n" + 
712
			"1:TYPE_DECLARATION,[11,40],,MALFORMED|RECOVERED,[TYPE,La/X;,]\n" + 
713
			"2:MARKER_ANNOTATION,[11,13],,,[ANNOTATION,La/X;@La/AnAnnotation;,]\n" + 
714
			"3:No corresponding node\n" + 
715
			"===== Problems =====\n" + 
716
			"1. ERROR in /Converter15/src/a/X.java (at line 2)\n" + 
717
			"	@AnAnnotation(name1=)\n" + 
718
			"	                   ^\n" + 
719
			"Syntax error on token \"=\", MemberValue expected after this token\n",
720
			result);
721
}
722
public void testBug130778p() throws JavaModelException {
723
	this.workingCopies = new ICompilationUnit[2];
724
	
725
	this.workingCopies[0] = getWorkingCopy(
726
			"/Converter15/src/a/AnAnnotation.java",
727
			"package a;\n" +
728
			"public @interface AnAnnotation {\n" +
729
			"  AnAnnotation2 value();\n" +
730
			"}\n",
731
			true/*resolve*/);
732
	
733
	this.workingCopies[1] = getWorkingCopy(
734
			"/Converter15/src/a/AnAnnotation2.java",
735
			"package a;\n" +
736
			"public @interface AnAnnotation2 {\n" +
737
			"  String value();\n" +
738
			"}\n",
739
			true/*resolve*/);
740
	
741
	ASTResult result = this.buildMarkedAST(
742
			"/Converter15/src/a/X.java",
743
			"package a;\n" +
744
			"[*1*]@AnAnnotation([*2*]value=[*3*]@AnAnnotation2(value=\"a\")[*3*][*2*])[*1*]\n" +
745
			"public class X {\n" +
746
			"}\n");
747
	
748
	assertASTResult(
749
			"===== AST =====\n" + 
750
			"package a;\n" + 
751
			"[*1*]@AnAnnotation([*2*]value=[*3*]@AnAnnotation2(value=\"a\")[*3*][*2*])[*1*] public class X {\n" + 
752
			"}\n" + 
753
			"\n" + 
754
			"===== Details =====\n" + 
755
			"1:NORMAL_ANNOTATION,[11,46],,,[ANNOTATION,La/X;@La/AnAnnotation;,]\n" + 
756
			"2:MEMBER_VALUE_PAIR,[25,31],,,[N/A]\n" + 
757
			"3:NORMAL_ANNOTATION,[31,25],,,[ANNOTATION,@La/AnAnnotation2;,]\n" + 
758
			"===== Problems =====\n" + 
759
			"No problem",
760
			result);
761
}
762
public void testBug130778q() throws JavaModelException {
763
	this.workingCopies = new ICompilationUnit[2];
764
	
765
	this.workingCopies[0] = getWorkingCopy(
766
			"/Converter15/src/a/AnAnnotation.java",
767
			"package a;\n" +
768
			"public @interface AnAnnotation {\n" +
769
			"  AnAnnotation2 value();\n" +
770
			"}\n",
771
			true/*resolve*/);
772
	
773
	this.workingCopies[1] = getWorkingCopy(
774
			"/Converter15/src/a/AnAnnotation2.java",
775
			"package a;\n" +
776
			"public @interface AnAnnotation2 {\n" +
777
			"  String value();\n" +
778
			"}\n",
779
			true/*resolve*/);
780
	
781
	ASTResult result = this.buildMarkedAST(
782
			"/Converter15/src/a/X.java",
783
			"package a;\n" +
784
			"[*1*]@AnAnnotation([*2*]value=[*3*]@AnAnnotation2(value=\"a\")[*3*][*2*][*1*]\n" +
785
			"public class X {\n" +
786
			"}\n");
787
	
788
	assertASTResult(
789
			"===== AST =====\n" + 
790
			"package a;\n" + 
791
			"[*1*]@AnAnnotation([*2*]value=[*3*]@AnAnnotation2(value=\"a\")[*3*][*2*])[*1*] public class X {\n" + 
792
			"}\n" + 
793
			"\n" + 
794
			"===== Details =====\n" + 
795
			"1:NORMAL_ANNOTATION,[11,45],,RECOVERED,[ANNOTATION,La/X;@La/AnAnnotation;,]\n" + 
796
			"2:MEMBER_VALUE_PAIR,[25,31],,,[N/A]\n" + 
797
			"3:NORMAL_ANNOTATION,[31,25],,RECOVERED,[ANNOTATION,@La/AnAnnotation2;,]\n" + 
798
			"===== Problems =====\n" + 
799
			"1. ERROR in /Converter15/src/a/X.java (at line 2)\n" + 
800
			"	@AnAnnotation(value=@AnAnnotation2(value=\"a\")\n" + 
801
			"	                                            ^\n" + 
802
			"Syntax error, insert \")\" to complete Modifiers\n",
803
			result);
804
}
805
public void testBug130778r() throws JavaModelException {
806
	this.workingCopies = new ICompilationUnit[2];
807
	
808
	this.workingCopies[0] = getWorkingCopy(
809
			"/Converter15/src/a/AnAnnotation.java",
810
			"package a;\n" +
811
			"public @interface AnAnnotation {\n" +
812
			"  AnAnnotation2 value();\n" +
813
			"}\n",
814
			true/*resolve*/);
815
	
816
	this.workingCopies[1] = getWorkingCopy(
817
			"/Converter15/src/a/AnAnnotation2.java",
818
			"package a;\n" +
819
			"public @interface AnAnnotation2 {\n" +
820
			"  String value();\n" +
821
			"}\n",
822
			true/*resolve*/);
823
	
824
	ASTResult result = this.buildMarkedAST(
825
			"/Converter15/src/a/X.java",
826
			"package a;\n" +
827
			"[*1*][*2*]@AnAnnotation[*2*](value=@AnAnnotation2(value=))\n" +
828
			"public class X {\n" +
829
			"}[*1*]\n");
830
	
831
	assertASTResult(
832
			"===== AST =====\n" + 
833
			"package a;\n" + 
834
			"[*1*][*2*]@AnAnnotation[*2*] public class X {\n" + 
835
			"}[*1*]\n" + 
836
			"\n" + 
837
			"===== Details =====\n" + 
838
			"1:TYPE_DECLARATION,[11,62],,MALFORMED|RECOVERED,[TYPE,La/X;,]\n" + 
839
			"2:MARKER_ANNOTATION,[11,13],,,[ANNOTATION,La/X;@La/AnAnnotation;,]\n" + 
840
			"===== Problems =====\n" + 
841
			"1. ERROR in /Converter15/src/a/X.java (at line 2)\n" + 
842
			"	@AnAnnotation(value=@AnAnnotation2(value=))\n" + 
843
			"	                                        ^\n" + 
844
			"Syntax error on token \"=\", MemberValue expected after this token\n",
845
			result);
846
}
847
public void testBug130778s() throws JavaModelException {
848
	this.workingCopies = new ICompilationUnit[2];
849
	
850
	this.workingCopies[0] = getWorkingCopy(
851
			"/Converter15/src/a/AnAnnotation.java",
852
			"package a;\n" +
853
			"public @interface AnAnnotation {\n" +
854
			"  String value1();\n" +
855
			"  AnAnnotation2 value2();\n" +
856
			"}\n",
857
			true/*resolve*/);
858
	
859
	this.workingCopies[1] = getWorkingCopy(
860
			"/Converter15/src/a/AnAnnotation2.java",
861
			"package a;\n" +
862
			"public @interface AnAnnotation2 {\n" +
863
			"  String value();\n" +
864
			"}\n",
865
			true/*resolve*/);
866
	
867
	ASTResult result = this.buildMarkedAST(
868
			"/Converter15/src/a/X.java",
869
			"package a;\n" +
870
			"[*1*][*2*]@AnAnnotation[*2*](value1=,[*3*]value=[*4*]@AnAnnotation2(value=\"b\")[*4*][*3*])\n" +
871
			"public class X {\n" +
872
			"}[*1*]\n");
873
	
874
	assertASTResult(
875
			"===== AST =====\n" + 
876
			"package a;\n" + 
877
			"[*1*][*2*]@AnAnnotation[*2*] [*4*]@AnAnnotation2(value=\"b\")[*4*] public class X {\n" + 
878
			"}[*1*]\n" + 
879
			"\n" + 
880
			"===== Details =====\n" + 
881
			"1:TYPE_DECLARATION,[11,73],,MALFORMED|RECOVERED,[TYPE,La/X;,]\n" + 
882
			"2:MARKER_ANNOTATION,[11,13],,,[ANNOTATION,La/X;@La/AnAnnotation;,]\n" + 
883
			"4:NORMAL_ANNOTATION,[39,25],,,[ANNOTATION,La/X;@La/AnAnnotation2;,]\n" + 
884
			"3:No corresponding node\n" + 
885
			"===== Problems =====\n" + 
886
			"1. ERROR in /Converter15/src/a/X.java (at line 2)\n" + 
887
			"	@AnAnnotation(value1=,value=@AnAnnotation2(value=\"b\"))\n" + 
888
			"	                    ^\n" + 
889
			"Syntax error on token \"=\", MemberValue expected after this token\n",
890
			result);
891
}
892
public void testBug130778t() throws JavaModelException {
893
	this.workingCopies = new ICompilationUnit[1];
894
	
895
	this.workingCopies[0] = getWorkingCopy(
896
			"/Converter15/src/a/AnAnnotation.java",
897
			"package a;\n" +
898
			"public @interface AnAnnotation {\n" +
899
			"  String value();\n" +
900
			"}\n",
901
			true/*resolve*/);
902
	
903
	ASTResult result = this.buildMarkedAST(
904
			"/Converter15/src/a/X.java",
905
			"package a;\n" +
906
			"[*1*]@AnAnnotation(\"b\")[*1*]\n" +
907
			"public class X {\n" +
908
			"}\n");
909
	
910
	assertASTResult(
911
			"===== AST =====\n" + 
912
			"package a;\n" + 
913
			"[*1*]@AnAnnotation(\"b\")[*1*] public class X {\n" + 
914
			"}\n" + 
915
			"\n" + 
916
			"===== Details =====\n" + 
917
			"1:SINGLE_MEMBER_ANNOTATION,[11,18],,,[ANNOTATION,La/X;@La/AnAnnotation;,]\n" + 
918
			"===== Problems =====\n" + 
919
			"No problem",
920
			result);
921
}
922
public void testBug130778u() throws JavaModelException {
923
	this.workingCopies = new ICompilationUnit[1];
924
	
925
	this.workingCopies[0] = getWorkingCopy(
926
			"/Converter15/src/a/AnAnnotation.java",
927
			"package a;\n" +
928
			"public @interface AnAnnotation {\n" +
929
			"  String value();\n" +
930
			"}\n",
931
			true/*resolve*/);
932
	
933
	ASTResult result = this.buildMarkedAST(
934
			"/Converter15/src/a/X.java",
935
			"package a;\n" +
936
			"[*1*]@AnAnnotation([*2*]\"b\"[*2*][*1*]\n" +
937
			"public class X {\n" +
938
			"}\n");
939
	
940
	assertASTResult(
941
			"===== AST =====\n" + 
942
			"package a;\n" + 
943
			"[*1*]@AnAnnotation([*2*]\"b\"[*2*])[*1*] public class X {\n" + 
944
			"}\n" + 
945
			"\n" + 
946
			"===== Details =====\n" + 
947
			"1:SINGLE_MEMBER_ANNOTATION,[11,17],,RECOVERED,[ANNOTATION,La/X;@La/AnAnnotation;,]\n" + 
948
			"2:STRING_LITERAL,[25,3],,,[N/A]\n" + 
949
			"===== Problems =====\n" + 
950
			"1. ERROR in /Converter15/src/a/X.java (at line 2)\n" + 
951
			"	@AnAnnotation(\"b\"\n" + 
952
			"	              ^^^\n" + 
953
			"Syntax error, insert \")\" to complete Modifiers\n",
954
			result);
955
}
956
public void testBug130778v() throws JavaModelException {
957
	this.workingCopies = new ICompilationUnit[2];
958
	
959
	this.workingCopies[0] = getWorkingCopy(
960
			"/Converter15/src/a/AnAnnotation.java",
961
			"package a;\n" +
962
			"public @interface AnAnnotation {\n" +
963
			"  AnAnnotation2 value();\n" +
964
			"}\n",
965
			true/*resolve*/);
966
	
967
	this.workingCopies[1] = getWorkingCopy(
968
			"/Converter15/src/a/AnAnnotation2.java",
969
			"package a;\n" +
970
			"public @interface AnAnnotation2 {\n" +
971
			"  String value();\n" +
972
			"}\n",
973
			true/*resolve*/);
974
	
975
	ASTResult result = this.buildMarkedAST(
976
			"/Converter15/src/a/X.java",
977
			"package a;\n" +
978
			"[*1*]@AnAnnotation[*1*](@AnAnnotation2(\"b\"\n" +
979
			"public class X {\n" +
980
			"}\n");
981
	
982
	assertASTResult(
983
			"===== AST =====\n" + 
984
			"package a;\n" + 
985
			"[*1*]@AnAnnotation[*1*] public class X {\n" + 
986
			"}\n" + 
987
			"\n" + 
988
			"===== Details =====\n" + 
989
			"1:MARKER_ANNOTATION,[11,13],,,[ANNOTATION,La/X;@La/AnAnnotation;,]\n" + 
990
			"===== Problems =====\n" + 
991
			"1. ERROR in /Converter15/src/a/X.java (at line 2)\n" + 
992
			"	@AnAnnotation(@AnAnnotation2(\"b\"\n" + 
993
			"	                             ^^^\n" + 
994
			"Syntax error, insert \")\" to complete SingleMemberAnnotation\n" + 
995
			"2. ERROR in /Converter15/src/a/X.java (at line 2)\n" + 
996
			"	@AnAnnotation(@AnAnnotation2(\"b\"\n" + 
997
			"	                             ^^^\n" + 
998
			"Syntax error, insert \")\" to complete Modifiers\n",
999
			result);
1000
}
1001
public void testBug130778x() throws JavaModelException {
1002
	this.workingCopies = new ICompilationUnit[1];
1003
	
1004
	this.workingCopies[0] = getWorkingCopy(
1005
			"/Converter15/src/a/AnAnnotation.java",
1006
			"package a;\n" +
1007
			"public @interface AnAnnotation {\n" +
1008
			"  String value();\n" +
1009
			"}\n",
1010
			true/*resolve*/);
1011
	
1012
	ASTResult result = this.buildMarkedAST(
1013
			"/Converter15/src/a/X.java",
1014
			"package a;\n" +
1015
			"[*1*]@AnAnnotation([*2*]\"a\"[*2*][*1*], [*3*]\"b\"[*3*])\n" +
1016
			"public class X {\n" +
1017
			"}\n");
1018
	
1019
	assertASTResult(
1020
			"===== AST =====\n" + 
1021
			"package a;\n" + 
1022
			"[*1*]@AnAnnotation([*2*]\"a\"[*2*])[*1*] public class X {\n" + 
1023
			"}\n" + 
1024
			"\n" + 
1025
			"===== Details =====\n" + 
1026
			"1:SINGLE_MEMBER_ANNOTATION,[11,17],,RECOVERED,[ANNOTATION,La/X;@La/AnAnnotation;,]\n" + 
1027
			"2:STRING_LITERAL,[25,3],,,[N/A]\n" + 
1028
			"3:No corresponding node\n" + 
1029
			"===== Problems =====\n" + 
1030
			"1. ERROR in /Converter15/src/a/X.java (at line 2)\n" + 
1031
			"	@AnAnnotation(\"a\", \"b\")\n" + 
1032
			"	                 ^\n" + 
1033
			"Syntax error on token \",\", < expected\n",
1034
			result);
1035
}
36
}
1036
}
(-)src/org/eclipse/jdt/core/tests/dom/MarkedASTFlattener.java (-10 / +28 lines)
Lines 462-468 Link Here
462
	private final static String DETAILS_DELIMITER = "===== Details =====";
462
	private final static String DETAILS_DELIMITER = "===== Details =====";
463
	private final static String PROBLEMS_DELIMITER = "===== Problems =====";
463
	private final static String PROBLEMS_DELIMITER = "===== Problems =====";
464
	
464
	
465
	private final static String NO_PROBLEM = "No Problem";
465
	private final static String NO_PROBLEM = "No problem";
466
	private static final String NO_CORRESPONDING_NODE = "No corresponding node";
466
	
467
	
467
	// options
468
	// options
468
	private boolean reportAST;
469
	private boolean reportAST;
Lines 475-481 Link Here
475
	private Map markerFromNode;
476
	private Map markerFromNode;
476
	private Map nodeFromMarker;
477
	private Map nodeFromMarker;
477
	private Map markerPositonInBuffer;
478
	private Map markerPositonInBuffer;
478
479
	
480
	private boolean[] foundNodeFromMarker;
479
	private StringBuffer markedNodesBuffer;
481
	private StringBuffer markedNodesBuffer;
480
	
482
	
481
	private MarkedNodeLabelProvider labelProvider;
483
	private MarkedNodeLabelProvider labelProvider;
Lines 542-555 Link Here
542
	}
544
	}
543
	public void preVisit(ASTNode node) {
545
	public void preVisit(ASTNode node) {
544
		String markerName = null;
546
		String markerName = null;
545
		int index = markerInfo.indexOfASTStart(node.getStartPosition());
547
		int index = -1;
546
		if (index != -1 && node.getStartPosition() + node.getLength() == markerInfo.astEnds[index]) {
548
		found : while ((index = markerInfo.indexOfASTStart(node.getStartPosition(), index + 1)) != -1) {
547
			markerName = String.valueOf(index + 1);
549
			if (node.getStartPosition() + node.getLength() == markerInfo.astEnds[index]) {
548
			
550
				markerName = String.valueOf(index + 1);
549
			if (this.nodeFromMarker.get(markerName) == null) {
551
				
550
				this.markerFromNode.put(node, markerName);
552
				if (this.nodeFromMarker.get(markerName) == null) {
551
				this.nodeFromMarker.put(markerName, node);
553
					this.markerFromNode.put(node, markerName);
552
				this.markerPositonInBuffer.put(markerName, new Integer(this.buffer.length()));
554
					this.nodeFromMarker.put(markerName, node);
555
					this.markerPositonInBuffer.put(markerName, new Integer(this.buffer.length()));
556
					this.foundNodeFromMarker[index] = true;
557
				}
558
				
559
				break found;
553
			}
560
			}
554
		}
561
		}
555
		
562
		
Lines 569-574 Link Here
569
		this.markerFromNode = new HashMap();
576
		this.markerFromNode = new HashMap();
570
		this.nodeFromMarker = new HashMap();
577
		this.nodeFromMarker = new HashMap();
571
		this.markerPositonInBuffer = new HashMap();
578
		this.markerPositonInBuffer = new HashMap();
579
		int length = mf.astStarts.length;
580
		this.foundNodeFromMarker = new boolean[length];
572
		this.unit.accept(this);
581
		this.unit.accept(this);
582
		
583
		for (int i = 0; i < length; i++) {
584
			if (!this.foundNodeFromMarker[i]) {
585
				this.markedNodesBuffer.append('\n');
586
				this.markedNodesBuffer.append(String.valueOf(i + 1));
587
				this.markedNodesBuffer.append(':');
588
				this.markedNodesBuffer.append(NO_CORRESPONDING_NODE);
589
			}
590
		}
573
	}
591
	}
574
}
592
}
(-)src/org/eclipse/jdt/core/tests/dom/AbstractASTTests.java (-1 / +5 lines)
Lines 129-135 Link Here
129
		}
129
		}
130
		
130
		
131
		public int indexOfASTStart(int astStart) {
131
		public int indexOfASTStart(int astStart) {
132
			for (int i = 0, length = this.astStarts.length; i < length; i++)
132
			return this.indexOfASTStart(astStart, 0);
133
		}
134
		
135
		public int indexOfASTStart(int astStart, int fromIndex) {
136
			for (int i = fromIndex, length = this.astStarts.length; i < length; i++)
133
				if (this.astStarts[i] == astStart)
137
				if (this.astStarts[i] == astStart)
134
					return i;
138
					return i;
135
			return -1;
139
			return -1;
(-)src/org/eclipse/jdt/core/tests/dom/ASTConverterBugsTest.java (-4 / +1 lines)
Lines 537-545 Link Here
537
	);
537
	);
538
}
538
}
539
539
540
/*
541
 * https://bugs.eclipse.org/bugs/show_bug.cgi?id=215759
542
 */
543
/**
540
/**
544
 * @bug 215759: DOM AST regression tests should be improved
541
 * @bug 215759: DOM AST regression tests should be improved
545
 * @test these tests test the new DOM AST test framework
542
 * @test these tests test the new DOM AST test framework
Lines 652-658 Link Here
652
			"4:METHOD_DECLARATION,[176,23],[165,34],,[METHOD,Lp/X;.bar()V,]\n" + 
649
			"4:METHOD_DECLARATION,[176,23],[165,34],,[METHOD,Lp/X;.bar()V,]\n" + 
653
			"5:METHOD_DECLARATION,[201,40],,,[METHOD,Lp/X;.bar2()V,DEPRECATED]\n" + 
650
			"5:METHOD_DECLARATION,[201,40],,,[METHOD,Lp/X;.bar2()V,DEPRECATED]\n" + 
654
			"===== Problems =====\n" + 
651
			"===== Problems =====\n" + 
655
			"No Problem",
652
			"No problem",
656
			result);
653
			result);
657
}
654
}
658
}
655
}

Return to bug 130778