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 / +16 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 the parameters of this method.
106
 * <p>An empty array is returned, if the method has no parameters.</p>
107
 * <p>For binary types, associated source is used to retrieve the {@link ILocalVariable#getNameRange() name range},
108
 * {@link ILocalVariable#getSourceRange() source range} and the {@link ILocalVariable#getFlags() flags}.</p>
109
 * <p>These local variables can be used to retrieve the {@link ILocalVariable#getAnnotations() parameter annotations}.</p>
110
 * 
111
 * @return the parameters of this method
112
 * @throws JavaModelException if this element does not exist or if an
113
 *      exception occurs while accessing its corresponding resource.
114
 * @since 3.7
115
 */
116
ILocalVariable[] getParameters() throws JavaModelException;
117
103
/**
118
/**
104
 * Returns the binding key for this method only if the given method is {@link #isResolved() resolved}.
119
 * 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
120
 * A binding key is a key that uniquely identifies this method. It allows access
(-)model/org/eclipse/jdt/internal/compiler/ISourceElementRequestor.java (-1 / +10 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 92-99 Link Here
92
		public int declaringTypeModifiers;
92
		public int declaringTypeModifiers;
93
		public int extraFlags;
93
		public int extraFlags;
94
		public AbstractMethodDeclaration node;
94
		public AbstractMethodDeclaration node;
95
		public ParameterInfo[] parameterInfos;
95
	}
96
	}
96
97
98
	public static class ParameterInfo {
99
		public int modifiers;
100
		public int declarationStart;
101
		public int declarationEnd;
102
		public int nameSourceStart;
103
		public int nameSourceEnd;
104
		public char[] name;
105
	}
97
	public static class FieldInfo {
106
	public static class FieldInfo {
98
		public int declarationStart;
107
		public int declarationStart;
99
		public int modifiers;
108
		public int modifiers;
(-)model/org/eclipse/jdt/internal/compiler/SourceElementNotifier.java (-8 / +24 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2008, 2010 IBM Corporation and others.
2
 * Copyright (c) 2008, 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 14-19 Link Here
14
import java.util.Map;
14
import java.util.Map;
15
15
16
import org.eclipse.jdt.core.compiler.CharOperation;
16
import org.eclipse.jdt.core.compiler.CharOperation;
17
import org.eclipse.jdt.internal.compiler.ISourceElementRequestor.ParameterInfo;
17
import org.eclipse.jdt.internal.compiler.ISourceElementRequestor.TypeParameterInfo;
18
import org.eclipse.jdt.internal.compiler.ISourceElementRequestor.TypeParameterInfo;
18
import org.eclipse.jdt.internal.compiler.ast.ASTNode;
19
import org.eclipse.jdt.internal.compiler.ast.ASTNode;
19
import org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration;
20
import org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration;
Lines 103-118 Link Here
103
	this.superTypeNames = new char[4][];
104
	this.superTypeNames = new char[4][];
104
	this.nestedTypeIndex = 0;
105
	this.nestedTypeIndex = 0;
105
}
106
}
106
protected char[][][] getArguments(Argument[] arguments) {
107
protected Object[][] getArgumentInfos(Argument[] arguments) {
107
	int argumentLength = arguments.length;
108
	int argumentLength = arguments.length;
108
	char[][] argumentTypes = new char[argumentLength][];
109
	char[][] argumentTypes = new char[argumentLength][];
109
	char[][] argumentNames = new char[argumentLength][];
110
	char[][] argumentNames = new char[argumentLength][];
111
	ParameterInfo[] parameterInfos = new ParameterInfo[argumentLength];
110
	for (int i = 0; i < argumentLength; i++) {
112
	for (int i = 0; i < argumentLength; i++) {
111
		argumentTypes[i] = CharOperation.concatWith(arguments[i].type.getParameterizedTypeName(), '.');
113
		Argument argument = arguments[i];
112
		argumentNames[i] = arguments[i].name;
114
		argumentTypes[i] = CharOperation.concatWith(argument.type.getParameterizedTypeName(), '.');
115
		char[] name = argument.name;
116
		argumentNames[i] = name;
117
		ParameterInfo parameterInfo = new ParameterInfo();
118
		parameterInfo.declarationStart = argument.declarationSourceStart;
119
		parameterInfo.declarationEnd = argument.declarationSourceEnd;
120
		parameterInfo.nameSourceStart = argument.sourceStart;
121
		parameterInfo.nameSourceEnd = argument.sourceEnd;
122
		parameterInfo.modifiers = argument.modifiers;
123
		parameterInfo.name = name;
124
		parameterInfos[i] = parameterInfo;
113
	}
125
	}
114
126
115
	return new char[][][] {argumentTypes, argumentNames};
127
	return new Object[][] { parameterInfos, new char[][][] { argumentTypes, argumentNames } };
116
}
128
}
117
protected char[][] getInterfaceNames(TypeDeclaration typeDeclaration) {
129
protected char[][] getInterfaceNames(TypeDeclaration typeDeclaration) {
118
	char[][] interfaceNames = null;
130
	char[][] interfaceNames = null;
Lines 256-265 Link Here
256
	char[][] argumentNames = null;
268
	char[][] argumentNames = null;
257
	boolean isVarArgs = false;
269
	boolean isVarArgs = false;
258
	Argument[] arguments = methodDeclaration.arguments;
270
	Argument[] arguments = methodDeclaration.arguments;
271
	ParameterInfo[] parameterInfos = null; 
259
	if (arguments != null) {
272
	if (arguments != null) {
260
		char[][][] argumentTypesAndNames = getArguments(arguments);
273
		Object[][] argumentInfos = getArgumentInfos(arguments);
261
		argumentTypes = argumentTypesAndNames[0];
274
		parameterInfos = (ParameterInfo[]) argumentInfos[0];
262
		argumentNames = argumentTypesAndNames[1];
275
		argumentTypes = (char[][]) argumentInfos[1][0];
276
		argumentNames = (char[][]) argumentInfos[1][1];
263
277
264
		isVarArgs = arguments[arguments.length-1].isVarArgs();
278
		isVarArgs = arguments[arguments.length-1].isVarArgs();
265
	}
279
	}
Lines 287-292 Link Here
287
			methodInfo.parameterNames = argumentNames;
301
			methodInfo.parameterNames = argumentNames;
288
			methodInfo.exceptionTypes = thrownExceptionTypes;
302
			methodInfo.exceptionTypes = thrownExceptionTypes;
289
			methodInfo.typeParameters = getTypeParameterInfos(methodDeclaration.typeParameters());
303
			methodInfo.typeParameters = getTypeParameterInfos(methodDeclaration.typeParameters());
304
			methodInfo.parameterInfos = parameterInfos;
290
			methodInfo.categories = (char[][]) this.nodesToCategories.get(methodDeclaration);
305
			methodInfo.categories = (char[][]) this.nodesToCategories.get(methodDeclaration);
291
			methodInfo.annotations = methodDeclaration.annotations;
306
			methodInfo.annotations = methodDeclaration.annotations;
292
			methodInfo.declaringPackageName = currentPackage == null ? CharOperation.NO_CHAR : CharOperation.concatWith(currentPackage.tokens, '.');
307
			methodInfo.declaringPackageName = currentPackage == null ? CharOperation.NO_CHAR : CharOperation.concatWith(currentPackage.tokens, '.');
Lines 346-351 Link Here
346
		methodInfo.parameterNames = argumentNames;
361
		methodInfo.parameterNames = argumentNames;
347
		methodInfo.exceptionTypes = thrownExceptionTypes;
362
		methodInfo.exceptionTypes = thrownExceptionTypes;
348
		methodInfo.typeParameters = getTypeParameterInfos(methodDeclaration.typeParameters());
363
		methodInfo.typeParameters = getTypeParameterInfos(methodDeclaration.typeParameters());
364
		methodInfo.parameterInfos = parameterInfos;
349
		methodInfo.categories = (char[][]) this.nodesToCategories.get(methodDeclaration);
365
		methodInfo.categories = (char[][]) this.nodesToCategories.get(methodDeclaration);
350
		methodInfo.annotations = methodDeclaration.annotations;
366
		methodInfo.annotations = methodDeclaration.annotations;
351
		methodInfo.node = methodDeclaration;
367
		methodInfo.node = methodDeclaration;
(-)model/org/eclipse/jdt/internal/core/BinaryMember.java (-3 / +7 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-53 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, binaryAnnotations[i], null);
53
	}
57
	}
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 / +55 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.ILocalVariable;
17
import org.eclipse.jdt.core.IMemberValuePair;
18
import org.eclipse.jdt.core.IMethod;
19
import org.eclipse.jdt.core.IType;
20
import org.eclipse.jdt.core.ITypeParameter;
21
import org.eclipse.jdt.core.JavaCore;
22
import org.eclipse.jdt.core.JavaModelException;
23
import org.eclipse.jdt.core.Signature;
15
import org.eclipse.jdt.core.compiler.CharOperation;
24
import org.eclipse.jdt.core.compiler.CharOperation;
16
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
25
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
17
import org.eclipse.jdt.internal.compiler.env.IBinaryAnnotation;
26
import org.eclipse.jdt.internal.compiler.env.IBinaryAnnotation;
Lines 61-66 Link Here
61
	IBinaryAnnotation[] binaryAnnotations = info.getAnnotations();
70
	IBinaryAnnotation[] binaryAnnotations = info.getAnnotations();
62
	return getAnnotations(binaryAnnotations, info.getTagBits());
71
	return getAnnotations(binaryAnnotations, info.getTagBits());
63
}
72
}
73
public ILocalVariable[] getParameters() throws JavaModelException {
74
	IBinaryMethod info = (IBinaryMethod) getElementInfo();
75
	int length = this.parameterTypes.length;
76
	if (length == 0) {
77
		return LocalVariable.NO_LOCAL_VARIABLES;
78
	}
79
	ILocalVariable[] localVariables = new ILocalVariable[length];
80
	char[][] argumentNames = info.getArgumentNames();
81
	if (argumentNames == null || argumentNames.length < length) {
82
		argumentNames = new char[length][];
83
		for (int j = 0; j < length; j++) {
84
			argumentNames[j] = ("arg" + j).toCharArray(); //$NON-NLS-1$
85
		}
86
	}
87
	for (int i= 0; i < length; i++) {
88
		LocalVariable localVariable = new LocalVariable(
89
				this,
90
				new String(argumentNames[i]),
91
				0,
92
				-1,
93
				0,
94
				-1,
95
				this.parameterTypes[i],
96
				null,
97
				-1,
98
				true);
99
		localVariables[i] = localVariable;
100
		IAnnotation[] annotations = getAnnotations(localVariable, info.getParameterAnnotations(i), info.getTagBits());
101
		localVariable.annotations = annotations;
102
	}
103
	return localVariables;
104
}
105
private IAnnotation[] getAnnotations(JavaElement annotationParent, IBinaryAnnotation[] binaryAnnotations, long tagBits) {
106
	IAnnotation[] standardAnnotations = getStandardAnnotations(tagBits);
107
	if (binaryAnnotations == null)
108
		return standardAnnotations;
109
	int length = binaryAnnotations.length;
110
	int standardLength = standardAnnotations.length;
111
	IAnnotation[] annotations = new IAnnotation[length + standardLength];
112
	for (int i = 0; i < length; i++) {
113
		annotations[i] = Util.getAnnotation(annotationParent, binaryAnnotations[i], null);
114
	}
115
	System.arraycopy(standardAnnotations, 0, annotations, length, standardLength);
116
	return annotations;
117
}
64
public IMemberValuePair getDefaultValue() throws JavaModelException {
118
public IMemberValuePair getDefaultValue() throws JavaModelException {
65
	IBinaryMethod info = (IBinaryMethod) getElementInfo();
119
	IBinaryMethod info = (IBinaryMethod) getElementInfo();
66
	Object defaultValue = info.getDefaultValue();
120
	Object defaultValue = info.getDefaultValue();
(-)model/org/eclipse/jdt/internal/core/ClassFileInfo.java (-17 / +45 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-63 Link Here
41
	 */
41
	 */
42
	protected ITypeParameter[] typeParameters;
42
	protected ITypeParameter[] typeParameters;
43
43
44
private void generateAnnotationsInfos(JavaElement 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(JavaElement 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, new String(typeName), memberValuePairName);
63
	while (newElements.containsKey(annotation)) {
66
	while (newElements.containsKey(annotation)) {
Lines 81-109 Link Here
81
		}
84
		}
82
	}
85
	}
83
}
86
}
84
private void generateStandardAnnotationsInfos(BinaryMember member, long tagBits, HashMap newElements) {
87
private void generateStandardAnnotationsInfos(JavaElement javaElement, 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) {
88
		generateStandardAnnotation(member, TypeConstants.JAVA_LANG_ANNOTATION_TARGET, getTargetElementTypes(tagBits), newElements);
91
		generateStandardAnnotation(javaElement, TypeConstants.JAVA_LANG_ANNOTATION_TARGET, getTargetElementTypes(tagBits), newElements);
89
	}
92
	}
