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 / +14 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>If the method does not come from source, the positions and the flag of the parameters are irrelevant.
108
 * These local variables can be used to retrieve the parameter annotations.</p>
109
 * 
110
 * @return the array of annotations for the specified parameter
111
 * @throws JavaModelException
112
 * @since 3.7
113
 */
114
ILocalVariable[] getParameters() throws JavaModelException;
115
103
/**
116
/**
104
 * Returns the binding key for this method only if the given method is {@link #isResolved() resolved}.
117
 * 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
118
 * A binding key is a key that uniquely identifies this method. It allows access
(-)model/org/eclipse/jdt/internal/core/Annotation.java (-1 / +17 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 30-42 Link Here
30
	// require to distinguish same annotations in different member value pairs
31
	// require to distinguish same annotations in different member value pairs
31
	protected String memberValuePairName;
32
	protected String memberValuePairName;
32
33
34
	protected char[] argumentName;
35
33
	public Annotation(JavaElement parent, String name) {
36
	public Annotation(JavaElement parent, String name) {
34
		this(parent, name, null);
37
		this(parent, name, null);
35
	}
38
	}
36
39
37
	public Annotation(JavaElement parent, String name, String memberValuePairName) {
40
	public Annotation(JavaElement parent, String name, String memberValuePairName) {
41
		this(parent, null, name, memberValuePairName);
42
	}
43
44
	public Annotation(JavaElement parent, char[] argumentName, String name, String memberValuePairName) {
38
		super(parent);
45
		super(parent);
39
		this.name = name;
46
		this.name = name;
47
		this.argumentName = argumentName;
40
		this.memberValuePairName = memberValuePairName;
48
		this.memberValuePairName = memberValuePairName;
41
	}
49
	}
42
50
Lines 45-50 Link Here
45
			return false;
53
			return false;
46
		}
54
		}
47
		Annotation other = (Annotation) o;
55
		Annotation other = (Annotation) o;
56
		if (this.argumentName == null) {
57
			if (other.argumentName != null) {
58
				return false;
59
			}
60
		} else if (!CharOperation.equals(this.argumentName, other.argumentName)) {
61
			return false;
62
		}
48
		if (this.memberValuePairName == null) {
63
		if (this.memberValuePairName == null) {
49
			if (other.memberValuePairName != null)
64
			if (other.memberValuePairName != null)
50
				return false;
65
				return false;
Lines 129-134 Link Here
129
		final int prime = 31;
144
		final int prime = 31;
130
		int result = super.hashCode();
145
		int result = super.hashCode();
131
		result = prime * result + ((this.memberValuePairName == null) ? 0 : this.memberValuePairName.hashCode());
146
		result = prime * result + ((this.memberValuePairName == null) ? 0 : this.memberValuePairName.hashCode());
147
		result = prime * result + ((this.argumentName == null) ? 0 : CharOperation.hashCode(this.argumentName));
132
		result = prime * result + this.name.hashCode();
148
		result = prime * result + this.name.hashCode();
133
		return result;
149
		return result;
134
	}
150
	}
(-)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 / +52 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
		localVariables[i] = new LocalVariable(
89
				this,
90
				new String(argumentNames[i]),
91
				-1,
92
				-1,
93
				-1,
94
				-1,
95
				this.parameterTypes[i],
96
				getAnnotations(argumentNames[i], info.getParameterAnnotations(i), info.getTagBits()),
97
				0,
98
				true);
99
	}
100
	return localVariables;
101
}
102
private IAnnotation[] getAnnotations(char[] argumentName, IBinaryAnnotation[] binaryAnnotations, long tagBits) {
103
	IAnnotation[] standardAnnotations = getStandardAnnotations(tagBits);
104
	if (binaryAnnotations == null)
105
		return standardAnnotations;
106
	int length = binaryAnnotations.length;
107
	int standardLength = standardAnnotations.length;
108
	IAnnotation[] annotations = new IAnnotation[length + standardLength];
109
	for (int i = 0; i < length; i++) {
110
		annotations[i] = Util.getAnnotation(this, argumentName, binaryAnnotations[i], null);
111
	}
112
	System.arraycopy(standardAnnotations, 0, annotations, length, standardLength);
113
	return annotations;
114
}
64
public IMemberValuePair getDefaultValue() throws JavaModelException {
115
public IMemberValuePair getDefaultValue() throws JavaModelException {
65
	IBinaryMethod info = (IBinaryMethod) getElementInfo();
116
	IBinaryMethod info = (IBinaryMethod) getElementInfo();
66
	Object defaultValue = info.getDefaultValue();
117
	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/LocalVariable.java (-1 / +27 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 66-71 Link Here
66
		this.isParameter = isParameter;
68
		this.isParameter = isParameter;
67
	}
69
	}
68
70
71
	public LocalVariable(
72
			JavaElement parent,
73
			String name,
74
			int declarationSourceStart,
75
			int declarationSourceEnd,
76
			int nameStart,
77
			int nameEnd,
78
			String typeSignature,
79
			IAnnotation[] annotations,
80
			int flags,
81
			boolean isParameter) {
82
83
		super(parent);
84
		this.name = name;
85
		this.declarationSourceStart = declarationSourceStart;
86
		this.declarationSourceEnd = declarationSourceEnd;
87
		this.nameStart = nameStart;
88
		this.nameEnd = nameEnd;
89
		this.typeSignature = typeSignature;
90
		this.annotations = annotations;
91
		this.flags = flags;
92
		this.isParameter = isParameter;
93
	}
94
69
	protected void closing(Object info) {
95
	protected void closing(Object info) {
70
		// a local variable has no info
96
		// a local variable has no info
71
	}
97
	}
(-)model/org/eclipse/jdt/internal/core/Member.java (-2 / +2 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 221-227 Link Here
221
			memento.nextToken(); // JEM_COUNT
221
			memento.nextToken(); // JEM_COUNT
222
			if (!memento.hasMoreTokens()) return this;
222
			if (!memento.hasMoreTokens()) return this;
223
			boolean isParameter = Boolean.valueOf(memento.nextToken()).booleanValue();
223
			boolean isParameter = Boolean.valueOf(memento.nextToken()).booleanValue();
224
			return new LocalVariable(this, varName, declarationStart, declarationEnd, nameStart, nameEnd, typeSignature, null, flags, isParameter);
224
			return new LocalVariable(this, varName, declarationStart, declarationEnd, nameStart, nameEnd, typeSignature, Annotation.NO_ANNOTATIONS, flags, isParameter);
225
		case JEM_TYPE_PARAMETER:
225
		case JEM_TYPE_PARAMETER:
226
			if (!memento.hasMoreTokens()) return this;
226
			if (!memento.hasMoreTokens()) return this;
227
			String typeParameterName = memento.nextToken();
227
			String typeParameterName = memento.nextToken();
(-)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.
(-)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/MementoTests.java (-4 / +5 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-22 Link Here
17
import org.eclipse.core.runtime.Path;
17
import org.eclipse.core.runtime.Path;
18
import org.eclipse.jdt.core.*;
18
import org.eclipse.jdt.core.*;
19
import org.eclipse.jdt.core.tests.util.Util;
19
import org.eclipse.jdt.core.tests.util.Util;
20
import org.eclipse.jdt.internal.core.Annotation;
20
import org.eclipse.jdt.internal.core.JavaElement;
21
import org.eclipse.jdt.internal.core.JavaElement;
21
import org.eclipse.jdt.internal.core.LocalVariable;
22
import org.eclipse.jdt.internal.core.LocalVariable;
22
23
Lines 486-492 Link Here
486
	IType type = getCompilationUnit("/P/src/p/X.java").getType("X");
487
	IType type = getCompilationUnit("/P/src/p/X.java").getType("X");
487
	IMethod method = type.getMethod("foo", new String[]{});
488
	IMethod method = type.getMethod("foo", new String[]{});
488
489
489
	ILocalVariable localVar = new LocalVariable((JavaElement)method, "var", 1, 2, 3, 4, "Z", null, 0, true);
490
	ILocalVariable localVar = new LocalVariable((JavaElement)method, "var", 1, 2, 3, 4, "Z", Annotation.NO_ANNOTATIONS, 0, true);
490
	assertMemento(
491
	assertMemento(
491
		"=P/src<p{X.java[X~foo@var!1!2!3!4!Z!0!true",
492
		"=P/src<p{X.java[X~foo@var!1!2!3!4!Z!0!true",
492
		localVar);
493
		localVar);
Lines 498-504 Link Here
498
	IType type = getClassFile("/P/src/p/X.class").getType();
499
	IType type = getClassFile("/P/src/p/X.class").getType();
499
	IMethod method = type.getMethod("foo", new String[]{"I"});
500
	IMethod method = type.getMethod("foo", new String[]{"I"});
500
501
501
	ILocalVariable localVar = new LocalVariable((JavaElement)method, "var", 1, 2, 3, 4, "Z", null,0, false);
502
	ILocalVariable localVar = new LocalVariable((JavaElement)method, "var", 1, 2, 3, 4, "Z", Annotation.NO_ANNOTATIONS,0, false);
502
	assertMemento(
503
	assertMemento(
503
		"=P/src<p(X.class[X~foo~I@var!1!2!3!4!Z!0!false",
504
		"=P/src<p(X.class[X~foo~I@var!1!2!3!4!Z!0!false",
504
		localVar);
505
		localVar);
Lines 510-516 Link Here
510
	IType type = getCompilationUnit("/P/src/p/X.java").getType("X");
511
	IType type = getCompilationUnit("/P/src/p/X.java").getType("X");
511
	IInitializer initializer = type.getInitializer(1);
512
	IInitializer initializer = type.getInitializer(1);
512
513
513
	ILocalVariable localVar = new LocalVariable((JavaElement)initializer, "var", 1, 2, 3, 4, "Z", null, 0, false);
514
	ILocalVariable localVar = new LocalVariable((JavaElement)initializer, "var", 1, 2, 3, 4, "Z", Annotation.NO_ANNOTATIONS, 0, false);
514
	assertMemento(
515
	assertMemento(
515
		"=P/src<p{X.java[X|1@var!1!2!3!4!Z!0!false",
516
		"=P/src<p{X.java[X|1@var!1!2!3!4!Z!0!false",
516
		localVar);
517
		localVar);
(-)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/SearchTests.java (-3 / +34 lines)
Lines 23-28 Link Here
23
import org.eclipse.jdt.core.search.*;
23
import org.eclipse.jdt.core.search.*;
24
import org.eclipse.jdt.core.tests.model.Semaphore.TimeOutException;
24
import org.eclipse.jdt.core.tests.model.Semaphore.TimeOutException;
25
import org.eclipse.jdt.core.tests.util.Util;
25
import org.eclipse.jdt.core.tests.util.Util;
26
import org.eclipse.jdt.internal.core.Annotation;
26
import org.eclipse.jdt.internal.core.JavaElement;
27
import org.eclipse.jdt.internal.core.JavaElement;
27
import org.eclipse.jdt.internal.core.JavaModelManager;
28
import org.eclipse.jdt.internal.core.JavaModelManager;
28
import org.eclipse.jdt.internal.core.LocalVariable;
29
import org.eclipse.jdt.internal.core.LocalVariable;
Lines 913-919 Link Here
913
 * Test LocalVarDeclarationPattern creation
914
 * Test LocalVarDeclarationPattern creation
914
 */
