View | Details | Raw Unified | Return to bug 133491 | Differences between
and this patch

Collapse All | Expand All

(-)model/org/eclipse/jdt/internal/core/SourceAnnotationMethodInfo.java (-9 / +2 lines)
Lines 10-17 Link Here
10
 *******************************************************************************/
10
 *******************************************************************************/
11
package org.eclipse.jdt.internal.core;
11
package org.eclipse.jdt.internal.core;
12
12
13
import org.eclipse.jdt.core.compiler.CharOperation;
14
15
/*
13
/*
16
 * Element info for annotation method from source.
14
 * Element info for annotation method from source.
17
 */
15
 */
Lines 22-37 Link Here
22
	 * These are {-1, -1} if the method is an annotation method with no default value.
20
	 * These are {-1, -1} if the method is an annotation method with no default value.
23
	 * Otherwise these are the start and end (inclusive) of the expression representing the default value.
21
	 * Otherwise these are the start and end (inclusive) of the expression representing the default value.
24
	 */
22
	 */
25
	protected int defaultValueStart;
23
 public int defaultValueStart;
26
	protected int defaultValueEnd;
24
 public int defaultValueEnd;
27
25
28
	public boolean isAnnotationMethod() {
26
	public boolean isAnnotationMethod() {
29
		return true;
27
		return true;
30
	}
28
	}
31
	
29
	
32
	public char[] getDefaultValueSource(char[] cuSource) {
33
		if (this.defaultValueStart == -1 && this.defaultValueEnd == -1) 
34
			return null;
35
		return CharOperation.subarray(cuSource, this.defaultValueStart, this.defaultValueEnd+1);
36
	}
37
}
30
}
(-)codeassist/org/eclipse/jdt/internal/codeassist/SelectionEngine.java (-5 lines)
Lines 532-542 Link Here
532
	public AssistParser getParser() {
532
	public AssistParser getParser() {
533
		return this.parser;
533
		return this.parser;
534
	}
534
	}
535
	
536
	protected int getSourceTypeConverterFlag() {
537
		return SourceTypeConverter.FIELD_AND_METHOD // need field and methods
538
				| SourceTypeConverter.MEMBER_TYPE; // need member types
539
	}