90
	if ((tagBits & TagBits.AnnotationRetentionMASK) != 0) {
93
	if ((tagBits & TagBits.AnnotationRetentionMASK) != 0) {
91
		generateStandardAnnotation(member, TypeConstants.JAVA_LANG_ANNOTATION_RETENTION, getRetentionPolicy(tagBits), newElements);
94
		generateStandardAnnotation(javaElement, TypeConstants.JAVA_LANG_ANNOTATION_RETENTION, getRetentionPolicy(tagBits), newElements);
92
	}
95
	}
93
	if ((tagBits & TagBits.AnnotationDeprecated) != 0) {
96
	if ((tagBits & TagBits.AnnotationDeprecated) != 0) {
94
		generateStandardAnnotation(member, TypeConstants.JAVA_LANG_DEPRECATED, Annotation.NO_MEMBER_VALUE_PAIRS, newElements);
97
		generateStandardAnnotation(javaElement, TypeConstants.JAVA_LANG_DEPRECATED, Annotation.NO_MEMBER_VALUE_PAIRS, newElements);
95
	}
98
	}
96
	if ((tagBits & TagBits.AnnotationDocumented) != 0) {
99
	if ((tagBits & TagBits.AnnotationDocumented) != 0) {
97
		generateStandardAnnotation(member, TypeConstants.JAVA_LANG_ANNOTATION_DOCUMENTED, Annotation.NO_MEMBER_VALUE_PAIRS, newElements);
100
		generateStandardAnnotation(javaElement, TypeConstants.JAVA_LANG_ANNOTATION_DOCUMENTED, Annotation.NO_MEMBER_VALUE_PAIRS, newElements);
98
	}
101
	}
