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

Collapse All | Expand All

(-)model/org/eclipse/jdt/core/IMethod.java (-1 / +13 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2010 IBM Corporation and others.
2
 * Copyright (c) 2000, 2011 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 100-105 Link Here
100
 * @return the number of parameters of this method
100
 * @return the number of parameters of this method
101
 */
101
 */
102
int getNumberOfParameters();
102
int getNumberOfParameters();
103
104
/**
105
 * Returns a two-dimensional array of annotations for this method's parameters.
106
 * <p>An empty array is returned, if the method has no parameters.</p>
107
 * <p>If a specific parameter has no annotations, an empty array is returned.</p>
108
 * 
109
 * @return the array of annotations for the specified parameter
110
 * @throws JavaModelException
111
 * @since 3.7
112
 */
113
IAnnotation[][] getParameterAnnotations() throws JavaModelException;
114
103
/**
115
/**
104
 * Returns the binding key for this method only if the given method is {@link #isResolved() resolved}.
116
 * Returns the binding key for this method only if the given method is {@link #isResolved() resolved}.
105
 * A binding key is a key that uniquely identifies this method. It allows access
117
 * A binding key is a key that uniquely identifies this method. It allows access
(-)model/org/eclipse/jdt/internal/core/Annotation.java (-1 / +18 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2009 IBM Corporation and others.
2
 * Copyright (c) 2000, 2011 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 17-22 Link Here
17
import org.eclipse.jdt.core.ISourceRange;
17
import org.eclipse.jdt.core.ISourceRange;
18
import org.eclipse.jdt.core.JavaModelException;
18
import org.eclipse.jdt.core.JavaModelException;
19
import org.eclipse.jdt.core.SourceRange;
19
import org.eclipse.jdt.core.SourceRange;
20
import org.eclipse.jdt.core.compiler.CharOperation;
20
import org.eclipse.jdt.internal.compiler.env.IBinaryAnnotation;
21
import org.eclipse.jdt.internal.compiler.env.IBinaryAnnotation;
21
import org.eclipse.jdt.internal.compiler.env.IBinaryElementValuePair;
22
import org.eclipse.jdt.internal.compiler.env.IBinaryElementValuePair;
22
import org.eclipse.jdt.internal.core.util.Util;
23
import org.eclipse.jdt.internal.core.util.Util;
Lines 24-42 Link Here
24
public class Annotation extends SourceRefElement implements IAnnotation {
25
public class Annotation extends SourceRefElement implements IAnnotation {
25
26
26
	public static final IAnnotation[] NO_ANNOTATIONS = new IAnnotation[0];
27
	public static final IAnnotation[] NO_ANNOTATIONS = new IAnnotation[0];
28
	public static final IAnnotation[][] NO_PARAMETER_ANNOTATIONS = new IAnnotation[0][0];
27
	public static final IMemberValuePair[] NO_MEMBER_VALUE_PAIRS = new IMemberValuePair[0];
29
	public static final IMemberValuePair[] NO_MEMBER_VALUE_PAIRS = new IMemberValuePair[0];
28
30
29
	protected String name;
31
	protected String name;
30
	// require to distinguish same annotations in different member value pairs
32
	// require to distinguish same annotations in different member value pairs
31
	protected String memberValuePairName;
33
	protected String memberValuePairName;
32
34
35
	protected char[] argumentName;
36
33
	public Annotation(JavaElement parent, String name) {
37
	public Annotation(JavaElement parent, String name) {
34
		this(parent, name, null);
38
		this(parent, name, null);
35
	}
39
	}
36
40
37
	public Annotation(JavaElement parent, String name, String memberValuePairName) {
41
	public Annotation(JavaElement parent, String name, String memberValuePairName) {
42
		this(parent, null, name, memberValuePairName);
43
	}
44
45
	public Annotation(JavaElement parent, char[] argumentName, String name, String memberValuePairName) {
38
		super(parent);
46
		super(parent);
39
		this.name = name;
47
		this.name = name;
48
		this.argumentName = argumentName;
40
		this.memberValuePairName = memberValuePairName;
49
		this.memberValuePairName = memberValuePairName;
41
	}
50
	}
42
51
Lines 45-50 Link Here
45
			return false;
54
			return false;
46
		}
55
		}
47
		Annotation other = (Annotation) o;
56
		Annotation other = (Annotation) o;
57
		if (this.argumentName == null) {
58
			if (other.argumentName != null) {
59
				return false;
60
			}
61
		} else if (!CharOperation.equals(this.argumentName, other.argumentName)) {
62
			return false;
63
		}
48
		if (this.memberValuePairName == null) {
64
		if (this.memberValuePairName == null) {
49
			if (other.memberValuePairName != null)
65
			if (other.memberValuePairName != null)
50
				return false;
66
				return false;
Lines 129-134 Link Here
129
		final int prime = 31;
145
		final int prime = 31;
130
		int result = super.hashCode();
146
		int result = super.hashCode();
131
		result = prime * result + ((this.memberValuePairName == null) ? 0 : this.memberValuePairName.hashCode());
147
		result = prime * result + ((this.memberValuePairName == null) ? 0 : this.memberValuePairName.hashCode());
148
		result = prime * result + ((this.argumentName == null) ? 0 : CharOperation.hashCode(this.argumentName));
132
		result = prime * result + this.name.hashCode();
149
		result = prime * result + this.name.hashCode();
133
		return result;
150
		return result;
134
	}
151
	}
(-)model/org/eclipse/jdt/internal/core/BinaryMember.java (-4 / +8 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2009 IBM Corporation and others.
2
 * Copyright (c) 2000, 2011 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 47-55 Link Here
47
		return standardAnnotations;
47
		return standardAnnotations;
48
	int length = binaryAnnotations.length;
48
	int length = binaryAnnotations.length;
49
	int standardLength = standardAnnotations.length;
49
	int standardLength = standardAnnotations.length;
50
	IAnnotation[] annotations = new IAnnotation[length + standardLength];
50
	int fullLength = length + standardLength;
51
	if (fullLength == 0) {
52
		return Annotation.NO_ANNOTATIONS;
53
	}
54
	IAnnotation[] annotations = new IAnnotation[fullLength];
51
	for (int i = 0; i < length; i++) {
55
	for (int i = 0; i < length; i++) {
52
		annotations[i] = Util.getAnnotation(this, binaryAnnotations[i], null);
56
		annotations[i] = Util.getAnnotation(this, null, binaryAnnotations[i], null);
53
	}
57
	}
54
	System.arraycopy(standardAnnotations, 0, annotations, length, standardLength);
58
	System.arraycopy(standardAnnotations, 0, annotations, length, standardLength);
55
	return annotations;
59
	return annotations;
Lines 57-63 Link Here
57
private IAnnotation getAnnotation(char[][] annotationName) {
61
private IAnnotation getAnnotation(char[][] annotationName) {
58
	return new Annotation(this, new String(CharOperation.concatWith(annotationName, '.')));
62
	return new Annotation(this, new String(CharOperation.concatWith(annotationName, '.')));
59
}
63
}
60
private IAnnotation[] getStandardAnnotations(long tagBits) {
64
protected IAnnotation[] getStandardAnnotations(long tagBits) {
61
	if ((tagBits & TagBits.AllStandardAnnotationsMask) == 0)
65
	if ((tagBits & TagBits.AllStandardAnnotationsMask) == 0)
62
		return Annotation.NO_ANNOTATIONS;
66
		return Annotation.NO_ANNOTATIONS;
63
	ArrayList annotations = new ArrayList();
67
	ArrayList annotations = new ArrayList();
(-)model/org/eclipse/jdt/internal/core/BinaryMethod.java (-1 / +44 lines)
Lines 11-17 Link Here
11
package org.eclipse.jdt.internal.core;
11
package org.eclipse.jdt.internal.core;
12
12
13
import org.eclipse.core.runtime.IProgressMonitor;
13
import org.eclipse.core.runtime.IProgressMonitor;
14
import org.eclipse.jdt.core.*;
14
import org.eclipse.jdt.core.Flags;
15
import org.eclipse.jdt.core.IAnnotation;
16
import org.eclipse.jdt.core.IMemberValuePair;
17
import org.eclipse.jdt.core.IMethod;
18
import org.eclipse.jdt.core.IType;
19
import org.eclipse.jdt.core.ITypeParameter;
20
import org.eclipse.jdt.core.JavaCore;
21
import org.eclipse.jdt.core.JavaModelException;
22
import org.eclipse.jdt.core.Signature;
15
import org.eclipse.jdt.core.compiler.CharOperation;
23
import org.eclipse.jdt.core.compiler.CharOperation;
16
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
24
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
17
import org.eclipse.jdt.internal.compiler.env.IBinaryAnnotation;
25
import org.eclipse.jdt.internal.compiler.env.IBinaryAnnotation;
Lines 61-66 Link Here
61
	IBinaryAnnotation[] binaryAnnotations = info.getAnnotations();
69
	IBinaryAnnotation[] binaryAnnotations = info.getAnnotations();
62
	return getAnnotations(binaryAnnotations, info.getTagBits());
70
	return getAnnotations(binaryAnnotations, info.getTagBits());
63
}
71
}
72
/**
73
 * @see IMethod#getParameterAnnotations()
74
 */
75
public IAnnotation[][] getParameterAnnotations() throws JavaModelException {
76
	IBinaryMethod info = (IBinaryMethod) getElementInfo();
77
	int length = this.parameterTypes.length;
78
	if (length == 0) {
79
		return Annotation.NO_PARAMETER_ANNOTATIONS;
80
	}
81
	IAnnotation[][] annotations = new IAnnotation[length][];
82
	char[][] argumentNames = info.getArgumentNames();
83
	if (argumentNames == null || argumentNames.length < length) {
84
		argumentNames = new char[length][];
85
		for (int j = 0; j < length; j++) {
86
			argumentNames[j] = ("arg" + j).toCharArray(); //$NON-NLS-1$
87
		}
88
	}
89
	for (int i= 0; i < length; i++) {
90
		annotations[i] = getAnnotations(argumentNames[i], info.getParameterAnnotations(i), info.getTagBits());
91
	}
92
	return annotations;
93
}
94
private IAnnotation[] getAnnotations(char[] argumentName, IBinaryAnnotation[] binaryAnnotations, long tagBits) {
95
	IAnnotation[] standardAnnotations = getStandardAnnotations(tagBits);
96
	if (binaryAnnotations == null)
97
		return standardAnnotations;
98
	int length = binaryAnnotations.length;
99
	int standardLength = standardAnnotations.length;
100
	IAnnotation[] annotations = new IAnnotation[length + standardLength];
101
	for (int i = 0; i < length; i++) {
102
		annotations[i] = Util.getAnnotation(this, argumentName, binaryAnnotations[i], null);
103
	}
104
	System.arraycopy(standardAnnotations, 0, annotations, length, standardLength);
105
	return annotations;
106
}
64
public IMemberValuePair getDefaultValue() throws JavaModelException {
107
public IMemberValuePair getDefaultValue() throws JavaModelException {
65
	IBinaryMethod info = (IBinaryMethod) getElementInfo();
108
	IBinaryMethod info = (IBinaryMethod) getElementInfo();
66
	Object defaultValue = info.getDefaultValue();
109
	Object defaultValue = info.getDefaultValue();
(-)model/org/eclipse/jdt/internal/core/ClassFileInfo.java (-11 / +28 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2010 IBM Corporation and others.
2
 * Copyright (c) 2000, 2011 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 41-65 Link Here
41
	 */
41
	 */
42
	protected ITypeParameter[] typeParameters;
42
	protected ITypeParameter[] typeParameters;
43
43
44
private void generateAnnotationsInfos(BinaryMember member, IBinaryAnnotation[] binaryAnnotations, long tagBits, HashMap newElements) {
45
	generateAnnotationsInfos(member, null, binaryAnnotations, tagBits, newElements);
46
}
44
/**
47
/**
45
 * Creates the handles and infos for the annotations of the given binary member.
48
 * Creates the handles and infos for the annotations of the given binary member.
46
 * Adds new handles to the given vector.
49
 * Adds new handles to the given vector.
47
 */
50
 */
48
private void generateAnnotationsInfos(BinaryMember member, IBinaryAnnotation[] binaryAnnotations, long tagBits, HashMap newElements) {
51
private void generateAnnotationsInfos(BinaryMember member, char[] parameterName, IBinaryAnnotation[] binaryAnnotations, long tagBits, HashMap newElements) {
49
	if (binaryAnnotations != null) {
52
	if (binaryAnnotations != null) {
50
		for (int i = 0, length = binaryAnnotations.length; i < length; i++) {
53
		for (int i = 0, length = binaryAnnotations.length; i < length; i++) {
51
			IBinaryAnnotation annotationInfo = binaryAnnotations[i];
54
			IBinaryAnnotation annotationInfo = binaryAnnotations[i];
52
			generateAnnotationInfo(member, newElements, annotationInfo);
55
			generateAnnotationInfo(member, parameterName, newElements, annotationInfo, null);
53
		}
56
		}
54
	}
57
	}
55
	generateStandardAnnotationsInfos(member, tagBits, newElements);
58
	generateStandardAnnotationsInfos(member, parameterName, tagBits, newElements);
56
}
57
private void generateAnnotationInfo(JavaElement parent, HashMap newElements, IBinaryAnnotation annotationInfo) {
58
	generateAnnotationInfo(parent, newElements, annotationInfo, null);
59
}
59
}
60
private void generateAnnotationInfo(JavaElement parent, HashMap newElements, IBinaryAnnotation annotationInfo, String memberValuePairName) {
60
private void generateAnnotationInfo(JavaElement parent, HashMap newElements, IBinaryAnnotation annotationInfo, String memberValuePairName) {
61
	generateAnnotationInfo(parent, null, newElements, annotationInfo, memberValuePairName);
62
}
63
private void generateAnnotationInfo(JavaElement parent, char[] parameterName, HashMap newElements, IBinaryAnnotation annotationInfo, String memberValuePairName) {
61
	char[] typeName = org.eclipse.jdt.core.Signature.toCharArray(CharOperation.replaceOnCopy(annotationInfo.getTypeName(), '/', '.'));
64
	char[] typeName = org.eclipse.jdt.core.Signature.toCharArray(CharOperation.replaceOnCopy(annotationInfo.getTypeName(), '/', '.'));
62
	Annotation annotation = new Annotation(parent, new String(typeName), memberValuePairName);
65
	Annotation annotation = new Annotation(parent, parameterName, new String(typeName), memberValuePairName);
63
	while (newElements.containsKey(annotation)) {
66
	while (newElements.containsKey(annotation)) {
64
		annotation.occurrenceCount++;
67
		annotation.occurrenceCount++;
65
	}
68
	}
Lines 81-87 Link Here
81
		}
84
		}
82
	}
85
	}
83
}
86
}
84
private void generateStandardAnnotationsInfos(BinaryMember member, long tagBits, HashMap newElements) {
87
private void generateStandardAnnotationsInfos(BinaryMember member, char[] parameterName, long tagBits, HashMap newElements) {
85
	if ((tagBits & TagBits.AllStandardAnnotationsMask) == 0)
88
	if ((tagBits & TagBits.AllStandardAnnotationsMask) == 0)
86
		return;
89
		return;
87
	if ((tagBits & TagBits.AnnotationTargetMASK) != 0) {
90
	if ((tagBits & TagBits.AnnotationTargetMASK) != 0) {
Lines 268-274 Link Here
268
				final String[] parameterTypes = Signature.getParameterTypes(new String(descriptor));
271
				final String[] parameterTypes = Signature.getParameterTypes(new String(descriptor));
269
				pNames[0] = parameterTypes[0];
272
				pNames[0] = parameterTypes[0];
270
			}
273
			}
271
		}catch (IllegalArgumentException e) {
274
		} catch (IllegalArgumentException e) {
272
			// protect against malformed .class file (e.g. com/sun/crypto/provider/SunJCE_b.class has a 'a' generic signature)
275
			// protect against malformed .class file (e.g. com/sun/crypto/provider/SunJCE_b.class has a 'a' generic signature)
273
			signature = methodInfo.getMethodDescriptor();
276
			signature = methodInfo.getMethodDescriptor();
274
			pNames = Signature.getParameterTypes(new String(signature));
277
			pNames = Signature.getParameterTypes(new String(signature));
Lines 290-302 Link Here
290
		BinaryMethod method = new BinaryMethod((JavaElement)type, selector, pNames);
293
		BinaryMethod method = new BinaryMethod((JavaElement)type, selector, pNames);
291
		childrenHandles.add(method);
294
		childrenHandles.add(method);
292
295
293
		// ensure that 2 binary methods with the same signature but with different return types have different occurence counts.
296
		// ensure that 2 binary methods with the same signature but with different return types have different occurrence counts.
294
		// (case of bridge methods in 1.5)
297
		// (case of bridge methods in 1.5)
295
		while (newElements.containsKey(method))
298
		while (newElements.containsKey(method))
296
			method.occurrenceCount++;
299
			method.occurrenceCount++;
297
300
298
		newElements.put(method, methodInfo);
301
		newElements.put(method, methodInfo);
299
302
303
		int max = pNames.length;
304
		char[][] argumentNames = methodInfo.getArgumentNames();
305
		if (argumentNames == null || argumentNames.length < max) {
306
			argumentNames = new char[max][];
307
			for (int j = 0; j < max; j++) {
308
				argumentNames[j] = ("arg" + j).toCharArray(); //$NON-NLS-1$
309
			}
310
		}
311
		for (int j = 0; j < max; j++) {
312
			IBinaryAnnotation[] parameterAnnotations = methodInfo.getParameterAnnotations(j);
313
			if (parameterAnnotations != null) {
314
				generateAnnotationsInfos(method, argumentNames[j], parameterAnnotations, methodInfo.getTagBits(), newElements);
315
			}
316
		}
300
		generateTypeParameterInfos(method, signature, newElements, typeParameterHandles);
317
		generateTypeParameterInfos(method, signature, newElements, typeParameterHandles);
301
		generateAnnotationsInfos(method, methodInfo.getAnnotations(), methodInfo.getTagBits(), newElements);
318
		generateAnnotationsInfos(method, methodInfo.getAnnotations(), methodInfo.getTagBits(), newElements);
302
		Object defaultValue = methodInfo.getDefaultValue();
319
		Object defaultValue = methodInfo.getDefaultValue();
(-)model/org/eclipse/jdt/internal/core/CompilationUnitStructureRequestor.java (-3 / +55 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2010 IBM Corporation and others.
2
 * Copyright (c) 2000, 2011 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 17-27 Link Here
17
import java.util.Stack;
17
import java.util.Stack;
18
18
19
import org.eclipse.core.runtime.Assert;
19
import org.eclipse.core.runtime.Assert;
20
import org.eclipse.jdt.core.*;
20
import org.eclipse.jdt.core.Flags;
21
import org.eclipse.jdt.core.IAnnotation;
22
import org.eclipse.jdt.core.ICompilationUnit;
23
import org.eclipse.jdt.core.IJavaElement;
24
import org.eclipse.jdt.core.IMemberValuePair;
25
import org.eclipse.jdt.core.ITypeParameter;
26
import org.eclipse.jdt.core.Signature;
21
import org.eclipse.jdt.core.compiler.CategorizedProblem;
27
import org.eclipse.jdt.core.compiler.CategorizedProblem;
22
import org.eclipse.jdt.core.compiler.CharOperation;
28
import org.eclipse.jdt.core.compiler.CharOperation;
23
import org.eclipse.jdt.core.compiler.IProblem;
29
import org.eclipse.jdt.core.compiler.IProblem;
24
import org.eclipse.jdt.internal.compiler.ISourceElementRequestor;
30
import org.eclipse.jdt.internal.compiler.ISourceElementRequestor;
31
import org.eclipse.jdt.internal.compiler.ast.ASTNode;
32
import org.eclipse.jdt.internal.compiler.ast.Argument;
25
import org.eclipse.jdt.internal.compiler.ast.ArrayInitializer;
33
import org.eclipse.jdt.internal.compiler.ast.ArrayInitializer;
26
import org.eclipse.jdt.internal.compiler.ast.ClassLiteralAccess;
34
import org.eclipse.jdt.internal.compiler.ast.ClassLiteralAccess;
27
import org.eclipse.jdt.internal.compiler.ast.Expression;
35
import org.eclipse.jdt.internal.compiler.ast.Expression;
Lines 39-45 Link Here
39
import org.eclipse.jdt.internal.compiler.util.HashtableOfObjectToInt;
47
import org.eclipse.jdt.internal.compiler.util.HashtableOfObjectToInt;
40
import org.eclipse.jdt.internal.core.util.ReferenceInfoAdapter;
48
import org.eclipse.jdt.internal.core.util.ReferenceInfoAdapter;
41
import org.eclipse.jdt.internal.core.util.Util;
49
import org.eclipse.jdt.internal.core.util.Util;
42
import org.eclipse.jdt.internal.compiler.ast.ASTNode;
43
/**
50
/**
44
 * A requestor for the fuzzy parser, used to compute the children of an ICompilationUnit.
51
 * A requestor for the fuzzy parser, used to compute the children of an ICompilationUnit.
45
 */
52
 */
Lines 427-434 Link Here
427
			acceptAnnotation(annotation, info, handle);
434
			acceptAnnotation(annotation, info, handle);
428
		}
435
		}
429
	}