915
 */
915
public void testSearchPatternCreation30() {
916
public void testSearchPatternCreation30() {
916
	ILocalVariable localVar = new LocalVariable((JavaElement)getCompilationUnit("/P/X.java").getType("X").getMethod("foo", new String[0]),  "var", 1, 2, 3, 4, "Z", null, 0, false);
917
	ILocalVariable localVar = new LocalVariable(
918
			(JavaElement)getCompilationUnit("/P/X.java").getType("X").getMethod("foo", new String[0]),
919
			"var",
920
			1,
921
			2,
922
			3,
923
			4,
924
			"Z",
925
			Annotation.NO_ANNOTATIONS,
926
			0,
927
			false);
917
	SearchPattern searchPattern = createPattern(
928
	SearchPattern searchPattern = createPattern(
918
			localVar,
929
			localVar,
919
			IJavaSearchConstants.DECLARATIONS);
930
			IJavaSearchConstants.DECLARATIONS);
Lines 927-933 Link Here
927
 * Test LocalVarReferencePattern creation
938
 * Test LocalVarReferencePattern creation
928
 */
939
 */
929
public void testSearchPatternCreation31() {
940
public void testSearchPatternCreation31() {
930
	ILocalVariable localVar = new LocalVariable((JavaElement)getCompilationUnit("/P/X.java").getType("X").getMethod("foo", new String[0]),  "var", 1, 2, 3, 4, "Z", null, 0, false);
941
	ILocalVariable localVar = new LocalVariable(
942
			(JavaElement)getCompilationUnit("/P/X.java").getType("X").getMethod("foo", new String[0]),
943
			"var",
944
			1,
945
			2,
946
			3,
947
			4,
948
			"Z",
949
			Annotation.NO_ANNOTATIONS,
950
			0,
951
			false);
931
	SearchPattern searchPattern = createPattern(
952
	SearchPattern searchPattern = createPattern(
932
			localVar,
953
			localVar,
933
			IJavaSearchConstants.REFERENCES);
954
			IJavaSearchConstants.REFERENCES);
Lines 941-947 Link Here
941
 * Test LocalVarCombinedPattern creation
962
 * Test LocalVarCombinedPattern creation
942
 */
963
 */
943
public void testSearchPatternCreation32() {
964
public void testSearchPatternCreation32() {
944
	ILocalVariable localVar = new LocalVariable((JavaElement)getCompilationUnit("/P/X.java").getType("X").getMethod("foo", new String[0]),  "var", 1, 2, 3, 4, "Z", null, 0, false);
965
	ILocalVariable localVar = new LocalVariable(
966
			(JavaElement)getCompilationUnit("/P/X.java").getType("X").getMethod("foo", new String[0]),
967
			"var",
968
			1,
969
			2,
970
			3,
971
			4,
972
			"Z",
973
			Annotation.NO_ANNOTATIONS,
974
			0,
975
			false);
945
	SearchPattern searchPattern = createPattern(
976
	SearchPattern searchPattern = createPattern(
946
			localVar,
977
			localVar,
947
			IJavaSearchConstants.ALL_OCCURRENCES);
978
			IJavaSearchConstants.ALL_OCCURRENCES);
(-)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;\n" +
314
				"public class X<T> {\n" +
315
				"  X<String> field;\n" +
316
				"	@Inject\n" +
317
				"	public void Test(@Default String processor) {}\n" +
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.getParameters()[0].getAnnotations()[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;\n" +
352
				"public class X<T> {\n" +
353
				"  X<String> field;\n" +
354
				"	@Inject\n" +
355
				"	public void Test(@Default String processor) {}\n" +
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.getParameters()[0].getAnnotations()[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;\n" +
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.getParameters()[1].getAnnotations();
411
		assertEquals("Wrong length", 2, parameterAnnotations.length);
412
		assertEquals(annotationString1, parameterAnnotations[0].toString());
413
		IAnnotation iAnnotation = parameterAnnotations[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, method.getParameters()[0].getAnnotations().length);
423
		assertEquals("Wrong length", 0, method.getParameters()[2].getAnnotations().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;\n" +
436
				"public class X<T> {\n" +
437
				"  X<String> field;\n" +
438
				"	@Inject @Marker(id=3)\n" +
439
				"	public void Test(int i, @Default @Marker(id=1) String processor, int k) {}\n" +
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.getParameters()[1].getAnnotations();
475
		assertEquals("Wrong length", 2, parameterAnnotations.length);
476
		assertEquals(annotationString1, parameterAnnotations[0].toString());
477
		annotation = parameterAnnotations[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, method.getParameters()[0].getAnnotations().length);
487
		assertEquals("Wrong length", 0, method.getParameters()[2].getAnnotations().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;\n" +
500
				"public class X<T> {\n" +
501
				"  X<String> field;\n" +
502
				"	@Inject @Marker(id=3)\n" +
503
				"	public void Test(int i, @Default @Marker(id=1) String processor, int k) {}\n" +
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.getParameters()[1].getAnnotations();
541
		assertEquals("Wrong length", 2, parameterAnnotations.length);
542
		assertEquals(annotationString1, parameterAnnotations[0].toString());
543
		annotation = parameterAnnotations[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, method.getParameters()[0].getAnnotations().length);
553
		assertEquals("Wrong length", 0, method.getParameters()[2].getAnnotations().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;\n" +
565
				"public class X<T> {\n" +
566
				"  X<String> field;\n" +
567
				"	public void Test() {}\n" +
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
		ILocalVariable[] localVariables = method.getParameters();
580
		assertNotNull(localVariables);
581
		assertEquals("Wrong length", 0, localVariables.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;\n" +
594
				"public class X<T> {\n" +
595
				"  X<String> field;\n" +
596
				"	public void Test() {}\n" +
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
		ILocalVariable[] localVariables = method.getParameters();
607
		assertNotNull(localVariables);
608
		assertEquals("Wrong length", 0, localVariables.length);
609
	} finally {
610
		deleteProject("P");
611
	}
612
}
302
}
613
}

Return to bug 334783