99
	if ((tagBits & TagBits.AnnotationInherited) != 0) {
102
	if ((tagBits & TagBits.AnnotationInherited) != 0) {
100
		generateStandardAnnotation(member, TypeConstants.JAVA_LANG_ANNOTATION_INHERITED, Annotation.NO_MEMBER_VALUE_PAIRS, newElements);
103
		generateStandardAnnotation(javaElement, TypeConstants.JAVA_LANG_ANNOTATION_INHERITED, Annotation.NO_MEMBER_VALUE_PAIRS, newElements);
101
	}
104
	}
102
	// note that JAVA_LANG_SUPPRESSWARNINGS and JAVA_LANG_OVERRIDE cannot appear in binaries
105
	// note that JAVA_LANG_SUPPRESSWARNINGS and JAVA_LANG_OVERRIDE cannot appear in binaries
103
}
106
}
104
107
105
private void generateStandardAnnotation(BinaryMember member, char[][] typeName, IMemberValuePair[] members, HashMap newElements) {
108
private void generateStandardAnnotation(JavaElement javaElement, char[][] typeName, IMemberValuePair[] members, HashMap newElements) {
106
	IAnnotation annotation = new Annotation(member, new String(CharOperation.concatWith(typeName, '.')));
109
	IAnnotation annotation = new Annotation(javaElement, new String(CharOperation.concatWith(typeName, '.')));
107
	AnnotationInfo annotationInfo = new AnnotationInfo();
110
	AnnotationInfo annotationInfo = new AnnotationInfo();
108
	annotationInfo.members = members;
111
	annotationInfo.members = members;
109
	newElements.put(annotation, annotationInfo);
112
	newElements.put(annotation, annotationInfo);
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
				LocalVariable localVariable = new LocalVariable(
315
						method,
316
						new String(argumentNames[j]),
317
						0,
318
						-1,
319
						0,
320
						-1,
321
						method.parameterTypes[j],
322
						null,
323
						-1,
324
						true);
325
				generateAnnotationsInfos(localVariable, argumentNames[j], parameterAnnotations, methodInfo.getTagBits(), newElements);
326
			}
327
		}
300
		generateTypeParameterInfos(method, signature, newElements, typeParameterHandles);
328
		generateTypeParameterInfos(method, signature, newElements, typeParameterHandles);
301
		generateAnnotationsInfos(method, methodInfo.getAnnotations(), methodInfo.getTagBits(), newElements);
329
		generateAnnotationsInfos(method, methodInfo.getAnnotations(), methodInfo.getTagBits(), newElements);
302
		Object defaultValue = methodInfo.getDefaultValue();
