Correctly strip qualified generic class names (Arnaud Rogues).

This commit is contained in:
Diomidis Spinellis 2005-11-23 09:36:16 +00:00
parent c5d0bcecf8
commit ac7963f269
2 changed files with 26 additions and 6 deletions

View File

@ -96,9 +96,19 @@ class ClassGraph {
private String qualifiedName(String r) {
if (!opt.showQualified) {
// Create readable string by stripping leading path
int dotpos = r.lastIndexOf('.');
if (dotpos != -1)
return r.substring(dotpos + 1, r.length());
for (;;) {
int dotpos = r.lastIndexOf('.');
if (dotpos == -1) break; // Work done!
/*
* Change all occurences of
* "p1.p2.myClass<S extends dummy.Otherclass>" into
* "myClass<S extends Otherclass>"
*/
int start = dotpos;
while (start > 0 && Character.isJavaIdentifierPart(r.charAt(start - 1)))
start--;
r = r.substring(0, start) + r.substring(dotpos + 1);
}
}
return r;
}

View File

@ -96,9 +96,19 @@ class ClassGraph {
private String qualifiedName(String r) {
if (!opt.showQualified) {
// Create readable string by stripping leading path
int dotpos = r.lastIndexOf('.');
if (dotpos != -1)
return r.substring(dotpos + 1, r.length());
for (;;) {
int dotpos = r.lastIndexOf('.');
if (dotpos == -1) break; // Work done!
/*
* Change all occurences of
* "p1.p2.myClass<S extends dummy.Otherclass>" into
* "myClass<S extends Otherclass>"
*/
int start = dotpos;
while (start > 0 && Character.isJavaIdentifierPart(r.charAt(start - 1)))
start--;
r = r.substring(0, start) + r.substring(dotpos + 1);
}
}
return r;
}