Code polish

This commit is contained in:
2024-09-12 01:03:24 +02:00
parent f093fe4d1e
commit 4fbc86e4b6
2 changed files with 9 additions and 5 deletions

View File

@@ -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

View File

@@ -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":