Lines 16-25
Link Here
|
16 |
import org.eclipse.jdt.core.compiler.CharOperation; |
16 |
import org.eclipse.jdt.core.compiler.CharOperation; |
17 |
import org.eclipse.jdt.internal.compiler.ast.Wildcard; |
17 |
import org.eclipse.jdt.internal.compiler.ast.Wildcard; |
18 |
|
18 |
|
19 |
/* |
|
|
20 |
* Converts a binding key into a signature |
21 |
*/ |
22 |
// TODO (jerome) handle methods and fields |
23 |
public class KeyToSignature extends BindingKeyParser { |
19 |
public class KeyToSignature extends BindingKeyParser { |
24 |
|
20 |
|
25 |
public static final int SIGNATURE = 0; |
21 |
public static final int SIGNATURE = 0; |
Lines 101-132
Link Here
|
101 |
this.signature.append(Signature.C_PARAM_START); |
97 |
this.signature.append(Signature.C_PARAM_START); |
102 |
char[][] parameters = Signature.getParameterTypes(methodSignature); |
98 |
char[][] parameters = Signature.getParameterTypes(methodSignature); |
103 |
for (int i = 0, parametersLength = parameters.length; i < parametersLength; i++) |
99 |
for (int i = 0, parametersLength = parameters.length; i < parametersLength; i++) |
104 |
this.signature.append(substitute(parameters[i], typeParameterSigs, typeParametersSize)); |
100 |
substitute(parameters[i], typeParameterSigs, typeParametersSize); |
105 |
this.signature.append(Signature.C_PARAM_END); |
101 |
this.signature.append(Signature.C_PARAM_END); |
106 |
|
102 |
|
107 |
// substitute return type |
103 |
// substitute return type |
108 |
char[] returnType = Signature.getReturnType(methodSignature); |
104 |
char[] returnType = Signature.getReturnType(methodSignature); |
109 |
returnType = substitute(returnType, typeParameterSigs, typeParametersSize); |
105 |
substitute(returnType, typeParameterSigs, typeParametersSize); |
110 |
this.signature.append(returnType); |
|
|
111 |
|
106 |
|
112 |
// substitute exceptions |
107 |
// substitute exceptions |
113 |
char[][] exceptions = Signature.getThrownExceptionTypes(methodSignature); |
108 |
char[][] exceptions = Signature.getThrownExceptionTypes(methodSignature); |
114 |
for (int i = 0, exceptionsLength = exceptions.length; i < exceptionsLength; i++) { |
109 |
for (int i = 0, exceptionsLength = exceptions.length; i < exceptionsLength; i++) { |
115 |
this.signature.append(Signature.C_EXCEPTION_START); |
110 |
this.signature.append(Signature.C_EXCEPTION_START); |
116 |
this.signature.append(substitute(exceptions[i], typeParameterSigs, typeParametersSize)); |
111 |
substitute(exceptions[i], typeParameterSigs, typeParametersSize); |
117 |
} |
112 |
} |
118 |
|
113 |
|
119 |
} |
114 |
} |
120 |
} |
115 |
} |
121 |
|
116 |
|
122 |
private char[] substitute(char[] parameter, char[][] typeParameterSigs, int typeParametersLength) { |
117 |
/* |
|
|
118 |
* Substitutes the type variables referenced in the given parameter (a parameterized type signature) with the corresponding |
119 |
* type argument. |
120 |
* Appends the given parameter if it is not a parameterized type signature. |
121 |
*/ |
122 |
private void substitute(char[] parameter, char[][] typeParameterSigs, int typeParametersLength) { |
123 |
for (int i = 0; i < typeParametersLength; i++) { |
123 |
for (int i = 0; i < typeParametersLength; i++) { |
124 |
if (CharOperation.equals(parameter, typeParameterSigs[i])) { |
124 |
if (CharOperation.equals(parameter, typeParameterSigs[i])) { |
125 |
String typeArgument = ((KeyToSignature) this.arguments.get(i)).signature.toString(); |
125 |
String typeArgument = ((KeyToSignature) this.arguments.get(i)).signature.toString(); |
126 |
return typeArgument.toCharArray(); |
126 |
this.signature.append(typeArgument); |
|
|
127 |
return; |
127 |
} |
128 |
} |
128 |
} |
129 |
} |
129 |
return parameter; |
130 |
int genericStart = CharOperation.indexOf(Signature.C_GENERIC_START, parameter); |
|
|
131 |
if (genericStart > -1) { |
132 |
this.signature.append(CharOperation.subarray(parameter, 0, genericStart)); |
133 |
char[][] parameters = Signature.getTypeArguments(parameter); |
134 |
this.signature.append(Signature.C_GENERIC_START); |
135 |
for (int j = 0, paramsLength = parameters.length; j < paramsLength; j++) |
136 |
substitute(parameters[j], typeParameterSigs, typeParametersLength); |
137 |
this.signature.append(Signature.C_GENERIC_END); |
138 |
this.signature.append(Signature.C_SEMICOLON); |
139 |
} else { |
140 |
this.signature.append(parameter); |
141 |
} |
130 |
} |
142 |
} |
131 |
|
143 |
|
132 |
public void consumeParameterizedType(char[] simpleTypeName, boolean isRaw) { |
144 |
public void consumeParameterizedType(char[] simpleTypeName, boolean isRaw) { |