From: aclement Date: Fri, 16 Sep 2011 00:58:28 +0000 (+0000) Subject: 351085 X-Git-Tag: V1_6_12~15 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=7a17cff55ff7d19fcbce6246ae9ef036d639d8b7;p=aspectj.git 351085 --- diff --git a/asm/src/org/aspectj/asm/internal/ProgramElement.java b/asm/src/org/aspectj/asm/internal/ProgramElement.java index b38a8286b..497b25028 100644 --- a/asm/src/org/aspectj/asm/internal/ProgramElement.java +++ b/asm/src/org/aspectj/asm/internal/ProgramElement.java @@ -493,11 +493,42 @@ public class ProgramElement implements IProgramElement { if (getFullyQualifiedType) { return returnType; } - int index = returnType.lastIndexOf("."); - if (index != -1) { - return returnType.substring(index + 1); + return trim(returnType); + } + + /** + * Trim down fully qualified types to their short form (e.g. a.b.c.D becomes D) + */ + public static String trim(String fqname) { + int i = fqname.indexOf("<"); + if (i == -1) { + int lastdot = fqname.lastIndexOf('.'); + if (lastdot == -1) { + return fqname; + } else { + return fqname.substring(lastdot + 1); + } + } + char[] charArray = fqname.toCharArray(); + StringBuilder candidate = new StringBuilder(charArray.length); + StringBuilder complete = new StringBuilder(charArray.length); + for (char c : charArray) { + switch (c) { + case '.': + candidate.setLength(0); + break; + case '<': + case ',': + case '>': + complete.append(candidate).append(c); + candidate.setLength(0); + break; + default: + candidate.append(c); + } } - return returnType; + complete.append(candidate); + return complete.toString(); } public String getName() {