436
	}
437
	// https://bugs.eclipse.org/bugs/show_bug.cgi?id=334783
438
	// Process the parameter annotations from the arguments
439
	if (methodInfo.node != null && methodInfo.node.arguments != null) {
440
		info.arguments = acceptMethodParameters(methodInfo.node.arguments, handle, methodInfo);
441
	}
430
	return info;
442
	return info;
431
}
443
}
444
private LocalVariable[] acceptMethodParameters(Argument[] arguments, JavaElement methodHandle, MethodInfo methodInfo) {
445
	if (arguments == null) return null;
446
	LocalVariable[] result = new LocalVariable[arguments.length];
447
	Annotation[][] paramAnnotations = new Annotation[arguments.length][];
448
	for(int i = 0; i < arguments.length; i++) {
449
		Argument argument = arguments[i];
450
		AnnotatableInfo localVarInfo = new AnnotatableInfo();
451
		localVarInfo.setSourceRangeStart(argument.declarationSourceStart);
452
		localVarInfo.setSourceRangeEnd(argument.declarationSourceStart);
453
		localVarInfo.setNameSourceStart(argument.sourceStart);
454
		localVarInfo.setNameSourceEnd(argument.sourceEnd);
455
		
456
		String paramTypeSig = JavaModelManager.getJavaModelManager().intern(Signature.createTypeSignature(methodInfo.parameterTypes[i], false));
457
		result[i] = new LocalVariable(
458
				methodHandle,
459
				new String(argument.name),
460
				argument.declarationSourceStart,
461
				argument. declarationSourceEnd,
462
				argument.sourceStart,
463
				argument.sourceEnd,
464
				paramTypeSig,
465
				argument.annotations,
466
				argument.modifiers, 
467
				true);
468
		this.newElements.put(result[i], localVarInfo);
469
		this.infoStack.push(localVarInfo);
470
		this.handleStack.push(result[i]);
471
		if (argument.annotations != null) {
472
			paramAnnotations[i] = new Annotation[argument.annotations.length];
473
			for (int  j = 0; j < argument.annotations.length; j++ ) {
474
				org.eclipse.jdt.internal.compiler.ast.Annotation annotation = argument.annotations[j];
475
				acceptAnnotation(annotation, localVarInfo, result[i]);
476
			}
477
		}
478
		this.infoStack.pop();
479
		this.handleStack.pop();
480
	}
481
	return result;
482
}
483
432
/**
484
/**
433
 * @see ISourceElementRequestor
485
 * @see ISourceElementRequestor
434
 */
