Code polish
This commit is contained in:
10
class.tmpl
10
class.tmpl
@@ -1,10 +1,7 @@
|
|||||||
---@diagnostic disable: missing-return
|
---@diagnostic disable: missing-return, lowercase-global
|
||||||
{{range .Fields -}}
|
{{range .Fields -}}
|
||||||
---@field {{.Name}} {{.Type}} {{.Comment}}
|
---@field {{.Name}} {{.Type}} {{.Comment}}
|
||||||
{{end -}}
|
{{end -}}
|
||||||
{{range .Constructors -}}
|
|
||||||
---@overload fun({{range $index, $param := .Params}}{{if $index}}, {{end}}{{$param.Name}}: {{$param.Type}}{{end}}): {{$.ClassName}}
|
|
||||||
{{end -}}
|
|
||||||
---@class {{.ClassName}}
|
---@class {{.ClassName}}
|
||||||
{{.ClassName}} = {
|
{{.ClassName}} = {
|
||||||
{{$n := len .Methods -}}
|
{{$n := len .Methods -}}
|
||||||
@@ -23,6 +20,9 @@
|
|||||||
{{end}}{{end}}
|
{{end}}{{end}}
|
||||||
}
|
}
|
||||||
|
|
||||||
---@type {{$.ClassName}}
|
|
||||||
-- Define class globally so it's "available" to other files
|
-- Define class globally so it's "available" to other files
|
||||||
|
---@type {{$.ClassName}}
|
||||||
|
{{range .Constructors -}}
|
||||||
|
---@overload fun({{range $index, $param := .Params}}{{if $index}}, {{end}}{{$param.Name}}: {{$param.Type}}{{end}}): {{$.ClassName}}
|
||||||
|
{{end -}}
|
||||||
{{$.ClassName}} = nil
|
{{$.ClassName}} = nil
|
||||||
4
main.go
4
main.go
@@ -120,6 +120,8 @@ func ParseFile(filename string) (*Class, error) {
|
|||||||
})
|
})
|
||||||
res.Constructors = append(res.Constructors, resConstructor)
|
res.Constructors = append(res.Constructors, resConstructor)
|
||||||
|
|
||||||
|
// constructorDetails := codeblocks.Eq(1)
|
||||||
|
|
||||||
log.Printf("%#v", res)
|
log.Printf("%#v", res)
|
||||||
|
|
||||||
return &res, nil
|
return &res, nil
|
||||||
@@ -131,6 +133,8 @@ func MapType(t string) string {
|
|||||||
return "any"
|
return "any"
|
||||||
case "int":
|
case "int":
|
||||||
return "number"
|
return "number"
|
||||||
|
case "float":
|
||||||
|
return "number"
|
||||||
case "string":
|
case "string":
|
||||||
return "string"
|
return "string"
|
||||||
case "boolean":
|
case "boolean":
|
||||||
|
|||||||
Reference in New Issue
Block a user