Merge pull request #2633 from yonaskolb/swift_case_sensitive_reserved_types

Make swift reserved words case sensitive again
This commit is contained in:
wing328 2016-04-19 16:27:49 +08:00
commit 894111e3de

View File

@ -95,10 +95,10 @@ public class SwiftCodegen extends DefaultCodegen implements CodegenConfig {
"Empty",
"AnyObject")
);
setReservedWordsLowerCase(
reservedWords = new HashSet<String>(
Arrays.asList(
"Int", "Int32", "Int64", "Int64", "Float", "Double", "Bool", "Void", "String", "Character", "AnyObject",
"class", "break", "as", "associativity", "deinit", "case", "dynamicType", "convenience", "enum", "continue",
"class", "Class", "break", "as", "associativity", "deinit", "case", "dynamicType", "convenience", "enum", "continue",
"false", "dynamic", "extension", "default", "is", "didSet", "func", "do", "nil", "final", "import", "else",
"self", "get", "init", "fallthrough", "Self", "infix", "internal", "for", "super", "inout", "let", "if",
"true", "lazy", "operator", "in", "COLUMN", "left", "private", "return", "FILE", "mutating", "protocol",
@ -204,6 +204,11 @@ public class SwiftCodegen extends DefaultCodegen implements CodegenConfig {
}
@Override
protected boolean isReservedWord(String word) {
return word != null && reservedWords.contains(word); //don't lowercase as super does
}
@Override
public String escapeReservedWord(String name) {
return "_" + name; // add an underscore to the name