486
 */
(-)model/org/eclipse/jdt/internal/core/SourceMethod.java (-1 / +16 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2008 IBM Corporation and others.
2
 * Copyright (c) 2000, 2011 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 135-140 Link Here
135
	return info.typeParameters;
135
	return info.typeParameters;
136
}
136
}
137
137
138
public IAnnotation[][] getParameterAnnotations() throws JavaModelException {
139
	ILocalVariable[] arguments = ((SourceMethodElementInfo) getElementInfo()).arguments;
140
	if (arguments == null)
141
		return Annotation.NO_PARAMETER_ANNOTATIONS;
142
	IAnnotation[][] annotations = new IAnnotation[arguments.length][];
143
	for (int i=0; i <arguments.length; i++) {
144
		LocalVariable argument = (LocalVariable) arguments[i];
145
		annotations[i] = new Annotation[argument.annotations.length];
146
		for (int j=0; j < argument.annotations.length; j++) {
147
			annotations[i][j] = argument.annotations[j];
148
		}
149
	}
150
	return annotations;
151
}
152
138
/**
153
/**
139
 * @see IMethod#getTypeParameterSignatures()
154
 * @see IMethod#getTypeParameterSignatures()
140
 * @since 3.0
155
 * @since 3.0
(-)model/org/eclipse/jdt/internal/core/SourceMethodElementInfo.java (-1 / +3 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2008 IBM Corporation and others.
2
 * Copyright (c) 2000, 2011 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 38-43 Link Here
38
	 * For example, Hashtable or java.util.Hashtable.
38
	 * For example, Hashtable or java.util.Hashtable.
39
	 */
