[Fernflower] When using -ren=1, make the default renamer rename classes that have names that are reserved by the windows namespace.
This commit is contained in:
@@ -28,6 +28,10 @@ public class ConverterHelper implements IIdentifierRenamer {
|
|||||||
"protected", "throw", "byte", "extends", "instanceof", "public", "throws", "case", "false", "int", "return", "transient", "catch",
|
"protected", "throw", "byte", "extends", "instanceof", "public", "throws", "case", "false", "int", "return", "transient", "catch",
|
||||||
"final", "interface", "short", "true", "char", "finally", "long", "static", "try", "class", "float", "native", "strictfp", "void",
|
"final", "interface", "short", "true", "char", "finally", "long", "static", "try", "class", "float", "native", "strictfp", "void",
|
||||||
"const", "for", "new", "super", "volatile", "continue", "goto", "null", "switch", "while", "default", "assert", "enum"));
|
"const", "for", "new", "super", "volatile", "continue", "goto", "null", "switch", "while", "default", "assert", "enum"));
|
||||||
|
private static final Set<String> RESERVED_WINDOWS_NAMESPACE = new HashSet<String>(Arrays.asList(
|
||||||
|
"aux", "prn", "aux", "nul",
|
||||||
|
"com1", "com2", "com3", "com4", "com5", "com6", "com7", "com8", "com9",
|
||||||
|
"lpt1", "lpt2", "lpt3", "lpt4", "lpt5", "lpt6", "lpt7", "lpt8", "lpt9"));
|
||||||
|
|
||||||
private int classCounter = 0;
|
private int classCounter = 0;
|
||||||
private int fieldCounter = 0;
|
private int fieldCounter = 0;
|
||||||
@@ -37,7 +41,8 @@ public class ConverterHelper implements IIdentifierRenamer {
|
|||||||
@Override
|
@Override
|
||||||
public boolean toBeRenamed(Type elementType, String className, String element, String descriptor) {
|
public boolean toBeRenamed(Type elementType, String className, String element, String descriptor) {
|
||||||
String value = elementType == Type.ELEMENT_CLASS ? className : element;
|
String value = elementType == Type.ELEMENT_CLASS ? className : element;
|
||||||
return value == null || value.length() == 0 || value.length() <= 2 || KEYWORDS.contains(value) || Character.isDigit(value.charAt(0));
|
return value == null || value.length() == 0 || value.length() <= 2 || KEYWORDS.contains(value) || Character.isDigit(value.charAt(0))
|
||||||
|
|| elementType == Type.ELEMENT_CLASS && RESERVED_WINDOWS_NAMESPACE.contains(value.toLowerCase());
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: consider possible conflicts with not renamed classes, fields and methods!
|
// TODO: consider possible conflicts with not renamed classes, fields and methods!
|
||||||
|
|||||||
Reference in New Issue
Block a user