Lines 307-320
Link Here
|
307 |
return CharOperation.NO_STRINGS; |
307 |
return CharOperation.NO_STRINGS; |
308 |
String[] typeSigs = new String[n]; |
308 |
String[] typeSigs = new String[n]; |
309 |
for (int i = 0; i < n; ++i) { |
309 |
for (int i = 0; i < n; ++i) { |
310 |
String typeSig = Signature.createTypeSignature(typeNames[i], false); |
310 |
char[] typeSig = Signature.createCharArrayTypeSignature(typeNames[i], false); |
311 |
int lastIndex = typeSig.lastIndexOf('.'); |
311 |
|
312 |
if (lastIndex == -1) { |
312 |
// transforms signatures that contains a qualification into unqualified signatures |
313 |
typeSigs[i] = typeSig; |
313 |
// e.g. "QX<+QMap.Entry;>;" becomes "QX<+QEntry;>;" |
|
|
314 |
StringBuffer simpleTypeSig = null; |
315 |
int start = 0; |
316 |
int dot = -1; |
317 |
int length = typeSig.length; |
318 |
for (int j = 0; j < length; j++) { |
319 |
switch (typeSig[j]) { |
320 |
case Signature.C_UNRESOLVED: |
321 |
if (simpleTypeSig != null) |
322 |
simpleTypeSig.append(typeSig, start, j-start); |
323 |
start = j; |
324 |
break; |
325 |
case Signature.C_DOT: |
326 |
dot = j; |
327 |
break; |
328 |
case Signature.C_GENERIC_START: |
329 |
case Signature.C_NAME_END: |
330 |
if (dot > start) { |
331 |
if (simpleTypeSig == null) |
332 |
simpleTypeSig = new StringBuffer().append(typeSig, 0, start); |
333 |
simpleTypeSig.append(Signature.C_UNRESOLVED); |
334 |
simpleTypeSig.append(typeSig, dot+1, j-dot-1); |
335 |
start = j; |
336 |
} |
337 |
break; |
338 |
} |
339 |
} |
340 |
if (simpleTypeSig == null) { |
341 |
typeSigs[i] = new String(typeSig); |
314 |
} else { |
342 |
} else { |
315 |
int arrayEnd = 0; |
343 |
simpleTypeSig.append(typeSig, start, length-start); |
316 |
while(typeSig.charAt(arrayEnd) == Signature.C_ARRAY) arrayEnd++; |
344 |
typeSigs[i] = simpleTypeSig.toString(); |
317 |
typeSigs[i] = typeSig.substring(0, arrayEnd) + Signature.C_UNRESOLVED + typeSig.substring(lastIndex + 1, typeSig.length()); |
|
|
318 |
} |
345 |
} |
319 |
} |
346 |
} |
320 |
return typeSigs; |
347 |
return typeSigs; |
Lines 1071-1125
Link Here
|
1071 |
String[] qualifiedParameterTypes = method.getParameterTypes(); |
1098 |
String[] qualifiedParameterTypes = method.getParameterTypes(); |
1072 |
String[] unqualifiedParameterTypes = new String[qualifiedParameterTypes.length]; |
1099 |
String[] unqualifiedParameterTypes = new String[qualifiedParameterTypes.length]; |
1073 |
for (int i = 0; i < qualifiedParameterTypes.length; i++) { |
1100 |
for (int i = 0; i < qualifiedParameterTypes.length; i++) { |
1074 |
StringBuffer unqualifiedName = new StringBuffer(); |
1101 |
StringBuffer unqualifiedTypeSig = new StringBuffer(); |
1075 |
String qualifiedName = qualifiedParameterTypes[i]; |
1102 |
getUnqualifiedTypeSignature(qualifiedParameterTypes[i], 0/*start*/, qualifiedParameterTypes[i].length(), unqualifiedTypeSig, noDollar); |
1076 |
int count = 0; |
1103 |
unqualifiedParameterTypes[i] = unqualifiedTypeSig.toString(); |
1077 |
while (qualifiedName.charAt(count) == Signature.C_ARRAY) { |
1104 |
hasDollar |= unqualifiedParameterTypes[i].lastIndexOf('$') != -1; |
1078 |
unqualifiedName.append(Signature.C_ARRAY); |
|
|
1079 |
++count; |
1080 |
} |
1081 |
char currentChar = qualifiedName.charAt(count); |
1082 |
if (currentChar == Signature.C_RESOLVED || currentChar == Signature.C_TYPE_VARIABLE) { |
1083 |
unqualifiedName.append(Signature.C_UNRESOLVED); |
1084 |
String simpleName = Signature.getSimpleName(qualifiedName.substring(count+1)); |
1085 |
int lastDollar = simpleName.lastIndexOf('$'); |
1086 |
hasDollar |= lastDollar != -1; |
1087 |
int start = noDollar ? lastDollar + 1 : 0; |
1088 |
boolean sigStart = false; |
1089 |
for (int j = start, length = simpleName.length(); j < length; j++) { |
1090 |
char current = simpleName.charAt(j); |
1091 |
switch (current) { |
1092 |
case Signature.C_SUPER: |
1093 |
case Signature.C_EXTENDS: |
1094 |
case Signature.C_GENERIC_START: |
1095 |
case Signature.C_NAME_END: |
1096 |
unqualifiedName.append(current); |
1097 |
sigStart = true; |
1098 |
break; |
1099 |
default: |
1100 |
if (sigStart) { |
1101 |
switch(current) { |
1102 |
case Signature.C_TYPE_VARIABLE : |
1103 |
unqualifiedName.append(Signature.C_UNRESOLVED); |
1104 |
break; |
1105 |
case Signature.C_GENERIC_END : |
1106 |
case Signature.C_STAR : |
1107 |
unqualifiedName.append(current); |
1108 |
break; |
1109 |
default: |
1110 |
unqualifiedName.append(Signature.C_UNRESOLVED); |
1111 |
unqualifiedName.append(current); |
1112 |
} |
1113 |
sigStart = false; |
1114 |
} else { |
1115 |
unqualifiedName.append(current); |
1116 |
} |
1117 |
} |
1118 |
} |
1119 |
} else { |
1120 |
unqualifiedName.append(qualifiedName.substring(count, qualifiedName.length())); |
1121 |
} |
1122 |
unqualifiedParameterTypes[i] = unqualifiedName.toString(); |
1123 |
} |
1105 |
} |
1124 |
|
1106 |
|
1125 |
IJavaElement[] result = new IJavaElement[2]; |
1107 |
IJavaElement[] result = new IJavaElement[2]; |
Lines 1131-1136
Link Here
|
1131 |
} |
1113 |
} |
1132 |
return result; |
1114 |
return result; |
1133 |
} |
1115 |
} |
|
|
1116 |
|
1117 |
private int getUnqualifiedTypeSignature(String qualifiedTypeSig, int start, int length, StringBuffer unqualifiedTypeSig, boolean noDollar) { |
1118 |
char firstChar = qualifiedTypeSig.charAt(start); |
1119 |
int end = start + 1; |
1120 |
boolean sigStart = false; |
1121 |
firstPass: for (int i = start; i < length; i++) { |
1122 |
char current = qualifiedTypeSig.charAt(i); |
1123 |
switch (current) { |
1124 |
case Signature.C_ARRAY : |
1125 |
case Signature.C_SUPER: |
1126 |
case Signature.C_EXTENDS: |
1127 |
unqualifiedTypeSig.append(current); |
1128 |
start = i + 1; |
1129 |
end = start + 1; |
1130 |
firstChar = qualifiedTypeSig.charAt(start); |
1131 |
break; |
1132 |
case Signature.C_RESOLVED : |
1133 |
case Signature.C_UNRESOLVED : |
1134 |
case Signature.C_TYPE_VARIABLE : |
1135 |
if (!sigStart) { |
1136 |
start = ++i; |
1137 |
sigStart = true; |
1138 |
} |
1139 |
break; |
1140 |
case Signature.C_NAME_END: |
1141 |
case Signature.C_GENERIC_START : |
1142 |
end = i; |
1143 |
break firstPass; |
1144 |
case Signature.C_STAR : |
1145 |
unqualifiedTypeSig.append(current); |
1146 |
start = i + 1; |
1147 |
end = start + 1; |
1148 |
firstChar = qualifiedTypeSig.charAt(start); |
1149 |
break; |
1150 |
case Signature.C_GENERIC_END : |
1151 |
return i; |
1152 |
case Signature.C_DOT: |
1153 |
start = ++i; |
1154 |
break; |
1155 |
} |
1156 |
} |
1157 |
switch (firstChar) { |
1158 |
case Signature.C_RESOLVED : |
1159 |
case Signature.C_UNRESOLVED : |
1160 |
case Signature.C_TYPE_VARIABLE : |
1161 |
unqualifiedTypeSig.append(Signature.C_UNRESOLVED); |
1162 |
if (noDollar) { |
1163 |
int lastDollar = qualifiedTypeSig.lastIndexOf('$', end); |
1164 |
if (lastDollar > start) |
1165 |
start = lastDollar + 1; |
1166 |
} |
1167 |
for (int i = start; i < length; i++) { |
1168 |
char current = qualifiedTypeSig.charAt(i); |
1169 |
switch (current) { |
1170 |
case Signature.C_GENERIC_START: |
1171 |
unqualifiedTypeSig.append(current); |
1172 |
i++; |
1173 |
do { |
1174 |
i = getUnqualifiedTypeSignature(qualifiedTypeSig, i, length, unqualifiedTypeSig, noDollar); |
1175 |
} while (qualifiedTypeSig.charAt(i) != Signature.C_GENERIC_END); |
1176 |
unqualifiedTypeSig.append(Signature.C_GENERIC_END); |
1177 |
break; |
1178 |
case Signature.C_NAME_END: |
1179 |
unqualifiedTypeSig.append(current); |
1180 |
return i + 1; |
1181 |
default: |
1182 |
unqualifiedTypeSig.append(current); |
1183 |
break; |
1184 |
} |
1185 |
} |
1186 |
return length; |
1187 |
default : |
1188 |
// primitive type or wildcard |
1189 |
unqualifiedTypeSig.append(qualifiedTypeSig.substring(start, end)); |
1190 |
return end; |
1191 |
} |
1192 |
} |
1134 |
|
1193 |
|
1135 |
/** |
1194 |
/** |
1136 |
* Maps the given source code to the given binary type and its children. |
1195 |
* Maps the given source code to the given binary type and its children. |