540
535
541
	/*
536
	/*
542
	 * Returns whether the given binding is a local/anonymous reference binding, or if its declaring class is
537
	 * Returns whether the given binding is a local/anonymous reference binding, or if its declaring class is
(-)codeassist/org/eclipse/jdt/internal/codeassist/CompletionEngine.java (-8 / +1 lines)
Lines 254-260 Link Here
254
			Map settings,
254
			Map settings,
255
			IJavaProject javaProject) {
255
			IJavaProject javaProject) {
256
		super(settings);
256
		super(settings);
257
		this.compilerOptions.storeAnnotations = true;
258
		this.javaProject = javaProject;
257
		this.javaProject = javaProject;
259
		this.requestor = requestor;
258
		this.requestor = requestor;
260
		this.nameEnvironment = nameEnvironment;
259
		this.nameEnvironment = nameEnvironment;
Lines 5873-5884 Link Here
5873
5872
5874
		return this.parser;
5873
		return this.parser;
5875
	}
5874
	}
5876
	
5877
	protected int getSourceTypeConverterFlag() {
5878
		return SourceTypeConverter.FIELD_AND_METHOD // need field and methods
5879
				| SourceTypeConverter.MEMBER_TYPE // need member types
5880
				| SourceTypeConverter.FIELD_INITIALIZATION; // need field initializer for annotations default value 
5881
	}
5882
5875
5883
	protected void reset() {
5876
	protected void reset() {
5884
5877
Lines 6104-6110 Link Here
6104
							CharOperation.equals(methodBindings[0].selector, VALUE)) {
6097
							CharOperation.equals(methodBindings[0].selector, VALUE)) {
6105
						boolean canBeSingleMemberAnnotation = true;
6098
						boolean canBeSingleMemberAnnotation = true;
6106
						done : for (int i = 1; i < methodBindings.length; i++) {
6099
						done : for (int i = 1; i < methodBindings.length; i++) {
6107
							if(methodBindings[i].getDefaultValue() == null) {
6100
							if((methodBindings[i].modifiers & ClassFileConstants.AccAnnotationDefault) == 0) {
6108
								canBeSingleMemberAnnotation = false;
6101
								canBeSingleMemberAnnotation = false;
6109
								break done;
6102
								break done;
6110
							}
6103
							}
(-)codeassist/org/eclipse/jdt/internal/codeassist/impl/Engine.java (-3 / +3 lines)
Lines 82-88 Link Here
82
		CompilationUnitDeclaration unit =
82
		CompilationUnitDeclaration unit =
83
			SourceTypeConverter.buildCompilationUnit(
83
			SourceTypeConverter.buildCompilationUnit(
84
				sourceTypes,//sourceTypes[0] is always toplevel here
84
				sourceTypes,//sourceTypes[0] is always toplevel here
85
				getSourceTypeConverterFlag(),
85
				SourceTypeConverter.FIELD_AND_METHOD // need field and methods
86
				| SourceTypeConverter.MEMBER_TYPE, // need member types
87
				// no need for field initialization
86
				lookupEnvironment.problemReporter,
88
				lookupEnvironment.problemReporter,
87
				result);
89
				result);
88
90
Lines 94-101 Link Here
94
96
95
	public abstract AssistParser getParser();
97
	public abstract AssistParser getParser();
96
	
98
	
97
	protected abstract int getSourceTypeConverterFlag();
98
	
99
	public void initializeImportCaches() {
99
	public void initializeImportCaches() {
100
		ImportBinding[] importBindings = this.unitScope.imports;
100
		ImportBinding[] importBindings = this.unitScope.imports;
101
		int length = importBindings == null ? 0 : importBindings.length;
101
		int length = importBindings == null ? 0 : importBindings.length;
(-)model/org/eclipse/jdt/internal/compiler/parser/SourceTypeConverter.java (-3 / +6 lines)
Lines 308-323 Link Here
308
				AnnotationMethodDeclaration annotationMethodDeclaration = new AnnotationMethodDeclaration(compilationResult);
308
				AnnotationMethodDeclaration annotationMethodDeclaration = new AnnotationMethodDeclaration(compilationResult);
309
309
310
				/* conversion of default value */
310
				/* conversion of default value */
311
				SourceAnnotationMethodInfo annotationMethodInfo = (SourceAnnotationMethodInfo) methodInfo;
312
				boolean hasDefaultValue = annotationMethodInfo.defaultValueStart != -1 || annotationMethodInfo.defaultValueEnd != -1;
311
				if ((this.flags & FIELD_INITIALIZATION) != 0) {
313
				if ((this.flags & FIELD_INITIALIZATION) != 0) {
312
					char[] defaultValueSource = ((SourceAnnotationMethodInfo) methodInfo).getDefaultValueSource(getSource());
314
					if (hasDefaultValue) {
313
					if (defaultValueSource != null) {
315
						char[] defaultValueSource = CharOperation.subarray(getSource(), annotationMethodInfo.defaultValueStart, annotationMethodInfo.defaultValueEnd+1);
314
						Expression expression =  parseMemberValue(defaultValueSource);
316
						Expression expression =  parseMemberValue(defaultValueSource);
315
						if (expression != null) {
317
						if (expression != null) {
316
							annotationMethodDeclaration.defaultValue = expression;
318
							annotationMethodDeclaration.defaultValue = expression;
317
							modifiers |= ClassFileConstants.AccAnnotationDefault;
318
						}
319
						}
319
					}
320
					}
320
				}
321
				}
322
				if (hasDefaultValue)
323
					modifiers |= ClassFileConstants.AccAnnotationDefault;
321
				decl = annotationMethodDeclaration;
324
				decl = annotationMethodDeclaration;
322
			} else {
325
			} else {
323
				decl = new MethodDeclaration(compilationResult);
326
				decl = new MethodDeclaration(compilationResult);

Return to bug 133491