39
	 */
40
	protected char[][] exceptionTypes;
40
	protected char[][] exceptionTypes;
41
	
42
	protected ILocalVariable[] arguments;
41
43
42
	/*
44
	/*
43
	 * The type parameters of this source type. Empty if none.
45
	 * The type parameters of this source type. Empty if none.
(-)model/org/eclipse/jdt/internal/core/util/Util.java (-3 / +3 lines)
Lines 3135-3143 Link Here
3135
		}
3135
		}
3136
		return typeArguments;
3136
		return typeArguments;
3137
	}
3137
	}
3138
	public static IAnnotation getAnnotation(JavaElement parent, IBinaryAnnotation binaryAnnotation, String memberValuePairName) {
3138
	public static IAnnotation getAnnotation(JavaElement parent, char[] argumentName, IBinaryAnnotation binaryAnnotation, String memberValuePairName) {
3139
		char[] typeName = org.eclipse.jdt.core.Signature.toCharArray(CharOperation.replaceOnCopy(binaryAnnotation.getTypeName(), '/', '.'));
3139
		char[] typeName = org.eclipse.jdt.core.Signature.toCharArray(CharOperation.replaceOnCopy(binaryAnnotation.getTypeName(), '/', '.'));
3140
		return new Annotation(parent, new String(typeName), memberValuePairName);
3140
		return new Annotation(parent, argumentName, new String(typeName), memberValuePairName);
3141
	}
3141
	}
3142
	
3142
	
3143
	public static Object getAnnotationMemberValue(JavaElement parent, MemberValuePair memberValuePair, Object binaryValue) {
3143
	public static Object getAnnotationMemberValue(JavaElement parent, MemberValuePair memberValuePair, Object binaryValue) {
Lines 3145-3151 Link Here
3145
			return getAnnotationMemberValue(memberValuePair, (Constant) binaryValue);
3145
			return getAnnotationMemberValue(memberValuePair, (Constant) binaryValue);
3146
		} else if (binaryValue instanceof IBinaryAnnotation) {
3146
		} else if (binaryValue instanceof IBinaryAnnotation) {
3147
			memberValuePair.valueKind = IMemberValuePair.K_ANNOTATION;
3147
			memberValuePair.valueKind = IMemberValuePair.K_ANNOTATION;
3148
			return getAnnotation(parent, (IBinaryAnnotation) binaryValue, memberValuePair.getMemberName());
3148
			return getAnnotation(parent, null, (IBinaryAnnotation) binaryValue, memberValuePair.getMemberName());
3149
		} else if (binaryValue instanceof ClassSignature) {
3149
		} else if (binaryValue instanceof ClassSignature) {
3150
			memberValuePair.valueKind = IMemberValuePair.K_CLASS;
3150
			memberValuePair.valueKind = IMemberValuePair.K_CLASS;
3151
			char[] className = Signature.toCharArray(CharOperation.replaceOnCopy(((ClassSignature) binaryValue).getTypeName(), '/', '.'));
3151
			char[] className = Signature.toCharArray(CharOperation.replaceOnCopy(((ClassSignature) binaryValue).getTypeName(), '/', '.'));
(-)src/org/eclipse/jdt/core/tests/util/Util.java (-2 / +4 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2010 IBM Corporation and others.
2
 * Copyright (c) 2000, 2011 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 382-388 Link Here
382
}
382
}
383
public static void createJar(String[] javaPathsAndContents, String[] extraPathsAndContents, String jarPath, String[] classpath, String compliance, Map options) throws IOException {
383
public static void createJar(String[] javaPathsAndContents, String[] extraPathsAndContents, String jarPath, String[] classpath, String compliance, Map options) throws IOException {
384
	Map compileOptions = getCompileOptions(compliance);
384
	Map compileOptions = getCompileOptions(compliance);
385
	compileOptions.putAll(options);
385
	if (options != null) {
386
		compileOptions.putAll(options);
387
	}
386
	createJar(javaPathsAndContents, extraPathsAndContents, compileOptions, classpath, jarPath);
388
	createJar(javaPathsAndContents, extraPathsAndContents, compileOptions, classpath, jarPath);
387
}
389
}
388
public static void createSourceZip(String[] pathsAndContents, String zipPath) throws IOException {
390
public static void createSourceZip(String[] pathsAndContents, String zipPath) throws IOException {
(-)src/org/eclipse/jdt/core/tests/model/AbstractJavaModelTests.java (-9 / +41 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2010 IBM Corporation and others.
2
 * Copyright (c) 2000, 2011 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 402-417 Link Here
402
		addLibraryEntry(javaProject, new Path(jarPath), true/*exported*/);