330
		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/LocalVariable.java (-3 / +67 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 34-39 Link Here
34
34
35
public class LocalVariable extends SourceRefElement implements ILocalVariable {
35
public class LocalVariable extends SourceRefElement implements ILocalVariable {
36
36
37
	public static final ILocalVariable[] NO_LOCAL_VARIABLES = new ILocalVariable[0];
38
	
37
	String name;
39
	String name;
38
	public int declarationSourceStart, declarationSourceEnd;
40
	public int declarationSourceStart, declarationSourceEnd;
39
	public int nameStart, nameEnd;
41
	public int nameStart, nameEnd;
Lines 288-297 Link Here
288
	 * @since 3.7
290
	 * @since 3.7
289
	 */
291
	 */
290
	public int getFlags() {
292
	public int getFlags() {
293
		if (this.flags == -1) {
294
			SourceMapper mapper= getSourceMapper();
295
			if (mapper != null) {
296
				try {
297
					// ensure the class file's buffer is open so that source ranges are computed
298
					ClassFile classFile = (ClassFile)getClassFile();
299
					if (classFile != null) {
300
						classFile.getBuffer();
301
						return mapper.getFlags(this);
302
					}
303
				} catch(JavaModelException e) {
304
					// ignore
305
				}
306
			}
307
			return 0;
308
		}
291
		return this.flags;
309
		return this.flags;
292
	}
310
	}
293
311
312
	/**
313
	 * @see IMember#getClassFile()
314
	 */
315
	public IClassFile getClassFile() {
316
		IJavaElement element = getParent();
317
		while (element instanceof IMember) {
318
			element= element.getParent();
319
		}
320
		if (element instanceof IClassFile) {
321
			return (IClassFile) element;
322
		}
323
		return null;
324
	}
325
	/**
326
	 * {@inheritDoc}
327
	 * @since 3.7
328
	 */
294
	public ISourceRange getNameRange() {
329
	public ISourceRange getNameRange() {
330
		if (this.nameEnd == -1) {
331
			SourceMapper mapper= getSourceMapper();
332
			if (mapper != null) {
333
				try {
334
					// ensure the class file's buffer is open so that source ranges are computed
335
					ClassFile classFile = (ClassFile)getClassFile();
336
					if (classFile != null) {
337
						classFile.getBuffer();
338
						return mapper.getNameRange(this);
339
					}
340
				} catch(JavaModelException e) {
341
					// ignore
342
				}
343
			}
344
			return SourceMapper.UNKNOWN_RANGE;
345
		}
295
		return new SourceRange(this.nameStart, this.nameEnd-this.nameStart+1);
346
		return new SourceRange(this.nameStart, this.nameEnd-this.nameStart+1);
296
	}
347
	}
297
348
Lines 326-334 Link Here
326
	}
377
	}
327
378
328
	/**
379
	/**
329
	 * @see ISourceReference
380
	 * {@inheritDoc}
381
	 * @since 3.7
330
	 */
382
	 */
331
	public ISourceRange getSourceRange() {
383
	public ISourceRange getSourceRange() throws JavaModelException {
384
		if (this.declarationSourceEnd == -1) {
385
			SourceMapper mapper= getSourceMapper();
386
			if (mapper != null) {
387
				// ensure the class file's buffer is open so that source ranges are computed
388
				ClassFile classFile = (ClassFile)getClassFile();
389
				if (classFile != null) {
390
					classFile.getBuffer();
391
					return mapper.getSourceRange(this);
392
				}
393
			}
394
			return SourceMapper.UNKNOWN_RANGE;
395
		}
332
		return new SourceRange(this.declarationSourceStart, this.declarationSourceEnd-this.declarationSourceStart+1);
396
		return new SourceRange(this.declarationSourceStart, this.declarationSourceEnd-this.declarationSourceStart+1);
333
	}
397
	}
334
398
(-)model/org/eclipse/jdt/internal/core/SourceMapper.java (-1 / +126 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 76-81 Link Here
76
	extends ReferenceInfoAdapter
76
	extends ReferenceInfoAdapter
77
	implements ISourceElementRequestor, SuffixConstants {
77
	implements ISourceElementRequestor, SuffixConstants {
78
78
79
	public static class LocalVariableElementKey {
80
		String parent;
81
		String name;
82
		
83
		public LocalVariableElementKey(IJavaElement method, String name) {
84
			StringBuffer buffer = new StringBuffer();
85
			buffer
86
				.append(method.getParent().getHandleIdentifier())
87
				.append('#')
88
				.append(method.getElementName())
89
				.append('(');
90
			if (method.getElementType() == IJavaElement.METHOD) {
91
				String[] parameterTypes = ((IMethod) method).getParameterTypes();
92
				for (int i = 0, max = parameterTypes.length; i < max; i++) {
93
					if (i > 0) {
94
						buffer.append(',');
95
					}
96
					buffer.append(Signature.getSignatureSimpleName(parameterTypes[i]));
97
				}
98
			}
99
			buffer.append(')');
100
			this.parent = String.valueOf(buffer);
101
			this.name = name;
102
		}
103
104
		public int hashCode() {
105
			final int prime = 31;
106
			int result = 1;
107
			result = prime * result + ((this.name == null) ? 0 : this.name.hashCode());
108
			result = prime * result + ((this.parent == null) ? 0 : this.parent.hashCode());
109
			return result;
110
		}
111
112
		public boolean equals(Object obj) {
113
			if (this == obj)
114
				return true;
115
			if (obj == null)
116
				return false;
117
			if (getClass() != obj.getClass())
118
				return false;
119
			LocalVariableElementKey other = (LocalVariableElementKey) obj;
120
			if (this.name == null) {
121
				if (other.name != null)
122
					return false;
123
			} else if (!this.name.equals(other.name))
124
				return false;
125
			if (this.parent == null) {
126
				if (other.parent != null)
127
					return false;
128
			} else if (!this.parent.equals(other.parent))
129
				return false;
130
			return true;
131
		}
132
		public String toString() {
133
			StringBuffer buffer = new StringBuffer();
134
			buffer.append('(').append(this.parent).append('.').append(this.name).append(')');
135
			return String.valueOf(buffer);
136
		}
137
	}
138
79
	public static boolean VERBOSE = false;
139
	public static boolean VERBOSE = false;
80
	/**
140
	/**
81
	 * Specifies the location of the package fragment roots within
141
	 * Specifies the location of the package fragment roots within
Lines 119-124 Link Here
119
	 */
179
	 */
120
	protected HashMap categories;
180
	protected HashMap categories;
121
181
182
	/**
183
	 * Table that contains all source ranges for local variables.
184
	 * Keys are the special local variable elements, entries are <code>char[][]</code>.
185
	 */
186
	protected HashMap parametersRanges;
187
	
188
	/**
189
	 * Set that contains all final local variables.
190
	 */
191
	protected HashSet finalParameters;
122
192
123
	/**
193
	/**
124
	 * The unknown source range {-1, 0}
194
	 * The unknown source range {-1, 0}
Lines 209-214 Link Here
209
		}
279
		}
210
		this.sourcePath = sourcePath;
280
		this.sourcePath = sourcePath;
211
		this.sourceRanges = new HashMap();
281
		this.sourceRanges = new HashMap();
282
		this.parametersRanges = new HashMap();
212
		this.parameterNames = new HashMap();
283
		this.parameterNames = new HashMap();
213
		this.importsTable = new HashMap();
284
		this.importsTable = new HashMap();
214
		this.importsCounterTable = new HashMap();
285
		this.importsCounterTable = new HashMap();
Lines 288-293 Link Here
288
	public void close() {
359
	public void close() {
289
		this.sourceRanges = null;
360
		this.sourceRanges = null;
290
		this.parameterNames = null;
361
		this.parameterNames = null;
362
		this.parametersRanges = null;
363
		this.finalParameters = null;
291
	}
364
	}
292
365
293
	/**
366
	/**
Lines 751-756 Link Here
751
							typeParameterInfo.nameSourceEnd - typeParameterInfo.nameSourceStart + 1));
824
							typeParameterInfo.nameSourceEnd - typeParameterInfo.nameSourceStart + 1));
752
				}
825
				}
753
			}
826
			}
827
			// parameters infos
828
			if (methodInfo.parameterInfos != null) {
829
				for (int i = 0, length = methodInfo.parameterInfos.length; i < length; i++) {
830
					ParameterInfo parameterInfo = methodInfo.parameterInfos[i];
831
					LocalVariableElementKey key = new LocalVariableElementKey(method, new String(parameterInfo.name));
832
					SourceRange[] allRanges = new SourceRange[] {
833
						new SourceRange(
834
							parameterInfo.declarationStart,
835
							parameterInfo.declarationEnd - parameterInfo.declarationStart + 1),
836
						new SourceRange(
837
							parameterInfo.nameSourceStart,
838
							parameterInfo.nameSourceEnd - parameterInfo.nameSourceStart + 1)
839
					};
840
					this.parametersRanges.put(
841
						key,
842
						allRanges);
843
					if (parameterInfo.modifiers != 0) {
844
						if (this.finalParameters == null) {
845
							this.finalParameters = new HashSet();
846
						}
847
						this.finalParameters.add(key);
848
					}
849
				}
850
			}
754
851
755
			// categories
852
			// categories
756
			addCategories(method, methodInfo.categories);
853
			addCategories(method, methodInfo.categories);
Lines 959-964 Link Here
959
	}
1056
	}
960
1057
961
1058
1059
	public int getFlags(IJavaElement element) {
1060
		switch(element.getElementType()) {
1061
			case IJavaElement.LOCAL_VARIABLE :
1062
				LocalVariableElementKey key = new LocalVariableElementKey(element.getParent(), element.getElementName());
1063
				if (this.finalParameters != null && this.finalParameters.contains(key)) {
1064
					return Flags.AccFinal;
1065
				}
1066
		}
1067
		return 0;
1068
	}
962
1069
963
	/**
1070
	/**
964
	 * Returns the SourceRange for the name of the given element, or
1071
	 * Returns the SourceRange for the name of the given element, or
Lines 990-995 Link Here
990
						element = method.getTypeParameter(element.getElementName());
1097
						element = method.getTypeParameter(element.getElementName());
991
					}
1098
					}
992
				}
1099
				}
1100
				break;
1101
			case IJavaElement.LOCAL_VARIABLE :
1102
				LocalVariableElementKey key = new LocalVariableElementKey(element.getParent(), element.getElementName());
1103
				SourceRange[] ranges = (SourceRange[]) this.parametersRanges.get(key);
1104
				if (ranges == null) {
1105
					return UNKNOWN_RANGE;
1106
				} else {
1107
					return ranges[1];
1108
				}
993
		}
1109
		}
994
		SourceRange[] ranges = (SourceRange[]) this.sourceRanges.get(element);
1110
		SourceRange[] ranges = (SourceRange[]) this.sourceRanges.get(element);
995
		if (ranges == null) {
1111
		if (ranges == null) {
Lines 1050-1055 Link Here
1050
						element = method.getTypeParameter(element.getElementName());
1166
						element = method.getTypeParameter(element.getElementName());
1051
					}
1167
					}
1052
				}
1168
				}
1169
				break;
1170
			case IJavaElement.LOCAL_VARIABLE :
1171
				LocalVariableElementKey key = new LocalVariableElementKey(element.getParent(), element.getElementName());
1172
				SourceRange[] ranges = (SourceRange[]) this.parametersRanges.get(key);
1173
				if (ranges == null) {
1174
					return UNKNOWN_RANGE;
1175
				} else {
1176
					return ranges[0];
1177
				}
1053
		}
1178
		}
1054
		SourceRange[] ranges = (SourceRange[]) this.sourceRanges.get(element);
1179
		SourceRange[] ranges = (SourceRange[]) this.sourceRanges.get(element);
1055
		if (ranges == null) {
1180
		if (ranges == null) {
(-)model/org/eclipse/jdt/internal/core/SourceMethod.java (-2 / +7 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 134-140 Link Here
134
	SourceMethodElementInfo info = (SourceMethodElementInfo) getElementInfo();
134
	SourceMethodElementInfo info = (SourceMethodElementInfo) getElementInfo();
135
	return info.typeParameters;
135
	return info.typeParameters;
136
}
136
}
137
137
public ILocalVariable[] getParameters() throws JavaModelException {
138
	ILocalVariable[] arguments = ((SourceMethodElementInfo) getElementInfo()).arguments;
139
	if (arguments == null)
140
		return LocalVariable.NO_LOCAL_VARIABLES;
141
	return arguments;
142
}
138
/**
143
/**
139
 * @see IMethod#getTypeParameterSignatures()
144
 * @see IMethod#getTypeParameterSignatures()
140
 * @since 3.0
145
 * @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.
(-)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 (-5 / +406 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-21 Link Here
10
 *******************************************************************************/
10
 *******************************************************************************/
11
package org.eclipse.jdt.core.tests.model;
11
package org.eclipse.jdt.core.tests.model;
12
12
13
import org.eclipse.core.runtime.CoreException;
13
import java.io.IOException;
14
import org.eclipse.jdt.core.*;
14
import java.util.HashMap;
15
import org.eclipse.jdt.core.tests.util.Util;
15
import java.util.Map;
16
16
17
import junit.framework.Test;
17
import junit.framework.Test;
18
18
19
import org.eclipse.core.runtime.CoreException;
20
import org.eclipse.jdt.core.Flags;
21
import org.eclipse.jdt.core.IAnnotation;
22
import org.eclipse.jdt.core.ICodeAssist;
23
import org.eclipse.jdt.core.ICompilationUnit;
24
import org.eclipse.jdt.core.IJavaElement;
25
import org.eclipse.jdt.core.IJavaProject;
26
import org.eclipse.jdt.core.ILocalVariable;
27
import org.eclipse.jdt.core.IMemberValuePair;
28
import org.eclipse.jdt.core.IMethod;
29
import org.eclipse.jdt.core.IPackageFragmentRoot;
30
import org.eclipse.jdt.core.ISourceRange;
31
import org.eclipse.jdt.core.IType;
32
import org.eclipse.jdt.core.JavaCore;
33
import org.eclipse.jdt.core.JavaModelException;
34
import org.eclipse.jdt.core.tests.util.Util;
35
import org.eclipse.jdt.internal.core.LocalVariable;
36
19
public class TypeResolveTests extends ModifyingResourceTests {
37
public class TypeResolveTests extends ModifyingResourceTests {
20
	ICompilationUnit cu;
38
	ICompilationUnit cu;
21
public TypeResolveTests(String name) {
39
public TypeResolveTests(String name) {
Lines 95-101 Link Here
95
}
113
}
96
	static {
114
	static {
97
//		TESTS_NUMBERS = new int[] { 182, 183 };
115
//		TESTS_NUMBERS = new int[] { 182, 183 };
98
//		TESTS_NAMES = new String[] {"test0177"};
116
//		TESTS_NAMES = new String[] { "testParamAnnotations4" };
99
	}
117
	}
100
	public static Test suite() {
118
	public static Test suite() {
101
		return buildModelTestSuite(TypeResolveTests.class);
119
		return buildModelTestSuite(TypeResolveTests.class);
Lines 299-302 Link Here
299
		"p4.A.Inner",
317
		"p4.A.Inner",
300
		types);
318
		types);
301
}
319
}
320
/**
321
 * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=334783"
322
 */
323
public void testParamAnnotations() throws CoreException {
324
	try {
325
		createJavaProject("P", new String[] {"src"}, new String[] {"JCL15_LIB"}, "bin", "1.5");
326
		String source = "package p;\n" +
327
				"public class X<T> {\n" +
328
				"	X<String> field;\n" +
329
				"	@Inject\n" +
330
				"	public void Test(@Default String processor) {}\n" +
331
				"}" +
332
				"@interface Inject{\n" +
333
				"}" +
334
				"@interface Default{\n" +
335
				"}";
336
		createFolder("/P/src/p");
337
		createFile(
338
			"/P/src/p/X.java",
339
			source
340
		);
341
		waitForAutoBuild();
342
		
343
		ICompilationUnit unit = getCompilationUnit("/P/src/p/X.java"); 
344
		IJavaElement[] variable = ((ICodeAssist) unit).codeSelect(source.indexOf("processor"), "processor".length());
345
346
		assertEquals(1, variable.length);
347
		String annotationString = "@Default [in processor [in Test(String) [in X [in X.java [in p [in src [in P]]]]]]]";
348
		assertEquals(annotationString, ((LocalVariable)variable[0]).getAnnotations()[0].toString());
349
		IType type = unit.getType("X");
350
		
351
		IMethod method = type.getMethods()[0];
352
		assertEquals(annotationString, method.getParameters()[0].getAnnotations()[0].toString());
353
	} finally {
354
		deleteProject("P");
355
	}
356
}
357
/**
358
 * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=334783"
359
 */
360
public void testParamAnnotations2() throws CoreException, IOException {
361
	try {
362
		IJavaProject project = createJavaProject("P", new String[] {"src"}, new String[] {"JCL15_LIB"}, "bin", "1.5");
363
		String[] pathAndContents = new String[]{"p/X.java",
364
				"package p;\n" +
365
				"public class X<T> {\n" +
366
				"	X<String> field;\n" +
367
				"	@Inject\n" +
368
				"	public void Test(@Default String processor) {}\n" +
369
				"}" +
370
				"@interface Inject{\n" +
371
				"}" +
372
				"@interface Default{\n" +
373
				"}"};
374
		addLibrary(project, "lib334783.jar", "libsrc.zip", pathAndContents, JavaCore.VERSION_1_5);
375
		
376
		waitForAutoBuild();
377
		IPackageFragmentRoot root = project.getPackageFragmentRoot(getFile("/P/lib334783.jar"));
378
		IType type = root.getPackageFragment("p").getClassFile("X.class").getType();
379
		String annotationString = "@p.Default [in processor [in Test(java.lang.String) [in X [in X.class [in p [in lib334783.jar [in P]]]]]]]";
380
		
381
		IMethod method = type.getMethods()[1];
382
		assertEquals(annotationString, method.getParameters()[0].getAnnotations()[0].toString());
383
	} finally {
384
		deleteProject("P");
385
	}
386
}
387
/**
388
 * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=334783"
389
 */
390
public void testParamAnnotations3() throws CoreException {
391
	try {
392
		createJavaProject("P", new String[] {"src"}, new String[] {"JCL15_LIB"}, "bin", "1.5");
393
		String source = "package p;\n" +
394
				"public class X<T> {\n" +
395
				"	X<String> field;\n" +
396
				"	@Inject\n" +
397
				"	public void Test(int i, @Default @Marker(id=1) String processor, int k) {}\n" +
398
				"}\n" +
399
				"@interface Inject{\n" +
400
				"}\n" +
401
				"@interface Marker {\n" +
402
				"	int id() default 0;\n" +
403
				"}\n" +
404
				"@interface Default{\n" +
405
				"}";
406
		createFolder("/P/src/p");
407
		createFile(
408
			"/P/src/p/X.java",
409
			source
410
		);
411
		waitForAutoBuild();
412
		
413
		ICompilationUnit unit = getCompilationUnit("/P/src/p/X.java"); 
414
		IJavaElement[] variable = ((ICodeAssist) unit).codeSelect(source.indexOf("processor"), "processor".length());
415
416
		assertEquals(1, variable.length);
417
		String annotationString1 = "@Default [in processor [in Test(int, String, int) [in X [in X.java [in p [in src [in P]]]]]]]";
418
		String annotationString2 = "@Marker [in processor [in Test(int, String, int) [in X [in X.java [in p [in src [in P]]]]]]]";
419
		assertEquals(annotationString1, ((LocalVariable)variable[0]).getAnnotations()[0].toString());
420
		IType type = unit.getType("X");
421
		
422
		IMethod method = type.getMethods()[0];
423
		IAnnotation[] parameterAnnotations = method.getParameters()[1].getAnnotations();
424
		assertEquals("Wrong length", 2, parameterAnnotations.length);
425
		assertEquals(annotationString1, parameterAnnotations[0].toString());
426
		IAnnotation iAnnotation = parameterAnnotations[1];
427
		assertEquals(annotationString2, iAnnotation.toString());
428
		IMemberValuePair[] memberValuePairs = iAnnotation.getMemberValuePairs();
429
		assertEquals("Wrong number of pairs", 1, memberValuePairs.length);
430
		StringBuffer output = new StringBuffer();
431
		output.append(memberValuePairs[0].getMemberName());
432
		output.append(' ');
433
		output.append(memberValuePairs[0].getValue());
434
		assertEquals("Wrong value", "id 1", String.valueOf(output));
435
		assertEquals("Wrong length", 0, method.getParameters()[0].getAnnotations().length);
436
		assertEquals("Wrong length", 0, method.getParameters()[2].getAnnotations().length);
437
	} finally {
438
		deleteProject("P");
439
	}
440
}
441
/**
442
 * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=334783"
443
 */
444
public void testParamAnnotations4() throws CoreException, IOException {
445
	try {
446
		IJavaProject project = createJavaProject("P", new String[] {"src"}, new String[] {"JCL15_LIB"}, "bin", "1.5");
447
		String sourceX =
448
				"package p;\n" +
449
				"public class X<T> {\n" +
450
				"	X<String> field;\n" +
451
				"	@Inject @Marker(id=3)\n" +
452
				"	public void Test(final int i, @Default final @Marker(id=1) String processor, int k) {}\n" +
453
				"}";
454
		String[] pathAndContents = new String[]{"p/X.java",
455
				sourceX,
456
				"p/Inject.java",
457
				"package p;\n"+
458
				"public @interface Inject{\n" +
459
				"}",
460
				"p/Marker.java",
461
				"package p;\n" +
462
				"public @interface Marker {\n" +
463
				"	int id() default 0;\n" +
464
				"}",
465
				"p/Default.java",
466
				"package p;\n" +
467
				"public @interface Default{\n" +
468
				"}"};
469
		addLibrary(project, "lib334783_2.jar", "lib334783_2src.zip", pathAndContents, JavaCore.VERSION_1_5);
470
		
471
		waitForAutoBuild();
472
		IPackageFragmentRoot root = project.getPackageFragmentRoot(getFile("/P/lib334783_2.jar"));
473
		IType type = root.getPackageFragment("p").getClassFile("X.class").getType();
474
		String annotationString1 = "@p.Default [in processor [in Test(int, java.lang.String, int) [in X [in X.class [in p [in lib334783_2.jar [in P]]]]]]]";
475
		String annotationString2 = "@p.Marker [in processor [in Test(int, java.lang.String, int) [in X [in X.class [in p [in lib334783_2.jar [in P]]]]]]]";
476
		IMethod method = type.getMethods()[1];
477
		IAnnotation[] annotations = method.getAnnotations();
478
		assertEquals("Wrong length", 2, annotations.length);
479
		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());
480
		IAnnotation annotation = annotations[1];
481
		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());
482
		IMemberValuePair[] memberValuePairs = annotation.getMemberValuePairs();
483
		assertEquals("Wrong number of pairs", 1, memberValuePairs.length);
484
		StringBuffer output = new StringBuffer();
485
		output.append(memberValuePairs[0].getMemberName());
486
		output.append(' ');
487
		output.append(memberValuePairs[0].getValue());
488
		assertEquals("Wrong value", "id 3", String.valueOf(output));
489
		ILocalVariable localVariable = method.getParameters()[1];
490
		ISourceRange sourceRange = localVariable.getSourceRange();
491
		String localSource = sourceX.substring(
492
				sourceRange.getOffset(),
493
				sourceRange.getOffset() + sourceRange.getLength());
494
		assertEquals("Wrong source", "@Default final @Marker(id=1) String processor", localSource);
495
		assertTrue("Wrong modifiers", Flags.isFinal(localVariable.getFlags()));
496
		IAnnotation[] parameterAnnotations = localVariable.getAnnotations();
497
		assertEquals("Wrong length", 2, parameterAnnotations.length);
498
		assertEquals(annotationString1, parameterAnnotations[0].toString());
499
		annotation = parameterAnnotations[1];
500
		assertEquals(annotationString2, annotation.toString());
501
		memberValuePairs = annotation.getMemberValuePairs();
502
		assertEquals("Wrong number of pairs", 1, memberValuePairs.length);
503
		output = new StringBuffer();
504
		output.append(memberValuePairs[0].getMemberName());
505
		output.append(' ');
506
		output.append(memberValuePairs[0].getValue());
507
		assertEquals("Wrong value", "id 1", String.valueOf(output));
508
		localVariable = method.getParameters()[0];
509
		assertEquals("Wrong length", 0, localVariable.getAnnotations().length);
510
		assertTrue("Wrong modifiers", Flags.isFinal(localVariable.getFlags()));
511
		assertEquals("Wrong length", 0, method.getParameters()[2].getAnnotations().length);
512
	} finally {
513
		deleteProject("P");
514
	}
515
}
516
/**
517
 * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=334783"
518
 */
519
public void testParamAnnotations5() throws CoreException, IOException {
520
	try {
521
		IJavaProject project = createJavaProject("P", new String[] {"src"}, new String[] {"JCL15_LIB"}, "bin", "1.5");
522
		String[] pathAndContents = new String[]{"p/X.java",
523
				"package p;\n" +
524
				"public class X<T> {\n" +
525
				"	X<String> field;\n" +
526
				"	@Inject @Marker(id=3)\n" +
527
				"	public void Test(int i, @Default @Marker(id=1) String processor, int k) {}\n" +
528
				"}",
529
				"p/Inject.java",
530
				"package p;\n"+
531
				"public @interface Inject{\n" +
532
				"}",
533
				"p/Marker.java",
534
				"package p;\n" +
535
				"public @interface Marker {\n" +
536
				"	int id() default 0;\n" +
537
				"}",
538
				"p/Default.java",
539
				"package p;\n" +
540
				"public @interface Default{\n" +
541
				"}"};
542
		Map options = new HashMap();
543
		options.put(JavaCore.COMPILER_LOCAL_VARIABLE_ATTR, JavaCore.DO_NOT_GENERATE);
544
		addLibrary(project, "lib334783_3.jar", "lib334783_3src.zip", pathAndContents, JavaCore.VERSION_1_5, options);
545
		
546
		waitForAutoBuild();
547
		IPackageFragmentRoot root = project.getPackageFragmentRoot(getFile("/P/lib334783_3.jar"));
548
		IType type = root.getPackageFragment("p").getClassFile("X.class").getType();
549
		String annotationString1 = "@p.Default [in arg1 [in Test(int, java.lang.String, int) [in X [in X.class [in p [in lib334783_3.jar [in P]]]]]]]";
550
		String annotationString2 = "@p.Marker [in arg1 [in Test(int, java.lang.String, int) [in X [in X.class [in p [in lib334783_3.jar [in P]]]]]]]";
551
		IMethod method = type.getMethods()[1];
552
		IAnnotation[] annotations = method.getAnnotations();
553
		assertEquals("Wrong length", 2, annotations.length);
554
		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());
555
		IAnnotation annotation = annotations[1];
556
		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());
557
		IMemberValuePair[] memberValuePairs = annotation.getMemberValuePairs();
558
		assertEquals("Wrong number of pairs", 1, memberValuePairs.length);
559
		StringBuffer output = new StringBuffer();
560
		output.append(memberValuePairs[0].getMemberName());
561
		output.append(' ');
562
		output.append(memberValuePairs[0].getValue());
563
		assertEquals("Wrong value", "id 3", String.valueOf(output));
564
		IAnnotation[] parameterAnnotations = method.getParameters()[1].getAnnotations();
565
		assertEquals("Wrong length", 2, parameterAnnotations.length);
566
		assertEquals(annotationString1, parameterAnnotations[0].toString());
567
		annotation = parameterAnnotations[1];
568
		assertEquals(annotationString2, annotation.toString());
569
		memberValuePairs = annotation.getMemberValuePairs();
570
		assertEquals("Wrong number of pairs", 1, memberValuePairs.length);
571
		output = new StringBuffer();
572
		output.append(memberValuePairs[0].getMemberName());
573
		output.append(' ');
574
		output.append(memberValuePairs[0].getValue());
575
		assertEquals("Wrong value", "id 1", String.valueOf(output));
576
		assertEquals("Wrong length", 0, method.getParameters()[0].getAnnotations().length);
577
		assertEquals("Wrong length", 0, method.getParameters()[2].getAnnotations().length);
578
	} finally {
579
		deleteProject("P");
580
	}
581
}
582
/**
583
 * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=334783"
584
 */
