diff options
author | Philippe Charles <charphi@users.noreply.github.com> | 2018-08-22 09:54:00 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-08-22 09:54:00 +0200 |
commit | 3ffac6642456e2c7d32952c62df8a565e2d4728b (patch) | |
tree | b0a28ac208dcb8af9add494c4caffe4f11bb287b /src/utils/lombok | |
parent | 35c7c6bda2e71da2e6e06cec5b0fb012c348f694 (diff) | |
parent | 769185e123dfd4a073161eafb58ce50bb79d6201 (diff) | |
download | lombok-3ffac6642456e2c7d32952c62df8a565e2d4728b.tar.gz lombok-3ffac6642456e2c7d32952c62df8a565e2d4728b.tar.bz2 lombok-3ffac6642456e2c7d32952c62df8a565e2d4728b.zip |
Merge branch 'master' into master
Diffstat (limited to 'src/utils/lombok')
-rw-r--r-- | src/utils/lombok/eclipse/Eclipse.java | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/src/utils/lombok/eclipse/Eclipse.java b/src/utils/lombok/eclipse/Eclipse.java index 5ef33086..943a7a7a 100644 --- a/src/utils/lombok/eclipse/Eclipse.java +++ b/src/utils/lombok/eclipse/Eclipse.java @@ -56,6 +56,8 @@ public class Eclipse { */ public static final int ECLIPSE_DO_NOT_TOUCH_FLAG = ASTNode.Bit24; + private static final Pattern SPLIT_AT_DOT = Pattern.compile("\\."); + private Eclipse() { //Prevent instantiation } @@ -65,19 +67,25 @@ public class Eclipse { * but we need to deal with it. This turns [[java][lang][String]] into "java.lang.String". */ public static String toQualifiedName(char[][] typeName) { - int len = typeName.length - 1; + int len = typeName.length - 1; // number of dots + if (len == 0) return new String(typeName[0]); + for (char[] c : typeName) len += c.length; - StringBuilder sb = new StringBuilder(len); - boolean first = true; - for (char[] c : typeName) { - sb.append(first ? "" : ".").append(c); - first = false; + char[] ret = new char[len]; + char[] part = typeName[0]; + System.arraycopy(part, 0, ret, 0, part.length); + int pos = part.length; + for (int i = 1; i < typeName.length; i++) { + ret[pos++] = '.'; + part = typeName[i]; + System.arraycopy(part, 0, ret, pos, part.length); + pos += part.length; } - return sb.toString(); + return new String(ret); } public static char[][] fromQualifiedName(String typeName) { - String[] split = typeName.split("\\."); + String[] split = SPLIT_AT_DOT.split(typeName); char[][] result = new char[split.length][]; for (int i = 0; i < split.length; i++) { result[i] = split[i].toCharArray(); |