|
|
|
@ -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,6 +124,8 @@ public class StrongRenamer implements Renamer, OptionHandler { |
|
|
|
|
headIndex = 0; |
|
|
|
|
return new String(name); |
|
|
|
|
} |
|
|
|
|
next_name: |
|
|
|
|
while (true) { |
|
|
|
|
if (++headIndex < theCharset[0].length()) { |
|
|
|
|
name[0] = theCharset[0].charAt(headIndex); |
|
|
|
|
return new String(name); |
|
|
|
@ -136,7 +148,14 @@ public class StrongRenamer implements Renamer, OptionHandler { |
|
|
|
|
char firstCont = theCharset[1].charAt(0); |
|
|
|
|
for (int i=1; i <name.length; i++) |
|
|
|
|
name[i] = firstCont; |
|
|
|
|
return new String(name); |
|
|
|
|
|
|
|
|
|
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() { |
|
|
|
|