}
//XXX inefficient implementation
- public static char[][] splitNames(String s) {
+ // we don't know whether $ characters are from nested types, or were
+ // part of the declared type name (generated code often uses $s in type
+ // names). More work required on our part to get this right...
+ public static char[][] splitNames(String s, boolean convertDollar) {
List ret = new ArrayList();
int startIndex = 0;
while (true) {
int breakIndex = s.indexOf('.', startIndex); // what about /
- if (breakIndex == -1) breakIndex = s.indexOf('$', startIndex); // we treat $ like . here
+ if (convertDollar && (breakIndex == -1)) breakIndex = s.indexOf('$', startIndex); // we treat $ like . here
if (breakIndex == -1) break;
char[] name = s.substring(startIndex, breakIndex).toCharArray();
ret.add(name);
// Ensure the annotation pattern is resolved
annotationPattern.resolve(type.getWorld());
- return matchesExactlyByName(targetTypeName,type.isAnonymous()) &&
+ return matchesExactlyByName(targetTypeName,type.isAnonymous(),type.isNested()) &&
matchesParameters(type,STATIC) &&
matchesBounds(type,STATIC) &&
annotationPattern.matches(annotatedType).alwaysTrue();
* @param targetTypeName
* @return
*/
- private boolean matchesExactlyByName(String targetTypeName, boolean isAnonymous) {
+ private boolean matchesExactlyByName(String targetTypeName, boolean isAnonymous, boolean isNested) {
// we deal with parameter matching separately...
if (targetTypeName.indexOf('<') != -1) {
targetTypeName = targetTypeName.substring(0,targetTypeName.indexOf('<'));
}
//XXX hack
if (knownMatches == null && importedPrefixes == null) {
- return innerMatchesExactly(targetTypeName,isAnonymous);
+ return innerMatchesExactly(targetTypeName,isAnonymous, isNested);
}
if (isNamePatternStar()) {
String knownPrefix = knownMatches[i] + "$";
if (targetTypeName.startsWith(knownPrefix)) {
int pos = lastIndexOfDotOrDollar(knownMatches[i]);
- if (innerMatchesExactly(targetTypeName.substring(pos+1),isAnonymous)) {
+ if (innerMatchesExactly(targetTypeName.substring(pos+1),isAnonymous,isNested)) {
return true;
}
}
//System.err.println("prefix match? " + prefix + " to " + targetTypeName);
if (targetTypeName.startsWith(prefix)) {
- if (innerMatchesExactly(targetTypeName.substring(prefix.length()),isAnonymous)) {
+ if (innerMatchesExactly(targetTypeName.substring(prefix.length()),isAnonymous,isNested)) {
return true;
}
}
}
- return innerMatchesExactly(targetTypeName,isAnonymous);
+ return innerMatchesExactly(targetTypeName,isAnonymous,isNested);
}
private int lastIndexOfDotOrDollar(String string) {
}
- private boolean innerMatchesExactly(String targetTypeName, boolean isAnonymous) {
+ private boolean innerMatchesExactly(String targetTypeName, boolean isAnonymous, boolean isNested) {
//??? doing this everytime is not very efficient
- char[][] names = splitNames(targetTypeName);
+ char[][] names = splitNames(targetTypeName,isNested);
return innerMatchesExactly(names, isAnonymous);
}
List ret = new ArrayList();
for (int i=0, len=possibleMatches.length; i < len; i++) {
- char[][] names = splitNames(possibleMatches[i]); //??? not most efficient
+ char[][] names = splitNames(possibleMatches[i],true); //??? not most efficient
if (namePatterns[0].matches(names[names.length-1])) {
ret.add(possibleMatches[i]);
+ continue;
+ }
+ if (possibleMatches[i].indexOf("$") != -1) {
+ names = splitNames(possibleMatches[i],false); //??? not most efficient
+ if (namePatterns[0].matches(names[names.length-1])) {
+ ret.add(possibleMatches[i]);
+ }
}
}
return (String[])ret.toArray(new String[ret.size()]);