From ac7963f2693f7024c9b1b95a39fe71acbc19c74f Mon Sep 17 00:00:00 2001 From: Diomidis Spinellis Date: Wed, 23 Nov 2005 09:36:16 +0000 Subject: [PATCH] Correctly strip qualified generic class names (Arnaud Rogues). --- src/gr/spinellis/umlgraph/doclet/ClassGraph.java | 16 +++++++++++++--- src/org/umlgraph/doclet/ClassGraph.java | 16 +++++++++++++--- 2 files changed, 26 insertions(+), 6 deletions(-) diff --git a/src/gr/spinellis/umlgraph/doclet/ClassGraph.java b/src/gr/spinellis/umlgraph/doclet/ClassGraph.java index b6cc72d..01b52f2 100644 --- a/src/gr/spinellis/umlgraph/doclet/ClassGraph.java +++ b/src/gr/spinellis/umlgraph/doclet/ClassGraph.java @@ -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" into + * "myClass" + */ + int start = dotpos; + while (start > 0 && Character.isJavaIdentifierPart(r.charAt(start - 1))) + start--; + r = r.substring(0, start) + r.substring(dotpos + 1); + } } return r; } diff --git a/src/org/umlgraph/doclet/ClassGraph.java b/src/org/umlgraph/doclet/ClassGraph.java index b6cc72d..01b52f2 100644 --- a/src/org/umlgraph/doclet/ClassGraph.java +++ b/src/org/umlgraph/doclet/ClassGraph.java @@ -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" into + * "myClass" + */ + int start = dotpos; + while (start > 0 && Character.isJavaIdentifierPart(r.charAt(start - 1))) + start--; + r = r.substring(0, start) + r.substring(dotpos + 1); + } } return r; }