402
		addLibraryEntry(javaProject, new Path(jarPath), true/*exported*/);
403
	}
403
	}
404
	protected void addLibrary(String jarName, String sourceZipName, String[] pathAndContents, String compliance) throws CoreException, IOException {
404
	protected void addLibrary(String jarName, String sourceZipName, String[] pathAndContents, String compliance) throws CoreException, IOException {
405
		addLibrary(this.currentProject, jarName, sourceZipName, pathAndContents, null/*no non-Java resources*/, null, null, compliance);
405
		addLibrary(this.currentProject, jarName, sourceZipName, pathAndContents, null/*no non-Java resources*/, null, null, compliance, null);
406
	}
407
	protected void addLibrary(IJavaProject javaProject, String jarName, String sourceZipName, String[] pathAndContents, String compliance, Map options) throws CoreException, IOException {
408
		addLibrary(javaProject, jarName, sourceZipName, pathAndContents, null/*no non-Java resources*/, null, null, compliance, options);
406
	}
409
	}
407
	protected void addLibrary(IJavaProject javaProject, String jarName, String sourceZipName, String[] pathAndContents, String compliance) throws CoreException, IOException {
410
	protected void addLibrary(IJavaProject javaProject, String jarName, String sourceZipName, String[] pathAndContents, String compliance) throws CoreException, IOException {
408
		addLibrary(javaProject, jarName, sourceZipName, pathAndContents, null/*no non-Java resources*/, null, null, compliance);
411
		addLibrary(javaProject, jarName, sourceZipName, pathAndContents, null/*no non-Java resources*/, null, null, compliance, null);
409
	}
412
	}
410
	protected void addLibrary(IJavaProject javaProject, String jarName, String sourceZipName, String[] pathAndContents, String[] nonJavaResources, String compliance) throws CoreException, IOException {
413
	protected void addLibrary(IJavaProject javaProject, String jarName, String sourceZipName, String[] pathAndContents, String[] nonJavaResources, String compliance) throws CoreException, IOException {
411
		addLibrary(javaProject, jarName, sourceZipName, pathAndContents, nonJavaResources, null, null, compliance);
414
		addLibrary(javaProject, jarName, sourceZipName, pathAndContents, nonJavaResources, null, null, compliance, null);
412
	}
415
	}
413
	protected void addLibrary(IJavaProject javaProject, String jarName, String sourceZipName, String[] pathAndContents, String[] nonJavaResources, String[] librariesInclusionPatterns, String[] librariesExclusionPatterns, String compliance) throws CoreException, IOException {
416
	protected void addLibrary(
414
		IProject project = createLibrary(javaProject, jarName, sourceZipName, pathAndContents, nonJavaResources, compliance);
417
			IJavaProject javaProject,
418
			String jarName,
419
			String sourceZipName,
420
			String[] pathAndContents,
421
			String[] nonJavaResources,
422
			String[] librariesInclusionPatterns,
423
			String[] librariesExclusionPatterns,
424
			String compliance,
425
			Map options) throws CoreException, IOException {
426
		IProject project = createLibrary(javaProject, jarName, sourceZipName, pathAndContents, nonJavaResources, compliance, options);
415
		String projectPath = '/' + project.getName() + '/';
427
		String projectPath = '/' + project.getName() + '/';
416
		addLibraryEntry(
428
		addLibraryEntry(
417
			javaProject,
429
			javaProject,
Lines 423-435 Link Here
423
			true
435
			true
424
		);
436
		);
425
	}
437
	}
