-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathDartPlatform.go
48 lines (42 loc) · 1.08 KB
/
DartPlatform.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
package main
import (
"regexp"
"strings"
"strconv"
)
func dartPlatformStringValueProcessor(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 = argumentString + ", String " + argName
} else {
argumentString = "String " + argName
}
return "$" + argName
})
}
sv.value = usingValue
sv.numberOfArguments = arguments
sv.argumentString = argumentString
sv.formatString = formatString
}