585
public void testParamAnnotations6() throws CoreException {
586
	try {
587
		createJavaProject("P", new String[] {"src"}, new String[] {"JCL15_LIB"}, "bin", "1.5");
588
		String source = "package p;\n" +
589
				"public class X<T> {\n" +
590
				"	X<String> field;\n" +
591
				"	public void Test() {}\n" +
592
				"}";
593
		createFolder("/P/src/p");
594
		createFile(
595
			"/P/src/p/X.java",
596
			source
597
		);
598
		waitForAutoBuild();
599
		
600
		ICompilationUnit unit = getCompilationUnit("/P/src/p/X.java"); 
601
		IType type = unit.getType("X");
602
		IMethod method = type.getMethods()[0];
603
		ILocalVariable[] localVariables = method.getParameters();
604
		assertNotNull(localVariables);
605
		assertEquals("Wrong length", 0, localVariables.length);
606
	} finally {
607
		deleteProject("P");
608
	}
609
}
610
/**
611
 * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=334783"
612
 */
613
public void testParamAnnotations7() throws CoreException, IOException {
614
	try {
615
		IJavaProject project = createJavaProject("P", new String[] {"src"}, new String[] {"JCL15_LIB"}, "bin", "1.5");
616
		String[] pathAndContents = new String[]{"p/X.java",
617
				"package p;\n" +
618
				"public class X<T> {\n" +
619
				"	X<String> field;\n" +
620
				"	public void Test() {}\n" +
621
				"}"
622
		};
623
		addLibrary(project, "lib334783.jar", "libsrc.zip", pathAndContents, JavaCore.VERSION_1_5);
624
		
625
		waitForAutoBuild();
626
		IPackageFragmentRoot root = project.getPackageFragmentRoot(getFile("/P/lib334783.jar"));
627
		IType type = root.getPackageFragment("p").getClassFile("X.class").getType();
628
		
629
		IMethod method = type.getMethods()[1];
630
		ILocalVariable[] localVariables = method.getParameters();
631
		assertNotNull(localVariables);
632
		assertEquals("Wrong length", 0, localVariables.length);
633
	} finally {
634
		deleteProject("P");
635
	}
636
}
637
/**
638
 * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=334783"
639
 */