426
438
	protected IProject createLibrary(
427
	protected IProject createLibrary(IJavaProject javaProject, String jarName, String sourceZipName, String[] pathAndContents, String[] nonJavaResources, String compliance) throws IOException, CoreException {
439
			IJavaProject javaProject,
440
			String jarName,
441
			String sourceZipName,
442
			String[] pathAndContents,
443
			String[] nonJavaResources,
444
			String compliance) throws IOException, CoreException {
445
		return createLibrary(javaProject, jarName, sourceZipName, pathAndContents, nonJavaResources, compliance, null);
446
	}
447
448
	protected IProject createLibrary(
449
			IJavaProject javaProject,
450
			String jarName,
451
			String sourceZipName,
452
			String[] pathAndContents,
453
			String[] nonJavaResources,
454
			String compliance,
455
			Map options) throws IOException, CoreException {
428
		IProject project = javaProject.getProject();
456
		IProject project = javaProject.getProject();
429
		String projectLocation = project.getLocation().toOSString();
457
		String projectLocation = project.getLocation().toOSString();
430
		String jarPath = projectLocation + File.separator + jarName;
458
		String jarPath = projectLocation + File.separator + jarName;
431
		String[] claspath = get15LibraryIfNeeded(compliance);
459
		String[] claspath = get15LibraryIfNeeded(compliance);
432
		org.eclipse.jdt.core.tests.util.Util.createJar(pathAndContents, nonJavaResources, jarPath, claspath, compliance);
460
		org.eclipse.jdt.core.tests.util.Util.createJar(pathAndContents, nonJavaResources, jarPath, claspath, compliance, options);
433
		if (pathAndContents != null && pathAndContents.length != 0) {
461
		if (pathAndContents != null && pathAndContents.length != 0) {
434
			String sourceZipPath = projectLocation + File.separator + sourceZipName;
462
			String sourceZipPath = projectLocation + File.separator + sourceZipName;
435
			org.eclipse.jdt.core.tests.util.Util.createSourceZip(pathAndContents, sourceZipPath);
463
			org.eclipse.jdt.core.tests.util.Util.createSourceZip(pathAndContents, sourceZipPath);
Lines 1159-1164 Link Here
1159
		org.eclipse.jdt.core.tests.util.Util.createJar(javaPathsAndContents, null,jarPath, classpath, compliance);
1187
		org.eclipse.jdt.core.tests.util.Util.createJar(javaPathsAndContents, null,jarPath, classpath, compliance);
1160
	}
1188
	}
1161
1189
1190
	protected void createJar(String[] javaPathsAndContents, String jarPath, String[] classpath, String compliance, Map options) throws IOException {
1191
		org.eclipse.jdt.core.tests.util.Util.createJar(javaPathsAndContents, null, jarPath, classpath, compliance, options);
1192
	}
1193
	
1162
	/*
1194
	/*
1163
	}
1195
	}
1164
	 * Creates a Java project where prj=src=bin and with JCL_LIB on its classpath.
1196
	 * Creates a Java project where prj=src=bin and with JCL_LIB on its classpath.
(-)src/org/eclipse/jdt/core/tests/model/ReconcilerTests.java (-2 / +3 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2010 IBM Corporation and others.
2
 * Copyright (c) 2000, 2011 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 356-362 Link Here
356
				"**/*"
356
				"**/*"
357
			},
357
			},
358
			null, 
358
			null, 
359
			"1.4"
359
			"1.4",
360
			null
360
		);
361
		);
361
		createJavaProject("P2", new String[] {"src"}, new String[] {"JCL_LIB"}, new String[] {"/P1"}, "bin");
362
		createJavaProject("P2", new String[] {"src"}, new String[] {"JCL_LIB"}, new String[] {"/P1"}, "bin");
362
		setUpWorkingCopy("/P2/src/Y.java", "public class Y extends p.X {}");
363
		setUpWorkingCopy("/P2/src/Y.java", "public class Y extends p.X {}");
(-)src/org/eclipse/jdt/core/tests/model/TypeResolveTests.java (-2 / +313 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2008 IBM Corporation and others.
2
 * Copyright (c) 2000, 2011 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 10-18 Link Here
10
 *******************************************************************************/
10
 *******************************************************************************/
11
package org.eclipse.jdt.core.tests.model;
11
package org.eclipse.jdt.core.tests.model;
12
12
13
import java.io.IOException;
14
import java.util.HashMap;
15
import java.util.Map;
16
13
import org.eclipse.core.runtime.CoreException;
17
import org.eclipse.core.runtime.CoreException;
14
import org.eclipse.jdt.core.*;
18
import org.eclipse.jdt.core.*;
15
import org.eclipse.jdt.core.tests.util.Util;
19
import org.eclipse.jdt.core.tests.util.Util;
20
import org.eclipse.jdt.internal.core.LocalVariable;
16
21
17
import junit.framework.Test;
22
import junit.framework.Test;
18
23
Lines 95-101 Link Here
95
}
100
}
96
	static {
101
	static {
97
//		TESTS_NUMBERS = new int[] { 182, 183 };
102
//		TESTS_NUMBERS = new int[] { 182, 183 };
98
//		TESTS_NAMES = new String[] {"test0177"};
103
//		TESTS_NAMES = new String[] { "testParamAnnotations5" };
99
	}
104
	}
100
	public static Test suite() {
105
	public static Test suite() {
101
		return buildModelTestSuite(TypeResolveTests.class);
106
		return buildModelTestSuite(TypeResolveTests.class);
Lines 299-302 Link Here
299
		"p4.A.Inner",
304
		"p4.A.Inner",
300
		types);
305
		types);
301
}
306
}
307
/**
308
 * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=334783"
309
 */
310
public void testParamAnnotations() throws CoreException {
311
	try {
312
		createJavaProject("P", new String[] {"src"}, new String[] {"JCL15_LIB"}, "bin", "1.5");
313
		String source = "package p;" +
314
				"public class X<T> {\n" +
315
				"  X<String> field;\n" +
316
				"	@Inject " +
317
				"	public void Test(@Default String processor) {}" +
318
				"}" +
319
				"@interface Inject{\n" +
320
				"}" +
321
				"@interface Default{\n" +
322
				"}";
323
		createFolder("/P/src/p");
324
		createFile(
325
			"/P/src/p/X.java",
326
			source
327
		);
328
		waitForAutoBuild();
329
		
330
		ICompilationUnit unit = getCompilationUnit("/P/src/p/X.java"); 
331
		IJavaElement[] variable = ((ICodeAssist) unit).codeSelect(source.indexOf("processor"), "processor".length());
332
333
		assertEquals(1, variable.length);
334
		String annotationString = "@Default [in processor [in Test(String) [in X [in X.java [in p [in src [in P]]]]]]]";
335
		assertEquals(annotationString, ((LocalVariable)variable[0]).getAnnotations()[0].toString());
336
		IType type = unit.getType("X");
337
		
338
		IMethod method = type.getMethods()[0];
339
		assertEquals(annotationString, method.getParameterAnnotations()[0][0].toString());
340
	} finally {
341
		deleteProject("P");
342
	}
343
}
344
/**
345
 * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=334783"
346
 */
