|
|
|
@ -1,4 +1,4 @@ |
|
|
|
|
/* StrongRenamer Copyright (C) 1999 Jochen Hoenicke. |
|
|
|
|
/* StrongRenamer Copyright (C) 1999, 2000 Jochen Hoenicke. |
|
|
|
|
* |
|
|
|
|
* This program is free software; you can redistribute it and/or modify |
|
|
|
|
* it under the terms of the GNU General Public License as published by |
|
|
|
@ -32,6 +32,18 @@ public class StrongRenamer implements Renamer, OptionHandler { |
|
|
|
|
}; |
|
|
|
|
String charsets[][]; |
|
|
|
|
|
|
|
|
|
String javaKeywords[] = { |
|
|
|
|
"abstract", "default", "if", "private", "throw", "boolean", |
|
|
|
|
"do", "implements", "protected", "throws", "break", "double", |
|
|
|
|
"import", "public", "transient", "byte", "else", "instanceof", |
|
|
|
|
"return", "try", "case", "extends", "int", "short", "void", |
|
|
|
|
"catch", "final", "interface", "static", "volatile", "char", |
|
|
|
|
"finally", "long", "super", "while", "class", "float", |
|
|
|
|
"native", "switch", "const", "for", "new", "synchronized", |
|
|
|
|
"continue", "goto", "package", "this", "strictfp", "null", |
|
|
|
|
"true", "false" |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
public StrongRenamer() { |
|
|
|
|
charsets = new String[idents.length][parts.length]; |
|
|
|
|
for (int i=0; i< idents.length; i++) |
|
|
|
@ -87,16 +99,14 @@ public class StrongRenamer implements Renamer, OptionHandler { |
|
|
|
|
int identType; |
|
|
|
|
if (ident instanceof PackageIdentifier) |
|
|
|
|
identType = 0; |
|
|
|
|
else if (ident instanceof PackageIdentifier) |
|
|
|
|
identType = 1; |
|
|
|
|
else if (ident instanceof ClassIdentifier) |
|
|
|
|
identType = 2; |
|
|
|
|
identType = 1; |
|
|
|
|
else if (ident instanceof FieldIdentifier) |
|
|
|
|
identType = 3; |
|
|
|
|
identType = 2; |
|
|
|
|
else if (ident instanceof MethodIdentifier) |
|
|
|
|
identType = 4; |
|
|
|
|
identType = 3; |
|
|
|
|
else if (ident instanceof LocalIdentifier) |
|
|
|
|
identType = 5; |
|
|
|
|
identType = 4; |
|
|
|
|
else |
|
|
|
|
throw new IllegalArgumentException(ident.getClass().getName()); |
|
|
|
|
final String[] theCharset = charsets[identType]; |
|
|
|
@ -114,29 +124,38 @@ public class StrongRenamer implements Renamer, OptionHandler { |
|
|
|
|
headIndex = 0; |
|
|
|
|
return new String(name); |
|
|
|
|
} |
|
|
|
|
if (++headIndex < theCharset[0].length()) { |
|
|
|
|
name[0] = theCharset[0].charAt(headIndex); |
|
|
|
|
return new String(name); |
|
|
|
|
} |
|
|
|
|
headIndex = 0; |
|
|
|
|
name[0] = theCharset[0].charAt(0); |
|
|
|
|
|
|
|
|
|
String charset = theCharset[1]; |
|
|
|
|
for (int pos = 1; pos < name.length; pos++) { |
|
|
|
|
int index = charset.indexOf(name[pos]) + 1; |
|
|
|
|
if (index < charset.length()) { |
|
|
|
|
name[pos] = charset.charAt(index); |
|
|
|
|
next_name: |
|
|
|
|
while (true) { |
|
|
|
|
if (++headIndex < theCharset[0].length()) { |
|
|
|
|
name[0] = theCharset[0].charAt(headIndex); |
|
|
|
|
return new String(name); |
|
|
|
|
} |
|
|
|
|
name[pos] = charset.charAt(0); |
|
|
|
|
} |
|
|
|
|
headIndex = 0; |
|
|
|
|
name[0] = theCharset[0].charAt(0); |
|
|
|
|
|
|
|
|
|
String charset = theCharset[1]; |
|
|
|
|
for (int pos = 1; pos < name.length; pos++) { |
|
|
|
|
int index = charset.indexOf(name[pos]) + 1; |
|
|
|
|
if (index < charset.length()) { |
|
|
|
|
name[pos] = charset.charAt(index); |
|
|
|
|
return new String(name); |
|
|
|
|
} |
|
|
|
|
name[pos] = charset.charAt(0); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
name = new char[name.length+1]; |
|
|
|
|
name[0] = theCharset[0].charAt(0); |
|
|
|
|
char firstCont = theCharset[1].charAt(0); |
|
|
|
|
for (int i=1; i <name.length; i++) |
|
|
|
|
name[i] = firstCont; |
|
|
|
|
return new String(name); |
|
|
|
|
name = new char[name.length+1]; |
|
|
|
|
name[0] = theCharset[0].charAt(0); |
|
|
|
|
char firstCont = theCharset[1].charAt(0); |
|
|
|
|
for (int i=1; i <name.length; i++) |
|
|
|
|
name[i] = firstCont; |
|
|
|
|
|
|
|
|
|
String next = new String(name); |
|
|
|
|
for (int i = 0; i < javaKeywords.length; i++) { |
|
|
|
|
if (next.equals(javaKeywords[i])) |
|
|
|
|
continue next_name; |
|
|
|
|
} |
|
|
|
|
return next; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public void remove() { |
|
|
|
|