640
public void testParamAnnotations8() throws CoreException, IOException {
641
	try {
642
		IJavaProject project = createJavaProject("P", new String[] {"src"}, new String[] {"JCL15_LIB"}, "bin", "1.5");
643
		String[] pathAndContents = new String[]{"p/X.java",
644
				"package p;\n" +
645
				"public class X<T> {\n" +
646
				"	X<String> field;\n" +
647
				"	@Inject @Marker(id=3)\n" +
648
				"	public X(int i, @Default @Marker(id=1) String processor, int k) {}\n" +
649
				"}",
650
				"p/Inject.java",
651
				"package p;\n"+
652
				"public @interface Inject{\n" +
653
				"}",
654
				"p/Marker.java",
655
				"package p;\n" +
656
				"public @interface Marker {\n" +
657
				"	int id() default 0;\n" +
658
				"}",
659
				"p/Default.java",
660
				"package p;\n" +
661
				"public @interface Default{\n" +
662
				"}"};
663
		Map options = new HashMap();
664
		options.put(JavaCore.COMPILER_LOCAL_VARIABLE_ATTR, JavaCore.DO_NOT_GENERATE);
665
		addLibrary(project, "lib334783_3.jar", "lib334783_3src.zip", pathAndContents, JavaCore.VERSION_1_5, options);
666
		
667
		waitForAutoBuild();
668
		IPackageFragmentRoot root = project.getPackageFragmentRoot(getFile("/P/lib334783_3.jar"));
669
		IType type = root.getPackageFragment("p").getClassFile("X.class").getType();
670
		String annotationString1 = "@p.Default [in arg1 [in X(int, java.lang.String, int) [in X [in X.class [in p [in lib334783_3.jar [in P]]]]]]]";
671
		String annotationString2 = "@p.Marker [in arg1 [in X(int, java.lang.String, int) [in X [in X.class [in p [in lib334783_3.jar [in P]]]]]]]";
672
		IMethod method = type.getMethods()[0];
673
		IAnnotation[] annotations = method.getAnnotations();
674
		assertEquals("Wrong length", 2, annotations.length);
675
		assertEquals("@p.Inject [in X(int, java.lang.String, int) [in X [in X.class [in p [in lib334783_3.jar [in P]]]]]]", annotations[0].toString());
676
		IAnnotation annotation = annotations[1];
677
		assertEquals("@p.Marker [in X(int, java.lang.String, int) [in X [in X.class [in p [in lib334783_3.jar [in P]]]]]]", annotation.toString());
678
		IMemberValuePair[] memberValuePairs = annotation.getMemberValuePairs();
679
		assertEquals("Wrong number of pairs", 1, memberValuePairs.length);
680
		StringBuffer output = new StringBuffer();
681
		output.append(memberValuePairs[0].getMemberName());
682
		output.append(' ');
683
		output.append(memberValuePairs[0].getValue());
684
		assertEquals("Wrong value", "id 3", String.valueOf(output));
685
		IAnnotation[] parameterAnnotations = method.getParameters()[1].getAnnotations();
686
		assertEquals("Wrong length", 2, parameterAnnotations.length);
687
		assertEquals(annotationString1, parameterAnnotations[0].toString());
688
		annotation = parameterAnnotations[1];
689
		assertEquals(annotationString2, annotation.toString());
690
		memberValuePairs = annotation.getMemberValuePairs();
691
		assertEquals("Wrong number of pairs", 1, memberValuePairs.length);
692
		output = new StringBuffer();
693
		output.append(memberValuePairs[0].getMemberName());
694
		output.append(' ');
695
		output.append(memberValuePairs[0].getValue());
696
		assertEquals("Wrong value", "id 1", String.valueOf(output));
697
		assertEquals("Wrong length", 0, method.getParameters()[0].getAnnotations().length);
698
		assertEquals("Wrong length", 0, method.getParameters()[2].getAnnotations().length);
699
	} finally {
700
		deleteProject("P");
701
	}
702
}
302
}
703
}

Return to bug 334783