347
public void testParamAnnotations2() throws CoreException, IOException {
348
	try {
349
		IJavaProject project = createJavaProject("P", new String[] {"src"}, new String[] {"JCL15_LIB"}, "bin", "1.5");
350
		String[] pathAndContents = new String[]{"p/X.java",
351
				"package p;" +
352
				"public class X<T> {\n" +
353
				"  X<String> field;\n" +
354
				"	@Inject " +
355
				"	public void Test(@Default String processor) {}" +
356
				"}" +
357
				"@interface Inject{\n" +
358
				"}" +
359
				"@interface Default{\n" +
360
				"}"};
361
		addLibrary(project, "lib334783.jar", "libsrc.zip", pathAndContents, JavaCore.VERSION_1_5);
362
		
363
		waitForAutoBuild();
364
		IPackageFragmentRoot root = project.getPackageFragmentRoot(getFile("/P/lib334783.jar"));
365
		IType type = root.getPackageFragment("p").getClassFile("X.class").getType();
366
		String annotationString = "@p.Default [in Test(java.lang.String) [in X [in X.class [in p [in lib334783.jar [in P]]]]]]";
367
		
368
		IMethod method = type.getMethods()[1];
369
		assertEquals(annotationString, method.getParameterAnnotations()[0][0].toString());
370
	} finally {
371
		deleteProject("P");
372
	}
373
}
374
/**
375
 * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=334783"
376
 */
377
public void testParamAnnotations3() throws CoreException {
378
	try {
379
		createJavaProject("P", new String[] {"src"}, new String[] {"JCL15_LIB"}, "bin", "1.5");
380
		String source = "package p;" +
381
				"public class X<T> {\n" +
382
				"  X<String> field;\n" +
383
				"	@Inject\n" +
384
				"	public void Test(int i, @Default @Marker(id=1) String processor, int k) {}\n" +
385
				"}\n" +
386
				"@interface Inject{\n" +
387
				"}\n" +
388
				"@interface Marker {\n" +
389
				"	int id() default 0;\n" +
390
				"}\n" +
391
				"@interface Default{\n" +
392
				"}";
393
		createFolder("/P/src/p");
394
		createFile(
395
			"/P/src/p/X.java",
396
			source
397
		);
398
		waitForAutoBuild();
399
		
400
		ICompilationUnit unit = getCompilationUnit("/P/src/p/X.java"); 
401
		IJavaElement[] variable = ((ICodeAssist) unit).codeSelect(source.indexOf("processor"), "processor".length());
402
403
		assertEquals(1, variable.length);
404
		String annotationString1 = "@Default [in processor [in Test(int, String, int) [in X [in X.java [in p [in src [in P]]]]]]]";
405
		String annotationString2 = "@Marker [in processor [in Test(int, String, int) [in X [in X.java [in p [in src [in P]]]]]]]";
406
		assertEquals(annotationString1, ((LocalVariable)variable[0]).getAnnotations()[0].toString());
407
		IType type = unit.getType("X");
408
		
409
		IMethod method = type.getMethods()[0];
410
		IAnnotation[][] parameterAnnotations = method.getParameterAnnotations();
411
		assertEquals("Wrong length", 2, parameterAnnotations[1].length);
412
		assertEquals(annotationString1, parameterAnnotations[1][0].toString());
413
		IAnnotation iAnnotation = parameterAnnotations[1][1];
414
		assertEquals(annotationString2, iAnnotation.toString());
415
		IMemberValuePair[] memberValuePairs = iAnnotation.getMemberValuePairs();
416
		assertEquals("Wrong number of pairs", 1, memberValuePairs.length);
417
		StringBuffer output = new StringBuffer();
418
		output.append(memberValuePairs[0].getMemberName());
419
		output.append(' ');
420
		output.append(memberValuePairs[0].getValue());
421
		assertEquals("Wrong value", "id 1", String.valueOf(output));
422
		assertEquals("Wrong length", 0, parameterAnnotations[0].length);
423
		assertEquals("Wrong length", 0, parameterAnnotations[2].length);
424
	} finally {
425
		deleteProject("P");
426
	}
427
}
428
/**
429
 * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=334783"
430
 */
431
public void testParamAnnotations4() throws CoreException, IOException {
432
	try {
433
		IJavaProject project = createJavaProject("P", new String[] {"src"}, new String[] {"JCL15_LIB"}, "bin", "1.5");
434
		String[] pathAndContents = new String[]{"p/X.java",
435
				"package p;" +
436
				"public class X<T> {\n" +
437
				"  X<String> field;\n" +
438
				"	@Inject @Marker(id=3)" +
439
				"	public void Test(int i, @Default @Marker(id=1) String processor, int k) {}" +
440
				"}",
441
				"p/Inject.java",
442
				"package p;\n"+
443
				"public @interface Inject{\n" +
444
				"}",
445
				"p/Marker.java",
446
				"package p;\n" +
447
				"public @interface Marker {\n" +
448
				"	int id() default 0;\n" +
449
				"}",
450
				"p/Default.java",
451
				"package p;\n" +
452
				"public @interface Default{\n" +
453
				"}"};
454
		addLibrary(project, "lib334783_2.jar", "lib334783_2src.zip", pathAndContents, JavaCore.VERSION_1_5);
455
		
456
		waitForAutoBuild();
457
		IPackageFragmentRoot root = project.getPackageFragmentRoot(getFile("/P/lib334783_2.jar"));
458
		IType type = root.getPackageFragment("p").getClassFile("X.class").getType();
459
		String annotationString1 = "@p.Default [in Test(int, java.lang.String, int) [in X [in X.class [in p [in lib334783_2.jar [in P]]]]]]";
460
		String annotationString2 = "@p.Marker [in Test(int, java.lang.String, int) [in X [in X.class [in p [in lib334783_2.jar [in P]]]]]]";
461
		IMethod method = type.getMethods()[1];
462
		IAnnotation[] annotations = method.getAnnotations();
463
		assertEquals("Wrong length", 2, annotations.length);
464
		assertEquals("@p.Inject [in Test(int, java.lang.String, int) [in X [in X.class [in p [in lib334783_2.jar [in P]]]]]]", annotations[0].toString());
465
		IAnnotation annotation = annotations[1];
466
		assertEquals("@p.Marker [in Test(int, java.lang.String, int) [in X [in X.class [in p [in lib334783_2.jar [in P]]]]]]", annotation.toString());
467
		IMemberValuePair[] memberValuePairs = annotation.getMemberValuePairs();
468
		assertEquals("Wrong number of pairs", 1, memberValuePairs.length);
469
		StringBuffer output = new StringBuffer();
470
		output.append(memberValuePairs[0].getMemberName());
471
		output.append(' ');
472
		output.append(memberValuePairs[0].getValue());
473
		assertEquals("Wrong value", "id 3", String.valueOf(output));
474
		IAnnotation[][] parameterAnnotations = method.getParameterAnnotations();
475
		assertEquals("Wrong length", 2, parameterAnnotations[1].length);
476
		assertEquals(annotationString1, parameterAnnotations[1][0].toString());
477
		annotation = parameterAnnotations[1][1];
478
		assertEquals(annotationString2, annotation.toString());
479
		memberValuePairs = annotation.getMemberValuePairs();
480
		assertEquals("Wrong number of pairs", 1, memberValuePairs.length);
481
		output = new StringBuffer();
482
		output.append(memberValuePairs[0].getMemberName());
483
		output.append(' ');
484
		output.append(memberValuePairs[0].getValue());
485
		assertEquals("Wrong value", "id 1", String.valueOf(output));
486
		assertEquals("Wrong length", 0, parameterAnnotations[0].length);
487
		assertEquals("Wrong length", 0, parameterAnnotations[2].length);
488
	} finally {
489
		deleteProject("P");
490
	}
491
}
492
/**
493
 * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=334783"
494
 */
