-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathKotlinPlatform.go
56 lines (48 loc) · 1.25 KB
/
KotlinPlatform.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
package main
import (
"regexp"
"strings"
"strconv"
)
func kotlinPlatformStringValueProcessor(value string, argNames string, sv *StringValue) {
usingValue := value
//%1$s
reg, _ := regexp.Compile(`(%[0-9]*\$s)`)
numOfArg := reg.FindAllString(usingValue,-1)
arguments := len(numOfArg)
argumentString := ""
formatString := ""
if arguments > 0 {
//find argument names here
i := 0
var argNamesFromXML []string
if len(argNames) > 0 {
strippedArgString := strings.Replace(argNames, " ", "", -1)
argNamesFromXML = strings.Split(strippedArgString, ",")
}
formatString = reg.ReplaceAllStringFunc(usingValue, func(replaceString string) string {
var argName string
if i < len(argNamesFromXML) {
argName = argNamesFromXML[i]
} else {
argName = "arg" + strconv.Itoa(i + 1)
}
if i == 0 {
argumentString = argName + ": String"
} else {
argumentString = argumentString + ", " + argName + ": String"
}
i++
return "${" + argName + "}"
})
i = 0
usingValue = reg.ReplaceAllStringFunc(usingValue, func(replaceString string) string {
i++
return "%" + strconv.Itoa(i) + "\\$s"
})
}
sv.value = usingValue
sv.numberOfArguments = arguments
sv.argumentString = argumentString
sv.formatString = formatString
}