|
|
@@ -44,6 +44,7 @@ function convert(line) { |
|
|
|
result = protocolReplace(result); |
|
|
|
result = typeArrayReplace(result); |
|
|
|
result = forEachReplace(result); |
|
|
|
result = recordReplace(result); |
|
|
|
return result; |
|
|
|
} |
|
|
|
|
|
|
@@ -100,6 +101,28 @@ function protocolReplaceVariable(line) { |
|
|
|
return line; |
|
|
|
} |
|
|
|
|
|
|
|
// Record<TypeA, TypeB> -> [TypeA: TypeB] |
|
|
|
// Record<TypeA, TypeB> = {} -> [TypeA: TypeB] = [:] |
|
|
|
function recordReplace(line) { |
|
|
|
if (!line.includes("Record")) { |
|
|
|
return line; |
|
|
|
} |
|
|
|
|
|
|
|
let partsR = line.split("Record<"); |
|
|
|
let typesAndEnding = partsR[1]; |
|
|
|
let partsT = typesAndEnding.split(">"); |
|
|
|
let types = partsT[0]; |
|
|
|
let ending = partsT[1]; |
|
|
|
let swiftTypes = types.split(", "); |
|
|
|
let was = `Record<${swiftTypes[0]}, ${swiftTypes[1]}>`; |
|
|
|
let now = `[${swiftTypes[0]}: ${swiftTypes[1]}]`; |
|
|
|
var result = line; |
|
|
|
result = result.replace(was, now); |
|
|
|
result = result.replace("] = {};", "] = [:]"); |
|
|
|
return result; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Type[] -> [Type] |
|
|
|
function typeArrayReplace(line) { |
|
|
|
let parts = line.split(" "); |
|
|
|