495
public void testParamAnnotations5() throws CoreException, IOException {
496
	try {
497
		IJavaProject project = createJavaProject("P", new String[] {"src"}, new String[] {"JCL15_LIB"}, "bin", "1.5");
498
		String[] pathAndContents = new String[]{"p/X.java",
499
				"package p;" +
500
				"public class X<T> {\n" +
501
				"  X<String> field;\n" +
502
				"	@Inject @Marker(id=3)" +
503
				"	public void Test(int i, @Default @Marker(id=1) String processor, int k) {}" +
504
				"}",
505
				"p/Inject.java",
506
				"package p;\n"+
507
				"public @interface Inject{\n" +
508
				"}",
509
				"p/Marker.java",
510
				"package p;\n" +
511
				"public @interface Marker {\n" +
512
				"	int id() default 0;\n" +
513
				"}",
514
				"p/Default.java",
515
				"package p;\n" +
516
				"public @interface Default{\n" +
517
				"}"};
518
		Map options = new HashMap();
519
		options.put(JavaCore.COMPILER_LOCAL_VARIABLE_ATTR, JavaCore.DO_NOT_GENERATE);
520
		addLibrary(project, "lib334783_3.jar", "lib334783_3src.zip", pathAndContents, JavaCore.VERSION_1_5, options);
521
		
522
		waitForAutoBuild();
523
		IPackageFragmentRoot root = project.getPackageFragmentRoot(getFile("/P/lib334783_3.jar"));
524
		IType type = root.getPackageFragment("p").getClassFile("X.class").getType();
525
		String annotationString1 = "@p.Default [in Test(int, java.lang.String, int) [in X [in X.class [in p [in lib334783_3.jar [in P]]]]]]";
526
		String annotationString2 = "@p.Marker [in Test(int, java.lang.String, int) [in X [in X.class [in p [in lib334783_3.jar [in P]]]]]]";
527
		IMethod method = type.getMethods()[1];
528
		IAnnotation[] annotations = method.getAnnotations();
529
		assertEquals("Wrong length", 2, annotations.length);
530
		assertEquals("@p.Inject [in Test(int, java.lang.String, int) [in X [in X.class [in p [in lib334783_3.jar [in P]]]]]]", annotations[0].toString());
531
		IAnnotation annotation = annotations[1];
532
		assertEquals("@p.Marker [in Test(int, java.lang.String, int) [in X [in X.class [in p [in lib334783_3.jar [in P]]]]]]", annotation.toString());
533
		IMemberValuePair[] memberValuePairs = annotation.getMemberValuePairs();
534
		assertEquals("Wrong number of pairs", 1, memberValuePairs.length);
535
		StringBuffer output = new StringBuffer();
536
		output.append(memberValuePairs[0].getMemberName());
537
		output.append(' ');
538
		output.append(memberValuePairs[0].getValue());
539
		assertEquals("Wrong value", "id 3", String.valueOf(output));
540
		IAnnotation[][] parameterAnnotations = method.getParameterAnnotations();
541
		assertEquals("Wrong length", 2, parameterAnnotations[1].length);
542
		assertEquals(annotationString1, parameterAnnotations[1][0].toString());
543
		annotation = parameterAnnotations[1][1];
544
		assertEquals(annotationString2, annotation.toString());
545
		memberValuePairs = annotation.getMemberValuePairs();
546
		assertEquals("Wrong number of pairs", 1, memberValuePairs.length);
547
		output = new StringBuffer();
548
		output.append(memberValuePairs[0].getMemberName());
549
		output.append(' ');
550
		output.append(memberValuePairs[0].getValue());
551
		assertEquals("Wrong value", "id 1", String.valueOf(output));
552
		assertEquals("Wrong length", 0, parameterAnnotations[0].length);
553
		assertEquals("Wrong length", 0, parameterAnnotations[2].length);
554
	} finally {
555
		deleteProject("P");
556
	}
557
}
558
/**
559
 * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=334783"
560
 */
561
public void testParamAnnotations6() throws CoreException {
562
	try {
563
		createJavaProject("P", new String[] {"src"}, new String[] {"JCL15_LIB"}, "bin", "1.5");
564
		String source = "package p;" +
565
				"public class X<T> {\n" +
566
				"  X<String> field;\n" +
567
				"	public void Test() {}" +
568
				"}";
569
		createFolder("/P/src/p");
570
		createFile(
571
			"/P/src/p/X.java",
572
			source
573
		);
574
		waitForAutoBuild();
575
		
576
		ICompilationUnit unit = getCompilationUnit("/P/src/p/X.java"); 
577
		IType type = unit.getType("X");
578
		IMethod method = type.getMethods()[0];
579
		IAnnotation[][] parameterAnnotations = method.getParameterAnnotations();
580
		assertNotNull(parameterAnnotations);
581
		assertEquals("Wrong length", 0, parameterAnnotations.length);
582
	} finally {
583
		deleteProject("P");
584
	}
585
}
586
/**
587
 * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=334783"
588
 */
589
public void testParamAnnotations7() throws CoreException, IOException {
590
	try {
591
		IJavaProject project = createJavaProject("P", new String[] {"src"}, new String[] {"JCL15_LIB"}, "bin", "1.5");
592
		String[] pathAndContents = new String[]{"p/X.java",
593
				"package p;" +
594
				"public class X<T> {\n" +
595
				"  X<String> field;\n" +
596
				"	public void Test() {}" +
597
				"}"
598
		};
599
		addLibrary(project, "lib334783.jar", "libsrc.zip", pathAndContents, JavaCore.VERSION_1_5);
600
		
601
		waitForAutoBuild();
602
		IPackageFragmentRoot root = project.getPackageFragmentRoot(getFile("/P/lib334783.jar"));
603
		IType type = root.getPackageFragment("p").getClassFile("X.class").getType();
604
		
605
		IMethod method = type.getMethods()[1];
606
		IAnnotation[][] parameterAnnotations = method.getParameterAnnotations();
607
		assertNotNull(parameterAnnotations);
608
		assertEquals("Wrong length", 0, parameterAnnotations.length);
609
	} finally {
610
		deleteProject("P");
611
	}
612
}
302
}
613
}

Return to bug 334783