Explorar o código

fix: 删除goctl

SongZihuan hai 1 ano
pai
achega
da4aeb8a36
Modificáronse 100 ficheiros con 0 adicións e 14396 borrados
  1. 0 34
      tools/goctlwt/Dockerfile
  2. 0 25
      tools/goctlwt/Makefile
  3. 0 24
      tools/goctlwt/api/apigen/api.tpl
  4. 0 78
      tools/goctlwt/api/apigen/gen.go
  5. 0 50
      tools/goctlwt/api/apigen/template.go
  6. 0 26
      tools/goctlwt/api/apigen/util.go
  7. 0 103
      tools/goctlwt/api/cmd.go
  8. 0 40
      tools/goctlwt/api/dartgen/format.go
  9. 0 69
      tools/goctlwt/api/dartgen/gen.go
  10. 0 103
      tools/goctlwt/api/dartgen/genapi.go
  11. 0 151
      tools/goctlwt/api/dartgen/gendata.go
  12. 0 102
      tools/goctlwt/api/dartgen/genvars.go
  13. 0 279
      tools/goctlwt/api/dartgen/util.go
  14. 0 71
      tools/goctlwt/api/dartgen/util_test.go
  15. 0 284
      tools/goctlwt/api/dartgen/vars.go
  16. 0 186
      tools/goctlwt/api/docgen/doc.go
  17. 0 77
      tools/goctlwt/api/docgen/gen.go
  18. 0 16
      tools/goctlwt/api/docgen/markdown.tpl
  19. 0 248
      tools/goctlwt/api/format/format.go
  20. 0 85
      tools/goctlwt/api/format/format_test.go
  21. 0 9
      tools/goctlwt/api/gogen/config.tpl
  22. 0 3
      tools/goctlwt/api/gogen/etc.tpl
  23. 0 170
      tools/goctlwt/api/gogen/gen.go
  24. 0 299
      tools/goctlwt/api/gogen/gen_test.go
  25. 0 65
      tools/goctlwt/api/gogen/genconfig.go
  26. 0 45
      tools/goctlwt/api/gogen/genetc.go
  27. 0 141
      tools/goctlwt/api/gogen/genhandlers.go
  28. 0 137
      tools/goctlwt/api/gogen/genlogic.go
  29. 0 53
      tools/goctlwt/api/gogen/genmain.go
  30. 0 43
      tools/goctlwt/api/gogen/genmiddleware.go
  31. 0 282
      tools/goctlwt/api/gogen/genroutes.go
  32. 0 58
      tools/goctlwt/api/gogen/gensvc.go
  33. 0 93
      tools/goctlwt/api/gogen/gentypes.go
  34. 0 26
      tools/goctlwt/api/gogen/handler.tpl
  35. 0 25
      tools/goctlwt/api/gogen/logic.tpl
  36. 0 26
      tools/goctlwt/api/gogen/main.tpl
  37. 0 19
      tools/goctlwt/api/gogen/middleware.tpl
  38. 0 17
      tools/goctlwt/api/gogen/svc.tpl
  39. 0 68
      tools/goctlwt/api/gogen/template.go
  40. 0 92
      tools/goctlwt/api/gogen/template_test.go
  41. 0 12
      tools/goctlwt/api/gogen/testdata/anonymous_annotation.api
  42. 0 14
      tools/goctlwt/api/gogen/testdata/ap_ino_info.api
  43. 0 15
      tools/goctlwt/api/gogen/testdata/api_has_middleware.api
  44. 0 4
      tools/goctlwt/api/gogen/testdata/api_has_no_request.api
  45. 0 16
      tools/goctlwt/api/gogen/testdata/api_jwt.api
  46. 0 17
      tools/goctlwt/api/gogen/testdata/api_jwt_with_middleware.api
  47. 0 16
      tools/goctlwt/api/gogen/testdata/api_route_test.api
  48. 0 20
      tools/goctlwt/api/gogen/testdata/has_comment_api_test.api
  49. 0 16
      tools/goctlwt/api/gogen/testdata/has_import_api.api
  50. 0 16
      tools/goctlwt/api/gogen/testdata/has_inline_no_exist_test.api
  51. 0 3
      tools/goctlwt/api/gogen/testdata/import_api.api
  52. 0 14
      tools/goctlwt/api/gogen/testdata/invalid_api_file.api
  53. 0 10
      tools/goctlwt/api/gogen/testdata/nest_type_api.api
  54. 0 20
      tools/goctlwt/api/gogen/testdata/no_struct_tag_api.api
  55. 0 36
      tools/goctlwt/api/gogen/testdata/test_api_template.api
  56. 0 27
      tools/goctlwt/api/gogen/testdata/test_multi_service_template.api
  57. 0 6
      tools/goctlwt/api/gogen/types.tpl
  58. 0 183
      tools/goctlwt/api/gogen/util.go
  59. 0 13
      tools/goctlwt/api/gogen/vars.go
  60. 0 9
      tools/goctlwt/api/javagen/bool.tpl
  61. 0 22
      tools/goctlwt/api/javagen/component.tpl
  62. 0 50
      tools/goctlwt/api/javagen/gen.go
  63. 0 319
      tools/goctlwt/api/javagen/gencomponents.go
  64. 0 219
      tools/goctlwt/api/javagen/genpacket.go
  65. 0 9
      tools/goctlwt/api/javagen/getset.tpl
  66. 0 25
      tools/goctlwt/api/javagen/packet.tpl
  67. 0 148
      tools/goctlwt/api/javagen/util.go
  68. 0 3
      tools/goctlwt/api/javagen/vars.go
  69. 0 22
      tools/goctlwt/api/ktgen/api.tpl
  70. 0 61
      tools/goctlwt/api/ktgen/apibase.tpl
  71. 0 53
      tools/goctlwt/api/ktgen/cmd.go
  72. 0 119
      tools/goctlwt/api/ktgen/funcs.go
  73. 0 90
      tools/goctlwt/api/ktgen/gen.go
  74. 0 14
      tools/goctlwt/api/new/api.tpl
  75. 0 88
      tools/goctlwt/api/new/newservice.go
  76. 0 50
      tools/goctlwt/api/new/template.go
  77. 0 46
      tools/goctlwt/api/parser/g4/ApiLexer.g4
  78. 0 74
      tools/goctlwt/api/parser/g4/ApiParser.g4
  79. 0 290
      tools/goctlwt/api/parser/g4/ast/api.go
  80. 0 534
      tools/goctlwt/api/parser/g4/ast/apiparser.go
  81. 0 98
      tools/goctlwt/api/parser/g4/ast/apiparser_test.go
  82. 0 317
      tools/goctlwt/api/parser/g4/ast/ast.go
  83. 0 106
      tools/goctlwt/api/parser/g4/ast/import.go
  84. 0 23
      tools/goctlwt/api/parser/g4/ast/importstack.go
  85. 0 71
      tools/goctlwt/api/parser/g4/ast/info.go
  86. 0 85
      tools/goctlwt/api/parser/g4/ast/kv.go
  87. 0 7
      tools/goctlwt/api/parser/g4/ast/placeholder.go
  88. 0 660
      tools/goctlwt/api/parser/g4/ast/service.go
  89. 0 64
      tools/goctlwt/api/parser/g4/ast/syntax.go
  90. 0 731
      tools/goctlwt/api/parser/g4/ast/type.go
  91. 0 158
      tools/goctlwt/api/parser/g4/gen/api/apiparser_base_visitor.go
  92. 0 240
      tools/goctlwt/api/parser/g4/gen/api/apiparser_lexer.go
  93. 0 655
      tools/goctlwt/api/parser/g4/gen/api/apiparser_parser.go
  94. 0 681
      tools/goctlwt/api/parser/g4/gen/api/apiparser_parser1.go
  95. 0 692
      tools/goctlwt/api/parser/g4/gen/api/apiparser_parser2.go
  96. 0 695
      tools/goctlwt/api/parser/g4/gen/api/apiparser_parser3.go
  97. 0 665
      tools/goctlwt/api/parser/g4/gen/api/apiparser_parser4.go
  98. 0 665
      tools/goctlwt/api/parser/g4/gen/api/apiparser_parser5.go
  99. 0 695
      tools/goctlwt/api/parser/g4/gen/api/apiparser_parser6.go
  100. 0 663
      tools/goctlwt/api/parser/g4/gen/api/apiparser_parser7.go

+ 0 - 34
tools/goctlwt/Dockerfile

@@ -1,34 +0,0 @@
-FROM golang:alpine AS builder
-
-LABEL stage=gobuilder
-
-ENV CGO_ENABLED 0
-ENV GOPROXY https://goproxy.cn,direct
-
-RUN apk update --no-cache && apk add --no-cache tzdata
-RUN go install google.golang.org/protobuf/cmd/protoc-gen-go@latest
-RUN go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest
-
-WORKDIR /build
-
-ADD go.mod .
-ADD go.sum .
-RUN go mod download
-COPY . .
-RUN go build -ldflags="-s -w" -o /app/goctlwt ./goctlwt.go
-
-
-FROM golang:alpine
-
-RUN apk update --no-cache && apk add --no-cache protoc
-
-COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt
-COPY --from=builder /usr/share/zoneinfo/Asia/Shanghai /usr/share/zoneinfo/Asia/Shanghai
-COPY --from=builder /go/bin/protoc-gen-go /usr/bin/protoc-gen-go
-COPY --from=builder /go/bin/protoc-gen-go-grpc /usr/bin/protoc-gen-go-grpc
-ENV TZ Asia/Shanghai
-
-WORKDIR /app
-COPY --from=builder /app/goctlwt /usr/bin/goctlwt
-
-CMD ["goctlwt"]

+ 0 - 25
tools/goctlwt/Makefile

@@ -1,25 +0,0 @@
-build:
-	go build -ldflags="-s -w" goctlwt.go
-	$(if $(shell command -v upx), upx goctlwt)
-
-mac:
-	GOOS=darwin go build -ldflags="-s -w" -o goctlwt-darwin goctlwt.go
-	$(if $(shell command -v upx), upx goctlwt-darwin)
-
-win:
-	GOOS=windows go build -ldflags="-s -w" -o goctlwt.exe goctlwt.go
-	$(if $(shell command -v upx), upx goctlwt.exe)
-
-linux:
-	GOOS=linux go build -ldflags="-s -w" -o goctlwt-linux goctlwt.go
-	$(if $(shell command -v upx), upx goctlwt-linux)
-
-image:
-	docker build --rm --platform linux/amd64 -t superhuan/goctlwt:$(version) .
-	docker tag superhuan/goctlwt:$(version) superhuan/goctlwt:latest
-	docker push superhuan/goctlwt:$(version)
-	docker push superhuan/goctlwt:latest
-	docker build --rm --platform linux/arm64 -t superhuan/goctlwt:$(version)-arm64 .
-	docker tag superhuan/goctlwt:$(version)-arm64 kevinwan/goctlwt:latest-arm64
-	docker push superhuan/goctlwt:$(version)-arm64
-	docker push superhuan/goctlwt:latest-arm64

+ 0 - 24
tools/goctlwt/api/apigen/api.tpl

@@ -1,24 +0,0 @@
-syntax = "v1"
-
-info (
-	title: // TODO: add title
-	desc: // TODO: add description
-	author: "{{.gitUser}}"
-	email: "{{.gitEmail}}"
-)
-
-type request {
-	// TODO: add members here and delete this comment
-}
-
-type response {
-	// TODO: add members here and delete this comment
-}
-
-service {{.serviceName}} {
-	@handler GetUser // TODO: set handler name and delete this comment
-	get /users/id/:userId(request) returns(response)
-
-	@handler CreateUser // TODO: set handler name and delete this comment
-	post /users/create(request)
-}

+ 0 - 78
tools/goctlwt/api/apigen/gen.go

@@ -1,78 +0,0 @@
-package apigen
-
-import (
-	_ "embed"
-	"errors"
-	"fmt"
-	"html/template"
-	"path/filepath"
-	"strings"
-
-	"github.com/gookit/color"
-	"github.com/spf13/cobra"
-	"github.com/wuntsong-org/go-zero-plus/tools/goctlwt/util"
-	"github.com/wuntsong-org/go-zero-plus/tools/goctlwt/util/pathx"
-)
-
-//go:embed api.tpl
-var apiTemplate string
-
-var (
-	// VarStringOutput describes the output.
-	VarStringOutput string
-	// VarStringHome describes the goctlwt home.
-	VarStringHome string
-	// VarStringRemote describes the remote git repository.
-	VarStringRemote string
-	// VarStringBranch describes the git branch.
-	VarStringBranch string
-)
-
-// CreateApiTemplate create api template file
-func CreateApiTemplate(_ *cobra.Command, _ []string) error {
-	apiFile := VarStringOutput
-	if len(apiFile) == 0 {
-		return errors.New("missing -o")
-	}
-
-	fp, err := pathx.CreateIfNotExist(apiFile)
-	if err != nil {
-		return err
-	}
-	defer fp.Close()
-
-	if len(VarStringRemote) > 0 {
-		repo, _ := util.CloneIntoGitHome(VarStringRemote, VarStringBranch)
-		if len(repo) > 0 {
-			VarStringHome = repo
-		}
-	}
-
-	if len(VarStringHome) > 0 {
-		pathx.RegisterGoctlHome(VarStringHome)
-	}
-
-	text, err := pathx.LoadTemplate(category, apiTemplateFile, apiTemplate)
-	if err != nil {
-		return err
-	}
-
-	baseName := pathx.FileNameWithoutExt(filepath.Base(apiFile))
-	if strings.HasSuffix(strings.ToLower(baseName), "-api") {
-		baseName = baseName[:len(baseName)-4]
-	} else if strings.HasSuffix(strings.ToLower(baseName), "api") {
-		baseName = baseName[:len(baseName)-3]
-	}
-
-	t := template.Must(template.New("etcTemplate").Parse(text))
-	if err := t.Execute(fp, map[string]string{
-		"gitUser":     getGitName(),
-		"gitEmail":    getGitEmail(),
-		"serviceName": baseName + "-api",
-	}); err != nil {
-		return err
-	}
-
-	fmt.Println(color.Green.Render("Done."))
-	return nil
-}

+ 0 - 50
tools/goctlwt/api/apigen/template.go

@@ -1,50 +0,0 @@
-package apigen
-
-import (
-	"fmt"
-
-	"github.com/wuntsong-org/go-zero-plus/tools/goctlwt/util/pathx"
-)
-
-const (
-	category        = "api"
-	apiTemplateFile = "template.tpl"
-)
-
-var templates = map[string]string{
-	apiTemplateFile: apiTemplate,
-}
-
-// Category returns the category of the api files.
-func Category() string {
-	return category
-}
-
-// Clean cleans the generated deployment files.
-func Clean() error {
-	return pathx.Clean(category)
-}
-
-// GenTemplates generates api template files.
-func GenTemplates() error {
-	return pathx.InitTemplates(category, templates)
-}
-
-// RevertTemplate reverts the given template file to the default value.
-func RevertTemplate(name string) error {
-	content, ok := templates[name]
-	if !ok {
-		return fmt.Errorf("%s: no such file name", name)
-	}
-	return pathx.CreateTemplate(category, name, content)
-}
-
-// Update updates the template files to the templates built in current goctlwt.
-func Update() error {
-	err := Clean()
-	if err != nil {
-		return err
-	}
-
-	return pathx.InitTemplates(category, templates)
-}

+ 0 - 26
tools/goctlwt/api/apigen/util.go

@@ -1,26 +0,0 @@
-package apigen
-
-import (
-	"os/exec"
-	"strings"
-)
-
-func getGitName() string {
-	cmd := exec.Command("git", "config", "user.name")
-	out, err := cmd.CombinedOutput()
-	if err != nil {
-		return ""
-	}
-
-	return strings.TrimSpace(string(out))
-}
-
-func getGitEmail() string {
-	cmd := exec.Command("git", "config", "user.email")
-	out, err := cmd.CombinedOutput()
-	if err != nil {
-		return ""
-	}
-
-	return strings.TrimSpace(string(out))
-}

+ 0 - 103
tools/goctlwt/api/cmd.go

@@ -1,103 +0,0 @@
-package api
-
-import (
-	"github.com/spf13/cobra"
-	"github.com/wuntsong-org/go-zero-plus/tools/goctlwt/api/apigen"
-	"github.com/wuntsong-org/go-zero-plus/tools/goctlwt/api/dartgen"
-	"github.com/wuntsong-org/go-zero-plus/tools/goctlwt/api/docgen"
-	"github.com/wuntsong-org/go-zero-plus/tools/goctlwt/api/format"
-	"github.com/wuntsong-org/go-zero-plus/tools/goctlwt/api/gogen"
-	"github.com/wuntsong-org/go-zero-plus/tools/goctlwt/api/javagen"
-	"github.com/wuntsong-org/go-zero-plus/tools/goctlwt/api/ktgen"
-	"github.com/wuntsong-org/go-zero-plus/tools/goctlwt/api/new"
-	"github.com/wuntsong-org/go-zero-plus/tools/goctlwt/api/tsgen"
-	"github.com/wuntsong-org/go-zero-plus/tools/goctlwt/api/validate"
-	"github.com/wuntsong-org/go-zero-plus/tools/goctlwt/config"
-	"github.com/wuntsong-org/go-zero-plus/tools/goctlwt/internal/cobrax"
-	"github.com/wuntsong-org/go-zero-plus/tools/goctlwt/plugin"
-)
-
-var (
-	// Cmd describes an api command.
-	Cmd       = cobrax.NewCommand("api", cobrax.WithRunE(apigen.CreateApiTemplate))
-	dartCmd   = cobrax.NewCommand("dart", cobrax.WithRunE(dartgen.DartCommand))
-	docCmd    = cobrax.NewCommand("doc", cobrax.WithRunE(docgen.DocCommand))
-	formatCmd = cobrax.NewCommand("format", cobrax.WithRunE(format.GoFormatApi))
-	goCmd     = cobrax.NewCommand("go", cobrax.WithRunE(gogen.GoCommand))
-	newCmd    = cobrax.NewCommand("new", cobrax.WithRunE(new.CreateServiceCommand),
-		cobrax.WithArgs(cobra.MatchAll(cobra.ExactArgs(1), cobra.OnlyValidArgs)))
-	validateCmd = cobrax.NewCommand("validate", cobrax.WithRunE(validate.GoValidateApi))
-	javaCmd     = cobrax.NewCommand("java", cobrax.WithRunE(javagen.JavaCommand), cobrax.WithHidden())
-	ktCmd       = cobrax.NewCommand("kt", cobrax.WithRunE(ktgen.KtCommand))
-	pluginCmd   = cobrax.NewCommand("plugin", cobrax.WithRunE(plugin.PluginCommand))
-	tsCmd       = cobrax.NewCommand("ts", cobrax.WithRunE(tsgen.TsCommand))
-)
-
-func init() {
-	var (
-		apiCmdFlags      = Cmd.Flags()
-		dartCmdFlags     = dartCmd.Flags()
-		docCmdFlags      = docCmd.Flags()
-		formatCmdFlags   = formatCmd.Flags()
-		goCmdFlags       = goCmd.Flags()
-		javaCmdFlags     = javaCmd.Flags()
-		ktCmdFlags       = ktCmd.Flags()
-		newCmdFlags      = newCmd.Flags()
-		pluginCmdFlags   = pluginCmd.Flags()
-		tsCmdFlags       = tsCmd.Flags()
-		validateCmdFlags = validateCmd.Flags()
-	)
-
-	apiCmdFlags.StringVar(&apigen.VarStringOutput, "o")
-	apiCmdFlags.StringVar(&apigen.VarStringHome, "home")
-	apiCmdFlags.StringVar(&apigen.VarStringRemote, "remote")
-	apiCmdFlags.StringVar(&apigen.VarStringBranch, "branch")
-
-	dartCmdFlags.StringVar(&dartgen.VarStringDir, "dir")
-	dartCmdFlags.StringVar(&dartgen.VarStringAPI, "api")
-	dartCmdFlags.BoolVar(&dartgen.VarStringLegacy, "legacy")
-	dartCmdFlags.StringVar(&dartgen.VarStringHostname, "hostname")
-	dartCmdFlags.StringVar(&dartgen.VarStringScheme, "scheme")
-
-	docCmdFlags.StringVar(&docgen.VarStringDir, "dir")
-	docCmdFlags.StringVar(&docgen.VarStringOutput, "o")
-
-	formatCmdFlags.StringVar(&format.VarStringDir, "dir")
-	formatCmdFlags.BoolVar(&format.VarBoolIgnore, "iu")
-	formatCmdFlags.BoolVar(&format.VarBoolUseStdin, "stdin")
-	formatCmdFlags.BoolVar(&format.VarBoolSkipCheckDeclare, "declare")
-
-	goCmdFlags.StringVar(&gogen.VarStringDir, "dir")
-	goCmdFlags.StringVar(&gogen.VarStringAPI, "api")
-	goCmdFlags.StringVar(&gogen.VarStringHome, "home")
-	goCmdFlags.StringVar(&gogen.VarStringRemote, "remote")
-	goCmdFlags.StringVar(&gogen.VarStringBranch, "branch")
-	goCmdFlags.StringVarWithDefaultValue(&gogen.VarStringStyle, "style", config.DefaultFormat)
-
-	javaCmdFlags.StringVar(&javagen.VarStringDir, "dir")
-	javaCmdFlags.StringVar(&javagen.VarStringAPI, "api")
-
-	ktCmdFlags.StringVar(&ktgen.VarStringDir, "dir")
-	ktCmdFlags.StringVar(&ktgen.VarStringAPI, "api")
-	ktCmdFlags.StringVar(&ktgen.VarStringPKG, "pkg")
-
-	newCmdFlags.StringVar(&new.VarStringHome, "home")
-	newCmdFlags.StringVar(&new.VarStringRemote, "remote")
-	newCmdFlags.StringVar(&new.VarStringBranch, "branch")
-	newCmdFlags.StringVarWithDefaultValue(&new.VarStringStyle, "style", config.DefaultFormat)
-
-	pluginCmdFlags.StringVarP(&plugin.VarStringPlugin, "plugin", "p")
-	pluginCmdFlags.StringVar(&plugin.VarStringDir, "dir")
-	pluginCmdFlags.StringVar(&plugin.VarStringAPI, "api")
-	pluginCmdFlags.StringVar(&plugin.VarStringStyle, "style")
-
-	tsCmdFlags.StringVar(&tsgen.VarStringDir, "dir")
-	tsCmdFlags.StringVar(&tsgen.VarStringAPI, "api")
-	tsCmdFlags.StringVar(&tsgen.VarStringCaller, "caller")
-	tsCmdFlags.BoolVar(&tsgen.VarBoolUnWrap, "unwrap")
-
-	validateCmdFlags.StringVar(&validate.VarStringAPI, "api")
-
-	// Add sub-commands
-	Cmd.AddCommand(dartCmd, docCmd, formatCmd, goCmd, javaCmd, ktCmd, newCmd, pluginCmd, tsCmd, validateCmd)
-}

+ 0 - 40
tools/goctlwt/api/dartgen/format.go

@@ -1,40 +0,0 @@
-package dartgen
-
-import (
-	"fmt"
-	"os"
-	"os/exec"
-)
-
-const dartExec = "dart"
-
-func formatDir(dir string) error {
-	ok, err := dirctoryExists(dir)
-	if err != nil {
-		return err
-	}
-	if !ok {
-		return fmt.Errorf("format failed, directory %q does not exist", dir)
-	}
-
-	_, err = exec.LookPath(dartExec)
-	if err != nil {
-		return err
-	}
-	cmd := exec.Command(dartExec, "format", dir)
-	cmd.Env = os.Environ()
-	cmd.Stderr = os.Stderr
-
-	return cmd.Run()
-}
-
-func dirctoryExists(dir string) (bool, error) {
-	_, err := os.Stat(dir)
-	if err == nil {
-		return true, nil
-	}
-	if os.IsNotExist(err) {
-		return false, nil
-	}
-	return false, err
-}

+ 0 - 69
tools/goctlwt/api/dartgen/gen.go

@@ -1,69 +0,0 @@
-package dartgen
-
-import (
-	"errors"
-	"fmt"
-	"strings"
-
-	"github.com/spf13/cobra"
-	"github.com/wuntsong-org/go-zero-plus/core/logx"
-	"github.com/wuntsong-org/go-zero-plus/tools/goctlwt/api/parser"
-)
-
-var (
-	// VarStringDir describes the directory.
-	VarStringDir string
-	// VarStringAPI defines the API.
-	VarStringAPI string
-	// VarStringLegacy describes whether legacy.
-	VarStringLegacy bool
-	// VarStringHostname defines the hostname.
-	VarStringHostname string
-	// VarStringSchema defines the scheme.
-	VarStringScheme string
-)
-
-// DartCommand create dart network request code
-func DartCommand(_ *cobra.Command, _ []string) error {
-	apiFile := VarStringAPI
-	dir := VarStringDir
-	isLegacy := VarStringLegacy
-	hostname := VarStringHostname
-	scheme := VarStringScheme
-	if len(apiFile) == 0 {
-		return errors.New("missing -api")
-	}
-	if len(dir) == 0 {
-		return errors.New("missing -dir")
-	}
-	if len(hostname) == 0 {
-		fmt.Println("you could use '-hostname' flag to specify your server hostname")
-		hostname = "go-zero.dev"
-	}
-	if len(scheme) == 0 {
-		fmt.Println("you could use '-scheme' flag to specify your server scheme")
-		scheme = "http"
-	}
-
-	api, err := parser.Parse(apiFile)
-	if err != nil {
-		return err
-	}
-
-	if err := api.Validate(); err != nil {
-		return err
-	}
-
-	api.Service = api.Service.JoinPrefix()
-	if !strings.HasSuffix(dir, "/") {
-		dir = dir + "/"
-	}
-	api.Info.Title = strings.Replace(apiFile, ".api", "", -1)
-	logx.Must(genData(dir+"data/", api, isLegacy))
-	logx.Must(genApi(dir+"api/", api, isLegacy))
-	logx.Must(genVars(dir+"vars/", isLegacy, scheme, hostname))
-	if err := formatDir(dir); err != nil {
-		logx.Errorf("failed to format, %v", err)
-	}
-	return nil
-}

+ 0 - 103
tools/goctlwt/api/dartgen/genapi.go

@@ -1,103 +0,0 @@
-package dartgen
-
-import (
-	"os"
-	"strings"
-	"text/template"
-
-	"github.com/wuntsong-org/go-zero-plus/tools/goctlwt/api/spec"
-)
-
-const apiTemplate = `import 'api.dart';
-import '../data/{{with .Info}}{{getBaseName .Title}}{{end}}.dart';
-{{with .Service}}
-/// {{.Name}}
-{{range .Routes}}
-/// --{{.Path}}--
-///
-/// 请求: {{with .RequestType}}{{.Name}}{{end}}
-/// 返回: {{with .ResponseType}}{{.Name}}{{end}}
-Future {{pathToFuncName .Path}}( {{if ne .Method "get"}}{{with .RequestType}}{{.Name}} request,{{end}}{{end}}
-    {Function({{with .ResponseType}}{{.Name}}{{end}}) ok,
-    Function(String) fail,
-    Function eventually}) async {
-  await api{{if eq .Method "get"}}Get{{else}}Post{{end}}('{{.Path}}',{{if ne .Method "get"}}request,{{end}}
-  	 ok: (data) {
-    if (ok != null) ok({{with .ResponseType}}{{.Name}}.fromJson(data){{end}});
-  }, fail: fail, eventually: eventually);
-}
-{{end}}
-{{end}}`
-
-const apiTemplateV2 = `import 'api.dart';
-import '../data/{{with .Service}}{{.Name}}{{end}}.dart';
-{{with .Service}}
-/// {{.Name}}
-{{range $i, $Route := .Routes}}
-/// --{{.Path}}--
-///
-/// request: {{with .RequestType}}{{.Name}}{{end}}
-/// response: {{with .ResponseType}}{{.Name}}{{end}}
-Future {{normalizeHandlerName .Handler}}(
-	{{if hasUrlPathParams $Route}}{{extractPositionalParamsFromPath $Route}},{{end}}
-	{{if ne .Method "get"}}{{with .RequestType}}{{.Name}} request,{{end}}{{end}}
-    {Function({{with .ResponseType}}{{.Name}}{{end}})? ok,
-    Function(String)? fail,
-    Function? eventually}) async {
-  await api{{if eq .Method "get"}}Get{{else}}Post{{end}}({{makeDartRequestUrlPath $Route}},{{if ne .Method "get"}}request,{{end}}
-  	 ok: (data) {
-    if (ok != null) ok({{with .ResponseType}}{{.Name}}.fromJson(data){{end}});
-  }, fail: fail, eventually: eventually);
-}
-{{end}}
-{{end}}`
-
-func genApi(dir string, api *spec.ApiSpec, isLegacy bool) error {
-	err := os.MkdirAll(dir, 0o755)
-	if err != nil {
-		return err
-	}
-
-	err = genApiFile(dir, isLegacy)
-	if err != nil {
-		return err
-	}
-
-	file, err := os.OpenFile(dir+strings.ToLower(api.Service.Name+".dart"), os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0o644)
-	if err != nil {
-		return err
-	}
-
-	defer file.Close()
-	t := template.New("apiTemplate")
-	t = t.Funcs(funcMap)
-	tpl := apiTemplateV2
-	if isLegacy {
-		tpl = apiTemplate
-	}
-	t, err = t.Parse(tpl)
-	if err != nil {
-		return err
-	}
-
-	return t.Execute(file, api)
-}
-
-func genApiFile(dir string, isLegacy bool) error {
-	path := dir + "api.dart"
-	if fileExists(path) {
-		return nil
-	}
-	apiFile, err := os.OpenFile(path, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0o644)
-	if err != nil {
-		return err
-	}
-
-	defer apiFile.Close()
-	tpl := apiFileContentV2
-	if isLegacy {
-		tpl = apiFileContent
-	}
-	_, err = apiFile.WriteString(tpl)
-	return err
-}

+ 0 - 151
tools/goctlwt/api/dartgen/gendata.go

@@ -1,151 +0,0 @@
-package dartgen
-
-import (
-	"os"
-	"strings"
-	"text/template"
-
-	"github.com/wuntsong-org/go-zero-plus/tools/goctlwt/api/spec"
-)
-
-const dataTemplate = `// --{{with .Info}}{{.Title}}{{end}}--
-{{ range .Types}}
-class {{.Name}}{
-	{{range .Members}}
-	/// {{.Comment}}
-	final {{if isNumberType .Type.Name}}num{{else}}{{.Type.Name}}{{end}} {{lowCamelCase .Name}};
-	{{end}}
-	{{.Name}}({ {{range .Members}}
-		this.{{lowCamelCase .Name}},{{end}}
-	});
-	factory {{.Name}}.fromJson(Map<String,dynamic> m) {
-		return {{.Name}}({{range .Members}}
-			{{lowCamelCase .Name}}: {{if isDirectType .Type.Name}}m['{{getPropertyFromMember .}}']{{else if isClassListType .Type.Name}}(m['{{getPropertyFromMember .}}'] as List<dynamic>).map((i) => {{getCoreType .Type.Name}}.fromJson(i)){{else}}{{.Type.Name}}.fromJson(m['{{getPropertyFromMember .}}']){{end}},{{end}}
-		);
-	}
-	Map<String,dynamic> toJson() {
-		return { {{range .Members}}
-			'{{getPropertyFromMember .}}': {{if isDirectType .Type.Name}}{{lowCamelCase .Name}}{{else if isClassListType .Type.Name}}{{lowCamelCase .Name}}.map((i) => i.toJson()){{else}}{{lowCamelCase .Name}}.toJson(){{end}},{{end}}
-		};
-	}
-}
-{{end}}
-`
-
-const dataTemplateV2 = `// --{{with .Info}}{{.Title}}{{end}}--
-{{ range .Types}}
-class {{.Name}} {
-	{{range .Members}}
-	{{if .Comment}}{{.Comment}}{{end}}
-	final {{if isNumberType .Type.Name}}num{{else}}{{.Type.Name}}{{end}} {{lowCamelCase .Name}};
-  {{end}}{{.Name}}({{if .Members}}{
-	{{range .Members}}  required this.{{lowCamelCase .Name}},
-	{{end}}}{{end}});
-	factory {{.Name}}.fromJson(Map<String,dynamic> m) {
-		return {{.Name}}(
-			{{range .Members}}
-				{{lowCamelCase .Name}}: {{appendNullCoalescing .}}
-					{{if isAtomicType .Type.Name}}
-						m['{{getPropertyFromMember .}}'] {{appendDefaultEmptyValue .Type.Name}}
-					{{else if isAtomicListType .Type.Name}}
-						m['{{getPropertyFromMember .}}']?.cast<{{getCoreType .Type.Name}}>() {{appendDefaultEmptyValue .Type.Name}}
-					{{else if isClassListType .Type.Name}}
-						((m['{{getPropertyFromMember .}}'] {{appendDefaultEmptyValue .Type.Name}}) as List<dynamic>).map((i) => {{getCoreType .Type.Name}}.fromJson(i)).toList()
-					{{else}}
-						{{.Type.Name}}.fromJson(m['{{getPropertyFromMember .}}']){{end}}
-			,{{end}}
-		);
-	}
-	Map<String,dynamic> toJson() {
-		return { {{range .Members}}
-			'{{getPropertyFromMember .}}': 
-				{{if isDirectType .Type.Name}}
-					{{lowCamelCase .Name}}
-				{{else if isClassListType .Type.Name}}
-					{{lowCamelCase .Name}}{{if isNullableType .Type.Name}}?{{end}}.map((i) => i{{if isListItemsNullable .Type.Name}}?{{end}}.toJson())
-				{{else}}
-					{{lowCamelCase .Name}}{{if isNullableType .Type.Name}}?{{end}}.toJson()
-				{{end}}
-			,{{end}}
-		};
-	}
-}
-{{end}}`
-
-func genData(dir string, api *spec.ApiSpec, isLegacy bool) error {
-	err := os.MkdirAll(dir, 0o755)
-	if err != nil {
-		return err
-	}
-
-	err = genTokens(dir, isLegacy)
-	if err != nil {
-		return err
-	}
-
-	file, err := os.OpenFile(dir+strings.ToLower(api.Service.Name+".dart"), os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0o644)
-	if err != nil {
-		return err
-	}
-	defer file.Close()
-
-	t := template.New("dataTemplate")
-	t = t.Funcs(funcMap)
-	tpl := dataTemplateV2
-	if isLegacy {
-		tpl = dataTemplate
-	}
-	t, err = t.Parse(tpl)
-	if err != nil {
-		return err
-	}
-
-	err = convertDataType(api)
-	if err != nil {
-		return err
-	}
-
-	return t.Execute(file, api)
-}
-
-func genTokens(dir string, isLeagcy bool) error {
-	path := dir + "tokens.dart"
-	if fileExists(path) {
-		return nil
-	}
-
-	tokensFile, err := os.OpenFile(path, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0o644)
-	if err != nil {
-		return err
-	}
-
-	defer tokensFile.Close()
-	tpl := tokensFileContentV2
-	if isLeagcy {
-		tpl = tokensFileContent
-	}
-	_, err = tokensFile.WriteString(tpl)
-	return err
-}
-
-func convertDataType(api *spec.ApiSpec) error {
-	types := api.Types
-	if len(types) == 0 {
-		return nil
-	}
-
-	for _, ty := range types {
-		defineStruct, ok := ty.(spec.DefineStruct)
-		if ok {
-			for index, member := range defineStruct.Members {
-				tp, err := specTypeToDart(member.Type)
-				if err != nil {
-					return err
-				}
-				defineStruct.Members[index].Type = buildSpecType(member.Type, tp)
-			}
-		}
-	}
-
-	return nil
-}

+ 0 - 102
tools/goctlwt/api/dartgen/genvars.go

@@ -1,102 +0,0 @@
-package dartgen
-
-import (
-	"fmt"
-	"os"
-)
-
-const (
-	varTemplate = `import 'dart:convert';
-import 'package:shared_preferences/shared_preferences.dart';
-import '../data/tokens.dart';
-
-/// 保存tokens到本地
-///
-/// 传入null则删除本地tokens
-/// 返回:true:设置成功  false:设置失败
-Future<bool> setTokens(Tokens tokens) async {
-  var sp = await SharedPreferences.getInstance();
-  if (tokens == null) {
-    sp.remove('tokens');
-    return true;
-  }
-  return await sp.setString('tokens', jsonEncode(tokens.toJson()));
-}
-
-/// 获取本地存储的tokens
-///
-/// 如果没有,则返回null
-Future<Tokens> getTokens() async {
-  try {
-    var sp = await SharedPreferences.getInstance();
-    var str = sp.getString('tokens');
-    if (str == null || str.isEmpty) {
-      return null;
-    }
-    return Tokens.fromJson(jsonDecode(str));
-  } catch (e) {
-    print(e);
-    return null;
-  }
-}
-`
-
-	varTemplateV2 = `import 'dart:convert';
-import 'package:shared_preferences/shared_preferences.dart';
-import '../data/tokens.dart';
-
-const String _tokenKey = 'tokens';
-
-/// Saves tokens
-Future<bool> setTokens(Tokens tokens) async {
-  var sp = await SharedPreferences.getInstance();
-  return await sp.setString(_tokenKey, jsonEncode(tokens.toJson()));
-}
-
-/// remove tokens
-Future<bool> removeTokens() async {
-  var sp = await SharedPreferences.getInstance();
-  return sp.remove(_tokenKey);
-}
-
-/// Reads tokens
-Future<Tokens?> getTokens() async {
-  try {
-    var sp = await SharedPreferences.getInstance();
-    var str = sp.getString('tokens');
-    if (str == null || str.isEmpty) {
-      return null;
-    }
-    return Tokens.fromJson(jsonDecode(str));
-  } catch (e) {
-    print(e);
-    return null;
-  }
-}`
-)
-
-func genVars(dir string, isLegacy bool, scheme string, hostname string) error {
-	err := os.MkdirAll(dir, 0o755)
-	if err != nil {
-		return err
-	}
-
-	if !fileExists(dir + "vars.dart") {
-		err = os.WriteFile(dir+"vars.dart", []byte(fmt.Sprintf(`const serverHost='%s://%s';`, scheme, hostname)), 0o644)
-		if err != nil {
-			return err
-		}
-	}
-
-	if !fileExists(dir + "kv.dart") {
-		tpl := varTemplateV2
-		if isLegacy {
-			tpl = varTemplate
-		}
-		err = os.WriteFile(dir+"kv.dart", []byte(tpl), 0o644)
-		if err != nil {
-			return err
-		}
-	}
-	return nil
-}

+ 0 - 279
tools/goctlwt/api/dartgen/util.go

@@ -1,279 +0,0 @@
-package dartgen
-
-import (
-	"errors"
-	"fmt"
-	"os"
-	"path"
-	"strings"
-
-	"github.com/wuntsong-org/go-zero-plus/tools/goctlwt/api/spec"
-	"github.com/wuntsong-org/go-zero-plus/tools/goctlwt/api/util"
-)
-
-const (
-	formTagKey   = "form"
-	pathTagKey   = "path"
-	headerTagKey = "header"
-)
-
-func normalizeHandlerName(handlerName string) string {
-	handler := strings.Replace(handlerName, "Handler", "", 1)
-	handler = lowCamelCase(handler)
-	return handler
-}
-
-func lowCamelCase(s string) string {
-	if len(s) < 1 {
-		return ""
-	}
-
-	s = util.ToCamelCase(util.ToSnakeCase(s))
-	return util.ToLower(s[:1]) + s[1:]
-}
-
-func getBaseName(str string) string {
-	return path.Base(str)
-}
-
-func getPropertyFromMember(member spec.Member) string {
-	name, err := member.GetPropertyName()
-	if err != nil {
-		panic(fmt.Sprintf("cannot get property name of %q", member.Name))
-	}
-	return name
-}
-
-func isDirectType(s string) bool {
-	return isAtomicType(s) || isListType(s) && isAtomicType(getCoreType(s))
-}
-
-func isAtomicType(s string) bool {
-	switch s {
-	case "String", "int", "double", "bool":
-		return true
-	default:
-		return false
-	}
-}
-
-func isNumberType(s string) bool {
-	switch s {
-	case "int", "double":
-		return true
-	default:
-		return false
-	}
-}
-
-func isListType(s string) bool {
-	return strings.HasPrefix(s, "List<")
-}
-
-func isClassListType(s string) bool {
-	return isListType(s) && !isAtomicType(getCoreType(s))
-}
-
-func isAtomicListType(s string) bool {
-	return isListType(s) && isAtomicType(getCoreType(s))
-}
-
-func isListItemsNullable(s string) bool {
-	return isListType(s) && isNullableType(getCoreType(s))
-}
-
-func isMapType(s string) bool {
-	return strings.HasPrefix(s, "Map<")
-}
-
-// Only interface types are nullable
-func isNullableType(s string) bool {
-	return strings.HasSuffix(s, "?")
-}
-
-func appendNullCoalescing(member spec.Member) string {
-	if isNullableType(member.Type.Name()) {
-		return "m['" + getPropertyFromMember(member) + "'] == null ? null : "
-	}
-	return ""
-}
-
-// To be compatible with omitempty tags in Golang
-// Only set default value for non-nullable types
-func appendDefaultEmptyValue(s string) string {
-	if isNullableType(s) {
-		return ""
-	}
-
-	if isAtomicType(s) {
-		switch s {
-		case "String":
-			return `?? ""`
-		case "int":
-			return "?? 0"
-		case "double":
-			return "?? 0.0"
-		case "bool":
-			return "?? false"
-		default:
-			panic(errors.New("unknown atomic type"))
-		}
-	}
-	if isListType(s) {
-		return "?? []"
-	}
-	if isMapType(s) {
-		return "?? {}"
-	}
-	return ""
-}
-
-func getCoreType(s string) string {
-	if isAtomicType(s) {
-		return s
-	}
-	if isListType(s) {
-		s = strings.Replace(s, "List<", "", -1)
-		return strings.Replace(s, ">", "", -1)
-	}
-	return s
-}
-
-func fileExists(path string) bool {
-	_, err := os.Stat(path)
-	return !os.IsNotExist(err)
-}
-
-func buildSpecType(tp spec.Type, name string) spec.Type {
-	switch v := tp.(type) {
-	case spec.PrimitiveType:
-		return spec.PrimitiveType{RawName: name}
-	case spec.MapType:
-		return spec.MapType{RawName: name, Key: v.Key, Value: v.Value}
-	case spec.ArrayType:
-		return spec.ArrayType{RawName: name, Value: v.Value}
-	case spec.InterfaceType:
-		return spec.InterfaceType{RawName: name}
-	case spec.PointerType:
-		return spec.PointerType{RawName: name, Type: v.Type}
-	}
-	return tp
-}
-
-func specTypeToDart(tp spec.Type) (string, error) {
-	switch v := tp.(type) {
-	case spec.DefineStruct:
-		return tp.Name(), nil
-	case spec.PrimitiveType:
-		r, ok := primitiveType(tp.Name())
-		if !ok {
-			return "", errors.New("unsupported primitive type " + tp.Name())
-		}
-		return r, nil
-	case spec.MapType:
-		valueType, err := specTypeToDart(v.Value)
-		if err != nil {
-			return "", err
-		}
-
-		return fmt.Sprintf("Map<String, %s>", valueType), nil
-	case spec.ArrayType:
-		if tp.Name() == "[]byte" {
-			return "List<int>", nil
-		}
-
-		valueType, err := specTypeToDart(v.Value)
-		if err != nil {
-			return "", err
-		}
-
-		s := getBaseType(valueType)
-		if len(s) != 0 {
-			return s, nil
-		}
-		return fmt.Sprintf("List<%s>", valueType), nil
-	case spec.InterfaceType:
-		return "Object?", nil
-	case spec.PointerType:
-		valueType, err := specTypeToDart(v.Type)
-		if err != nil {
-			return "", err
-		}
-		return fmt.Sprintf("%s?", valueType), nil
-	}
-
-	return "", errors.New("unsupported primitive type " + tp.Name())
-}
-
-func getBaseType(valueType string) string {
-	switch valueType {
-	case "int":
-		return "List<int>"
-	case "double":
-		return "List<double>"
-	case "boolean":
-		return "List<bool>"
-	case "String":
-		return "List<String>"
-	default:
-		return ""
-	}
-}
-
-func primitiveType(tp string) (string, bool) {
-	switch tp {
-	case "string":
-		return "String", true
-	case "int", "int8", "int16", "int32", "int64", "uint", "uint8", "uint16", "uint32", "uint64", "rune":
-		return "int", true
-	case "float32", "float64":
-		return "double", true
-	case "bool":
-		return "bool", true
-	}
-
-	return "", false
-}
-
-func hasUrlPathParams(route spec.Route) bool {
-	ds, ok := route.RequestType.(spec.DefineStruct)
-	if !ok {
-		return false
-	}
-
-	return len(route.RequestTypeName()) > 0 && len(ds.GetTagMembers(pathTagKey)) > 0
-}
-
-func extractPositionalParamsFromPath(route spec.Route) string {
-	ds, ok := route.RequestType.(spec.DefineStruct)
-	if !ok {
-		return ""
-	}
-
-	var params []string
-	for _, member := range ds.GetTagMembers(pathTagKey) {
-		dartType := member.Type.Name()
-		params = append(params, fmt.Sprintf("%s %s", dartType, getPropertyFromMember(member)))
-	}
-
-	return strings.Join(params, ", ")
-}
-
-func makeDartRequestUrlPath(route spec.Route) string {
-	path := route.Path
-	if route.RequestType == nil {
-		return `"` + path + `"`
-	}
-
-	ds, ok := route.RequestType.(spec.DefineStruct)
-	if !ok {
-		return path
-	}
-
-	for _, member := range ds.GetTagMembers(pathTagKey) {
-		paramName := member.Tags()[0].Name
-		path = strings.ReplaceAll(path, ":"+paramName, "${"+getPropertyFromMember(member)+"}")
-	}
-
-	return `"` + path + `"`
-}

+ 0 - 71
tools/goctlwt/api/dartgen/util_test.go

@@ -1,71 +0,0 @@
-package dartgen
-
-import (
-	"testing"
-
-	"github.com/wuntsong-org/go-zero-plus/tools/goctlwt/api/spec"
-)
-
-func Test_getPropertyFromMember(t *testing.T) {
-	tests := []struct {
-		name   string
-		member spec.Member
-		want   string
-	}{
-		{
-			name: "json tag should be ok",
-			member: spec.Member{
-				Tag:  "`json:\"foo\"`",
-				Name: "Foo",
-			},
-			want: "foo",
-		},
-		{
-			name: "form tag should be ok",
-			member: spec.Member{
-				Tag:  "`form:\"bar\"`",
-				Name: "Bar",
-			},
-			want: "bar",
-		},
-	}
-	for _, tt := range tests {
-		t.Run(tt.name, func(t *testing.T) {
-			if got := getPropertyFromMember(tt.member); got != tt.want {
-				t.Errorf("getPropertyFromMember() = %v, want %v", got, tt.want)
-			}
-		})
-	}
-}
-
-func Test_specTypeToDart(t *testing.T) {
-	tests := []struct {
-		name     string
-		specType spec.Type
-		want     string
-		wantErr  bool
-	}{
-		{
-			name:     "[]string should return List<String>",
-			specType: spec.ArrayType{RawName: "[]string", Value: spec.PrimitiveType{RawName: "string"}},
-			want:     "List<String>",
-		},
-		{
-			name:     "[]Foo should return List<Foo>",
-			specType: spec.ArrayType{RawName: "[]Foo", Value: spec.DefineStruct{RawName: "Foo"}},
-			want:     "List<Foo>",
-		},
-	}
-	for _, tt := range tests {
-		t.Run(tt.name, func(t *testing.T) {
-			got, err := specTypeToDart(tt.specType)
-			if (err != nil) != tt.wantErr {
-				t.Errorf("specTypeToDart() error = %v, wantErr %v", err, tt.wantErr)
-				return
-			}
-			if got != tt.want {
-				t.Errorf("specTypeToDart() = %v, want %v", got, tt.want)
-			}
-		})
-	}
-}

+ 0 - 284
tools/goctlwt/api/dartgen/vars.go

@@ -1,284 +0,0 @@
-package dartgen
-
-import "text/template"
-
-var funcMap = template.FuncMap{
-	"getBaseName":                     getBaseName,
-	"getPropertyFromMember":           getPropertyFromMember,
-	"isDirectType":                    isDirectType,
-	"isAtomicType":                    isAtomicType,
-	"isNumberType":                    isNumberType,
-	"isClassListType":                 isClassListType,
-	"isAtomicListType":                isAtomicListType,
-	"isListItemsNullable":             isListItemsNullable,
-	"isNullableType":                  isNullableType,
-	"appendNullCoalescing":            appendNullCoalescing,
-	"appendDefaultEmptyValue":         appendDefaultEmptyValue,
-	"getCoreType":                     getCoreType,
-	"lowCamelCase":                    lowCamelCase,
-	"normalizeHandlerName":            normalizeHandlerName,
-	"hasUrlPathParams":                hasUrlPathParams,
-	"extractPositionalParamsFromPath": extractPositionalParamsFromPath,
-	"makeDartRequestUrlPath":          makeDartRequestUrlPath,
-}
-
-const (
-	apiFileContent = `import 'dart:io';
-import 'dart:convert';
-import '../vars/kv.dart';
-import '../vars/vars.dart';
-
-/// 发送POST请求.
-///
-/// data:为你要post的结构体,我们会帮你转换成json字符串;
-/// ok函数:请求成功的时候调用,fail函数:请求失败的时候会调用,eventually函数:无论成功失败都会调用
-Future apiPost(String path, dynamic data,
-    {Map<String, String> header,
-    Function(Map<String, dynamic>) ok,
-    Function(String) fail,
-    Function eventually}) async {
-  await _apiRequest('POST', path, data,
-      header: header, ok: ok, fail: fail, eventually: eventually);
-}
-
-/// 发送GET请求.
-///
-/// ok函数:请求成功的时候调用,fail函数:请求失败的时候会调用,eventually函数:无论成功失败都会调用
-Future apiGet(String path,
-    {Map<String, String> header,
-    Function(Map<String, dynamic>) ok,
-    Function(String) fail,
-    Function eventually}) async {
-  await _apiRequest('GET', path, null,
-      header: header, ok: ok, fail: fail, eventually: eventually);
-}
-
-Future _apiRequest(String method, String path, dynamic data,
-    {Map<String, String> header,
-    Function(Map<String, dynamic>) ok,
-    Function(String) fail,
-    Function eventually}) async {
-  var tokens = await getTokens();
-  try {
-    var client = HttpClient();
-    HttpClientRequest r;
-    if (method == 'POST') {
-      r = await client.postUrl(Uri.parse(serverHost + path));
-    } else {
-      r = await client.getUrl(Uri.parse(serverHost + path));
-    }
-
-    var strData = '';
-    if (data != null) {
-      strData = jsonEncode(data);
-    }
-
-    if (method == 'POST') {
-      r.headers.set('Content-Type', 'application/json; charset=utf-8');
-      r.headers.set('Content-Length', utf8.encode(strData).length);
-    }
-
-    if (tokens != null) {
-      r.headers.set('Authorization', tokens.accessToken);
-    }
-    if (header != null) {
-      header.forEach((k, v) {
-        r.headers.set(k, v);
-      });
-    }
-
-    r.write(strData);
-
-    var rp = await r.close();
-    var body = await rp.transform(utf8.decoder).join();
-    print('${rp.statusCode} - $path');
-    print('-- request --');
-    print(strData);
-    print('-- response --');
-    print('$body \n');
-    if (rp.statusCode == 404) {
-      if (fail != null) fail('404 not found');
-    } else {
-      Map<String, dynamic> base = jsonDecode(body);
-      if (rp.statusCode == 200) {
-        if (base['code'] != 0) {
-          if (fail != null) fail(base['desc']);
-        } else {
-          if (ok != null) ok(base['data']);
-        }
-      } else if (base['code'] != 0) {
-        if (fail != null) fail(base['desc']);
-      }
-    }
-  } catch (e) {
-    if (fail != null) fail(e.toString());
-  }
-  if (eventually != null) eventually();
-}
-`
-
-	apiFileContentV2 = `import 'dart:io';
-	import 'dart:convert';
-	import '../vars/kv.dart';
-	import '../vars/vars.dart';
-
-	/// send request with post method
-	///
-	/// data: any request class that will be converted to json automatically
-	/// ok: is called when request succeeds
-	/// fail: is called when request fails
-	/// eventually: is always called until the nearby functions returns
-	Future apiPost(String path, dynamic data,
-			{Map<String, String>? header,
-			Function(Map<String, dynamic>)? ok,
-			Function(String)? fail,
-			Function? eventually}) async {
-		await _apiRequest('POST', path, data,
-				header: header, ok: ok, fail: fail, eventually: eventually);
-	}
-
-	/// send request with get method
-	///
-	/// ok: is called when request succeeds
-	/// fail: is called when request fails
-	/// eventually: is always called until the nearby functions returns
-	Future apiGet(String path,
-			{Map<String, String>? header,
-			Function(Map<String, dynamic>)? ok,
-			Function(String)? fail,
-			Function? eventually}) async {
-		await _apiRequest('GET', path, null,
-				header: header, ok: ok, fail: fail, eventually: eventually);
-	}
-
-	Future _apiRequest(String method, String path, dynamic data,
-			{Map<String, String>? header,
-			Function(Map<String, dynamic>)? ok,
-			Function(String)? fail,
-			Function? eventually}) async {
-		var tokens = await getTokens();
-		try {
-			var client = HttpClient();
-			HttpClientRequest r;
-			if (method == 'POST') {
-				r = await client.postUrl(Uri.parse(serverHost + path));
-			} else {
-				r = await client.getUrl(Uri.parse(serverHost + path));
-			}
-
-      var strData = '';
-			if (data != null) {
-				strData = jsonEncode(data);
-			}
-			if (method == 'POST') {
-        r.headers.set('Content-Type', 'application/json; charset=utf-8');
-        r.headers.set('Content-Length', utf8.encode(strData).length);
-      }
-			if (tokens != null) {
-				r.headers.set('Authorization', tokens.accessToken);
-			}
-			if (header != null) {
-				header.forEach((k, v) {
-					r.headers.set(k, v);
-				});
-			}
-
-			r.write(strData);
-			var rp = await r.close();
-			var body = await rp.transform(utf8.decoder).join();
-			print('${rp.statusCode} - $path');
-			print('-- request --');
-			print(strData);
-			print('-- response --');
-			print('$body \n');
-			if (rp.statusCode == 404) {
-				if (fail != null) fail('404 not found');
-			} else {
-				Map<String, dynamic> base = jsonDecode(body);
-				if (rp.statusCode == 200) {
-					if (base['code'] != 0) {
-						if (fail != null) fail(base['desc']);
-					} else {
-						if (ok != null) ok(base['data']);
-					}
-				} else if (base['code'] != 0) {
-					if (fail != null) fail(base['desc']);
-				}
-			}
-		} catch (e) {
-			if (fail != null) fail(e.toString());
-		}
-		if (eventually != null) eventually();
-	}`
-
-	tokensFileContent = `class Tokens {
-  /// 用于访问的token, 每次请求都必须带在Header里面
-  final String accessToken;
-  final int accessExpire;
-
-  /// 用于刷新token
-  final String refreshToken;
-  final int refreshExpire;
-  final int refreshAfter;
-  Tokens(
-      {this.accessToken,
-      this.accessExpire,
-      this.refreshToken,
-      this.refreshExpire,
-      this.refreshAfter});
-  factory Tokens.fromJson(Map<String, dynamic> m) {
-    return Tokens(
-        accessToken: m['access_token'],
-        accessExpire: m['access_expire'],
-        refreshToken: m['refresh_token'],
-        refreshExpire: m['refresh_expire'],
-        refreshAfter: m['refresh_after']);
-  }
-  Map<String, dynamic> toJson() {
-    return {
-      'access_token': accessToken,
-      'access_expire': accessExpire,
-      'refresh_token': refreshToken,
-      'refresh_expire': refreshExpire,
-      'refresh_after': refreshAfter,
-    };
-  }
-}
-`
-
-	tokensFileContentV2 = `class Tokens {
-  /// 用于访问的token, 每次请求都必须带在Header里面
-  final String accessToken;
-  final int accessExpire;
-
-  /// 用于刷新token
-  final String refreshToken;
-  final int refreshExpire;
-  final int refreshAfter;
-  Tokens({
-		required this.accessToken,
-		required this.accessExpire,
-		required this.refreshToken,
-		required this.refreshExpire,
-		required this.refreshAfter
-	});
-  factory Tokens.fromJson(Map<String, dynamic> m) {
-    return Tokens(
-        accessToken: m['access_token'],
-        accessExpire: m['access_expire'],
-        refreshToken: m['refresh_token'],
-        refreshExpire: m['refresh_expire'],
-        refreshAfter: m['refresh_after']);
-  }
-  Map<String, dynamic> toJson() {
-    return {
-      'access_token': accessToken,
-      'access_expire': accessExpire,
-      'refresh_token': refreshToken,
-      'refresh_expire': refreshExpire,
-      'refresh_after': refreshAfter,
-    };
-  }
-}
-`
-)

+ 0 - 186
tools/goctlwt/api/docgen/doc.go

@@ -1,186 +0,0 @@
-package docgen
-
-import (
-	"bytes"
-	_ "embed"
-	"fmt"
-	"html/template"
-	"io"
-	"strconv"
-	"strings"
-
-	"github.com/wuntsong-org/go-zero-plus/core/stringx"
-	"github.com/wuntsong-org/go-zero-plus/tools/goctlwt/api/spec"
-	apiutil "github.com/wuntsong-org/go-zero-plus/tools/goctlwt/api/util"
-	"github.com/wuntsong-org/go-zero-plus/tools/goctlwt/util"
-)
-
-//go:embed markdown.tpl
-var markdownTemplate string
-
-func genDoc(api *spec.ApiSpec, dir, filename string) error {
-	if len(api.Service.Routes()) == 0 {
-		return nil
-	}
-
-	fp, _, err := apiutil.MaybeCreateFile(dir, "", filename)
-	if err != nil {
-		return err
-	}
-	defer fp.Close()
-
-	var builder strings.Builder
-	for index, route := range api.Service.Routes() {
-		routeComment := route.JoinedDoc()
-		if len(routeComment) == 0 {
-			routeComment = "N/A"
-		}
-
-		requestContent, err := buildDoc(route.RequestType, api.Types)
-		if err != nil {
-			return err
-		}
-
-		responseContent, err := buildDoc(route.ResponseType, api.Types)
-		if err != nil {
-			return err
-		}
-
-		t := template.Must(template.New("markdownTemplate").Parse(markdownTemplate))
-		var tmplBytes bytes.Buffer
-		err = t.Execute(&tmplBytes, map[string]string{
-			"index":           strconv.Itoa(index + 1),
-			"routeComment":    routeComment,
-			"method":          strings.ToUpper(route.Method),
-			"uri":             route.Path,
-			"requestType":     "`" + stringx.TakeOne(route.RequestTypeName(), "-") + "`",
-			"responseType":    "`" + stringx.TakeOne(route.ResponseTypeName(), "-") + "`",
-			"requestContent":  requestContent,
-			"responseContent": responseContent,
-		})
-		if err != nil {
-			return err
-		}
-
-		builder.Write(tmplBytes.Bytes())
-	}
-
-	_, err = fp.WriteString(strings.Replace(builder.String(), "&#34;", `"`, -1))
-	return err
-}
-
-func buildDoc(route spec.Type, types []spec.Type) (string, error) {
-	if route == nil || len(route.Name()) == 0 {
-		return "", nil
-	}
-
-	tps := make([]spec.Type, 0)
-	tps = append(tps, route)
-	if definedType, ok := route.(spec.DefineStruct); ok {
-		associatedTypes(definedType, &tps)
-	}
-	value, err := buildTypes(tps, types)
-	if err != nil {
-		return "", err
-	}
-
-	return fmt.Sprintf("\n\n```golang\n%s\n```\n", value), nil
-}
-
-func associatedTypes(tp spec.DefineStruct, tps *[]spec.Type) {
-	hasAdded := false
-	for _, item := range *tps {
-		if item.Name() == tp.Name() {
-			hasAdded = true
-			break
-		}
-	}
-	if !hasAdded {
-		*tps = append(*tps, tp)
-	}
-
-	for _, item := range tp.Members {
-		if definedType, ok := item.Type.(spec.DefineStruct); ok {
-			associatedTypes(definedType, tps)
-		}
-	}
-}
-
-// buildTypes gen types to string
-func buildTypes(types, all []spec.Type) (string, error) {
-	var builder strings.Builder
-	first := true
-	for _, tp := range types {
-		if first {
-			first = false
-		} else {
-			builder.WriteString("\n\n")
-		}
-		if err := writeType(&builder, tp, all); err != nil {
-			return "", apiutil.WrapErr(err, "Type "+tp.Name()+" generate error")
-		}
-	}
-
-	return builder.String(), nil
-}
-
-func writeType(writer io.Writer, tp spec.Type, all []spec.Type) error {
-	fmt.Fprintf(writer, "type %s struct {\n", util.Title(tp.Name()))
-	if err := writerMembers(writer, tp, all); err != nil {
-		return err
-	}
-	fmt.Fprintf(writer, "}")
-	return nil
-}
-
-func writerMembers(writer io.Writer, tp spec.Type, all []spec.Type) error {
-	structType, ok := tp.(spec.DefineStruct)
-	if !ok {
-		return fmt.Errorf("unspport struct type: %s", tp.Name())
-	}
-
-	getTargetType := func(tp string) spec.Type {
-		for _, v := range all {
-			if v.Name() == tp {
-				return v
-			}
-		}
-		return nil
-	}
-	for _, member := range structType.Members {
-		if member.IsInline {
-			inlineType := getTargetType(member.Type.Name())
-			if inlineType == nil {
-				if _, err := fmt.Fprintf(writer, "%s\n", strings.Title(member.Type.Name())); err != nil {
-					return err
-				}
-			} else {
-				if err := writerMembers(writer, inlineType, all); err != nil {
-					return err
-				}
-			}
-
-			continue
-		}
-
-		if err := writeProperty(writer, member.Name, member.Tag, member.GetComment(), member.Type, 1); err != nil {
-			return err
-		}
-	}
-
-	return nil
-}
-
-func writeProperty(writer io.Writer, name, tag, comment string, tp spec.Type, indent int) error {
-	apiutil.WriteIndent(writer, indent)
-	var err error
-	if len(comment) > 0 {
-		comment = strings.TrimPrefix(comment, "//")
-		comment = "//" + comment
-		_, err = fmt.Fprintf(writer, "%s %s %s %s\n", strings.Title(name), tp.Name(), tag, comment)
-	} else {
-		_, err = fmt.Fprintf(writer, "%s %s %s\n", strings.Title(name), tp.Name(), tag)
-	}
-
-	return err
-}

+ 0 - 77
tools/goctlwt/api/docgen/gen.go

@@ -1,77 +0,0 @@
-package docgen
-
-import (
-	"errors"
-	"fmt"
-	"os"
-	"path/filepath"
-	"strings"
-
-	"github.com/spf13/cobra"
-	"github.com/wuntsong-org/go-zero-plus/tools/goctlwt/api/parser"
-	"github.com/wuntsong-org/go-zero-plus/tools/goctlwt/util/pathx"
-)
-
-var (
-	// VarStringDir describes a directory.
-	VarStringDir string
-	// VarStringOutput describes an output directory.
-	VarStringOutput string
-)
-
-// DocCommand generate Markdown doc file
-func DocCommand(_ *cobra.Command, _ []string) error {
-	dir := VarStringDir
-	if len(dir) == 0 {
-		return errors.New("missing -dir")
-	}
-
-	outputDir := VarStringOutput
-	if len(outputDir) == 0 {
-		var err error
-		outputDir, err = os.Getwd()
-		if err != nil {
-			return err
-		}
-	}
-
-	if !pathx.FileExists(dir) {
-		return fmt.Errorf("dir %s not exsit", dir)
-	}
-
-	dir, err := filepath.Abs(dir)
-	if err != nil {
-		return err
-	}
-
-	files, err := filePathWalkDir(dir)
-	if err != nil {
-		return err
-	}
-
-	for _, p := range files {
-		api, err := parser.Parse(p)
-		if err != nil {
-			return fmt.Errorf("parse file: %s, err: %w", p, err)
-		}
-
-		api.Service = api.Service.JoinPrefix()
-		err = genDoc(api, filepath.Dir(filepath.Join(outputDir, p[len(dir):])),
-			strings.Replace(p[len(filepath.Dir(p)):], ".api", ".md", 1))
-		if err != nil {
-			return err
-		}
-	}
-	return nil
-}
-
-func filePathWalkDir(root string) ([]string, error) {
-	var files []string
-	err := filepath.Walk(root, func(path string, info os.FileInfo, err error) error {
-		if !info.IsDir() && strings.HasSuffix(path, ".api") {
-			files = append(files, path)
-		}
-		return nil
-	})
-	return files, err
-}

+ 0 - 16
tools/goctlwt/api/docgen/markdown.tpl

@@ -1,16 +0,0 @@
-### {{.index}}. {{.routeComment}}
-
-1. route definition
-
-- Url: {{.uri}}
-- Method: {{.method}}
-- Request: {{.requestType}}
-- Response: {{.responseType}}
-
-2. request definition
-
-{{.requestContent}}
-
-3. response definition
-
-{{.responseContent}}

+ 0 - 248
tools/goctlwt/api/format/format.go

@@ -1,248 +0,0 @@
-package format
-
-import (
-	"bufio"
-	"errors"
-	"fmt"
-	"go/format"
-	"go/scanner"
-	"io"
-	"os"
-	"path/filepath"
-	"strings"
-
-	"github.com/spf13/cobra"
-	"github.com/wuntsong-org/go-zero-plus/core/errorx"
-	"github.com/wuntsong-org/go-zero-plus/tools/goctlwt/api/parser"
-	"github.com/wuntsong-org/go-zero-plus/tools/goctlwt/api/util"
-	"github.com/wuntsong-org/go-zero-plus/tools/goctlwt/pkg/env"
-	apiF "github.com/wuntsong-org/go-zero-plus/tools/goctlwt/pkg/parser/api/format"
-	"github.com/wuntsong-org/go-zero-plus/tools/goctlwt/util/pathx"
-)
-
-const (
-	leftParenthesis  = "("
-	rightParenthesis = ")"
-	leftBrace        = "{"
-	rightBrace       = "}"
-)
-
-var (
-	// VarBoolUseStdin describes whether to use stdin or not.
-	VarBoolUseStdin bool
-	// VarBoolSkipCheckDeclare describes whether to skip.
-	VarBoolSkipCheckDeclare bool
-	// VarStringDir describes the directory.
-	VarStringDir string
-	// VarBoolIgnore describes whether to ignore.
-	VarBoolIgnore bool
-)
-
-// GoFormatApi format api file
-func GoFormatApi(_ *cobra.Command, _ []string) error {
-	var be errorx.BatchError
-	if VarBoolUseStdin {
-		if err := apiFormatReader(os.Stdin, VarStringDir, VarBoolSkipCheckDeclare); err != nil {
-			be.Add(err)
-		}
-	} else {
-		if len(VarStringDir) == 0 {
-			return errors.New("missing -dir")
-		}
-
-		_, err := os.Lstat(VarStringDir)
-		if err != nil {
-			return errors.New(VarStringDir + ": No such file or directory")
-		}
-
-		err = filepath.Walk(VarStringDir, func(path string, fi os.FileInfo, errBack error) (err error) {
-			if strings.HasSuffix(path, ".api") {
-				if err := ApiFormatByPath(path, VarBoolSkipCheckDeclare); err != nil {
-					be.Add(util.WrapErr(err, fi.Name()))
-				}
-			}
-			return nil
-		})
-		be.Add(err)
-	}
-
-	if be.NotNil() {
-		scanner.PrintError(os.Stderr, be.Err())
-		os.Exit(1)
-	}
-
-	return be.Err()
-}
-
-// apiFormatReader
-// filename is needed when there are `import` literals.
-func apiFormatReader(reader io.Reader, filename string, skipCheckDeclare bool) error {
-	data, err := io.ReadAll(reader)
-	if err != nil {
-		return err
-	}
-	result, err := apiFormat(string(data), skipCheckDeclare, filename)
-	if err != nil {
-		return err
-	}
-
-	_, err = fmt.Print(result)
-	return err
-}
-
-// ApiFormatByPath format api from file path
-func ApiFormatByPath(apiFilePath string, skipCheckDeclare bool) error {
-	if env.UseExperimental() {
-		return apiF.File(apiFilePath)
-	}
-
-	data, err := os.ReadFile(apiFilePath)
-	if err != nil {
-		return err
-	}
-
-	abs, err := filepath.Abs(apiFilePath)
-	if err != nil {
-		return err
-	}
-
-	result, err := apiFormat(string(data), skipCheckDeclare, abs)
-	if err != nil {
-		return err
-	}
-
-	_, err = parser.ParseContentWithParserSkipCheckTypeDeclaration(result, abs)
-	if err != nil {
-		return err
-	}
-
-	return os.WriteFile(apiFilePath, []byte(result), os.ModePerm)
-}
-
-func apiFormat(data string, skipCheckDeclare bool, filename ...string) (string, error) {
-	var err error
-	if skipCheckDeclare {
-		_, err = parser.ParseContentWithParserSkipCheckTypeDeclaration(data, filename...)
-	} else {
-		_, err = parser.ParseContent(data, filename...)
-	}
-	if err != nil {
-		return "", err
-	}
-
-	var builder strings.Builder
-	s := bufio.NewScanner(strings.NewReader(data))
-	tapCount := 0
-	newLineCount := 0
-	var preLine string
-	for s.Scan() {
-		line := strings.TrimSpace(s.Text())
-		if len(line) == 0 {
-			if newLineCount > 0 {
-				continue
-			}
-			newLineCount++
-		} else {
-			if preLine == rightBrace {
-				builder.WriteString(pathx.NL)
-			}
-			newLineCount = 0
-		}
-
-		if tapCount == 0 {
-			ft, err := formatGoTypeDef(line, s, &builder)
-			if err != nil {
-				return "", err
-			}
-
-			if ft {
-				continue
-			}
-		}
-
-		noCommentLine := util.RemoveComment(line)
-		if noCommentLine == rightParenthesis || noCommentLine == rightBrace {
-			tapCount--
-		}
-		if tapCount < 0 {
-			line := strings.TrimSuffix(noCommentLine, rightBrace)
-			line = strings.TrimSpace(line)
-			if strings.HasSuffix(line, leftBrace) {
-				tapCount++
-			}
-		}
-		if line != "" {
-			util.WriteIndent(&builder, tapCount)
-		}
-		builder.WriteString(line + pathx.NL)
-		if strings.HasSuffix(noCommentLine, leftParenthesis) || strings.HasSuffix(noCommentLine, leftBrace) {
-			tapCount++
-		}
-		preLine = line
-	}
-
-	return strings.TrimSpace(builder.String()), nil
-}
-
-func formatGoTypeDef(line string, scanner *bufio.Scanner, builder *strings.Builder) (bool, error) {
-	noCommentLine := util.RemoveComment(line)
-	tokenCount := 0
-	if strings.HasPrefix(noCommentLine, "type") && (strings.HasSuffix(noCommentLine, leftParenthesis) ||
-		strings.HasSuffix(noCommentLine, leftBrace)) {
-		var typeBuilder strings.Builder
-		typeBuilder.WriteString(mayInsertStructKeyword(line, &tokenCount) + pathx.NL)
-		for scanner.Scan() {
-			noCommentLine := util.RemoveComment(scanner.Text())
-			typeBuilder.WriteString(mayInsertStructKeyword(scanner.Text(), &tokenCount) + pathx.NL)
-			if noCommentLine == rightBrace || noCommentLine == rightParenthesis {
-				tokenCount--
-			}
-			if tokenCount == 0 {
-				ts, err := format.Source([]byte(typeBuilder.String()))
-				if err != nil {
-					return false, errors.New("error format \n" + typeBuilder.String())
-				}
-
-				result := strings.ReplaceAll(string(ts), " struct ", " ")
-				result = strings.ReplaceAll(result, "type ()", "")
-				builder.WriteString(result)
-				break
-			}
-		}
-		return true, nil
-	}
-
-	return false, nil
-}
-
-func mayInsertStructKeyword(line string, token *int) string {
-	insertStruct := func() string {
-		if strings.Contains(line, " struct") {
-			return line
-		}
-		index := strings.Index(line, leftBrace)
-		return line[:index] + " struct " + line[index:]
-	}
-
-	noCommentLine := util.RemoveComment(line)
-	if strings.HasSuffix(noCommentLine, leftBrace) {
-		*token++
-		return insertStruct()
-	}
-	if strings.HasSuffix(noCommentLine, rightBrace) {
-		noCommentLine = strings.TrimSuffix(noCommentLine, rightBrace)
-		noCommentLine = util.RemoveComment(noCommentLine)
-		if strings.HasSuffix(noCommentLine, leftBrace) {
-			return insertStruct()
-		}
-	}
-	if strings.HasSuffix(noCommentLine, leftParenthesis) {
-		*token++
-	}
-
-	if strings.Contains(noCommentLine, "`") {
-		return util.UpperFirst(strings.TrimSpace(line))
-	}
-
-	return line
-}

+ 0 - 85
tools/goctlwt/api/format/format_test.go

@@ -1,85 +0,0 @@
-package format
-
-import (
-	"fmt"
-	"io/fs"
-	"os"
-	"path"
-	"testing"
-
-	"github.com/stretchr/testify/assert"
-	"github.com/stretchr/testify/require"
-)
-
-const (
-	notFormattedStr = `
-type Request struct {
-  Name string ` + "`" + `path:"name,options=you|me"` + "`" + `
-}
-type Response struct {
-  Message string ` + "`" + `json:"message"` + "`" + `
-  Students []Student ` + "`" + `json:"students"` + "`" + `
-}
-service A-api {
-@server(
-handler: GreetHandler
-  )
-  get /greet/from/:name(Request) returns (Response)
-
-@server(
-handler: GreetHandler2
-  )
-  get /greet/from2/:name(Request) returns (Response)
-}
-`
-
-	formattedStr = `type Request {
-	Name string ` + "`" + `path:"name,options=you|me"` + "`" + `
-}
-type Response {
-	Message  string    ` + "`" + `json:"message"` + "`" + `
-	Students []Student ` + "`" + `json:"students"` + "`" + `
-}
-service A-api {
-	@server(
-		handler: GreetHandler
-	)
-	get /greet/from/:name(Request) returns (Response)
-
-	@server(
-		handler: GreetHandler2
-	)
-	get /greet/from2/:name(Request) returns (Response)
-}`
-)
-
-func TestFormat(t *testing.T) {
-	r, err := apiFormat(notFormattedStr, true)
-	assert.Nil(t, err)
-	assert.Equal(t, formattedStr, r)
-	_, err = apiFormat(notFormattedStr, false)
-	assert.Errorf(t, err, " line 7:13 can not find declaration 'Student' in context")
-}
-
-func Test_apiFormatReader_issue1721(t *testing.T) {
-	dir, err := os.MkdirTemp("", "goctlwt-api-format")
-	require.NoError(t, err)
-	defer os.RemoveAll(dir)
-	subDir := path.Join(dir, "sub")
-	err = os.MkdirAll(subDir, fs.ModePerm)
-	require.NoError(t, err)
-
-	importedFilename := path.Join(dir, "foo.api")
-	err = os.WriteFile(importedFilename, []byte{}, fs.ModePerm)
-	require.NoError(t, err)
-
-	filename := path.Join(subDir, "bar.api")
-	err = os.WriteFile(filename, []byte(fmt.Sprintf(`import "%s"`, importedFilename)), 0o644)
-	require.NoError(t, err)
-
-	f, err := os.Open(filename)
-	require.NoError(t, err)
-
-	err = apiFormatReader(f, filename, false)
-	assert.NoError(t, err)
-}

+ 0 - 9
tools/goctlwt/api/gogen/config.tpl

@@ -1,9 +0,0 @@
-package config
-
-import {{.authImport}}
-
-type Config struct {
-	rest.RestConf
-	{{.auth}}
-	{{.jwtTrans}}
-}

+ 0 - 3
tools/goctlwt/api/gogen/etc.tpl

@@ -1,3 +0,0 @@
-Name: {{.serviceName}}
-Host: {{.host}}
-Port: {{.port}}

+ 0 - 170
tools/goctlwt/api/gogen/gen.go

@@ -1,170 +0,0 @@
-package gogen
-
-import (
-	"errors"
-	"fmt"
-	"os"
-	"path"
-	"path/filepath"
-	"strconv"
-	"strings"
-	"sync"
-	"time"
-
-	"github.com/gookit/color"
-	"github.com/spf13/cobra"
-	"github.com/wuntsong-org/go-zero-plus/core/logx"
-	apiformat "github.com/wuntsong-org/go-zero-plus/tools/goctlwt/api/format"
-	"github.com/wuntsong-org/go-zero-plus/tools/goctlwt/api/parser"
-	apiutil "github.com/wuntsong-org/go-zero-plus/tools/goctlwt/api/util"
-	"github.com/wuntsong-org/go-zero-plus/tools/goctlwt/config"
-	"github.com/wuntsong-org/go-zero-plus/tools/goctlwt/pkg/golang"
-	"github.com/wuntsong-org/go-zero-plus/tools/goctlwt/util"
-	"github.com/wuntsong-org/go-zero-plus/tools/goctlwt/util/pathx"
-)
-
-const tmpFile = "%s-%d"
-
-var (
-	tmpDir = path.Join(os.TempDir(), "goctlwt")
-	// VarStringDir describes the directory.
-	VarStringDir string
-	// VarStringAPI describes the API.
-	VarStringAPI string
-	// VarStringHome describes the go home.
-	VarStringHome string
-	// VarStringRemote describes the remote git repository.
-	VarStringRemote string
-	// VarStringBranch describes the branch.
-	VarStringBranch string
-	// VarStringStyle describes the style of output files.
-	VarStringStyle string
-)
-
-// GoCommand gen go project files from command line
-func GoCommand(_ *cobra.Command, _ []string) error {
-	apiFile := VarStringAPI
-	dir := VarStringDir
-	namingStyle := VarStringStyle
-	home := VarStringHome
-	remote := VarStringRemote
-	branch := VarStringBranch
-	if len(remote) > 0 {
-		repo, _ := util.CloneIntoGitHome(remote, branch)
-		if len(repo) > 0 {
-			home = repo
-		}
-	}
-
-	if len(home) > 0 {
-		pathx.RegisterGoctlHome(home)
-	}
-	if len(apiFile) == 0 {
-		return errors.New("missing -api")
-	}
-	if len(dir) == 0 {
-		return errors.New("missing -dir")
-	}
-
-	return DoGenProject(apiFile, dir, namingStyle)
-}
-
-// DoGenProject gen go project files with api file
-func DoGenProject(apiFile, dir, style string) error {
-	api, err := parser.Parse(apiFile)
-	if err != nil {
-		return err
-	}
-
-	if err := api.Validate(); err != nil {
-		return err
-	}
-
-	cfg, err := config.NewConfig(style)
-	if err != nil {
-		return err
-	}
-
-	logx.Must(pathx.MkdirIfNotExist(dir))
-	rootPkg, err := golang.GetParentPackage(dir)
-	if err != nil {
-		return err
-	}
-
-	logx.Must(genEtc(dir, cfg, api))
-	logx.Must(genConfig(dir, cfg, api))
-	logx.Must(genMain(dir, rootPkg, cfg, api))
-	logx.Must(genServiceContext(dir, rootPkg, cfg, api))
-	logx.Must(genTypes(dir, cfg, api))
-	logx.Must(genRoutes(dir, rootPkg, cfg, api))
-	logx.Must(genHandlers(dir, rootPkg, cfg, api))
-	logx.Must(genLogic(dir, rootPkg, cfg, api))
-	logx.Must(genMiddleware(dir, cfg, api))
-
-	if err := backupAndSweep(apiFile); err != nil {
-		return err
-	}
-
-	if err := apiformat.ApiFormatByPath(apiFile, false); err != nil {
-		return err
-	}
-
-	fmt.Println(color.Green.Render("Done."))
-	return nil
-}
-
-func backupAndSweep(apiFile string) error {
-	var err error
-	var wg sync.WaitGroup
-
-	wg.Add(2)
-	_ = os.MkdirAll(tmpDir, os.ModePerm)
-
-	go func() {
-		_, fileName := filepath.Split(apiFile)
-		_, e := apiutil.Copy(apiFile, fmt.Sprintf(path.Join(tmpDir, tmpFile), fileName, time.Now().Unix()))
-		if e != nil {
-			err = e
-		}
-		wg.Done()
-	}()
-	go func() {
-		if e := sweep(); e != nil {
-			err = e
-		}
-		wg.Done()
-	}()
-	wg.Wait()
-
-	return err
-}
-
-func sweep() error {
-	keepTime := time.Now().AddDate(0, 0, -7)
-	return filepath.Walk(tmpDir, func(fpath string, info os.FileInfo, err error) error {
-		if info.IsDir() {
-			return nil
-		}
-
-		pos := strings.LastIndexByte(info.Name(), '-')
-		if pos > 0 {
-			timestamp := info.Name()[pos+1:]
-			seconds, err := strconv.ParseInt(timestamp, 10, 64)
-			if err != nil {
-				// print error and ignore
-				fmt.Println(color.Red.Sprintf("sweep ignored file: %s", fpath))
-				return nil
-			}
-
-			tm := time.Unix(seconds, 0)
-			if tm.Before(keepTime) {
-				if err := os.RemoveAll(fpath); err != nil {
-					fmt.Println(color.Red.Sprintf("failed to remove file: %s", fpath))
-					return err
-				}
-			}
-		}
-
-		return nil
-	})
-}

+ 0 - 299
tools/goctlwt/api/gogen/gen_test.go

@@ -1,299 +0,0 @@
-package gogen
-
-import (
-	_ "embed"
-	goformat "go/format"
-	"os"
-	"path/filepath"
-	"strings"
-	"testing"
-
-	"github.com/stretchr/testify/assert"
-	"github.com/wuntsong-org/go-zero-plus/tools/goctlwt/api/parser"
-	"github.com/wuntsong-org/go-zero-plus/tools/goctlwt/rpc/execx"
-	"github.com/wuntsong-org/go-zero-plus/tools/goctlwt/util/pathx"
-)
-
-var (
-	//go:embed testdata/test_api_template.api
-	testApiTemplate string
-	//go:embed testdata/test_multi_service_template.api
-	testMultiServiceTemplate string
-	//go:embed testdata/ap_ino_info.api
-	apiNoInfo string
-	//go:embed testdata/invalid_api_file.api
-	invalidApiFile string
-	//go:embed testdata/anonymous_annotation.api
-	anonymousAnnotation string
-	//go:embed testdata/api_has_middleware.api
-	apiHasMiddleware string
-	//go:embed testdata/api_jwt.api
-	apiJwt string
-	//go:embed testdata/api_jwt_with_middleware.api
-	apiJwtWithMiddleware string
-	//go:embed testdata/api_has_no_request.api
-	apiHasNoRequest string
-	//go:embed testdata/api_route_test.api
-	apiRouteTest string
-	//go:embed testdata/has_comment_api_test.api
-	hasCommentApiTest string
-	//go:embed testdata/has_inline_no_exist_test.api
-	hasInlineNoExistTest string
-	//go:embed testdata/import_api.api
-	importApi string
-	//go:embed testdata/has_import_api.api
-	hasImportApi string
-	//go:embed testdata/no_struct_tag_api.api
-	noStructTagApi string
-	//go:embed testdata/nest_type_api.api
-	nestTypeApi string
-)
-
-func TestParser(t *testing.T) {
-	filename := "greet.api"
-	err := os.WriteFile(filename, []byte(testApiTemplate), os.ModePerm)
-	assert.Nil(t, err)
-	defer os.Remove(filename)
-
-	api, err := parser.Parse(filename)
-	assert.Nil(t, err)
-
-	assert.Equal(t, len(api.Types), 2)
-	assert.Equal(t, len(api.Service.Routes()), 2)
-
-	assert.Equal(t, api.Service.Routes()[0].Path, "/greet/from/:name")
-	assert.Equal(t, api.Service.Routes()[1].Path, "/greet/get")
-
-	assert.Equal(t, api.Service.Routes()[1].RequestTypeName(), "Request")
-	assert.Equal(t, api.Service.Routes()[1].ResponseType, nil)
-
-	validate(t, filename)
-}
-
-func TestMultiService(t *testing.T) {
-	filename := "greet.api"
-	err := os.WriteFile(filename, []byte(testMultiServiceTemplate), os.ModePerm)
-	assert.Nil(t, err)
-	defer os.Remove(filename)
-
-	api, err := parser.Parse(filename)
-	assert.Nil(t, err)
-
-	assert.Equal(t, len(api.Service.Routes()), 2)
-	assert.Equal(t, len(api.Service.Groups), 2)
-
-	validate(t, filename)
-}
-
-func TestApiNoInfo(t *testing.T) {
-	filename := "greet.api"
-	err := os.WriteFile(filename, []byte(apiNoInfo), os.ModePerm)
-	assert.Nil(t, err)
-	defer os.Remove(filename)
-
-	_, err = parser.Parse(filename)
-	assert.Nil(t, err)
-
-	validate(t, filename)
-}
-
-func TestInvalidApiFile(t *testing.T) {
-	filename := "greet.api"
-	err := os.WriteFile(filename, []byte(invalidApiFile), os.ModePerm)
-	assert.Nil(t, err)
-	defer os.Remove(filename)
-
-	_, err = parser.Parse(filename)
-	assert.NotNil(t, err)
-}
-
-func TestAnonymousAnnotation(t *testing.T) {
-	filename := "greet.api"
-	err := os.WriteFile(filename, []byte(anonymousAnnotation), os.ModePerm)
-	assert.Nil(t, err)
-	defer os.Remove(filename)
-
-	api, err := parser.Parse(filename)
-	assert.Nil(t, err)
-
-	assert.Equal(t, len(api.Service.Routes()), 1)
-	assert.Equal(t, api.Service.Routes()[0].Handler, "GreetHandler")
-
-	validate(t, filename)
-}
-
-func TestApiHasMiddleware(t *testing.T) {
-	filename := "greet.api"
-	err := os.WriteFile(filename, []byte(apiHasMiddleware), os.ModePerm)
-	assert.Nil(t, err)
-	defer os.Remove(filename)
-
-	_, err = parser.Parse(filename)
-	assert.Nil(t, err)
-
-	validate(t, filename)
-}
-
-func TestApiHasJwt(t *testing.T) {
-	filename := "jwt.api"
-	err := os.WriteFile(filename, []byte(apiJwt), os.ModePerm)
-	assert.Nil(t, err)
-	defer os.Remove(filename)
-
-	_, err = parser.Parse(filename)
-	assert.Nil(t, err)
-
-	validate(t, filename)
-}
-
-func TestApiHasJwtAndMiddleware(t *testing.T) {
-	filename := "jwt.api"
-	err := os.WriteFile(filename, []byte(apiJwtWithMiddleware), os.ModePerm)
-	assert.Nil(t, err)
-	defer os.Remove(filename)
-
-	_, err = parser.Parse(filename)
-	assert.Nil(t, err)
-
-	validate(t, filename)
-}
-
-func TestApiHasNoRequestBody(t *testing.T) {
-	filename := "greet.api"
-	err := os.WriteFile(filename, []byte(apiHasNoRequest), os.ModePerm)
-	assert.Nil(t, err)
-	defer os.Remove(filename)
-
-	_, err = parser.Parse(filename)
-	assert.Nil(t, err)
-}
-
-func TestApiRoutes(t *testing.T) {
-	filename := "greet.api"
-	err := os.WriteFile(filename, []byte(apiRouteTest), os.ModePerm)
-	assert.Nil(t, err)
-	defer os.Remove(filename)
-
-	_, err = parser.Parse(filename)
-	assert.Nil(t, err)
-
-	validate(t, filename)
-}
-
-func TestHasCommentRoutes(t *testing.T) {
-	filename := "greet.api"
-	err := os.WriteFile(filename, []byte(hasCommentApiTest), os.ModePerm)
-	assert.Nil(t, err)
-	defer os.Remove(filename)
-
-	_, err = parser.Parse(filename)
-	assert.Nil(t, err)
-
-	validate(t, filename)
-}
-
-func TestInlineTypeNotExist(t *testing.T) {
-	filename := "greet.api"
-	err := os.WriteFile(filename, []byte(hasInlineNoExistTest), os.ModePerm)
-	assert.Nil(t, err)
-	defer os.Remove(filename)
-
-	_, err = parser.Parse(filename)
-	assert.NotNil(t, err)
-}
-
-func TestHasImportApi(t *testing.T) {
-	filename := "greet.api"
-	err := os.WriteFile(filename, []byte(hasImportApi), os.ModePerm)
-	assert.Nil(t, err)
-	defer os.Remove(filename)
-
-	importApiName := "importApi.api"
-	err = os.WriteFile(importApiName, []byte(importApi), os.ModePerm)
-	assert.Nil(t, err)
-	defer os.Remove(importApiName)
-
-	api, err := parser.Parse(filename)
-	assert.Nil(t, err)
-
-	var hasInline bool
-	for _, ty := range api.Types {
-		if ty.Name() == "ImportData" {
-			hasInline = true
-			break
-		}
-	}
-	assert.True(t, hasInline)
-
-	validate(t, filename)
-}
-
-func TestNoStructApi(t *testing.T) {
-	filename := "greet.api"
-	err := os.WriteFile(filename, []byte(noStructTagApi), os.ModePerm)
-	assert.Nil(t, err)
-	defer os.Remove(filename)
-
-	spec, err := parser.Parse(filename)
-	assert.Nil(t, err)
-	assert.Equal(t, len(spec.Types), 5)
-
-	validate(t, filename)
-}
-
-func TestNestTypeApi(t *testing.T) {
-	filename := "greet.api"
-	err := os.WriteFile(filename, []byte(nestTypeApi), os.ModePerm)
-	assert.Nil(t, err)
-	defer os.Remove(filename)
-
-	_, err = parser.Parse(filename)
-	assert.NotNil(t, err)
-}
-
-func TestCamelStyle(t *testing.T) {
-	filename := "greet.api"
-	err := os.WriteFile(filename, []byte(testApiTemplate), os.ModePerm)
-	assert.Nil(t, err)
-	defer os.Remove(filename)
-
-	_, err = parser.Parse(filename)
-	assert.Nil(t, err)
-
-	validateWithCamel(t, filename, "GoZero")
-}
-
-func validate(t *testing.T, api string) {
-	validateWithCamel(t, api, "gozero")
-}
-
-func validateWithCamel(t *testing.T, api, camel string) {
-	dir := "workspace"
-	defer func() {
-		os.RemoveAll(dir)
-	}()
-	err := pathx.MkdirIfNotExist(dir)
-	assert.Nil(t, err)
-	err = initMod(dir)
-	assert.Nil(t, err)
-	err = DoGenProject(api, dir, camel)
-	assert.Nil(t, err)
-	filepath.Walk(dir, func(path string, info os.FileInfo, err error) error {
-		if strings.HasSuffix(path, ".go") {
-			code, err := os.ReadFile(path)
-			assert.Nil(t, err)
-			assert.Nil(t, validateCode(string(code)))
-		}
-		return nil
-	})
-}
-
-func initMod(mod string) error {
-	_, err := execx.Run("go mod init "+mod, mod)
-	return err
-}
-
-func validateCode(code string) error {
-	_, err := goformat.Source([]byte(code))
-	return err
-}

+ 0 - 65
tools/goctlwt/api/gogen/genconfig.go

@@ -1,65 +0,0 @@
-package gogen
-
-import (
-	_ "embed"
-	"fmt"
-	"strings"
-
-	"github.com/wuntsong-org/go-zero-plus/tools/goctlwt/api/spec"
-	"github.com/wuntsong-org/go-zero-plus/tools/goctlwt/config"
-	"github.com/wuntsong-org/go-zero-plus/tools/goctlwt/util/format"
-	"github.com/wuntsong-org/go-zero-plus/tools/goctlwt/vars"
-)
-
-const (
-	configFile = "config"
-
-	jwtTemplate = ` struct {
-		AccessSecret string
-		AccessExpire int64
-	}
-`
-	jwtTransTemplate = ` struct {
-		Secret     string
-		PrevSecret string
-	}
-`
-)
-
-//go:embed config.tpl
-var configTemplate string
-
-func genConfig(dir string, cfg *config.Config, api *spec.ApiSpec) error {
-	filename, err := format.FileNamingFormat(cfg.NamingFormat, configFile)
-	if err != nil {
-		return err
-	}
-
-	authNames := getAuths(api)
-	var auths []string
-	for _, item := range authNames {
-		auths = append(auths, fmt.Sprintf("%s %s", item, jwtTemplate))
-	}
-
-	jwtTransNames := getJwtTrans(api)
-	var jwtTransList []string
-	for _, item := range jwtTransNames {
-		jwtTransList = append(jwtTransList, fmt.Sprintf("%s %s", item, jwtTransTemplate))
-	}
-	authImportStr := fmt.Sprintf("\"%s/rest\"", vars.ProjectOpenSourceURL)
-
-	return genFile(fileGenConfig{
-		dir:             dir,
-		subdir:          configDir,
-		filename:        filename + ".go",
-		templateName:    "configTemplate",
-		category:        category,
-		templateFile:    configTemplateFile,
-		builtinTemplate: configTemplate,
-		data: map[string]string{
-			"authImport": authImportStr,
-			"auth":       strings.Join(auths, "\n"),
-			"jwtTrans":   strings.Join(jwtTransList, "\n"),
-		},
-	})
-}

+ 0 - 45
tools/goctlwt/api/gogen/genetc.go

@@ -1,45 +0,0 @@
-package gogen
-
-import (
-	_ "embed"
-	"fmt"
-	"strconv"
-
-	"github.com/wuntsong-org/go-zero-plus/tools/goctlwt/api/spec"
-	"github.com/wuntsong-org/go-zero-plus/tools/goctlwt/config"
-	"github.com/wuntsong-org/go-zero-plus/tools/goctlwt/util/format"
-)
-
-const (
-	defaultPort = 8888
-	etcDir      = "etc"
-)
-
-//go:embed etc.tpl
-var etcTemplate string
-
-func genEtc(dir string, cfg *config.Config, api *spec.ApiSpec) error {
-	filename, err := format.FileNamingFormat(cfg.NamingFormat, api.Service.Name)
-	if err != nil {
-		return err
-	}
-
-	service := api.Service
-	host := "0.0.0.0"
-	port := strconv.Itoa(defaultPort)
-
-	return genFile(fileGenConfig{
-		dir:             dir,
-		subdir:          etcDir,
-		filename:        fmt.Sprintf("%s.yaml", filename),
-		templateName:    "etcTemplate",
-		category:        category,
-		templateFile:    etcTemplateFile,
-		builtinTemplate: etcTemplate,
-		data: map[string]string{
-			"serviceName": service.Name,
-			"host":        host,
-			"port":        port,
-		},
-	})
-}

+ 0 - 141
tools/goctlwt/api/gogen/genhandlers.go

@@ -1,141 +0,0 @@
-package gogen
-
-import (
-	_ "embed"
-	"fmt"
-	"path"
-	"strings"
-
-	"github.com/wuntsong-org/go-zero-plus/tools/goctlwt/api/spec"
-	"github.com/wuntsong-org/go-zero-plus/tools/goctlwt/config"
-	"github.com/wuntsong-org/go-zero-plus/tools/goctlwt/util"
-	"github.com/wuntsong-org/go-zero-plus/tools/goctlwt/util/format"
-	"github.com/wuntsong-org/go-zero-plus/tools/goctlwt/util/pathx"
-)
-
-const defaultLogicPackage = "logic"
-
-//go:embed handler.tpl
-var handlerTemplate string
-
-type handlerInfo struct {
-	PkgName            string
-	ImportPackages     string
-	ImportHttpxPackage string
-	HandlerName        string
-	RequestType        string
-	LogicName          string
-	LogicType          string
-	Call               string
-	HasResp            bool
-	HasRequest         bool
-}
-
-func genHandler(dir, rootPkg string, cfg *config.Config, group spec.Group, route spec.Route) error {
-	handler := getHandlerName(route)
-	handlerPath := getHandlerFolderPath(group, route)
-	pkgName := handlerPath[strings.LastIndex(handlerPath, "/")+1:]
-	logicName := defaultLogicPackage
-	if handlerPath != handlerDir {
-		handler = strings.Title(handler)
-		logicName = pkgName
-	}
-
-	return doGenToFile(dir, handler, cfg, group, route, handlerInfo{
-		PkgName:        pkgName,
-		ImportPackages: genHandlerImports(group, route, rootPkg),
-		HandlerName:    handler,
-		RequestType:    util.Title(route.RequestTypeName()),
-		LogicName:      logicName,
-		LogicType:      strings.Title(getLogicName(route)),
-		Call:           strings.Title(strings.TrimSuffix(handler, "Handler")),
-		HasResp:        len(route.ResponseTypeName()) > 0,
-		HasRequest:     len(route.RequestTypeName()) > 0,
-	})
-}
-
-func doGenToFile(dir, handler string, cfg *config.Config, group spec.Group,
-	route spec.Route, handleObj handlerInfo,
-) error {
-	filename, err := format.FileNamingFormat(cfg.NamingFormat, handler)
-	if err != nil {
-		return err
-	}
-
-	return genFile(fileGenConfig{
-		dir:             dir,
-		subdir:          getHandlerFolderPath(group, route),
-		filename:        filename + ".go",
-		templateName:    "handlerTemplate",
-		category:        category,
-		templateFile:    handlerTemplateFile,
-		builtinTemplate: handlerTemplate,
-		data:            handleObj,
-	})
-}
-
-func genHandlers(dir, rootPkg string, cfg *config.Config, api *spec.ApiSpec) error {
-	for _, group := range api.Service.Groups {
-		for _, route := range group.Routes {
-			if err := genHandler(dir, rootPkg, cfg, group, route); err != nil {
-				return err
-			}
-		}
-	}
-
-	return nil
-}
-
-func genHandlerImports(group spec.Group, route spec.Route, parentPkg string) string {
-	imports := []string{
-		fmt.Sprintf("\"%s\"", pathx.JoinPackages(parentPkg, getLogicFolderPath(group, route))),
-		fmt.Sprintf("\"%s\"", pathx.JoinPackages(parentPkg, contextDir)),
-	}
-	if len(route.RequestTypeName()) > 0 {
-		imports = append(imports, fmt.Sprintf("\"%s\"\n", pathx.JoinPackages(parentPkg, typesDir)))
-	}
-
-	return strings.Join(imports, "\n\t")
-}
-
-func getHandlerBaseName(route spec.Route) (string, error) {
-	handler := route.Handler
-	handler = strings.TrimSpace(handler)
-	handler = strings.TrimSuffix(handler, "handler")
-	handler = strings.TrimSuffix(handler, "Handler")
-
-	return handler, nil
-}
-
-func getHandlerFolderPath(group spec.Group, route spec.Route) string {
-	folder := route.GetAnnotation(groupProperty)
-	if len(folder) == 0 {
-		folder = group.GetAnnotation(groupProperty)
-		if len(folder) == 0 {
-			return handlerDir
-		}
-	}
-
-	folder = strings.TrimPrefix(folder, "/")
-	folder = strings.TrimSuffix(folder, "/")
-
-	return path.Join(handlerDir, folder)
-}
-
-func getHandlerName(route spec.Route) string {
-	handler, err := getHandlerBaseName(route)
-	if err != nil {
-		panic(err)
-	}
-
-	return handler + "Handler"
-}
-
-func getLogicName(route spec.Route) string {
-	handler, err := getHandlerBaseName(route)
-	if err != nil {
-		panic(err)
-	}
-
-	return handler + "Logic"
-}

+ 0 - 137
tools/goctlwt/api/gogen/genlogic.go

@@ -1,137 +0,0 @@
-package gogen
-
-import (
-	_ "embed"
-	"fmt"
-	"path"
-	"strconv"
-	"strings"
-
-	"github.com/wuntsong-org/go-zero-plus/tools/goctlwt/api/parser/g4/gen/api"
-	"github.com/wuntsong-org/go-zero-plus/tools/goctlwt/api/spec"
-	"github.com/wuntsong-org/go-zero-plus/tools/goctlwt/config"
-	"github.com/wuntsong-org/go-zero-plus/tools/goctlwt/util/format"
-	"github.com/wuntsong-org/go-zero-plus/tools/goctlwt/util/pathx"
-	"github.com/wuntsong-org/go-zero-plus/tools/goctlwt/vars"
-)
-
-//go:embed logic.tpl
-var logicTemplate string
-
-func genLogic(dir, rootPkg string, cfg *config.Config, api *spec.ApiSpec) error {
-	for _, g := range api.Service.Groups {
-		for _, r := range g.Routes {
-			err := genLogicByRoute(dir, rootPkg, cfg, g, r)
-			if err != nil {
-				return err
-			}
-		}
-	}
-	return nil
-}
-
-func genLogicByRoute(dir, rootPkg string, cfg *config.Config, group spec.Group, route spec.Route) error {
-	logic := getLogicName(route)
-	goFile, err := format.FileNamingFormat(cfg.NamingFormat, logic)
-	if err != nil {
-		return err
-	}
-
-	imports := genLogicImports(route, rootPkg)
-	var responseString string
-	var returnString string
-	var requestString string
-	if len(route.ResponseTypeName()) > 0 {
-		resp := responseGoTypeName(route, typesPacket)
-		responseString = "(resp " + resp + ", err error)"
-		returnString = "return"
-	} else {
-		responseString = "error"
-		returnString = "return nil"
-	}
-	if len(route.RequestTypeName()) > 0 {
-		requestString = "req *" + requestGoTypeName(route, typesPacket)
-	}
-
-	subDir := getLogicFolderPath(group, route)
-	return genFile(fileGenConfig{
-		dir:             dir,
-		subdir:          subDir,
-		filename:        goFile + ".go",
-		templateName:    "logicTemplate",
-		category:        category,
-		templateFile:    logicTemplateFile,
-		builtinTemplate: logicTemplate,
-		data: map[string]string{
-			"pkgName":      subDir[strings.LastIndex(subDir, "/")+1:],
-			"imports":      imports,
-			"logic":        strings.Title(logic),
-			"function":     strings.Title(strings.TrimSuffix(logic, "Logic")),
-			"responseType": responseString,
-			"returnString": returnString,
-			"request":      requestString,
-		},
-	})
-}
-
-func getLogicFolderPath(group spec.Group, route spec.Route) string {
-	folder := route.GetAnnotation(groupProperty)
-	if len(folder) == 0 {
-		folder = group.GetAnnotation(groupProperty)
-		if len(folder) == 0 {
-			return logicDir
-		}
-	}
-	folder = strings.TrimPrefix(folder, "/")
-	folder = strings.TrimSuffix(folder, "/")
-	return path.Join(logicDir, folder)
-}
-
-func genLogicImports(route spec.Route, parentPkg string) string {
-	var imports []string
-	imports = append(imports, `"context"`+"\n")
-	imports = append(imports, fmt.Sprintf("\"%s\"", pathx.JoinPackages(parentPkg, contextDir)))
-	if shallImportTypesPackage(route) {
-		imports = append(imports, fmt.Sprintf("\"%s\"\n", pathx.JoinPackages(parentPkg, typesDir)))
-	}
-	imports = append(imports, fmt.Sprintf("\"%s/core/logx\"", vars.ProjectOpenSourceURL))
-	return strings.Join(imports, "\n\t")
-}
-
-func onlyPrimitiveTypes(val string) bool {
-	fields := strings.FieldsFunc(val, func(r rune) bool {
-		return r == '[' || r == ']' || r == ' '
-	})
-
-	for _, field := range fields {
-		if field == "map" {
-			continue
-		}
-		// ignore array dimension number, like [5]int
-		if _, err := strconv.Atoi(field); err == nil {
-			continue
-		}
-		if !api.IsBasicType(field) {
-			return false
-		}
-	}
-
-	return true
-}
-
-func shallImportTypesPackage(route spec.Route) bool {
-	if len(route.RequestTypeName()) > 0 {
-		return true
-	}
-
-	respTypeName := route.ResponseTypeName()
-	if len(respTypeName) == 0 {
-		return false
-	}
-
-	if onlyPrimitiveTypes(respTypeName) {
-		return false
-	}
-
-	return true
-}

+ 0 - 53
tools/goctlwt/api/gogen/genmain.go

@@ -1,53 +0,0 @@
-package gogen
-
-import (
-	_ "embed"
-	"fmt"
-	"strings"
-
-	"github.com/wuntsong-org/go-zero-plus/tools/goctlwt/api/spec"
-	"github.com/wuntsong-org/go-zero-plus/tools/goctlwt/config"
-	"github.com/wuntsong-org/go-zero-plus/tools/goctlwt/util/format"
-	"github.com/wuntsong-org/go-zero-plus/tools/goctlwt/util/pathx"
-	"github.com/wuntsong-org/go-zero-plus/tools/goctlwt/vars"
-)
-
-//go:embed main.tpl
-var mainTemplate string
-
-func genMain(dir, rootPkg string, cfg *config.Config, api *spec.ApiSpec) error {
-	name := strings.ToLower(api.Service.Name)
-	filename, err := format.FileNamingFormat(cfg.NamingFormat, name)
-	if err != nil {
-		return err
-	}
-
-	configName := filename
-	if strings.HasSuffix(filename, "-api") {
-		filename = strings.ReplaceAll(filename, "-api", "")
-	}
-
-	return genFile(fileGenConfig{
-		dir:             dir,
-		subdir:          "",
-		filename:        filename + ".go",
-		templateName:    "mainTemplate",
-		category:        category,
-		templateFile:    mainTemplateFile,
-		builtinTemplate: mainTemplate,
-		data: map[string]string{
-			"importPackages": genMainImports(rootPkg),
-			"serviceName":    configName,
-		},
-	})
-}
-
-func genMainImports(parentPkg string) string {
-	var imports []string
-	imports = append(imports, fmt.Sprintf("\"%s\"", pathx.JoinPackages(parentPkg, configDir)))
-	imports = append(imports, fmt.Sprintf("\"%s\"", pathx.JoinPackages(parentPkg, handlerDir)))
-	imports = append(imports, fmt.Sprintf("\"%s\"\n", pathx.JoinPackages(parentPkg, contextDir)))
-	imports = append(imports, fmt.Sprintf("\"%s/core/conf\"", vars.ProjectOpenSourceURL))
-	imports = append(imports, fmt.Sprintf("\"%s/rest\"", vars.ProjectOpenSourceURL))
-	return strings.Join(imports, "\n\t")
-}

+ 0 - 43
tools/goctlwt/api/gogen/genmiddleware.go

@@ -1,43 +0,0 @@
-package gogen
-
-import (
-	_ "embed"
-	"strings"
-
-	"github.com/wuntsong-org/go-zero-plus/tools/goctlwt/api/spec"
-	"github.com/wuntsong-org/go-zero-plus/tools/goctlwt/config"
-	"github.com/wuntsong-org/go-zero-plus/tools/goctlwt/util/format"
-)
-
-//go:embed middleware.tpl
-var middlewareImplementCode string
-
-func genMiddleware(dir string, cfg *config.Config, api *spec.ApiSpec) error {
-	middlewares := getMiddleware(api)
-	for _, item := range middlewares {
-		middlewareFilename := strings.TrimSuffix(strings.ToLower(item), "middleware") + "_middleware"
-		filename, err := format.FileNamingFormat(cfg.NamingFormat, middlewareFilename)
-		if err != nil {
-			return err
-		}
-
-		name := strings.TrimSuffix(item, "Middleware") + "Middleware"
-		err = genFile(fileGenConfig{
-			dir:             dir,
-			subdir:          middlewareDir,
-			filename:        filename + ".go",
-			templateName:    "contextTemplate",
-			category:        category,
-			templateFile:    middlewareImplementCodeFile,
-			builtinTemplate: middlewareImplementCode,
-			data: map[string]string{
-				"name": strings.Title(name),
-			},
-		})
-		if err != nil {
-			return err
-		}
-	}
-
-	return nil
-}

+ 0 - 282
tools/goctlwt/api/gogen/genroutes.go

@@ -1,282 +0,0 @@
-package gogen
-
-import (
-	"fmt"
-	"os"
-	"path"
-	"sort"
-	"strconv"
-	"strings"
-	"text/template"
-	"time"
-
-	"github.com/wuntsong-org/go-zero-plus/core/collection"
-	"github.com/wuntsong-org/go-zero-plus/tools/goctlwt/api/spec"
-	"github.com/wuntsong-org/go-zero-plus/tools/goctlwt/config"
-	"github.com/wuntsong-org/go-zero-plus/tools/goctlwt/util/format"
-	"github.com/wuntsong-org/go-zero-plus/tools/goctlwt/util/pathx"
-	"github.com/wuntsong-org/go-zero-plus/tools/goctlwt/vars"
-)
-
-const (
-	jwtTransKey    = "jwtTransition"
-	routesFilename = "routes"
-	routesTemplate = `// Code generated by goctlwt. DO NOT EDIT.
-package handler
-
-import (
-	"net/http"{{if .hasTimeout}}
-	"time"{{end}}
-
-	{{.importPackages}}
-)
-
-func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
-	{{.routesAdditions}}
-}
-`
-	routesAdditionTemplate = `
-	server.AddRoutes(
-		{{.routes}} {{.jwt}}{{.signature}} {{.prefix}} {{.timeout}} {{.maxBytes}}
-	)
-`
-	timeoutThreshold = time.Millisecond
-)
-
-var mapping = map[string]string{
-	"delete":  "http.MethodDelete",
-	"get":     "http.MethodGet",
-	"head":    "http.MethodHead",
-	"post":    "http.MethodPost",
-	"put":     "http.MethodPut",
-	"patch":   "http.MethodPatch",
-	"connect": "http.MethodConnect",
-	"options": "http.MethodOptions",
-	"trace":   "http.MethodTrace",
-}
-
-type (
-	group struct {
-		routes           []route
-		jwtEnabled       bool
-		signatureEnabled bool
-		authName         string
-		timeout          string
-		middlewares      []string
-		prefix           string
-		jwtTrans         string
-		maxBytes         string
-	}
-	route struct {
-		method  string
-		path    string
-		handler string
-	}
-)
-
-func genRoutes(dir, rootPkg string, cfg *config.Config, api *spec.ApiSpec) error {
-	var builder strings.Builder
-	groups, err := getRoutes(api)
-	if err != nil {
-		return err
-	}
-
-	templateText, err := pathx.LoadTemplate(category, routesAdditionTemplateFile, routesAdditionTemplate)
-	if err != nil {
-		return err
-	}
-
-	var hasTimeout bool
-	gt := template.Must(template.New("groupTemplate").Parse(templateText))
-	for _, g := range groups {
-		var gbuilder strings.Builder
-		gbuilder.WriteString("[]rest.Route{")
-		for _, r := range g.routes {
-			fmt.Fprintf(&gbuilder, `
-		{
-			Method:  %s,
-			Path:    "%s",
-			Handler: %s,
-		},`,
-				r.method, r.path, r.handler)
-		}
-
-		var jwt string
-		if g.jwtEnabled {
-			jwt = fmt.Sprintf("\n rest.WithJwt(serverCtx.Config.%s.AccessSecret),", g.authName)
-		}
-		if len(g.jwtTrans) > 0 {
-			jwt = jwt + fmt.Sprintf("\n rest.WithJwtTransition(serverCtx.Config.%s.PrevSecret,serverCtx.Config.%s.Secret),", g.jwtTrans, g.jwtTrans)
-		}
-		var signature, prefix string
-		if g.signatureEnabled {
-			signature = "\n rest.WithSignature(serverCtx.Config.Signature),"
-		}
-		if len(g.prefix) > 0 {
-			prefix = fmt.Sprintf(`
-rest.WithPrefix("%s"),`, g.prefix)
-		}
-
-		var timeout string
-		if len(g.timeout) > 0 {
-			duration, err := time.ParseDuration(g.timeout)
-			if err != nil {
-				return err
-			}
-
-			// why we check this, maybe some users set value 1, it's 1ns, not 1s.
-			if duration < timeoutThreshold {
-				return fmt.Errorf("timeout should not less than 1ms, now %v", duration)
-			}
-
-			timeout = fmt.Sprintf("\n rest.WithTimeout(%d * time.Millisecond),", duration.Milliseconds())
-			hasTimeout = true
-		}
-
-		var maxBytes string
-		if len(g.maxBytes) > 0 {
-			_, err := strconv.ParseInt(g.maxBytes, 10, 64)
-			if err != nil {
-				return fmt.Errorf("maxBytes %s parse error,it is an invalid number", g.maxBytes)
-			}
-
-			maxBytes = fmt.Sprintf("\n rest.WithMaxBytes(%s),", g.maxBytes)
-		}
-
-		var routes string
-		if len(g.middlewares) > 0 {
-			gbuilder.WriteString("\n}...,")
-			params := g.middlewares
-			for i := range params {
-				params[i] = "serverCtx." + params[i]
-			}
-			middlewareStr := strings.Join(params, ", ")
-			routes = fmt.Sprintf("rest.WithMiddlewares(\n[]rest.Middleware{ %s }, \n %s \n),",
-				middlewareStr, strings.TrimSpace(gbuilder.String()))
-		} else {
-			gbuilder.WriteString("\n},")
-			routes = strings.TrimSpace(gbuilder.String())
-		}
-
-		if err := gt.Execute(&builder, map[string]string{
-			"routes":    routes,
-			"jwt":       jwt,
-			"signature": signature,
-			"prefix":    prefix,
-			"timeout":   timeout,
-			"maxBytes":  maxBytes,
-		}); err != nil {
-			return err
-		}
-	}
-
-	routeFilename, err := format.FileNamingFormat(cfg.NamingFormat, routesFilename)
-	if err != nil {
-		return err
-	}
-
-	routeFilename = routeFilename + ".go"
-	filename := path.Join(dir, handlerDir, routeFilename)
-	os.Remove(filename)
-
-	return genFile(fileGenConfig{
-		dir:             dir,
-		subdir:          handlerDir,
-		filename:        routeFilename,
-		templateName:    "routesTemplate",
-		category:        category,
-		templateFile:    routesTemplateFile,
-		builtinTemplate: routesTemplate,
-		data: map[string]any{
-			"hasTimeout":      hasTimeout,
-			"importPackages":  genRouteImports(rootPkg, api),
-			"routesAdditions": strings.TrimSpace(builder.String()),
-		},
-	})
-}
-
-func genRouteImports(parentPkg string, api *spec.ApiSpec) string {
-	importSet := collection.NewSet()
-	importSet.AddStr(fmt.Sprintf("\"%s\"", pathx.JoinPackages(parentPkg, contextDir)))
-	for _, group := range api.Service.Groups {
-		for _, route := range group.Routes {
-			folder := route.GetAnnotation(groupProperty)
-			if len(folder) == 0 {
-				folder = group.GetAnnotation(groupProperty)
-				if len(folder) == 0 {
-					continue
-				}
-			}
-			importSet.AddStr(fmt.Sprintf("%s \"%s\"", toPrefix(folder),
-				pathx.JoinPackages(parentPkg, handlerDir, folder)))
-		}
-	}
-	imports := importSet.KeysStr()
-	sort.Strings(imports)
-	projectSection := strings.Join(imports, "\n\t")
-	depSection := fmt.Sprintf("\"%s/rest\"", vars.ProjectOpenSourceURL)
-	return fmt.Sprintf("%s\n\n\t%s", projectSection, depSection)
-}
-
-func getRoutes(api *spec.ApiSpec) ([]group, error) {
-	var routes []group
-
-	for _, g := range api.Service.Groups {
-		var groupedRoutes group
-		for _, r := range g.Routes {
-			handler := getHandlerName(r)
-			handler = handler + "(serverCtx)"
-			folder := r.GetAnnotation(groupProperty)
-			if len(folder) > 0 {
-				handler = toPrefix(folder) + "." + strings.ToUpper(handler[:1]) + handler[1:]
-			} else {
-				folder = g.GetAnnotation(groupProperty)
-				if len(folder) > 0 {
-					handler = toPrefix(folder) + "." + strings.ToUpper(handler[:1]) + handler[1:]
-				}
-			}
-			groupedRoutes.routes = append(groupedRoutes.routes, route{
-				method:  mapping[r.Method],
-				path:    r.Path,
-				handler: handler,
-			})
-		}
-
-		groupedRoutes.timeout = g.GetAnnotation("timeout")
-		groupedRoutes.maxBytes = g.GetAnnotation("maxBytes")
-
-		jwt := g.GetAnnotation("jwt")
-		if len(jwt) > 0 {
-			groupedRoutes.authName = jwt
-			groupedRoutes.jwtEnabled = true
-		}
-		jwtTrans := g.GetAnnotation(jwtTransKey)
-		if len(jwtTrans) > 0 {
-			groupedRoutes.jwtTrans = jwtTrans
-		}
-
-		signature := g.GetAnnotation("signature")
-		if signature == "true" {
-			groupedRoutes.signatureEnabled = true
-		}
-		middleware := g.GetAnnotation("middleware")
-		if len(middleware) > 0 {
-			groupedRoutes.middlewares = append(groupedRoutes.middlewares,
-				strings.Split(middleware, ",")...)
-		}
-		prefix := g.GetAnnotation(spec.RoutePrefixKey)
-		prefix = strings.ReplaceAll(prefix, `"`, "")
-		prefix = strings.TrimSpace(prefix)
-		if len(prefix) > 0 {
-			prefix = path.Join("/", prefix)
-			groupedRoutes.prefix = prefix
-		}
-		routes = append(routes, groupedRoutes)
-	}
-
-	return routes, nil
-}
-
-func toPrefix(folder string) string {
-	return strings.ReplaceAll(folder, "/", "")
-}

+ 0 - 58
tools/goctlwt/api/gogen/gensvc.go

@@ -1,58 +0,0 @@
-package gogen
-
-import (
-	_ "embed"
-	"fmt"
-	"strings"
-
-	"github.com/wuntsong-org/go-zero-plus/tools/goctlwt/api/spec"
-	"github.com/wuntsong-org/go-zero-plus/tools/goctlwt/config"
-	"github.com/wuntsong-org/go-zero-plus/tools/goctlwt/util/format"
-	"github.com/wuntsong-org/go-zero-plus/tools/goctlwt/util/pathx"
-	"github.com/wuntsong-org/go-zero-plus/tools/goctlwt/vars"
-)
-
-const contextFilename = "service_context"
-
-//go:embed svc.tpl
-var contextTemplate string
-
-func genServiceContext(dir, rootPkg string, cfg *config.Config, api *spec.ApiSpec) error {
-	filename, err := format.FileNamingFormat(cfg.NamingFormat, contextFilename)
-	if err != nil {
-		return err
-	}
-
-	var middlewareStr string
-	var middlewareAssignment string
-	middlewares := getMiddleware(api)
-
-	for _, item := range middlewares {
-		middlewareStr += fmt.Sprintf("%s rest.Middleware\n", item)
-		name := strings.TrimSuffix(item, "Middleware") + "Middleware"
-		middlewareAssignment += fmt.Sprintf("%s: %s,\n", item,
-			fmt.Sprintf("middleware.New%s().%s", strings.Title(name), "Handle"))
-	}
-
-	configImport := "\"" + pathx.JoinPackages(rootPkg, configDir) + "\""
-	if len(middlewareStr) > 0 {
-		configImport += "\n\t\"" + pathx.JoinPackages(rootPkg, middlewareDir) + "\""
-		configImport += fmt.Sprintf("\n\t\"%s/rest\"", vars.ProjectOpenSourceURL)
-	}
-
-	return genFile(fileGenConfig{
-		dir:             dir,
-		subdir:          contextDir,
-		filename:        filename + ".go",
-		templateName:    "contextTemplate",
-		category:        category,
-		templateFile:    contextTemplateFile,
-		builtinTemplate: contextTemplate,
-		data: map[string]string{
-			"configImport":         configImport,
-			"config":               "config.Config",
-			"middleware":           middlewareStr,
-			"middlewareAssignment": middlewareAssignment,
-		},
-	})
-}

+ 0 - 93
tools/goctlwt/api/gogen/gentypes.go

@@ -1,93 +0,0 @@
-package gogen
-
-import (
-	_ "embed"
-	"fmt"
-	"io"
-	"os"
-	"path"
-	"strings"
-
-	"github.com/wuntsong-org/go-zero-plus/tools/goctlwt/api/spec"
-	apiutil "github.com/wuntsong-org/go-zero-plus/tools/goctlwt/api/util"
-	"github.com/wuntsong-org/go-zero-plus/tools/goctlwt/config"
-	"github.com/wuntsong-org/go-zero-plus/tools/goctlwt/util"
-	"github.com/wuntsong-org/go-zero-plus/tools/goctlwt/util/format"
-)
-
-const typesFile = "types"
-
-//go:embed types.tpl
-var typesTemplate string
-
-// BuildTypes gen types to string
-func BuildTypes(types []spec.Type) (string, error) {
-	var builder strings.Builder
-	first := true
-	for _, tp := range types {
-		if first {
-			first = false
-		} else {
-			builder.WriteString("\n\n")
-		}
-		if err := writeType(&builder, tp); err != nil {
-			return "", apiutil.WrapErr(err, "Type "+tp.Name()+" generate error")
-		}
-	}
-
-	return builder.String(), nil
-}
-
-func genTypes(dir string, cfg *config.Config, api *spec.ApiSpec) error {
-	val, err := BuildTypes(api.Types)
-	if err != nil {
-		return err
-	}
-
-	typeFilename, err := format.FileNamingFormat(cfg.NamingFormat, typesFile)
-	if err != nil {
-		return err
-	}
-
-	typeFilename = typeFilename + ".go"
-	filename := path.Join(dir, typesDir, typeFilename)
-	os.Remove(filename)
-
-	return genFile(fileGenConfig{
-		dir:             dir,
-		subdir:          typesDir,
-		filename:        typeFilename,
-		templateName:    "typesTemplate",
-		category:        category,
-		templateFile:    typesTemplateFile,
-		builtinTemplate: typesTemplate,
-		data: map[string]any{
-			"types":        val,
-			"containsTime": false,
-		},
-	})
-}
-
-func writeType(writer io.Writer, tp spec.Type) error {
-	structType, ok := tp.(spec.DefineStruct)
-	if !ok {
-		return fmt.Errorf("unspport struct type: %s", tp.Name())
-	}
-
-	fmt.Fprintf(writer, "type %s struct {\n", util.Title(tp.Name()))
-	for _, member := range structType.Members {
-		if member.IsInline {
-			if _, err := fmt.Fprintf(writer, "%s\n", strings.Title(member.Type.Name())); err != nil {
-				return err
-			}
-
-			continue
-		}
-
-		if err := writeProperty(writer, member.Name, member.Tag, member.GetComment(), member.Type, 1); err != nil {
-			return err
-		}
-	}
-	fmt.Fprintf(writer, "}")
-	return nil
-}

+ 0 - 26
tools/goctlwt/api/gogen/handler.tpl

@@ -1,26 +0,0 @@
-package {{.PkgName}}
-
-import (
-	"net/http"
-
-	"github.com/zeromicro/go-zero/rest/httpx"
-	{{.ImportPackages}}
-)
-
-func {{.HandlerName}}(svcCtx *svc.ServiceContext) http.HandlerFunc {
-	return func(w http.ResponseWriter, r *http.Request) {
-		{{if .HasRequest}}var req types.{{.RequestType}}
-		if err := httpx.Parse(r, &req); err != nil {
-			httpx.ErrorCtx(r.Context(), w, err)
-			return
-		}
-
-		{{end}}l := {{.LogicName}}.New{{.LogicType}}(r.Context(), svcCtx)
-		{{if .HasResp}}resp, {{end}}err := l.{{.Call}}({{if .HasRequest}}&req{{end}})
-		if err != nil {
-			httpx.ErrorCtx(r.Context(), w, err)
-		} else {
-			{{if .HasResp}}httpx.OkJsonCtx(r.Context(), w, resp){{else}}httpx.Ok(w){{end}}
-		}
-	}
-}

+ 0 - 25
tools/goctlwt/api/gogen/logic.tpl

@@ -1,25 +0,0 @@
-package {{.pkgName}}
-
-import (
-	{{.imports}}
-)
-
-type {{.logic}} struct {
-	logx.Logger
-	ctx    context.Context
-	svcCtx *svc.ServiceContext
-}
-
-func New{{.logic}}(ctx context.Context, svcCtx *svc.ServiceContext) *{{.logic}} {
-	return &{{.logic}}{
-		Logger: logx.WithContext(ctx),
-		ctx:    ctx,
-		svcCtx: svcCtx,
-	}
-}
-
-func (l *{{.logic}}) {{.function}}({{.request}}) {{.responseType}} {
-	// todo: add your logic here and delete this line
-
-	{{.returnString}}
-}

+ 0 - 26
tools/goctlwt/api/gogen/main.tpl

@@ -1,26 +0,0 @@
-package main
-
-import (
-	"flag"
-	"fmt"
-
-	{{.importPackages}}
-)
-
-var configFile = flag.String("f", "etc/{{.serviceName}}.yaml", "the config file")
-
-func main() {
-	flag.Parse()
-
-	var c config.Config
-	conf.MustLoad(*configFile, &c)
-
-	server := rest.MustNewServer(c.RestConf)
-	defer server.Stop()
-
-	ctx := svc.NewServiceContext(c)
-	handler.RegisterHandlers(server, ctx)
-
-	fmt.Printf("Starting server at %s:%d...\n", c.Host, c.Port)
-	server.Start()
-}

+ 0 - 19
tools/goctlwt/api/gogen/middleware.tpl

@@ -1,19 +0,0 @@
-package middleware
-
-import "net/http"
-
-type {{.name}} struct {
-}
-
-func New{{.name}}() *{{.name}} {
-	return &{{.name}}{}
-}
-
-func (m *{{.name}})Handle(next http.HandlerFunc) http.HandlerFunc {
-	return func(w http.ResponseWriter, r *http.Request) {
-		// TODO generate middleware implement function, delete after code implementation
-
-		// Passthrough to next handler if need
-		next(w, r)
-	}
-}

+ 0 - 17
tools/goctlwt/api/gogen/svc.tpl

@@ -1,17 +0,0 @@
-package svc
-
-import (
-	{{.configImport}}
-)
-
-type ServiceContext struct {
-	Config {{.config}}
-	{{.middleware}}
-}
-
-func NewServiceContext(c {{.config}}) *ServiceContext {
-	return &ServiceContext{
-		Config: c,
-		{{.middlewareAssignment}}
-	}
-}

+ 0 - 68
tools/goctlwt/api/gogen/template.go

@@ -1,68 +0,0 @@
-package gogen
-
-import (
-	"fmt"
-
-	"github.com/wuntsong-org/go-zero-plus/tools/goctlwt/util/pathx"
-)
-
-const (
-	category                    = "api"
-	configTemplateFile          = "config.tpl"
-	contextTemplateFile         = "context.tpl"
-	etcTemplateFile             = "etc.tpl"
-	handlerTemplateFile         = "handler.tpl"
-	logicTemplateFile           = "logic.tpl"
-	mainTemplateFile            = "main.tpl"
-	middlewareImplementCodeFile = "middleware.tpl"
-	routesTemplateFile          = "routes.tpl"
-	routesAdditionTemplateFile  = "route-addition.tpl"
-	typesTemplateFile           = "types.tpl"
-)
-
-var templates = map[string]string{
-	configTemplateFile:          configTemplate,
-	contextTemplateFile:         contextTemplate,
-	etcTemplateFile:             etcTemplate,
-	handlerTemplateFile:         handlerTemplate,
-	logicTemplateFile:           logicTemplate,
-	mainTemplateFile:            mainTemplate,
-	middlewareImplementCodeFile: middlewareImplementCode,
-	routesTemplateFile:          routesTemplate,
-	routesAdditionTemplateFile:  routesAdditionTemplate,
-	typesTemplateFile:           typesTemplate,
-}
-
-// Category returns the category of the api files.
-func Category() string {
-	return category
-}
-
-// Clean cleans the generated deployment files.
-func Clean() error {
-	return pathx.Clean(category)
-}
-
-// GenTemplates generates api template files.
-func GenTemplates() error {
-	return pathx.InitTemplates(category, templates)
-}
-
-// RevertTemplate reverts the given template file to the default value.
-func RevertTemplate(name string) error {
-	content, ok := templates[name]
-	if !ok {
-		return fmt.Errorf("%s: no such file name", name)
-	}
-	return pathx.CreateTemplate(category, name, content)
-}
-
-// Update updates the template files to the templates built in current goctlwt.
-func Update() error {
-	err := Clean()
-	if err != nil {
-		return err
-	}
-
-	return pathx.InitTemplates(category, templates)
-}

+ 0 - 92
tools/goctlwt/api/gogen/template_test.go

@@ -1,92 +0,0 @@
-package gogen
-
-import (
-	"os"
-	"path/filepath"
-	"testing"
-
-	"github.com/stretchr/testify/assert"
-	"github.com/wuntsong-org/go-zero-plus/tools/goctlwt/util/pathx"
-)
-
-func TestGenTemplates(t *testing.T) {
-	err := pathx.InitTemplates(category, templates)
-	assert.Nil(t, err)
-	dir, err := pathx.GetTemplateDir(category)
-	assert.Nil(t, err)
-	file := filepath.Join(dir, "main.tpl")
-	data, err := os.ReadFile(file)
-	assert.Nil(t, err)
-	assert.Equal(t, string(data), mainTemplate)
-}
-
-func TestRevertTemplate(t *testing.T) {
-	name := "main.tpl"
-	err := pathx.InitTemplates(category, templates)
-	assert.Nil(t, err)
-
-	dir, err := pathx.GetTemplateDir(category)
-	assert.Nil(t, err)
-
-	file := filepath.Join(dir, name)
-	data, err := os.ReadFile(file)
-	assert.Nil(t, err)
-
-	modifyData := string(data) + "modify"
-	err = pathx.CreateTemplate(category, name, modifyData)
-	assert.Nil(t, err)
-
-	data, err = os.ReadFile(file)
-	assert.Nil(t, err)
-
-	assert.Equal(t, string(data), modifyData)
-
-	assert.Nil(t, RevertTemplate(name))
-
-	data, err = os.ReadFile(file)
-	assert.Nil(t, err)
-	assert.Equal(t, mainTemplate, string(data))
-}
-
-func TestClean(t *testing.T) {
-	name := "main.tpl"
-	err := pathx.InitTemplates(category, templates)
-	assert.Nil(t, err)
-
-	assert.Nil(t, Clean())
-
-	dir, err := pathx.GetTemplateDir(category)
-	assert.Nil(t, err)
-
-	file := filepath.Join(dir, name)
-	_, err = os.ReadFile(file)
-	assert.NotNil(t, err)
-}
-
-func TestUpdate(t *testing.T) {
-	name := "main.tpl"
-	err := pathx.InitTemplates(category, templates)
-	assert.Nil(t, err)
-
-	dir, err := pathx.GetTemplateDir(category)
-	assert.Nil(t, err)
-
-	file := filepath.Join(dir, name)
-	data, err := os.ReadFile(file)
-	assert.Nil(t, err)
-
-	modifyData := string(data) + "modify"
-	err = pathx.CreateTemplate(category, name, modifyData)
-	assert.Nil(t, err)
-
-	data, err = os.ReadFile(file)
-	assert.Nil(t, err)
-
-	assert.Equal(t, string(data), modifyData)
-
-	assert.Nil(t, Update())
-
-	data, err = os.ReadFile(file)
-	assert.Nil(t, err)
-	assert.Equal(t, mainTemplate, string(data))
-}

+ 0 - 12
tools/goctlwt/api/gogen/testdata/anonymous_annotation.api

@@ -1,12 +0,0 @@
-type Request struct {
-    Name string `path:"name,options=you|me"`
-}
-
-type Response struct {
-    Message string `json:"message"`
-}
-
-service A-api {
-    @handler GreetHandler
-    get /greet/from/:name(Request) returns (Response)
-}

+ 0 - 14
tools/goctlwt/api/gogen/testdata/ap_ino_info.api

@@ -1,14 +0,0 @@
-type Request struct {
-    Name string `path:"name,options=you|me"`
-}
-
-type Response struct {
-    Message string `json:"message"`
-}
-
-service A-api {
-    @server(
-        handler: GreetHandler
-    )
-    get /greet/from/:name(Request) returns (Response)
-}

+ 0 - 15
tools/goctlwt/api/gogen/testdata/api_has_middleware.api

@@ -1,15 +0,0 @@
-type Request struct {
-    Name string `path:"name,options=you|me"`
-}
-
-type Response struct {
-    Message string `json:"message"`
-}
-
-@server(
-    middleware: TokenValidate
-)
-service A-api {
-    @handler GreetHandler
-    get /greet/from/:name(Request) returns (Response)
-}

+ 0 - 4
tools/goctlwt/api/gogen/testdata/api_has_no_request.api

@@ -1,4 +0,0 @@
-service A-api {
-    @handler GreetHandler
-    post /greet/ping ()
-}

+ 0 - 16
tools/goctlwt/api/gogen/testdata/api_jwt.api

@@ -1,16 +0,0 @@
-type Request struct {
-    Name string `path:"name,options=you|me"`
-}
-
-type Response struct {
-    Message string `json:"message"`
-}
-
-@server(
-    jwt: Auth
-    signature: true
-)
-service A-api {
-    @handler GreetHandler
-    get /greet/from/:name(Request) returns (Response)
-}

+ 0 - 17
tools/goctlwt/api/gogen/testdata/api_jwt_with_middleware.api

@@ -1,17 +0,0 @@
-type Request struct {
-    Name string `path:"name,options=you|me"`
-}
-
-type Response struct {
-    Message string `json:"message"`
-}
-
-@server(
-    jwt: Auth
-    jwtTransition: Trans
-    middleware: TokenValidate
-)
-service A-api {
-    @handler GreetHandler
-    get /greet/from/:name(Request) returns (Response)
-}

+ 0 - 16
tools/goctlwt/api/gogen/testdata/api_route_test.api

@@ -1,16 +0,0 @@
-type Request struct {
-    Name string `path:"name,options=you|me"`
-}
-type Response struct {
-    Message string `json:"message"`
-}
-service A-api {
-    @handler NormalHandler
-    get /greet/from/:name(Request) returns (Response)
-    @handler NoResponseHandler
-    get /greet/from/:sex(Request)
-    @handler NoRequestHandler
-    get /greet/from/request returns (Response)
-    @handler NoRequestNoResponseHandler
-    get /greet/from
-}

+ 0 - 20
tools/goctlwt/api/gogen/testdata/has_comment_api_test.api

@@ -1,20 +0,0 @@
-type Inline struct {
-
-}
-
-type Request struct {
-    Inline
-    Name string `path:"name,options=you|me"` // name in path
-}
-
-type Response struct {
-    Message string `json:"msg"` // message
-}
-
-service A-api {
-    @doc ("helloworld")
-    @server(
-        handler: GreetHandler
-    )
-    get /greet/from/:name(Request) returns (Response)
-}

+ 0 - 16
tools/goctlwt/api/gogen/testdata/has_import_api.api

@@ -1,16 +0,0 @@
-import "importApi.api"
-
-type Request struct {
-    Name string `path:"name,options=you|me"`
-}
-
-type Response struct {
-    Message string `json:"message"` // message
-}
-
-service A-api {
-    @server(
-        handler: GreetHandler
-    )
-    get /greet/from/:name(Request) returns (Response)
-}

+ 0 - 16
tools/goctlwt/api/gogen/testdata/has_inline_no_exist_test.api

@@ -1,16 +0,0 @@
-type Request struct {
-    Inline
-    Name string `path:"name,options=you|me"`
-}
-
-type Response struct {
-    Message string `json:"message"` // message
-}
-
-service A-api {
-    @doc ("helloworld")
-    @server(
-        handler: GreetHandler
-    )
-    get /greet/from/:name(Request) returns (Response)
-}

+ 0 - 3
tools/goctlwt/api/gogen/testdata/import_api.api

@@ -1,3 +0,0 @@
-type ImportData struct {
-    Name string `path:"name,options=you|me"`
-}

+ 0 - 14
tools/goctlwt/api/gogen/testdata/invalid_api_file.api

@@ -1,14 +0,0 @@
-type Request struct {
-    Name string `path:"name,options=you|me"`
-}
-
-type Response struct {
-    Message string `json:"message"`
-}
-
-service A-api
-    @server(
-        handler: GreetHandler
-    )
-    get /greet/from/:name(Request) returns (Response)
-}

+ 0 - 10
tools/goctlwt/api/gogen/testdata/nest_type_api.api

@@ -1,10 +0,0 @@
-type Request {
-    Name string `path:"name,options=you|me"`
-    XXX struct {
-    }
-}
-
-service A-api {
-    @handler GreetHandler
-    get /greet/from/:name(Request)
-}

+ 0 - 20
tools/goctlwt/api/gogen/testdata/no_struct_tag_api.api

@@ -1,20 +0,0 @@
-type Request {
-    Name string `path:"name,options=you|me"`
-}
-
-type XXX {}
-
-type (
-    Response {
-        Message string `json:"message"`
-    }
-
-    A {}
-
-    B struct {}
-)
-
-service A-api {
-    @handler GreetHandler
-    get /greet/from/:name(Request) returns (Response)
-}

+ 0 - 36
tools/goctlwt/api/gogen/testdata/test_api_template.api

@@ -1,36 +0,0 @@
-info(
-    title: doc title
-desc: ">
-doc description first part,
-doc description second part<"
-version: 1.0
-)
-
-// TODO: test
-// {
-type Request struct {  // TODO: test
-                       // TODO
-    Name string `path:"name,options=you|me"`   // }
-} // TODO: test
-
-// TODO: test
-type Response struct {
-    Message string `json:"message"`
-}
-
-@server(
-    // C0
-    group: greet/s1
-)
-    // C1
-service A-api {
-    // C2
-    @server( // C3
-        handler: GreetHandler
-    )
-    get /greet/from/:name(Request) returns (Response)   // hello
-
-    // C4
-    @handler NoResponseHandler  // C5
-    get /greet/get(Request)
-}

+ 0 - 27
tools/goctlwt/api/gogen/testdata/test_multi_service_template.api

@@ -1,27 +0,0 @@
-info(
-    title: doc title
-desc: doc description first part
-version: 1.0
-)
-
-type Request struct {
-    Name string `path:"name,options=you|me"`
-}
-
-type Response struct {
-    Message string `json:"message"`
-}
-
-service A-api {
-    @server(
-        handler: GreetHandler
-    )
-    get /greet/from/:name(Request) returns (Response)
-}
-
-service A-api {
-    @server(
-        handler: NoResponseHandler
-    )
-    get /greet/get(Request)
-}

+ 0 - 6
tools/goctlwt/api/gogen/types.tpl

@@ -1,6 +0,0 @@
-// Code generated by goctl. DO NOT EDIT.
-package types{{if .containsTime}}
-import (
-	"time"
-){{end}}
-{{.types}}

+ 0 - 183
tools/goctlwt/api/gogen/util.go

@@ -1,183 +0,0 @@
-package gogen
-
-import (
-	"bytes"
-	"fmt"
-	"io"
-	"strings"
-	"text/template"
-
-	"github.com/wuntsong-org/go-zero-plus/core/collection"
-	"github.com/wuntsong-org/go-zero-plus/tools/goctlwt/api/spec"
-	"github.com/wuntsong-org/go-zero-plus/tools/goctlwt/api/util"
-	"github.com/wuntsong-org/go-zero-plus/tools/goctlwt/pkg/golang"
-	"github.com/wuntsong-org/go-zero-plus/tools/goctlwt/util/pathx"
-)
-
-type fileGenConfig struct {
-	dir             string
-	subdir          string
-	filename        string
-	templateName    string
-	category        string
-	templateFile    string
-	builtinTemplate string
-	data            any
-}
-
-func genFile(c fileGenConfig) error {
-	fp, created, err := util.MaybeCreateFile(c.dir, c.subdir, c.filename)
-	if err != nil {
-		return err
-	}
-	if !created {
-		return nil
-	}
-	defer fp.Close()
-
-	var text string
-	if len(c.category) == 0 || len(c.templateFile) == 0 {
-		text = c.builtinTemplate
-	} else {
-		text, err = pathx.LoadTemplate(c.category, c.templateFile, c.builtinTemplate)
-		if err != nil {
-			return err
-		}
-	}
-
-	t := template.Must(template.New(c.templateName).Parse(text))
-	buffer := new(bytes.Buffer)
-	err = t.Execute(buffer, c.data)
-	if err != nil {
-		return err
-	}
-
-	code := golang.FormatCode(buffer.String())
-	_, err = fp.WriteString(code)
-	return err
-}
-
-func writeProperty(writer io.Writer, name, tag, comment string, tp spec.Type, indent int) error {
-	util.WriteIndent(writer, indent)
-	var err error
-	if len(comment) > 0 {
-		comment = strings.TrimPrefix(comment, "//")
-		comment = "//" + comment
-		_, err = fmt.Fprintf(writer, "%s %s %s %s\n", strings.Title(name), tp.Name(), tag, comment)
-	} else {
-		_, err = fmt.Fprintf(writer, "%s %s %s\n", strings.Title(name), tp.Name(), tag)
-	}
-
-	return err
-}
-
-func getAuths(api *spec.ApiSpec) []string {
-	authNames := collection.NewSet()
-	for _, g := range api.Service.Groups {
-		jwt := g.GetAnnotation("jwt")
-		if len(jwt) > 0 {
-			authNames.Add(jwt)
-		}
-	}
-	return authNames.KeysStr()
-}
-
-func getJwtTrans(api *spec.ApiSpec) []string {
-	jwtTransList := collection.NewSet()
-	for _, g := range api.Service.Groups {
-		jt := g.GetAnnotation(jwtTransKey)
-		if len(jt) > 0 {
-			jwtTransList.Add(jt)
-		}
-	}
-	return jwtTransList.KeysStr()
-}
-
-func getMiddleware(api *spec.ApiSpec) []string {
-	result := collection.NewSet()
-	for _, g := range api.Service.Groups {
-		middleware := g.GetAnnotation("middleware")
-		if len(middleware) > 0 {
-			for _, item := range strings.Split(middleware, ",") {
-				result.Add(strings.TrimSpace(item))
-			}
-		}
-	}
-
-	return result.KeysStr()
-}
-
-func responseGoTypeName(r spec.Route, pkg ...string) string {
-	if r.ResponseType == nil {
-		return ""
-	}
-
-	resp := golangExpr(r.ResponseType, pkg...)
-	switch r.ResponseType.(type) {
-	case spec.DefineStruct:
-		if !strings.HasPrefix(resp, "*") {
-			return "*" + resp
-		}
-	}
-
-	return resp
-}
-
-func requestGoTypeName(r spec.Route, pkg ...string) string {
-	if r.RequestType == nil {
-		return ""
-	}
-
-	return golangExpr(r.RequestType, pkg...)
-}
-
-func golangExpr(ty spec.Type, pkg ...string) string {
-	switch v := ty.(type) {
-	case spec.PrimitiveType:
-		return v.RawName
-	case spec.DefineStruct:
-		if len(pkg) > 1 {
-			panic("package cannot be more than 1")
-		}
-
-		if len(pkg) == 0 {
-			return v.RawName
-		}
-
-		return fmt.Sprintf("%s.%s", pkg[0], strings.Title(v.RawName))
-	case spec.ArrayType:
-		if len(pkg) > 1 {
-			panic("package cannot be more than 1")
-		}
-
-		if len(pkg) == 0 {
-			return v.RawName
-		}
-
-		return fmt.Sprintf("[]%s", golangExpr(v.Value, pkg...))
-	case spec.MapType:
-		if len(pkg) > 1 {
-			panic("package cannot be more than 1")
-		}
-
-		if len(pkg) == 0 {
-			return v.RawName
-		}
-
-		return fmt.Sprintf("map[%s]%s", v.Key, golangExpr(v.Value, pkg...))
-	case spec.PointerType:
-		if len(pkg) > 1 {
-			panic("package cannot be more than 1")
-		}
-
-		if len(pkg) == 0 {
-			return v.RawName
-		}
-
-		return fmt.Sprintf("*%s", golangExpr(v.Type, pkg...))
-	case spec.InterfaceType:
-		return v.RawName
-	}
-
-	return ""
-}

+ 0 - 13
tools/goctlwt/api/gogen/vars.go

@@ -1,13 +0,0 @@
-package gogen
-
-const (
-	internal      = "internal/"
-	typesPacket   = "types"
-	configDir     = internal + "config"
-	contextDir    = internal + "svc"
-	handlerDir    = internal + "handler"
-	logicDir      = internal + "logic"
-	middlewareDir = internal + "middleware"
-	typesDir      = internal + typesPacket
-	groupProperty = "group"
-)

+ 0 - 9
tools/goctlwt/api/javagen/bool.tpl

@@ -1,9 +0,0 @@
-
-{{.indent}}{{.decorator}}
-{{.indent}}public {{.returnType}} is{{.property}}() {
-{{.indent}}	return this.{{.tagValue}};
-{{.indent}}}
-
-{{.indent}}public void set{{.property}}({{.type}} {{.propertyValue}}) {
-{{.indent}}	this.{{.tagValue}} = {{.propertyValue}};
-{{.indent}}}

+ 0 - 22
tools/goctlwt/api/javagen/component.tpl

@@ -1,22 +0,0 @@
-// Code generated by goctl. DO NOT EDIT.
-package com.xhb.logic.http.packet.{{.packet}}.model;
-
-import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
-{{.imports}}
-
-public class {{.className}} extends {{.superClassName}} {
-
-{{.properties}}
-{{if .HasProperty}}
-
-	public {{.className}}() {
-	}
-
-	public {{.className}}({{.params}}) {
-{{.constructorSetter}}
-	}
-{{end}}
-
-{{.getSet}}
-}

+ 0 - 50
tools/goctlwt/api/javagen/gen.go

@@ -1,50 +0,0 @@
-package javagen
-
-import (
-	"errors"
-	"fmt"
-	"strings"
-
-	"github.com/gookit/color"
-	"github.com/spf13/cobra"
-	"github.com/wuntsong-org/go-zero-plus/core/logx"
-	"github.com/wuntsong-org/go-zero-plus/tools/goctlwt/api/parser"
-	"github.com/wuntsong-org/go-zero-plus/tools/goctlwt/util/pathx"
-)
-
-var (
-	// VarStringDir describes a directory.
-	VarStringDir string
-	// VarStringAPI describes an API.
-	VarStringAPI string
-)
-
-// JavaCommand generates java code command entrance.
-func JavaCommand(_ *cobra.Command, _ []string) error {
-	apiFile := VarStringAPI
-	dir := VarStringDir
-	if len(apiFile) == 0 {
-		return errors.New("missing -api")
-	}
-	if len(dir) == 0 {
-		return errors.New("missing -dir")
-	}
-
-	api, err := parser.Parse(apiFile)
-	if err != nil {
-		return err
-	}
-
-	if err := api.Validate(); err != nil {
-		return err
-	}
-
-	api.Service = api.Service.JoinPrefix()
-	packetName := strings.TrimSuffix(api.Service.Name, "-api")
-	logx.Must(pathx.MkdirIfNotExist(dir))
-	logx.Must(genPacket(dir, packetName, api))
-	logx.Must(genComponents(dir, packetName, api))
-
-	fmt.Println(color.Green.Render("Done."))
-	return nil
-}

+ 0 - 319
tools/goctlwt/api/javagen/gencomponents.go

@@ -1,319 +0,0 @@
-package javagen
-
-import (
-	"bufio"
-	"bytes"
-	_ "embed"
-	"errors"
-	"fmt"
-	"io"
-	"path"
-	"strings"
-	"text/template"
-
-	"github.com/wuntsong-org/go-zero-plus/core/stringx"
-	"github.com/wuntsong-org/go-zero-plus/tools/goctlwt/api/spec"
-	apiutil "github.com/wuntsong-org/go-zero-plus/tools/goctlwt/api/util"
-	"github.com/wuntsong-org/go-zero-plus/tools/goctlwt/util"
-	"github.com/wuntsong-org/go-zero-plus/tools/goctlwt/util/pathx"
-)
-
-const (
-	httpResponseData = "import com.xhb.core.response.HttpResponseData;"
-	httpData         = "import com.xhb.core.packet.HttpData;"
-)
-
-var (
-	//go:embed component.tpl
-	componentTemplate string
-	//go:embed getset.tpl
-	getSetTemplate string
-	//go:embed bool.tpl
-	boolTemplate string
-)
-
-type componentsContext struct {
-	api           *spec.ApiSpec
-	requestTypes  []spec.Type
-	responseTypes []spec.Type
-	imports       []string
-	members       []spec.Member
-}
-
-func genComponents(dir, packetName string, api *spec.ApiSpec) error {
-	types := api.Types
-	if len(types) == 0 {
-		return nil
-	}
-
-	var requestTypes []spec.Type
-	var responseTypes []spec.Type
-	for _, group := range api.Service.Groups {
-		for _, route := range group.Routes {
-			if route.RequestType != nil {
-				requestTypes = append(requestTypes, route.RequestType)
-			}
-			if route.ResponseType != nil {
-				responseTypes = append(responseTypes, route.ResponseType)
-			}
-		}
-	}
-
-	context := componentsContext{api: api, requestTypes: requestTypes, responseTypes: responseTypes}
-	for _, ty := range types {
-		if err := context.createComponent(dir, packetName, ty); err != nil {
-			return err
-		}
-	}
-
-	return nil
-}
-
-func (c *componentsContext) createComponent(dir, packetName string, ty spec.Type) error {
-	defineStruct, done, err := c.checkStruct(ty)
-	if done {
-		return err
-	}
-
-	modelFile := util.Title(ty.Name()) + ".java"
-	filename := path.Join(dir, modelDir, modelFile)
-	if err := pathx.RemoveOrQuit(filename); err != nil {
-		return err
-	}
-
-	propertiesString, err := c.buildProperties(defineStruct)
-	if err != nil {
-		return err
-	}
-
-	getSetString, err := c.buildGetterSetter(defineStruct)
-	if err != nil {
-		return err
-	}
-
-	superClassName := "HttpData"
-	for _, item := range c.responseTypes {
-		if item.Name() == defineStruct.Name() {
-			superClassName = "HttpResponseData"
-			if !stringx.Contains(c.imports, httpResponseData) {
-				c.imports = append(c.imports, httpResponseData)
-			}
-			break
-		}
-	}
-	if superClassName == "HttpData" && !stringx.Contains(c.imports, httpData) {
-		c.imports = append(c.imports, httpData)
-	}
-
-	params, constructorSetter, err := c.buildConstructor()
-	if err != nil {
-		return err
-	}
-
-	fp, created, err := apiutil.MaybeCreateFile(dir, modelDir, modelFile)
-	if err != nil {
-		return err
-	}
-	if !created {
-		return nil
-	}
-	defer fp.Close()
-
-	buffer := new(bytes.Buffer)
-	t := template.Must(template.New("componentType").Parse(componentTemplate))
-	err = t.Execute(buffer, map[string]any{
-		"properties":        propertiesString,
-		"params":            params,
-		"constructorSetter": constructorSetter,
-		"getSet":            getSetString,
-		"packet":            packetName,
-		"imports":           strings.Join(c.imports, "\n"),
-		"className":         util.Title(defineStruct.Name()),
-		"superClassName":    superClassName,
-		"HasProperty":       len(strings.TrimSpace(propertiesString)) > 0,
-	})
-	if err != nil {
-		return err
-	}
-
-	_, err = fp.WriteString(formatSource(buffer.String()))
-	return err
-}
-
-func (c *componentsContext) checkStruct(ty spec.Type) (spec.DefineStruct, bool, error) {
-	defineStruct, ok := ty.(spec.DefineStruct)
-	if !ok {
-		return spec.DefineStruct{}, true, errors.New("unsupported type %s" + ty.Name())
-	}
-
-	for _, item := range c.requestTypes {
-		if item.Name() == defineStruct.Name() {
-			if len(defineStruct.GetFormMembers())+len(defineStruct.GetBodyMembers()) == 0 {
-				return spec.DefineStruct{}, true, nil
-			}
-		}
-	}
-	return defineStruct, false, nil
-}
-
-func (c *componentsContext) buildProperties(defineStruct spec.DefineStruct) (string, error) {
-	var builder strings.Builder
-	if err := c.writeType(&builder, defineStruct); err != nil {
-		return "", apiutil.WrapErr(err, "Type "+defineStruct.Name()+" generate error")
-	}
-
-	return builder.String(), nil
-}
-
-func (c *componentsContext) buildGetterSetter(defineStruct spec.DefineStruct) (string, error) {
-	var builder strings.Builder
-	if err := c.genGetSet(&builder, 1); err != nil {
-		return "", apiutil.WrapErr(err, "Type "+defineStruct.Name()+" get or set generate error")
-	}
-
-	return builder.String(), nil
-}
-
-func (c *componentsContext) writeType(writer io.Writer, defineStruct spec.DefineStruct) error {
-	c.members = make([]spec.Member, 0)
-	err := c.writeMembers(writer, defineStruct, 1)
-	if err != nil {
-		return err
-	}
-
-	return nil
-}
-
-func (c *componentsContext) writeMembers(writer io.Writer, tp spec.Type, indent int) error {
-	definedType, ok := tp.(spec.DefineStruct)
-	if !ok {
-		pointType, ok := tp.(spec.PointerType)
-		if ok {
-			return c.writeMembers(writer, pointType.Type, indent)
-		}
-		return fmt.Errorf("type %s not supported", tp.Name())
-	}
-
-	for _, member := range definedType.Members {
-		if member.IsInline {
-			err := c.writeMembers(writer, member.Type, indent)
-			if err != nil {
-				return err
-			}
-			continue
-		}
-
-		if member.IsBodyMember() || member.IsFormMember() {
-			if err := writeProperty(writer, member, indent); err != nil {
-				return err
-			}
-
-			c.members = append(c.members, member)
-		}
-	}
-
-	return nil
-}
-
-func (c *componentsContext) buildConstructor() (string, string, error) {
-	var params strings.Builder
-	var constructorSetter strings.Builder
-	for index, member := range c.members {
-		tp, err := specTypeToJava(member.Type)
-		if err != nil {
-			return "", "", err
-		}
-
-		params.WriteString(fmt.Sprintf("%s %s", tp, util.Untitle(member.Name)))
-		pn, err := member.GetPropertyName()
-		if err != nil {
-			return "", "", err
-		}
-
-		if index != len(c.members)-1 {
-			params.WriteString(", ")
-		}
-
-		writeIndent(&constructorSetter, 2)
-		constructorSetter.WriteString(fmt.Sprintf("this.%s = %s;", pn, util.Untitle(member.Name)))
-		if index != len(c.members)-1 {
-			constructorSetter.WriteString(pathx.NL)
-		}
-	}
-	return params.String(), constructorSetter.String(), nil
-}
-
-func (c *componentsContext) genGetSet(writer io.Writer, indent int) error {
-	members := c.members
-	for _, member := range members {
-		javaType, err := specTypeToJava(member.Type)
-		if err != nil {
-			return nil
-		}
-
-		property := util.Title(member.Name)
-		templateStr := getSetTemplate
-		if javaType == "boolean" {
-			templateStr = boolTemplate
-			property = strings.TrimPrefix(property, "Is")
-			property = strings.TrimPrefix(property, "is")
-		}
-		t := template.Must(template.New(templateStr).Parse(getSetTemplate))
-		var tmplBytes bytes.Buffer
-
-		tyString := javaType
-		decorator := ""
-		javaPrimitiveType := []string{"int", "long", "boolean", "float", "double", "short"}
-		if !stringx.Contains(javaPrimitiveType, javaType) {
-			if member.IsOptional() || member.IsOmitEmpty() {
-				decorator = "@Nullable "
-			} else {
-				decorator = "@NotNull "
-			}
-			tyString = decorator + tyString
-		}
-
-		tagName, err := member.GetPropertyName()
-		if err != nil {
-			return err
-		}
-
-		err = t.Execute(&tmplBytes, map[string]string{
-			"property":      property,
-			"propertyValue": util.Untitle(member.Name),
-			"tagValue":      tagName,
-			"type":          tyString,
-			"decorator":     decorator,
-			"returnType":    javaType,
-			"indent":        indentString(indent),
-		})
-		if err != nil {
-			return err
-		}
-
-		r := tmplBytes.String()
-		r = strings.Replace(r, " boolean get", " boolean is", 1)
-		writer.Write([]byte(r))
-	}
-	return nil
-}
-
-func formatSource(source string) string {
-	var builder strings.Builder
-	scanner := bufio.NewScanner(strings.NewReader(source))
-	preIsBreakLine := false
-	for scanner.Scan() {
-		text := strings.TrimSpace(scanner.Text())
-		if text == "" && preIsBreakLine {
-			continue
-		}
-		preIsBreakLine = text == ""
-		builder.WriteString(scanner.Text() + "\n")
-	}
-
-	if err := scanner.Err(); err != nil {
-		fmt.Println(err)
-	}
-
-	return builder.String()
-}

+ 0 - 219
tools/goctlwt/api/javagen/genpacket.go

@@ -1,219 +0,0 @@
-package javagen
-
-import (
-	"bytes"
-	_ "embed"
-	"fmt"
-	"strings"
-	"text/template"
-
-	"github.com/wuntsong-org/go-zero-plus/core/stringx"
-	"github.com/wuntsong-org/go-zero-plus/tools/goctlwt/api/spec"
-	apiutil "github.com/wuntsong-org/go-zero-plus/tools/goctlwt/api/util"
-	"github.com/wuntsong-org/go-zero-plus/tools/goctlwt/util"
-)
-
-//go:embed packet.tpl
-var packetTemplate string
-
-func genPacket(dir, packetName string, api *spec.ApiSpec) error {
-	for _, route := range api.Service.Routes() {
-		if err := createWith(dir, api, route, packetName); err != nil {
-			return err
-		}
-	}
-
-	return nil
-}
-
-func createWith(dir string, api *spec.ApiSpec, route spec.Route, packetName string) error {
-	packet := route.Handler
-	packet = strings.Replace(packet, "Handler", "Packet", 1)
-	packet = strings.Title(packet)
-	if !strings.HasSuffix(packet, "Packet") {
-		packet += "Packet"
-	}
-
-	javaFile := packet + ".java"
-	fp, created, err := apiutil.MaybeCreateFile(dir, "", javaFile)
-	if err != nil {
-		return err
-	}
-	if !created {
-		return nil
-	}
-	defer fp.Close()
-
-	hasRequestBody := false
-	if route.RequestType != nil {
-		if defineStruct, ok := route.RequestType.(spec.DefineStruct); ok {
-			hasRequestBody = len(defineStruct.GetBodyMembers()) > 0 || len(defineStruct.GetFormMembers()) > 0
-		}
-	}
-
-	params := strings.TrimSpace(paramsForRoute(route))
-	if len(params) > 0 && hasRequestBody {
-		params += ", "
-	}
-	paramsDeclaration := declarationForRoute(route)
-	paramsSetter := paramsSet(route)
-	imports := getImports(api, packetName)
-
-	if len(route.ResponseTypeName()) == 0 {
-		imports += fmt.Sprintf("\v%s", "import com.xhb.core.response.EmptyResponse;")
-	}
-
-	t := template.Must(template.New("packetTemplate").Parse(packetTemplate))
-	var tmplBytes bytes.Buffer
-	err = t.Execute(&tmplBytes, map[string]any{
-		"packetName":        packet,
-		"method":            strings.ToUpper(route.Method),
-		"uri":               processUri(route),
-		"responseType":      stringx.TakeOne(util.Title(route.ResponseTypeName()), "EmptyResponse"),
-		"params":            params,
-		"paramsDeclaration": strings.TrimSpace(paramsDeclaration),
-		"paramsSetter":      paramsSetter,
-		"packet":            packetName,
-		"requestType":       util.Title(route.RequestTypeName()),
-		"HasRequestBody":    hasRequestBody,
-		"imports":           imports,
-		"doc":               doc(route),
-	})
-	if err != nil {
-		return err
-	}
-
-	_, err = fp.WriteString(formatSource(tmplBytes.String()))
-	return err
-}
-
-func doc(route spec.Route) string {
-	comment := route.JoinedDoc()
-	if len(comment) > 0 {
-		formatter := `
-/*
-    %s	
-*/`
-		return fmt.Sprintf(formatter, comment)
-	}
-	return ""
-}
-
-func getImports(api *spec.ApiSpec, packetName string) string {
-	var builder strings.Builder
-	allTypes := api.Types
-	if len(allTypes) > 0 {
-		fmt.Fprintf(&builder, "import com.xhb.logic.http.packet.%s.model.*;\n", packetName)
-	}
-
-	return builder.String()
-}
-
-func paramsSet(route spec.Route) string {
-	path := route.Path
-	cops := strings.Split(path, "/")
-	var builder strings.Builder
-	for _, cop := range cops {
-		if len(cop) == 0 {
-			continue
-		}
-		if strings.HasPrefix(cop, ":") {
-			param := cop[1:]
-			builder.WriteString("\n")
-			builder.WriteString(fmt.Sprintf("\t\tthis.%s = %s;", param, param))
-		}
-	}
-	result := builder.String()
-	return result
-}
-
-func paramsForRoute(route spec.Route) string {
-	path := route.Path
-	cops := strings.Split(path, "/")
-	var builder strings.Builder
-	for _, cop := range cops {
-		if len(cop) == 0 {
-			continue
-		}
-		if strings.HasPrefix(cop, ":") {
-			builder.WriteString(fmt.Sprintf("String %s, ", cop[1:]))
-		}
-	}
-	return strings.TrimSuffix(builder.String(), ", ")
-}
-
-func declarationForRoute(route spec.Route) string {
-	path := route.Path
-	cops := strings.Split(path, "/")
-	var builder strings.Builder
-	writeIndent(&builder, 1)
-	for _, cop := range cops {
-		if len(cop) == 0 {
-			continue
-		}
-		if strings.HasPrefix(cop, ":") {
-			writeIndent(&builder, 1)
-			builder.WriteString(fmt.Sprintf("private String %s;\n", cop[1:]))
-		}
-	}
-	result := strings.TrimSpace(builder.String())
-	if len(result) > 0 {
-		result = "\n" + result
-	}
-	return result
-}
-
-func processUri(route spec.Route) string {
-	path := route.Path
-
-	var builder strings.Builder
-	cops := strings.Split(path, "/")
-	for index, cop := range cops {
-		if len(cop) == 0 {
-			continue
-		}
-		if strings.HasPrefix(cop, ":") {
-			builder.WriteString("/\" + " + cop[1:] + " + \"")
-		} else {
-			builder.WriteString("/" + cop)
-			if index == len(cops)-1 {
-				builder.WriteString("\"")
-			}
-		}
-	}
-	result := strings.TrimSuffix(builder.String(), " + \"")
-	if strings.HasPrefix(result, "/") {
-		result = strings.TrimPrefix(result, "/")
-		result = "\"" + result
-	}
-	return result + formString(route)
-}
-
-func formString(route spec.Route) string {
-	var keyValues []string
-	if defineStruct, ok := route.RequestType.(spec.DefineStruct); ok {
-		forms := defineStruct.GetFormMembers()
-		for _, item := range forms {
-			name, err := item.GetPropertyName()
-			if err != nil {
-				panic(err)
-			}
-
-			strcat := "?"
-			if len(keyValues) > 0 {
-				strcat = "&"
-			}
-			if item.Type.Name() == "bool" {
-				name = strings.TrimPrefix(name, "Is")
-				name = strings.TrimPrefix(name, "is")
-				keyValues = append(keyValues, fmt.Sprintf(`"%s%s=" + request.is%s()`, strcat, name, strings.Title(name)))
-			} else {
-				keyValues = append(keyValues, fmt.Sprintf(`"%s%s=" + request.get%s()`, strcat, name, strings.Title(name)))
-			}
-		}
-		if len(keyValues) > 0 {
-			return " + " + strings.Join(keyValues, " + ")
-		}
-	}
-	return ""
-}

+ 0 - 9
tools/goctlwt/api/javagen/getset.tpl

@@ -1,9 +0,0 @@
-
-{{.indent}}{{.decorator}}
-{{.indent}}public {{.returnType}} get{{.property}}() {
-{{.indent}}	return this.{{.tagValue}};
-{{.indent}}}
-
-{{.indent}}public void set{{.property}}({{.type}} {{.propertyValue}}) {
-{{.indent}}	this.{{.tagValue}} = {{.propertyValue}};
-{{.indent}}}

+ 0 - 25
tools/goctlwt/api/javagen/packet.tpl

@@ -1,25 +0,0 @@
-package com.xhb.logic.http.packet.{{.packet}};
-
-import com.xhb.core.packet.HttpPacket;
-import com.xhb.core.network.HttpRequestClient;
-{{.imports}}
-
-{{.doc}}
-public class {{.packetName}} extends HttpPacket<{{.responseType}}> {
-	{{.paramsDeclaration}}
-
-	public {{.packetName}}({{.params}}{{if .HasRequestBody}}{{.requestType}} request{{end}}) {
-		{{if .HasRequestBody}}super(request);{{else}}super(EmptyRequest.instance);{{end}}
-		{{if .HasRequestBody}}this.request = request;{{end}}{{.paramsSetter}}
-    }
-
-	@Override
-    public HttpRequestClient.Method requestMethod() {
-        return HttpRequestClient.Method.{{.method}};
-    }
-
-	@Override
-    public String requestUri() {
-        return {{.uri}};
-    }
-}

+ 0 - 148
tools/goctlwt/api/javagen/util.go

@@ -1,148 +0,0 @@
-package javagen
-
-import (
-	"errors"
-	"fmt"
-	"io"
-	"strings"
-
-	"github.com/wuntsong-org/go-zero-plus/tools/goctlwt/api/spec"
-	"github.com/wuntsong-org/go-zero-plus/tools/goctlwt/util"
-	"github.com/wuntsong-org/go-zero-plus/tools/goctlwt/util/pathx"
-)
-
-func writeProperty(writer io.Writer, member spec.Member, indent int) error {
-	if len(member.Comment) > 0 {
-		writeIndent(writer, indent)
-		fmt.Fprint(writer, member.Comment+pathx.NL)
-	}
-	writeIndent(writer, indent)
-	ty, err := specTypeToJava(member.Type)
-	ty = strings.Replace(ty, "*", "", 1)
-	if err != nil {
-		return err
-	}
-
-	name, err := member.GetPropertyName()
-	if err != nil {
-		return err
-	}
-
-	_, err = fmt.Fprintf(writer, "private %s %s", ty, name)
-	if err != nil {
-		return err
-	}
-
-	err = writeDefaultValue(writer, member)
-	if err != nil {
-		return err
-	}
-
-	fmt.Fprint(writer, ";\n")
-	return err
-}
-
-func writeDefaultValue(writer io.Writer, member spec.Member) error {
-	javaType, err := specTypeToJava(member.Type)
-	if err != nil {
-		return err
-	}
-
-	if javaType == "String" {
-		_, err := fmt.Fprintf(writer, " = \"\"")
-		return err
-	}
-	return nil
-}
-
-func writeIndent(writer io.Writer, indent int) {
-	for i := 0; i < indent; i++ {
-		fmt.Fprint(writer, "\t")
-	}
-}
-
-func indentString(indent int) string {
-	result := ""
-	for i := 0; i < indent; i++ {
-		result += "\t"
-	}
-	return result
-}
-
-func specTypeToJava(tp spec.Type) (string, error) {
-	switch v := tp.(type) {
-	case spec.DefineStruct:
-		return util.Title(tp.Name()), nil
-	case spec.PrimitiveType:
-		r, ok := primitiveType(tp.Name())
-		if !ok {
-			return "", errors.New("unsupported primitive type " + tp.Name())
-		}
-		return r, nil
-	case spec.MapType:
-		valueType, err := specTypeToJava(v.Value)
-		if err != nil {
-			return "", err
-		}
-
-		return fmt.Sprintf("java.util.HashMap<String, %s>", util.Title(valueType)), nil
-	case spec.ArrayType:
-		if tp.Name() == "[]byte" {
-			return "byte[]", nil
-		}
-
-		valueType, err := specTypeToJava(v.Value)
-		if err != nil {
-			return "", err
-		}
-
-		s := getBaseType(valueType)
-		if len(s) == 0 {
-			return s, errors.New("unsupported primitive type " + tp.Name())
-		}
-
-		return fmt.Sprintf("java.util.ArrayList<%s>", util.Title(valueType)), nil
-	case spec.InterfaceType:
-		return "Object", nil
-	case spec.PointerType:
-		return specTypeToJava(v.Type)
-	}
-
-	return "", errors.New("unsupported primitive type " + tp.Name())
-}
-
-func getBaseType(valueType string) string {
-	switch valueType {
-	case "int":
-		return "Integer[]"
-	case "long":
-		return "Long[]"
-	case "float":
-		return "Float[]"
-	case "double":
-		return "Double[]"
-	case "boolean":
-		return "Boolean[]"
-	default:
-		return ""
-	}
-}
-
-func primitiveType(tp string) (string, bool) {
-	switch tp {
-	case "string":
-		return "String", true
-	case "int64", "uint64":
-		return "long", true
-	case "int", "int8", "int32", "uint", "uint8", "uint16", "uint32":
-		return "int", true
-	case "float", "float32":
-		return "float", true
-	case "float64":
-		return "double", true
-	case "bool":
-		return "boolean", true
-	}
-
-	return "", false
-}

+ 0 - 3
tools/goctlwt/api/javagen/vars.go

@@ -1,3 +0,0 @@
-package javagen
-
-const modelDir = "model"

+ 0 - 22
tools/goctlwt/api/ktgen/api.tpl

@@ -1,22 +0,0 @@
-package {{.Pkg}}
-
-import com.google.gson.Gson
-
-object {{with .Info}}{{.Title}}{{end}}{
-	{{range .Types}}
-	data class {{.Name}}({{$length := (len .Members)}}{{range $i,$item := .Members}}
-		val {{with $item}}{{lowCamelCase .Name}}: {{parseType .Type.Name}}{{end}}{{if ne $i (add $length -1)}},{{end}}{{end}}
-	){{end}}
-	{{with .Service}}
-	{{range .Routes}}suspend fun {{routeToFuncName .Method .Path}}({{with .RequestType}}{{if ne .Name ""}}
-		req:{{.Name}},{{end}}{{end}}
-		onOk: (({{with .ResponseType}}{{.Name}}{{end}}) -> Unit)? = null,
-        onFail: ((String) -> Unit)? = null,
-        eventually: (() -> Unit)? = null
-    ){
-        apiRequest("{{upperCase .Method}}","{{.Path}}",{{with .RequestType}}{{if ne .Name ""}}body=req,{{end}}{{end}} onOk = { {{with .ResponseType}}
-            onOk?.invoke({{if ne .Name ""}}Gson().fromJson(it,{{.Name}}::class.java){{end}}){{end}}
-        }, onFail = onFail, eventually =eventually)
-    }
-	{{end}}{{end}}
-}

+ 0 - 61
tools/goctlwt/api/ktgen/apibase.tpl

@@ -1,61 +0,0 @@
-package {{.}}
-
-import com.google.gson.Gson
-import kotlinx.coroutines.Dispatchers
-import kotlinx.coroutines.withContext
-import java.io.BufferedReader
-import java.io.InputStreamReader
-import java.io.OutputStreamWriter
-import java.net.HttpURLConnection
-import java.net.URL
-
-const val SERVER = "http://localhost:8080"
-
-suspend fun apiRequest(
-    method: String,
-    uri: String,
-    body: Any = "",
-    onOk: ((String) -> Unit)? = null,
-    onFail: ((String) -> Unit)? = null,
-    eventually: (() -> Unit)? = null
-) = withContext(Dispatchers.IO) {
-    val url = URL(SERVER + uri)
-    with(url.openConnection() as HttpURLConnection) {
-        connectTimeout = 3000
-        requestMethod = method
-        doInput = true
-        if (method == "POST" || method == "PUT" || method == "PATCH") {
-            setRequestProperty("Content-Type", "application/json; charset=utf-8")
-            doOutput = true
-            val data = when (body) {
-                is String -> {
-                    body
-                }
-                else -> {
-                    Gson().toJson(body)
-                }
-            }
-            val wr = OutputStreamWriter(outputStream)
-            wr.write(data)
-            wr.flush()
-        }
-
-         try {
-            if (responseCode >= 400) {
-                BufferedReader(InputStreamReader(errorStream)).use {
-                    val response = it.readText()
-                    onFail?.invoke(response)
-                }
-                return@with
-            }
-            //response
-            BufferedReader(InputStreamReader(inputStream)).use {
-                val response = it.readText()
-                onOk?.invoke(response)
-            }
-        } catch (e: Exception) {
-            e.message?.let { onFail?.invoke(it) }
-        }
-    }
-    eventually?.invoke()
-}

+ 0 - 53
tools/goctlwt/api/ktgen/cmd.go

@@ -1,53 +0,0 @@
-package ktgen
-
-import (
-	"errors"
-
-	"github.com/spf13/cobra"
-	"github.com/wuntsong-org/go-zero-plus/tools/goctlwt/api/parser"
-)
-
-var (
-	// VarStringDir describes a directory.
-	VarStringDir string
-	// VarStringAPI describes an API.
-	VarStringAPI string
-	// VarStringPKG describes a package.
-	VarStringPKG string
-)
-
-// KtCommand generates kotlin code command entrance
-func KtCommand(_ *cobra.Command, _ []string) error {
-	apiFile := VarStringAPI
-	if apiFile == "" {
-		return errors.New("missing -api")
-	}
-	dir := VarStringDir
-	if dir == "" {
-		return errors.New("missing -dir")
-	}
-	pkg := VarStringPKG
-	if pkg == "" {
-		return errors.New("missing -pkg")
-	}
-
-	api, e := parser.Parse(apiFile)
-	if e != nil {
-		return e
-	}
-
-	if err := api.Validate(); err != nil {
-		return err
-	}
-
-	api.Service = api.Service.JoinPrefix()
-	e = genBase(dir, pkg, api)
-	if e != nil {
-		return e
-	}
-	e = genApi(dir, pkg, api)
-	if e != nil {
-		return e
-	}
-	return nil
-}

+ 0 - 119
tools/goctlwt/api/ktgen/funcs.go

@@ -1,119 +0,0 @@
-package ktgen
-
-import (
-	"fmt"
-	"log"
-	"strings"
-	"text/template"
-
-	"github.com/iancoleman/strcase"
-	"github.com/wuntsong-org/go-zero-plus/tools/goctlwt/api/util"
-)
-
-var funcsMap = template.FuncMap{
-	"lowCamelCase":    lowCamelCase,
-	"routeToFuncName": routeToFuncName,
-	"parseType":       parseType,
-	"add":             add,
-	"upperCase":       upperCase,
-}
-
-func lowCamelCase(s string) string {
-	if len(s) < 1 {
-		return ""
-	}
-	s = util.ToCamelCase(util.ToSnakeCase(s))
-	return util.ToLower(s[:1]) + s[1:]
-}
-
-func routeToFuncName(method, path string) string {
-	if !strings.HasPrefix(path, "/") {
-		path = "/" + path
-	}
-
-	path = strings.ReplaceAll(path, "/", "_")
-	path = strings.ReplaceAll(path, "-", "_")
-	path = strings.ReplaceAll(path, ":", "With_")
-
-	return strings.ToLower(method) + strcase.ToCamel(path)
-}
-
-func parseType(t string) string {
-	t = strings.Replace(t, "*", "", -1)
-	if strings.HasPrefix(t, "[]") {
-		return "List<" + parseType(t[2:]) + ">"
-	}
-
-	if strings.HasPrefix(t, "map") {
-		tys, e := decomposeType(t)
-		if e != nil {
-			log.Fatal(e)
-		}
-		if len(tys) != 2 {
-			log.Fatal("Map type number !=2")
-		}
-		return "Map<String," + parseType(tys[1]) + ">"
-	}
-
-	switch t {
-	case "string":
-		return "String"
-	case "int", "int32", "int64":
-		return "Int"
-	case "float", "float32", "float64":
-		return "Double"
-	case "bool":
-		return "Boolean"
-	default:
-		return t
-	}
-}
-
-func decomposeType(t string) (result []string, err error) {
-	add := func(tp string) error {
-		ret, err := decomposeType(tp)
-		if err != nil {
-			return err
-		}
-
-		result = append(result, ret...)
-		return nil
-	}
-	if strings.HasPrefix(t, "map") {
-		t = strings.ReplaceAll(t, "map", "")
-		if t[0] == '[' {
-			pos := strings.Index(t, "]")
-			if pos > 1 {
-				if err = add(t[1:pos]); err != nil {
-					return
-				}
-				if len(t) > pos+1 {
-					err = add(t[pos+1:])
-					return
-				}
-			}
-		}
-	} else if strings.HasPrefix(t, "[]") {
-		if len(t) > 2 {
-			err = add(t[2:])
-			return
-		}
-	} else if strings.HasPrefix(t, "*") {
-		err = add(t[1:])
-		return
-	} else {
-		result = append(result, t)
-		return
-	}
-
-	err = fmt.Errorf("bad type %q", t)
-	return
-}
-
-func add(a, i int) int {
-	return a + i
-}
-
-func upperCase(s string) string {
-	return strings.ToUpper(s)
-}

+ 0 - 90
tools/goctlwt/api/ktgen/gen.go

@@ -1,90 +0,0 @@
-package ktgen
-
-import (
-	_ "embed"
-	"fmt"
-	"os"
-	"path/filepath"
-	"text/template"
-
-	"github.com/iancoleman/strcase"
-	"github.com/wuntsong-org/go-zero-plus/tools/goctlwt/api/spec"
-)
-
-var (
-	//go:embed apibase.tpl
-	apiBaseTemplate string
-	//go:embed api.tpl
-	apiTemplate string
-)
-
-func genBase(dir, pkg string, api *spec.ApiSpec) error {
-	e := os.MkdirAll(dir, 0o755)
-	if e != nil {
-		return e
-	}
-	path := filepath.Join(dir, "BaseApi.kt")
-	if _, e := os.Stat(path); e == nil {
-		fmt.Println("BaseApi.kt already exists, skipped it.")
-		return nil
-	}
-
-	file, e := os.OpenFile(path, os.O_CREATE|os.O_TRUNC|os.O_WRONLY, 0o644)
-	if e != nil {
-		return e
-	}
-	defer file.Close()
-
-	t, e := template.New("n").Parse(apiBaseTemplate)
-	if e != nil {
-		return e
-	}
-	e = t.Execute(file, pkg)
-	if e != nil {
-		return e
-	}
-	return nil
-}
-
-func genApi(dir, pkg string, api *spec.ApiSpec) error {
-	properties := api.Info.Properties
-	if properties == nil {
-		return fmt.Errorf("none properties")
-	}
-
-	title := properties["Title"]
-	if len(title) == 0 {
-		return fmt.Errorf("none title")
-	}
-
-	desc := properties["Desc"]
-	if len(desc) == 0 {
-		return fmt.Errorf("none desc")
-	}
-
-	name := strcase.ToCamel(title + "Api")
-	path := filepath.Join(dir, name+".kt")
-	api.Info.Title = name
-	api.Info.Desc = desc
-
-	e := os.MkdirAll(dir, 0o755)
-	if e != nil {
-		return e
-	}
-
-	file, e := os.OpenFile(path, os.O_WRONLY|os.O_TRUNC|os.O_CREATE, 0o644)
-	if e != nil {
-		return e
-	}
-	defer file.Close()
-
-	t, e := template.New("api").Funcs(funcsMap).Parse(apiTemplate)
-	if e != nil {
-		return e
-	}
-	type data struct {
-		*spec.ApiSpec
-		Pkg string
-	}
-	return t.Execute(file, data{api, pkg})
-}

+ 0 - 14
tools/goctlwt/api/new/api.tpl

@@ -1,14 +0,0 @@
-syntax = "v1"
-
-type Request {
-  Name string `path:"name,options=you|me"`
-}
-
-type Response {
-  Message string `json:"message"`
-}
-
-service {{.name}}-api {
-  @handler {{.handler}}Handler
-  get /from/:name(Request) returns (Response)
-}

+ 0 - 88
tools/goctlwt/api/new/newservice.go

@@ -1,88 +0,0 @@
-package new
-
-import (
-	_ "embed"
-	"errors"
-	"html/template"
-	"os"
-	"path/filepath"
-	"strings"
-
-	"github.com/spf13/cobra"
-	"github.com/wuntsong-org/go-zero-plus/tools/goctlwt/api/gogen"
-	conf "github.com/wuntsong-org/go-zero-plus/tools/goctlwt/config"
-	"github.com/wuntsong-org/go-zero-plus/tools/goctlwt/util"
-	"github.com/wuntsong-org/go-zero-plus/tools/goctlwt/util/pathx"
-)
-
-//go:embed api.tpl
-var apiTemplate string
-
-var (
-	// VarStringHome describes the goctlwt home.
-	VarStringHome string
-	// VarStringRemote describes the remote git repository.
-	VarStringRemote string
-	// VarStringBranch describes the git branch.
-	VarStringBranch string
-	// VarStringStyle describes the style of output files.
-	VarStringStyle string
-)
-
-// CreateServiceCommand fast create service
-func CreateServiceCommand(_ *cobra.Command, args []string) error {
-	dirName := args[0]
-	if len(VarStringStyle) == 0 {
-		VarStringStyle = conf.DefaultFormat
-	}
-	if strings.Contains(dirName, "-") {
-		return errors.New("api new command service name not support strikethrough, because this will used by function name")
-	}
-
-	abs, err := filepath.Abs(dirName)
-	if err != nil {
-		return err
-	}
-
-	err = pathx.MkdirIfNotExist(abs)
-	if err != nil {
-		return err
-	}
-
-	dirName = filepath.Base(filepath.Clean(abs))
-	filename := dirName + ".api"
-	apiFilePath := filepath.Join(abs, filename)
-	fp, err := os.Create(apiFilePath)
-	if err != nil {
-		return err
-	}
-
-	defer fp.Close()
-
-	if len(VarStringRemote) > 0 {
-		repo, _ := util.CloneIntoGitHome(VarStringRemote, VarStringBranch)
-		if len(repo) > 0 {
-			VarStringHome = repo
-		}
-	}
-
-	if len(VarStringHome) > 0 {
-		pathx.RegisterGoctlHome(VarStringHome)
-	}
-
-	text, err := pathx.LoadTemplate(category, apiTemplateFile, apiTemplate)
-	if err != nil {
-		return err
-	}
-
-	t := template.Must(template.New("template").Parse(text))
-	if err := t.Execute(fp, map[string]string{
-		"name":    dirName,
-		"handler": strings.Title(dirName),
-	}); err != nil {
-		return err
-	}
-
-	err = gogen.DoGenProject(apiFilePath, abs, VarStringStyle)
-	return err
-}

+ 0 - 50
tools/goctlwt/api/new/template.go

@@ -1,50 +0,0 @@
-package new
-
-import (
-	"fmt"
-
-	"github.com/wuntsong-org/go-zero-plus/tools/goctlwt/util/pathx"
-)
-
-const (
-	category        = "newapi"
-	apiTemplateFile = "newtemplate.tpl"
-)
-
-var templates = map[string]string{
-	apiTemplateFile: apiTemplate,
-}
-
-// Category returns the category of the api files.
-func Category() string {
-	return category
-}
-
-// Clean cleans the generated deployment files.
-func Clean() error {
-	return pathx.Clean(category)
-}
-
-// GenTemplates generates api template files.
-func GenTemplates() error {
-	return pathx.InitTemplates(category, templates)
-}
-
-// RevertTemplate reverts the given template file to the default value.
-func RevertTemplate(name string) error {
-	content, ok := templates[name]
-	if !ok {
-		return fmt.Errorf("%s: no such file name", name)
-	}
-	return pathx.CreateTemplate(category, name, content)
-}
-
-// Update updates the template files to the templates built in current goctlwt.
-func Update() error {
-	err := Clean()
-	if err != nil {
-		return err
-	}
-
-	return pathx.InitTemplates(category, templates)
-}

+ 0 - 46
tools/goctlwt/api/parser/g4/ApiLexer.g4

@@ -1,46 +0,0 @@
-lexer grammar ApiLexer;
-
-// Keywords
-ATDOC:              '@doc';
-ATHANDLER:          '@handler';
-INTERFACE:          'interface{}';
-ATSERVER:           '@server';
-
-// Whitespace and comments
-WS:                 [ \t\r\n\u000C]+ -> channel(HIDDEN);
-COMMENT:            '/*' .*? '*/' -> channel(88);
-LINE_COMMENT:       '//' ~[\r\n]* -> channel(88);
-STRING:             '"' (~["\\] | EscapeSequence)* '"';
-RAW_STRING:         '`' (~[`\\\r\n] | EscapeSequence)+ '`';
-LINE_VALUE:         ':' [ \t]* (STRING|(~[\r\n"`]*));
-ID:         Letter LetterOrDigit*;
-
-
-LetterOrDigit
-    : Letter
-    | [0-9]
-    ;
-fragment ExponentPart
-    : [eE] [+-]? Digits
-    ;
-
-fragment EscapeSequence
-    : '\\' [btnfr"'\\]
-    | '\\' ([0-3]? [0-7])? [0-7]
-    | '\\' 'u'+ HexDigit HexDigit HexDigit HexDigit
-    ;
-fragment HexDigits
-    : HexDigit ((HexDigit | '_')* HexDigit)?
-    ;
-fragment HexDigit
-    : [0-9a-fA-F]
-    ;
-fragment Digits
-    : [0-9] ([0-9_]* [0-9])?
-    ;
-
-fragment Letter
-    : [a-zA-Z$_] // these are the "java letters" below 0x7F
-    | ~[\u0000-\u007F\uD800-\uDBFF] // covers all characters above 0x7F which are not a surrogate
-    | [\uD800-\uDBFF] [\uDC00-\uDFFF] // covers UTF-16 surrogate pairs encodings for U+10000 to U+10FFFF
-    ;

+ 0 - 74
tools/goctlwt/api/parser/g4/ApiParser.g4

@@ -1,74 +0,0 @@
-grammar ApiParser;
-
-import ApiLexer;
-
-@lexer::members{
-    const COMEMNTS = 88
-}
-
-api:            spec*;
-spec:           syntaxLit
-                |importSpec
-                |infoSpec
-                |typeSpec
-                |serviceSpec
-                ;
-
-// syntax
-syntaxLit:      {match(p,"syntax")}syntaxToken=ID assign='=' {checkVersion(p)}version=STRING;
-
-// import
-importSpec:     importLit|importBlock;
-importLit:      {match(p,"import")}importToken=ID importValue ;
-importBlock:    {match(p,"import")}importToken=ID '(' importBlockValue+ ')';
-importBlockValue:   importValue;
-importValue:    {checkImportValue(p)}STRING;
-
-// info
-infoSpec:       {match(p,"info")}infoToken=ID lp='(' kvLit+ rp=')';
-
-// type
-typeSpec:       typeLit
-                |typeBlock;
-
-// eg: type Foo int
-typeLit:        {match(p,"type")}typeToken=ID  typeLitBody;
-// eg: type (...)
-typeBlock:      {match(p,"type")}typeToken=ID lp='(' typeBlockBody* rp=')';
-typeLitBody:    typeStruct|typeAlias;
-typeBlockBody:  typeBlockStruct|typeBlockAlias;
-typeStruct:     {checkKeyword(p)}structName=ID structToken=ID? lbrace='{'  field* rbrace='}';
-typeAlias:      {checkKeyword(p)}alias=ID assign='='? dataType;
-typeBlockStruct: {checkKeyword(p)}structName=ID structToken=ID? lbrace='{'  field* rbrace='}';
-typeBlockAlias: {checkKeyword(p)}alias=ID assign='='? dataType;
-field:          {isNormal(p)}? normalField|anonymousFiled ;
-normalField:    {checkKeyword(p)}fieldName=ID dataType tag=RAW_STRING?;
-anonymousFiled: star='*'? ID;
-dataType:       {isInterface(p)}ID
-                |mapType
-                |arrayType
-                |inter='interface{}'
-                |time='time.Time'
-                |pointerType
-                |typeStruct
-                ;
-pointerType:    star='*' {checkKeyword(p)}ID;
-mapType:        {match(p,"map")}mapToken=ID lbrack='[' {checkKey(p)}key=ID rbrack=']' value=dataType;
-arrayType:      lbrack='[' rbrack=']' dataType;
-
-// service
-serviceSpec:    atServer? serviceApi;
-atServer:       ATSERVER lp='(' kvLit+ rp=')';
-serviceApi:     {match(p,"service")}serviceToken=ID serviceName lbrace='{' serviceRoute* rbrace='}';
-serviceRoute:   atDoc? (atServer|atHandler) route;
-atDoc:          ATDOC lp='('? ((kvLit+)|STRING) rp=')'?;
-atHandler:      ATHANDLER ID;
-route:          {checkHTTPMethod(p)}httpMethod=ID path request=body? response=replybody?;
-body:           lp='(' (ID)? rp=')';
-replybody:      returnToken='returns' lp='(' dataType? rp=')';
-// kv
-kvLit:          key=ID {checkKeyValue(p)}value=LINE_VALUE;
-
-serviceName:    (ID '-'?)+;
-path:           (('/' (pathItem ('-' pathItem)*))|('/:' (pathItem ('-' pathItem)?)))+ | '/';
-pathItem:       (ID|LetterOrDigit)+;

+ 0 - 290
tools/goctlwt/api/parser/g4/ast/api.go

@@ -1,290 +0,0 @@
-package ast
-
-import (
-	"fmt"
-	"path"
-	"sort"
-
-	"github.com/wuntsong-org/go-zero-plus/tools/goctlwt/api/parser/g4/gen/api"
-)
-
-const (
-	prefixKey = "prefix"
-	groupKey  = "group"
-)
-
-// Api describes syntax for api
-type Api struct {
-	LinePrefix string
-	Syntax     *SyntaxExpr
-	Import     []*ImportExpr
-	importM    map[string]PlaceHolder
-	Info       *InfoExpr
-	Type       []TypeExpr
-	typeM      map[string]PlaceHolder
-	Service    []*Service
-	serviceM   map[string]PlaceHolder
-	handlerM   map[string]PlaceHolder
-	routeM     map[string]PlaceHolder
-}
-
-// VisitApi implements from api.BaseApiParserVisitor
-func (v *ApiVisitor) VisitApi(ctx *api.ApiContext) any {
-	var final Api
-	final.importM = map[string]PlaceHolder{}
-	final.typeM = map[string]PlaceHolder{}
-	final.serviceM = map[string]PlaceHolder{}
-	final.handlerM = map[string]PlaceHolder{}
-	final.routeM = map[string]PlaceHolder{}
-	for _, each := range ctx.AllSpec() {
-		root := each.Accept(v).(*Api)
-		v.acceptSyntax(root, &final)
-		v.acceptImport(root, &final)
-		v.acceptInfo(root, &final)
-		v.acceptType(root, &final)
-		v.acceptService(root, &final)
-	}
-
-	return &final
-}
-
-func (v *ApiVisitor) acceptService(root, final *Api) {
-	for _, service := range root.Service {
-		if _, ok := final.serviceM[service.ServiceApi.Name.Text()]; !ok && len(final.serviceM) > 0 {
-			v.panic(service.ServiceApi.Name, "multiple service declaration")
-		}
-		v.duplicateServerItemCheck(service)
-
-		var prefix, group string
-		if service.AtServer != nil {
-			p := service.AtServer.Kv.Get(prefixKey)
-			if p != nil {
-				prefix = p.Text()
-			}
-			g := service.AtServer.Kv.Get(groupKey)
-			if g != nil {
-				group = g.Text()
-			}
-		}
-		for _, route := range service.ServiceApi.ServiceRoute {
-			uniqueRoute := fmt.Sprintf("%s %s", route.Route.Method.Text(), path.Join(prefix, route.Route.Path.Text()))
-			if _, ok := final.routeM[uniqueRoute]; ok {
-				v.panic(route.Route.Method, fmt.Sprintf("duplicate route '%s'", uniqueRoute))
-			}
-
-			final.routeM[uniqueRoute] = Holder
-			var handlerExpr Expr
-			if route.AtServer != nil {
-				atServerM := map[string]PlaceHolder{}
-				for _, kv := range route.AtServer.Kv {
-					if _, ok := atServerM[kv.Key.Text()]; ok {
-						v.panic(kv.Key, fmt.Sprintf("duplicate key '%s'", kv.Key.Text()))
-					}
-					atServerM[kv.Key.Text()] = Holder
-					if kv.Key.Text() == "handler" {
-						handlerExpr = kv.Value
-					}
-				}
-			}
-
-			if route.AtHandler != nil {
-				handlerExpr = route.AtHandler.Name
-			}
-
-			if handlerExpr == nil {
-				v.panic(route.Route.Method, "mismatched handler")
-			}
-
-			if handlerExpr.Text() == "" {
-				v.panic(handlerExpr, "mismatched handler")
-			}
-
-			handlerKey := handlerExpr.Text()
-			if len(group) > 0 {
-				handlerKey = fmt.Sprintf("%s/%s", group, handlerExpr.Text())
-			}
-			if _, ok := final.handlerM[handlerKey]; ok {
-				v.panic(handlerExpr, fmt.Sprintf("duplicate handler '%s'", handlerExpr.Text()))
-			}
-			final.handlerM[handlerKey] = Holder
-		}
-		final.Service = append(final.Service, service)
-	}
-}
-
-func (v *ApiVisitor) duplicateServerItemCheck(service *Service) {
-	if service.AtServer != nil {
-		atServerM := map[string]PlaceHolder{}
-		for _, kv := range service.AtServer.Kv {
-			if _, ok := atServerM[kv.Key.Text()]; ok {
-				v.panic(kv.Key, fmt.Sprintf("duplicate key '%s'", kv.Key.Text()))
-			}
-
-			atServerM[kv.Key.Text()] = Holder
-		}
-	}
-}
-
-func (v *ApiVisitor) acceptType(root, final *Api) {
-	for _, tp := range root.Type {
-		if _, ok := final.typeM[tp.NameExpr().Text()]; ok {
-			v.panic(tp.NameExpr(), fmt.Sprintf("duplicate type '%s'", tp.NameExpr().Text()))
-		}
-
-		final.typeM[tp.NameExpr().Text()] = Holder
-		final.Type = append(final.Type, tp)
-	}
-}
-
-func (v *ApiVisitor) acceptInfo(root, final *Api) {
-	if root.Info != nil {
-		infoM := map[string]PlaceHolder{}
-		if final.Info != nil {
-			v.panic(root.Info.Info, "multiple info declaration")
-		}
-
-		for _, value := range root.Info.Kvs {
-			if _, ok := infoM[value.Key.Text()]; ok {
-				v.panic(value.Key, fmt.Sprintf("duplicate key '%s'", value.Key.Text()))
-			}
-			infoM[value.Key.Text()] = Holder
-		}
-
-		final.Info = root.Info
-	}
-}
-
-func (v *ApiVisitor) acceptImport(root, final *Api) {
-	for _, imp := range root.Import {
-		if _, ok := final.importM[imp.Value.Text()]; ok {
-			v.panic(imp.Import, fmt.Sprintf("duplicate import '%s'", imp.Value.Text()))
-		}
-
-		final.importM[imp.Value.Text()] = Holder
-		final.Import = append(final.Import, imp)
-	}
-}
-
-func (v *ApiVisitor) acceptSyntax(root, final *Api) {
-	if root.Syntax != nil {
-		if final.Syntax != nil {
-			v.panic(root.Syntax.Syntax, "multiple syntax declaration")
-		}
-
-		final.Syntax = root.Syntax
-	}
-}
-
-// VisitSpec implements from api.BaseApiParserVisitor
-func (v *ApiVisitor) VisitSpec(ctx *api.SpecContext) any {
-	var root Api
-	if ctx.SyntaxLit() != nil {
-		root.Syntax = ctx.SyntaxLit().Accept(v).(*SyntaxExpr)
-	}
-
-	if ctx.ImportSpec() != nil {
-		root.Import = ctx.ImportSpec().Accept(v).([]*ImportExpr)
-	}
-
-	if ctx.InfoSpec() != nil {
-		root.Info = ctx.InfoSpec().Accept(v).(*InfoExpr)
-	}
-
-	if ctx.TypeSpec() != nil {
-		tp := ctx.TypeSpec().Accept(v)
-		root.Type = tp.([]TypeExpr)
-	}
-
-	if ctx.ServiceSpec() != nil {
-		root.Service = []*Service{ctx.ServiceSpec().Accept(v).(*Service)}
-	}
-
-	return &root
-}
-
-// Format provides a formatter for api command, now nothing to do
-func (a *Api) Format() error {
-	// todo
-	return nil
-}
-
-// Equal compares whether the element literals in two Api are equal
-func (a *Api) Equal(v any) bool {
-	if v == nil || a == nil {
-		return false
-	}
-
-	root, ok := v.(*Api)
-	if !ok {
-		return false
-	}
-
-	if !a.Syntax.Equal(root.Syntax) {
-		return false
-	}
-
-	if len(a.Import) != len(root.Import) {
-		return false
-	}
-
-	var expectingImport, actualImport []*ImportExpr
-	expectingImport = append(expectingImport, a.Import...)
-	actualImport = append(actualImport, root.Import...)
-
-	sort.Slice(expectingImport, func(i, j int) bool {
-		return expectingImport[i].Value.Text() < expectingImport[j].Value.Text()
-	})
-
-	sort.Slice(actualImport, func(i, j int) bool {
-		return actualImport[i].Value.Text() < actualImport[j].Value.Text()
-	})
-
-	for index, each := range expectingImport {
-		ac := actualImport[index]
-		if !each.Equal(ac) {
-			return false
-		}
-	}
-
-	if !a.Info.Equal(root.Info) {
-		return false
-	}
-
-	if len(a.Type) != len(root.Type) {
-		return false
-	}
-
-	var expectingType, actualType []TypeExpr
-	expectingType = append(expectingType, a.Type...)
-	actualType = append(actualType, root.Type...)
-
-	sort.Slice(expectingType, func(i, j int) bool {
-		return expectingType[i].NameExpr().Text() < expectingType[j].NameExpr().Text()
-	})
-	sort.Slice(actualType, func(i, j int) bool {
-		return actualType[i].NameExpr().Text() < actualType[j].NameExpr().Text()
-	})
-
-	for index, each := range expectingType {
-		ac := actualType[index]
-		if !each.Equal(ac) {
-			return false
-		}
-	}
-
-	if len(a.Service) != len(root.Service) {
-		return false
-	}
-
-	var expectingService, actualService []*Service
-	expectingService = append(expectingService, a.Service...)
-	actualService = append(actualService, root.Service...)
-	for index, each := range expectingService {
-		ac := actualService[index]
-		if !each.Equal(ac) {
-			return false
-		}
-	}
-
-	return true
-}

+ 0 - 534
tools/goctlwt/api/parser/g4/ast/apiparser.go

@@ -1,534 +0,0 @@
-package ast
-
-import (
-	"fmt"
-	"os"
-	"path"
-	"path/filepath"
-	"strings"
-
-	"github.com/wuntsong-org/go-zero-plus/tools/goctlwt/api/parser/g4/gen/api"
-	"github.com/wuntsong-org/go-zero-plus/tools/goctlwt/util/console"
-	"github.com/zeromicro/antlr"
-)
-
-type (
-	// Parser provides api parsing capabilities
-	Parser struct {
-		antlr.DefaultErrorListener
-		linePrefix               string
-		debug                    bool
-		log                      console.Console
-		skipCheckTypeDeclaration bool
-		handlerMap               map[string]PlaceHolder
-		routeMap                 map[string]PlaceHolder
-		typeMap                  map[string]PlaceHolder
-		fileMap                  map[string]PlaceHolder
-		importStatck             importStack
-		syntax                   *SyntaxExpr
-	}
-
-	// ParserOption defines an function with argument Parser
-	ParserOption func(p *Parser)
-)
-
-// NewParser creates an instance for Parser
-func NewParser(options ...ParserOption) *Parser {
-	p := &Parser{
-		log: console.NewColorConsole(),
-	}
-	for _, opt := range options {
-		opt(p)
-	}
-	p.handlerMap = make(map[string]PlaceHolder)
-	p.routeMap = make(map[string]PlaceHolder)
-	p.typeMap = make(map[string]PlaceHolder)
-	p.fileMap = make(map[string]PlaceHolder)
-
-	return p
-}
-
-// Accept can parse any terminalNode of api tree by fn.
-// -- for debug
-func (p *Parser) Accept(fn func(p *api.ApiParserParser, visitor *ApiVisitor) any, content string) (v any, err error) {
-	defer func() {
-		p := recover()
-		if p != nil {
-			switch e := p.(type) {
-			case error:
-				err = e
-			default:
-				err = fmt.Errorf("%+v", p)
-			}
-		}
-	}()
-
-	inputStream := antlr.NewInputStream(content)
-	lexer := api.NewApiParserLexer(inputStream)
-	lexer.RemoveErrorListeners()
-	tokens := antlr.NewCommonTokenStream(lexer, antlr.LexerDefaultTokenChannel)
-	apiParser := api.NewApiParserParser(tokens)
-	apiParser.RemoveErrorListeners()
-	apiParser.AddErrorListener(p)
-	var visitorOptions []VisitorOption
-	visitorOptions = append(visitorOptions, WithVisitorPrefix(p.linePrefix))
-	if p.debug {
-		visitorOptions = append(visitorOptions, WithVisitorDebug())
-	}
-	visitor := NewApiVisitor(visitorOptions...)
-	v = fn(apiParser, visitor)
-	return
-}
-
-// Parse is used to parse the api from the specified file name
-func (p *Parser) Parse(filename string) (*Api, error) {
-	abs, err := filepath.Abs(filename)
-	if err != nil {
-		return nil, err
-	}
-
-	data, err := p.readContent(filename)
-	if err != nil {
-		return nil, err
-	}
-
-	p.importStatck.push(abs)
-	return p.parse(filename, data)
-}
-
-// ParseContent is used to parse the api from the specified content
-func (p *Parser) ParseContent(content string, filename ...string) (*Api, error) {
-	var f, abs string
-	if len(filename) > 0 {
-		f = filename[0]
-		a, err := filepath.Abs(f)
-		if err != nil {
-			return nil, err
-		}
-
-		abs = a
-	}
-
-	p.importStatck.push(abs)
-	return p.parse(f, content)
-}
-
-// parse is used to parse api from the content
-// filename is only used to mark the file where the error is located
-func (p *Parser) parse(filename, content string) (*Api, error) {
-	root, err := p.invoke(filename, content)
-	if err != nil {
-		return nil, err
-	}
-
-	var apiAstList []*Api
-	apiAstList = append(apiAstList, root)
-	p.storeVerificationInfo(root)
-	p.syntax = root.Syntax
-	impApiAstList, err := p.invokeImportedApi(filename, root.Import)
-	if err != nil {
-		return nil, err
-	}
-	apiAstList = append(apiAstList, impApiAstList...)
-
-	if !p.skipCheckTypeDeclaration {
-		err = p.checkTypeDeclaration(apiAstList)
-		if err != nil {
-			return nil, err
-		}
-	}
-
-	allApi := p.memberFill(apiAstList)
-	return allApi, nil
-}
-
-func (p *Parser) invokeImportedApi(filename string, imports []*ImportExpr) ([]*Api, error) {
-	var apiAstList []*Api
-	for _, imp := range imports {
-		dir := filepath.Dir(filename)
-		impPath := strings.ReplaceAll(imp.Value.Text(), "\"", "")
-		if !filepath.IsAbs(impPath) {
-			impPath = filepath.Join(dir, impPath)
-		}
-		// import cycle check
-		if err := p.importStatck.push(impPath); err != nil {
-			return nil, err
-		}
-		// ignore already imported file
-		if p.alreadyImported(impPath) {
-			continue
-		}
-		p.fileMap[impPath] = PlaceHolder{}
-
-		data, err := p.readContent(impPath)
-		if err != nil {
-			return nil, err
-		}
-
-		nestedApi, err := p.invoke(impPath, data)
-		if err != nil {
-			return nil, err
-		}
-
-		err = p.valid(nestedApi)
-		if err != nil {
-			return nil, err
-		}
-		p.storeVerificationInfo(nestedApi)
-		apiAstList = append(apiAstList, nestedApi)
-		list, err := p.invokeImportedApi(impPath, nestedApi.Import)
-		p.importStatck.pop()
-		apiAstList = append(apiAstList, list...)
-
-		if err != nil {
-			return nil, err
-		}
-	}
-	return apiAstList, nil
-}
-
-func (p *Parser) alreadyImported(filename string) bool {
-	_, ok := p.fileMap[filename]
-	return ok
-}
-
-func (p *Parser) invoke(linePrefix, content string) (v *Api, err error) {
-	defer func() {
-		p := recover()
-		if p != nil {
-			switch e := p.(type) {
-			case error:
-				err = e
-			default:
-				err = fmt.Errorf("%+v", p)
-			}
-		}
-	}()
-
-	if linePrefix != "" {
-		p.linePrefix = linePrefix
-	}
-
-	inputStream := antlr.NewInputStream(content)
-	lexer := api.NewApiParserLexer(inputStream)
-	lexer.RemoveErrorListeners()
-	tokens := antlr.NewCommonTokenStream(lexer, antlr.LexerDefaultTokenChannel)
-	apiParser := api.NewApiParserParser(tokens)
-	apiParser.RemoveErrorListeners()
-	apiParser.AddErrorListener(p)
-	var visitorOptions []VisitorOption
-	visitorOptions = append(visitorOptions, WithVisitorPrefix(p.linePrefix))
-	if p.debug {
-		visitorOptions = append(visitorOptions, WithVisitorDebug())
-	}
-
-	visitor := NewApiVisitor(visitorOptions...)
-	v = apiParser.Api().Accept(visitor).(*Api)
-	v.LinePrefix = p.linePrefix
-	return
-}
-
-// storeVerificationInfo stores information for verification
-func (p *Parser) storeVerificationInfo(api *Api) {
-	routeMap := func(list []*ServiceRoute, prefix string) {
-		for _, g := range list {
-			handler := g.GetHandler()
-			if handler.IsNotNil() {
-				handlerName := handler.Text()
-				p.handlerMap[handlerName] = Holder
-				route := fmt.Sprintf("%s://%s", g.Route.Method.Text(), path.Join(prefix, g.Route.Path.Text()))
-				p.routeMap[route] = Holder
-			}
-		}
-	}
-
-	for _, each := range api.Service {
-		var prefix string
-		if each.AtServer != nil {
-			pExp := each.AtServer.Kv.Get(prefixKey)
-			if pExp != nil {
-				prefix = pExp.Text()
-			}
-		}
-		routeMap(each.ServiceApi.ServiceRoute, prefix)
-	}
-
-	for _, each := range api.Type {
-		p.typeMap[each.NameExpr().Text()] = Holder
-	}
-}
-
-func (p *Parser) valid(nestedApi *Api) error {
-	if p.syntax != nil && nestedApi.Syntax != nil {
-		if p.syntax.Version.Text() != nestedApi.Syntax.Version.Text() {
-			syntaxToken := nestedApi.Syntax.Syntax
-			return fmt.Errorf("%s line %d:%d multiple syntax declaration, expecting syntax '%s', but found '%s'",
-				nestedApi.LinePrefix, syntaxToken.Line(), syntaxToken.Column(), p.syntax.Version.Text(), nestedApi.Syntax.Version.Text())
-		}
-	}
-
-	// duplicate route check
-	err := p.duplicateRouteCheck(nestedApi)
-	if err != nil {
-		return err
-	}
-
-	// duplicate type check
-	for _, each := range nestedApi.Type {
-		if _, ok := p.typeMap[each.NameExpr().Text()]; ok {
-			return fmt.Errorf("%s line %d:%d duplicate type declaration '%s'",
-				nestedApi.LinePrefix, each.NameExpr().Line(), each.NameExpr().Column(), each.NameExpr().Text())
-		}
-	}
-
-	return nil
-}
-
-func (p *Parser) duplicateRouteCheck(nestedApi *Api) error {
-	for _, each := range nestedApi.Service {
-		var prefix, group string
-		if each.AtServer != nil {
-			p := each.AtServer.Kv.Get(prefixKey)
-			if p != nil {
-				prefix = p.Text()
-			}
-			g := each.AtServer.Kv.Get(groupKey)
-			if g != nil {
-				group = g.Text()
-			}
-		}
-		for _, r := range each.ServiceApi.ServiceRoute {
-			handler := r.GetHandler()
-			if !handler.IsNotNil() {
-				return fmt.Errorf("%s handler not exist near line %d", nestedApi.LinePrefix, r.Route.Method.Line())
-			}
-
-			handlerKey := handler.Text()
-			if len(group) > 0 {
-				handlerKey = fmt.Sprintf("%s/%s", group, handler.Text())
-			}
-			if _, ok := p.handlerMap[handlerKey]; ok {
-				return fmt.Errorf("%s line %d:%d duplicate handler '%s'",
-					nestedApi.LinePrefix, handler.Line(), handler.Column(), handlerKey)
-			}
-
-			routeKey := fmt.Sprintf("%s://%s", r.Route.Method.Text(), path.Join(prefix, r.Route.Path.Text()))
-			if _, ok := p.routeMap[routeKey]; ok {
-				return fmt.Errorf("%s line %d:%d duplicate route '%s'",
-					nestedApi.LinePrefix, r.Route.Method.Line(), r.Route.Method.Column(), r.Route.Method.Text()+" "+r.Route.Path.Text())
-			}
-		}
-	}
-	return nil
-}
-
-func (p *Parser) nestedApiCheck(mainApi, nestedApi *Api) error {
-	if len(nestedApi.Import) > 0 {
-		importToken := nestedApi.Import[0].Import
-		return fmt.Errorf("%s line %d:%d the nested api does not support import",
-			nestedApi.LinePrefix, importToken.Line(), importToken.Column())
-	}
-
-	if mainApi.Syntax != nil && nestedApi.Syntax != nil {
-		if mainApi.Syntax.Version.Text() != nestedApi.Syntax.Version.Text() {
-			syntaxToken := nestedApi.Syntax.Syntax
-			return fmt.Errorf("%s line %d:%d multiple syntax declaration, expecting syntax '%s', but found '%s'",
-				nestedApi.LinePrefix, syntaxToken.Line(), syntaxToken.Column(), mainApi.Syntax.Version.Text(), nestedApi.Syntax.Version.Text())
-		}
-	}
-
-	if len(mainApi.Service) > 0 {
-		mainService := mainApi.Service[0]
-		for _, service := range nestedApi.Service {
-			if mainService.ServiceApi.Name.Text() != service.ServiceApi.Name.Text() {
-				return fmt.Errorf("%s multiple service name declaration, expecting service name '%s', but found '%s'",
-					nestedApi.LinePrefix, mainService.ServiceApi.Name.Text(), service.ServiceApi.Name.Text())
-			}
-		}
-	}
-	return nil
-}
-
-func (p *Parser) memberFill(apiList []*Api) *Api {
-	var root Api
-	for index, each := range apiList {
-		if index == 0 {
-			root.Syntax = each.Syntax
-			root.Info = each.Info
-			root.Import = each.Import
-		}
-
-		root.Type = append(root.Type, each.Type...)
-		root.Service = append(root.Service, each.Service...)
-	}
-
-	return &root
-}
-
-// checkTypeDeclaration checks whether a struct type has been declared in context
-func (p *Parser) checkTypeDeclaration(apiList []*Api) error {
-	types := make(map[string]TypeExpr)
-
-	for _, root := range apiList {
-		for _, each := range root.Type {
-			types[each.NameExpr().Text()] = each
-		}
-	}
-
-	for _, apiItem := range apiList {
-		linePrefix := apiItem.LinePrefix
-		err := p.checkTypes(apiItem, linePrefix, types)
-		if err != nil {
-			return err
-		}
-
-		err = p.checkServices(apiItem, types, linePrefix)
-		if err != nil {
-			return err
-		}
-	}
-	return nil
-}
-
-func (p *Parser) checkServices(apiItem *Api, types map[string]TypeExpr, linePrefix string) error {
-	for _, service := range apiItem.Service {
-		for _, each := range service.ServiceApi.ServiceRoute {
-			route := each.Route
-			err := p.checkRequestBody(route, types, linePrefix)
-			if err != nil {
-				return err
-			}
-
-			if route.Reply != nil && route.Reply.Name.IsNotNil() && route.Reply.Name.Expr().IsNotNil() {
-				reply := route.Reply.Name
-				var structName string
-				switch tp := reply.(type) {
-				case *Literal:
-					structName = tp.Literal.Text()
-				case *Array:
-					switch innerTp := tp.Literal.(type) {
-					case *Literal:
-						structName = innerTp.Literal.Text()
-					case *Pointer:
-						structName = innerTp.Name.Text()
-					}
-				}
-
-				if api.IsBasicType(structName) {
-					continue
-				}
-
-				_, ok := types[structName]
-				if !ok {
-					return fmt.Errorf("%s line %d:%d can not find declaration '%s' in context",
-						linePrefix, route.Reply.Name.Expr().Line(), route.Reply.Name.Expr().Column(), structName)
-				}
-			}
-		}
-	}
-	return nil
-}
-
-func (p *Parser) checkRequestBody(route *Route, types map[string]TypeExpr, linePrefix string) error {
-	if route.Req != nil && route.Req.Name.IsNotNil() && route.Req.Name.Expr().IsNotNil() {
-		_, ok := types[route.Req.Name.Expr().Text()]
-		if !ok {
-			return fmt.Errorf("%s line %d:%d can not find declaration '%s' in context",
-				linePrefix, route.Req.Name.Expr().Line(), route.Req.Name.Expr().Column(), route.Req.Name.Expr().Text())
-		}
-	}
-	return nil
-}
-
-func (p *Parser) checkTypes(apiItem *Api, linePrefix string, types map[string]TypeExpr) error {
-	for _, each := range apiItem.Type {
-		tp, ok := each.(*TypeStruct)
-		if !ok {
-			continue
-		}
-
-		for _, member := range tp.Fields {
-			err := p.checkType(linePrefix, types, member.DataType)
-			if err != nil {
-				return err
-			}
-		}
-	}
-	return nil
-}
-
-func (p *Parser) checkType(linePrefix string, types map[string]TypeExpr, expr DataType) error {
-	if expr == nil {
-		return nil
-	}
-
-	switch v := expr.(type) {
-	case *Literal:
-		name := v.Literal.Text()
-		if api.IsBasicType(name) {
-			return nil
-		}
-		_, ok := types[name]
-		if !ok {
-			return fmt.Errorf("%s line %d:%d can not find declaration '%s' in context",
-				linePrefix, v.Literal.Line(), v.Literal.Column(), name)
-		}
-
-	case *Pointer:
-		name := v.Name.Text()
-		if api.IsBasicType(name) {
-			return nil
-		}
-		_, ok := types[name]
-		if !ok {
-			return fmt.Errorf("%s line %d:%d can not find declaration '%s' in context",
-				linePrefix, v.Name.Line(), v.Name.Column(), name)
-		}
-	case *Map:
-		return p.checkType(linePrefix, types, v.Value)
-	case *Array:
-		return p.checkType(linePrefix, types, v.Literal)
-	default:
-		return nil
-	}
-	return nil
-}
-
-func (p *Parser) readContent(filename string) (string, error) {
-	filename = strings.ReplaceAll(filename, `"`, "")
-	data, err := os.ReadFile(filename)
-	if err != nil {
-		return "", err
-	}
-
-	return string(data), nil
-}
-
-// SyntaxError accepts errors and panic it
-func (p *Parser) SyntaxError(_ antlr.Recognizer, _ any, line, column int, msg string, _ antlr.RecognitionException) {
-	str := fmt.Sprintf(`%s line %d:%d  %s`, p.linePrefix, line, column, msg)
-	if p.debug {
-		p.log.Error(str)
-	}
-	panic(str)
-}
-
-// WithParserDebug returns a debug ParserOption
-func WithParserDebug() ParserOption {
-	return func(p *Parser) {
-		p.debug = true
-	}
-}
-
-// WithParserPrefix returns a prefix ParserOption
-func WithParserPrefix(prefix string) ParserOption {
-	return func(p *Parser) {
-		p.linePrefix = prefix
-	}
-}
-
-func WithParserSkipCheckTypeDeclaration() ParserOption {
-	return func(p *Parser) {
-		p.skipCheckTypeDeclaration = true
-	}
-}

+ 0 - 98
tools/goctlwt/api/parser/g4/ast/apiparser_test.go

@@ -1,98 +0,0 @@
-package ast
-
-import (
-	"os"
-	"path/filepath"
-	"testing"
-
-	"github.com/stretchr/testify/assert"
-	"github.com/stretchr/testify/require"
-	"github.com/wuntsong-org/go-zero-plus/tools/goctlwt/util/pathx"
-)
-
-func Test_ImportCycle(t *testing.T) {
-	const (
-		mainFilename = "main.api"
-		subAFilename = "a.api"
-		subBFilename = "b.api"
-		mainSrc      = `import "./a.api"`
-		subASrc      = `import "./b.api"`
-		subBSrc      = `import "./a.api"`
-	)
-	var err error
-	dir := pathx.MustTempDir()
-	defer os.RemoveAll(dir)
-
-	mainPath := filepath.Join(dir, mainFilename)
-	err = os.WriteFile(mainPath, []byte(mainSrc), 0o777)
-	require.NoError(t, err)
-	subAPath := filepath.Join(dir, subAFilename)
-	err = os.WriteFile(subAPath, []byte(subASrc), 0o777)
-	require.NoError(t, err)
-	subBPath := filepath.Join(dir, subBFilename)
-	err = os.WriteFile(subBPath, []byte(subBSrc), 0o777)
-	require.NoError(t, err)
-
-	_, err = NewParser().Parse(mainPath)
-	assert.ErrorIs(t, err, ErrImportCycleNotAllowed)
-}
-
-func Test_MultiImportedShouldAllowed(t *testing.T) {
-	const (
-		mainFilename = "main.api"
-		subAFilename = "a.api"
-		subBFilename = "b.api"
-		mainSrc      = "import \"./b.api\"\n" +
-			"import \"./a.api\"\n" +
-			"type Main { b B `json:\"b\"`}"
-		subASrc = "import \"./b.api\"\n" +
-			"type A { b B `json:\"b\"`}\n"
-		subBSrc = `type B{}`
-	)
-	var err error
-	dir := pathx.MustTempDir()
-	defer os.RemoveAll(dir)
-
-	mainPath := filepath.Join(dir, mainFilename)
-	err = os.WriteFile(mainPath, []byte(mainSrc), 0o777)
-	require.NoError(t, err)
-	subAPath := filepath.Join(dir, subAFilename)
-	err = os.WriteFile(subAPath, []byte(subASrc), 0o777)
-	require.NoError(t, err)
-	subBPath := filepath.Join(dir, subBFilename)
-	err = os.WriteFile(subBPath, []byte(subBSrc), 0o777)
-	require.NoError(t, err)
-
-	_, err = NewParser().Parse(mainPath)
-	assert.NoError(t, err)
-}
-
-func Test_RedundantDeclarationShouldNotBeAllowed(t *testing.T) {
-	const (
-		mainFilename = "main.api"
-		subAFilename = "a.api"
-		subBFilename = "b.api"
-		mainSrc      = "import \"./a.api\"\n" +
-			"import \"./b.api\"\n"
-		subASrc = `import "./b.api"
-							 type A{}`
-		subBSrc = `type A{}`
-	)
-	var err error
-	dir := pathx.MustTempDir()
-	defer os.RemoveAll(dir)
-
-	mainPath := filepath.Join(dir, mainFilename)
-	err = os.WriteFile(mainPath, []byte(mainSrc), 0o777)
-	require.NoError(t, err)
-	subAPath := filepath.Join(dir, subAFilename)
-	err = os.WriteFile(subAPath, []byte(subASrc), 0o777)
-	require.NoError(t, err)
-	subBPath := filepath.Join(dir, subBFilename)
-	err = os.WriteFile(subBPath, []byte(subBSrc), 0o777)
-	require.NoError(t, err)
-
-	_, err = NewParser().Parse(mainPath)
-	assert.Error(t, err)
-	assert.Contains(t, err.Error(), "duplicate type declaration")
-}

+ 0 - 317
tools/goctlwt/api/parser/g4/ast/ast.go

@@ -1,317 +0,0 @@
-package ast
-
-import (
-	"fmt"
-	"sort"
-	"strings"
-
-	"github.com/wuntsong-org/go-zero-plus/tools/goctlwt/api/parser/g4/gen/api"
-	"github.com/wuntsong-org/go-zero-plus/tools/goctlwt/util/console"
-	"github.com/zeromicro/antlr"
-)
-
-type (
-	// TokenStream defines a token
-	TokenStream interface {
-		GetStart() antlr.Token
-		GetStop() antlr.Token
-		GetParser() antlr.Parser
-	}
-
-	// ApiVisitor wraps api.BaseApiParserVisitor to call methods which has prefix Visit to
-	// visit node from the api syntax
-	ApiVisitor struct {
-		*api.BaseApiParserVisitor
-		debug    bool
-		log      console.Console
-		prefix   string
-		infoFlag bool
-	}
-
-	// VisitorOption defines a function with argument ApiVisitor
-	VisitorOption func(v *ApiVisitor)
-
-	// Spec describes api spec
-	Spec interface {
-		Doc() []Expr
-		Comment() Expr
-		Format() error
-		Equal(v any) bool
-	}
-
-	// Expr describes ast expression
-	Expr interface {
-		Prefix() string
-		Line() int
-		Column() int
-		Text() string
-		SetText(text string)
-		Start() int
-		Stop() int
-		Equal(expr Expr) bool
-		IsNotNil() bool
-	}
-)
-
-// NewApiVisitor creates an instance for ApiVisitor
-func NewApiVisitor(options ...VisitorOption) *ApiVisitor {
-	v := &ApiVisitor{
-		log: console.NewColorConsole(),
-	}
-	for _, opt := range options {
-		opt(v)
-	}
-	return v
-}
-
-func (v *ApiVisitor) panic(expr Expr, msg string) {
-	errString := fmt.Sprintf("%s line %d:%d  %s", v.prefix, expr.Line(), expr.Column(), msg)
-	if v.debug {
-		fmt.Println(errString)
-	}
-
-	panic(errString)
-}
-
-// WithVisitorPrefix returns a VisitorOption wrap with specified prefix
-func WithVisitorPrefix(prefix string) VisitorOption {
-	return func(v *ApiVisitor) {
-		v.prefix = prefix
-	}
-}
-
-// WithVisitorDebug returns a debug VisitorOption
-func WithVisitorDebug() VisitorOption {
-	return func(v *ApiVisitor) {
-		v.debug = true
-	}
-}
-
-type defaultExpr struct {
-	prefix, v    string
-	line, column int
-	start, stop  int
-}
-
-// NewTextExpr creates a default instance for Expr
-func NewTextExpr(v string) *defaultExpr {
-	return &defaultExpr{
-		v: v,
-	}
-}
-
-func (v *ApiVisitor) newExprWithTerminalNode(node antlr.TerminalNode) *defaultExpr {
-	if node == nil {
-		return nil
-	}
-
-	token := node.GetSymbol()
-	return v.newExprWithToken(token)
-}
-
-func (v *ApiVisitor) newExprWithToken(token antlr.Token) *defaultExpr {
-	if token == nil {
-		return nil
-	}
-
-	instance := &defaultExpr{}
-	instance.prefix = v.prefix
-	instance.v = token.GetText()
-	instance.line = token.GetLine()
-	instance.column = token.GetColumn()
-	instance.start = token.GetStart()
-	instance.stop = token.GetStop()
-
-	return instance
-}
-
-func (v *ApiVisitor) newExprWithText(text string, line, column, start, stop int) *defaultExpr {
-	instance := &defaultExpr{}
-	instance.prefix = v.prefix
-	instance.v = text
-	instance.line = line
-	instance.column = column
-	instance.start = start
-	instance.stop = stop
-
-	return instance
-}
-
-func (e *defaultExpr) Prefix() string {
-	if e == nil {
-		return ""
-	}
-
-	return e.prefix
-}
-
-func (e *defaultExpr) Line() int {
-	if e == nil {
-		return 0
-	}
-
-	return e.line
-}
-
-func (e *defaultExpr) Column() int {
-	if e == nil {
-		return 0
-	}
-
-	return e.column
-}
-
-func (e *defaultExpr) Text() string {
-	if e == nil {
-		return ""
-	}
-
-	return e.v
-}
-
-func (e *defaultExpr) SetText(text string) {
-	if e == nil {
-		return
-	}
-
-	e.v = text
-}
-
-func (e *defaultExpr) Start() int {
-	if e == nil {
-		return 0
-	}
-
-	return e.start
-}
-
-func (e *defaultExpr) Stop() int {
-	if e == nil {
-		return 0
-	}
-
-	return e.stop
-}
-
-func (e *defaultExpr) Equal(expr Expr) bool {
-	if e == nil {
-		return expr == nil
-	}
-
-	if expr == nil {
-		return false
-	}
-
-	return e.v == expr.Text()
-}
-
-func (e *defaultExpr) IsNotNil() bool {
-	return e != nil
-}
-
-// EqualDoc compares whether the element literals in two Spec are equal
-func EqualDoc(spec1, spec2 Spec) bool {
-	if spec1 == nil {
-		return spec2 == nil
-	}
-
-	if spec2 == nil {
-		return false
-	}
-
-	var expectDoc, actualDoc []Expr
-	expectDoc = append(expectDoc, spec2.Doc()...)
-	actualDoc = append(actualDoc, spec1.Doc()...)
-	sort.Slice(expectDoc, func(i, j int) bool {
-		return expectDoc[i].Line() < expectDoc[j].Line()
-	})
-
-	for index, each := range actualDoc {
-		if !each.Equal(actualDoc[index]) {
-			return false
-		}
-	}
-
-	if spec1.Comment() != nil {
-		if spec2.Comment() == nil {
-			return false
-		}
-
-		if !spec1.Comment().Equal(spec2.Comment()) {
-			return false
-		}
-	} else {
-		if spec2.Comment() != nil {
-			return false
-		}
-	}
-
-	return true
-}
-
-func (v *ApiVisitor) getDoc(t TokenStream) []Expr {
-	return v.getHiddenTokensToLeft(t, api.COMMENTS, false)
-}
-
-func (v *ApiVisitor) getComment(t TokenStream) Expr {
-	list := v.getHiddenTokensToRight(t, api.COMMENTS)
-	if len(list) == 0 {
-		return nil
-	}
-
-	commentExpr := list[0]
-	stop := t.GetStop()
-	text := stop.GetText()
-	nlCount := strings.Count(text, "\n")
-
-	if commentExpr.Line() != stop.GetLine()+nlCount {
-		return nil
-	}
-
-	return commentExpr
-}
-
-func (v *ApiVisitor) getHiddenTokensToLeft(t TokenStream, channel int, containsCommentOfDefaultChannel bool) []Expr {
-	ct := t.GetParser().GetTokenStream().(*antlr.CommonTokenStream)
-	tokens := ct.GetHiddenTokensToLeft(t.GetStart().GetTokenIndex(), channel)
-
-	var list []Expr
-	for _, each := range tokens {
-		if !containsCommentOfDefaultChannel {
-			index := each.GetTokenIndex() - 1
-
-			if index > 0 {
-				allTokens := ct.GetAllTokens()
-				flag := false
-				for i := index; i >= 0; i-- {
-					tk := allTokens[i]
-					if tk.GetChannel() == antlr.LexerDefaultTokenChannel {
-						if tk.GetLine() == each.GetLine() {
-							flag = true
-							break
-						}
-					}
-				}
-
-				if flag {
-					continue
-				}
-			}
-		}
-
-		list = append(list, v.newExprWithToken(each))
-	}
-
-	return list
-}
-
-func (v *ApiVisitor) getHiddenTokensToRight(t TokenStream, channel int) []Expr {
-	ct := t.GetParser().GetTokenStream().(*antlr.CommonTokenStream)
-	tokens := ct.GetHiddenTokensToRight(t.GetStop().GetTokenIndex(), channel)
-	var list []Expr
-	for _, each := range tokens {
-		list = append(list, v.newExprWithToken(each))
-	}
-
-	return list
-}

+ 0 - 106
tools/goctlwt/api/parser/g4/ast/import.go

@@ -1,106 +0,0 @@
-package ast
-
-import (
-	"github.com/wuntsong-org/go-zero-plus/tools/goctlwt/api/parser/g4/gen/api"
-)
-
-// ImportExpr defines import syntax for api
-type ImportExpr struct {
-	Import      Expr
-	Value       Expr
-	DocExpr     []Expr
-	CommentExpr Expr
-}
-
-// VisitImportSpec implements from api.BaseApiParserVisitor
-func (v *ApiVisitor) VisitImportSpec(ctx *api.ImportSpecContext) any {
-	var list []*ImportExpr
-	if ctx.ImportLit() != nil {
-		lits := ctx.ImportLit().Accept(v).([]*ImportExpr)
-		list = append(list, lits...)
-	}
-	if ctx.ImportBlock() != nil {
-		blocks := ctx.ImportBlock().Accept(v).([]*ImportExpr)
-		list = append(list, blocks...)
-	}
-
-	return list
-}
-
-// VisitImportLit implements from api.BaseApiParserVisitor
-func (v *ApiVisitor) VisitImportLit(ctx *api.ImportLitContext) any {
-	importToken := v.newExprWithToken(ctx.GetImportToken())
-	valueExpr := ctx.ImportValue().Accept(v).(Expr)
-	return []*ImportExpr{
-		{
-			Import:      importToken,
-			Value:       valueExpr,
-			DocExpr:     v.getDoc(ctx),
-			CommentExpr: v.getComment(ctx),
-		},
-	}
-}
-
-// VisitImportBlock implements from api.BaseApiParserVisitor
-func (v *ApiVisitor) VisitImportBlock(ctx *api.ImportBlockContext) any {
-	importToken := v.newExprWithToken(ctx.GetImportToken())
-	values := ctx.AllImportBlockValue()
-	var list []*ImportExpr
-
-	for _, value := range values {
-		importExpr := value.Accept(v).(*ImportExpr)
-		importExpr.Import = importToken
-		list = append(list, importExpr)
-	}
-
-	return list
-}
-
-// VisitImportBlockValue implements from api.BaseApiParserVisitor
-func (v *ApiVisitor) VisitImportBlockValue(ctx *api.ImportBlockValueContext) any {
-	value := ctx.ImportValue().Accept(v).(Expr)
-	return &ImportExpr{
-		Value:       value,
-		DocExpr:     v.getDoc(ctx),
-		CommentExpr: v.getComment(ctx),
-	}
-}
-
-// VisitImportValue implements from api.BaseApiParserVisitor
-func (v *ApiVisitor) VisitImportValue(ctx *api.ImportValueContext) any {
-	return v.newExprWithTerminalNode(ctx.STRING())
-}
-
-// Format provides a formatter for api command, now nothing to do
-func (i *ImportExpr) Format() error {
-	// todo
-	return nil
-}
-
-// Equal compares whether the element literals in two ImportExpr are equal
-func (i *ImportExpr) Equal(v any) bool {
-	if v == nil {
-		return false
-	}
-
-	imp, ok := v.(*ImportExpr)
-	if !ok {
-		return false
-	}
-
-	if !EqualDoc(i, imp) {
-		return false
-	}
-
-	return i.Import.Equal(imp.Import) && i.Value.Equal(imp.Value)
-}
-
-// Doc returns the document of ImportExpr, like // some text
-func (i *ImportExpr) Doc() []Expr {
-	return i.DocExpr
-}
-
-// Comment returns the comment of ImportExpr, like // some text
-func (i *ImportExpr) Comment() Expr {
-	return i.CommentExpr
-}

+ 0 - 23
tools/goctlwt/api/parser/g4/ast/importstack.go

@@ -1,23 +0,0 @@
-package ast
-
-import "errors"
-
-// ErrImportCycleNotAllowed defines an error for circular importing
-var ErrImportCycleNotAllowed = errors.New("import cycle not allowed")
-
-// importStack a stack of import paths
-type importStack []string
-
-func (s *importStack) push(p string) error {
-	for _, x := range *s {
-		if x == p {
-			return ErrImportCycleNotAllowed
-		}
-	}
-	*s = append(*s, p)
-	return nil
-}
-
-func (s *importStack) pop() {
-	*s = (*s)[0 : len(*s)-1]
-}

+ 0 - 71
tools/goctlwt/api/parser/g4/ast/info.go

@@ -1,71 +0,0 @@
-package ast
-
-import (
-	"github.com/wuntsong-org/go-zero-plus/tools/goctlwt/api/parser/g4/gen/api"
-)
-
-// InfoExpr defines info syntax for api
-type InfoExpr struct {
-	Info Expr
-	Lp   Expr
-	Rp   Expr
-	Kvs  []*KvExpr
-}
-
-// VisitInfoSpec implements from api.BaseApiParserVisitor
-func (v *ApiVisitor) VisitInfoSpec(ctx *api.InfoSpecContext) any {
-	var expr InfoExpr
-	expr.Info = v.newExprWithToken(ctx.GetInfoToken())
-	expr.Lp = v.newExprWithToken(ctx.GetLp())
-	expr.Rp = v.newExprWithToken(ctx.GetRp())
-	list := ctx.AllKvLit()
-	for _, each := range list {
-		kvExpr := each.Accept(v).(*KvExpr)
-		expr.Kvs = append(expr.Kvs, kvExpr)
-	}
-
-	if v.infoFlag {
-		v.panic(expr.Info, "duplicate declaration 'info'")
-	}
-
-	return &expr
-}
-
-// Format provides a formatter for api command, now nothing to do
-func (i *InfoExpr) Format() error {
-	// todo
-	return nil
-}
-
-// Equal compares whether the element literals in two InfoExpr are equal
-func (i *InfoExpr) Equal(v any) bool {
-	if v == nil {
-		return false
-	}
-
-	info, ok := v.(*InfoExpr)
-	if !ok {
-		return false
-	}
-
-	if !i.Info.Equal(info.Info) {
-		return false
-	}
-
-	var expected, actual []*KvExpr
-	expected = append(expected, i.Kvs...)
-	actual = append(actual, info.Kvs...)
-
-	if len(expected) != len(actual) {
-		return false
-	}
-
-	for index, each := range expected {
-		ac := actual[index]
-		if !each.Equal(ac) {
-			return false
-		}
-	}
-
-	return true
-}

+ 0 - 85
tools/goctlwt/api/parser/g4/ast/kv.go

@@ -1,85 +0,0 @@
-package ast
-
-import (
-	"strings"
-
-	"github.com/wuntsong-org/go-zero-plus/tools/goctlwt/api/parser/g4/gen/api"
-)
-
-// KvExpr describes key-value for api
-type KvExpr struct {
-	Key         Expr
-	Value       Expr
-	DocExpr     []Expr
-	CommentExpr Expr
-}
-
-// VisitKvLit implements from api.BaseApiParserVisitor
-func (v *ApiVisitor) VisitKvLit(ctx *api.KvLitContext) any {
-	var kvExpr KvExpr
-	kvExpr.Key = v.newExprWithToken(ctx.GetKey())
-	commentExpr := v.getComment(ctx)
-	if ctx.GetValue() != nil {
-		valueText := ctx.GetValue().GetText()
-		valueExpr := v.newExprWithToken(ctx.GetValue())
-		if strings.Contains(valueText, "//") {
-			if commentExpr == nil {
-				commentExpr = v.newExprWithToken(ctx.GetValue())
-				commentExpr.SetText("")
-			}
-
-			index := strings.Index(valueText, "//")
-			commentExpr.SetText(valueText[index:])
-			valueExpr.SetText(strings.TrimSpace(valueText[:index]))
-		} else if strings.Contains(valueText, "/*") {
-			if commentExpr == nil {
-				commentExpr = v.newExprWithToken(ctx.GetValue())
-				commentExpr.SetText("")
-			}
-
-			index := strings.Index(valueText, "/*")
-			commentExpr.SetText(valueText[index:])
-			valueExpr.SetText(strings.TrimSpace(valueText[:index]))
-		}
-
-		kvExpr.Value = valueExpr
-	}
-
-	kvExpr.DocExpr = v.getDoc(ctx)
-	kvExpr.CommentExpr = commentExpr
-	return &kvExpr
-}
-
-// Format provides a formatter for api command, now nothing to do
-func (k *KvExpr) Format() error {
-	// todo
-	return nil
-}
-
-// Equal compares whether the element literals in two KvExpr are equal
-func (k *KvExpr) Equal(v any) bool {
-	if v == nil {
-		return false
-	}
-
-	kv, ok := v.(*KvExpr)
-	if !ok {
-		return false
-	}
-
-	if !EqualDoc(k, kv) {
-		return false
-	}
-
-	return k.Key.Equal(kv.Key) && k.Value.Equal(kv.Value)
-}
-
-// Doc returns the document of KvExpr, like // some text
-func (k *KvExpr) Doc() []Expr {
-	return k.DocExpr
-}
-
-// Comment returns the comment of KvExpr, like // some text
-func (k *KvExpr) Comment() Expr {
-	return k.CommentExpr
-}

+ 0 - 7
tools/goctlwt/api/parser/g4/ast/placeholder.go

@@ -1,7 +0,0 @@
-package ast
-
-// Holder defines a default instance for PlaceHolder
-var Holder PlaceHolder
-
-// PlaceHolder defines an empty struct
-type PlaceHolder struct{}

+ 0 - 660
tools/goctlwt/api/parser/g4/ast/service.go

@@ -1,660 +0,0 @@
-package ast
-
-import (
-	"fmt"
-	"sort"
-
-	"github.com/wuntsong-org/go-zero-plus/tools/goctlwt/api/parser/g4/gen/api"
-)
-
-// Service describes service for api syntax
-type Service struct {
-	AtServer   *AtServer
-	ServiceApi *ServiceApi
-}
-
-// KV defines a slice for KvExpr
-type KV []*KvExpr
-
-// AtServer describes server metadata for api syntax
-type AtServer struct {
-	AtServerToken Expr
-	Lp            Expr
-	Rp            Expr
-	Kv            KV
-}
-
-// ServiceApi describes service ast for api syntax
-type ServiceApi struct {
-	ServiceToken Expr
-	Name         Expr
-	Lbrace       Expr
-	Rbrace       Expr
-	ServiceRoute []*ServiceRoute
-}
-
-// ServiceRoute describes service route ast for api syntax
-type ServiceRoute struct {
-	AtDoc     *AtDoc
-	AtServer  *AtServer
-	AtHandler *AtHandler
-	Route     *Route
-}
-
-// AtDoc describes service comments ast for api syntax
-type AtDoc struct {
-	AtDocToken Expr
-	Lp         Expr
-	Rp         Expr
-	LineDoc    Expr
-	Kv         []*KvExpr
-}
-
-// AtHandler describes service handler ast for api syntax
-type AtHandler struct {
-	AtHandlerToken Expr
-	Name           Expr
-	DocExpr        []Expr
-	CommentExpr    Expr
-}
-
-// Route describes route ast for api syntax
-type Route struct {
-	Method      Expr
-	Path        Expr
-	Req         *Body
-	ReturnToken Expr
-	Reply       *Body
-	DocExpr     []Expr
-	CommentExpr Expr
-}
-
-// Body describes request,response body ast for api syntax
-type Body struct {
-	ReturnExpr Expr
-	Lp         Expr
-	Rp         Expr
-	Name       DataType
-}
-
-// VisitServiceSpec implements from api.BaseApiParserVisitor
-func (v *ApiVisitor) VisitServiceSpec(ctx *api.ServiceSpecContext) any {
-	var serviceSpec Service
-	if ctx.AtServer() != nil {
-		serviceSpec.AtServer = ctx.AtServer().Accept(v).(*AtServer)
-	}
-
-	serviceSpec.ServiceApi = ctx.ServiceApi().Accept(v).(*ServiceApi)
-	return &serviceSpec
-}
-
-// VisitAtServer implements from api.BaseApiParserVisitor
-func (v *ApiVisitor) VisitAtServer(ctx *api.AtServerContext) any {
-	var atServer AtServer
-	atServer.AtServerToken = v.newExprWithTerminalNode(ctx.ATSERVER())
-	atServer.Lp = v.newExprWithToken(ctx.GetLp())
-	atServer.Rp = v.newExprWithToken(ctx.GetRp())
-
-	for _, each := range ctx.AllKvLit() {
-		atServer.Kv = append(atServer.Kv, each.Accept(v).(*KvExpr))
-	}
-
-	return &atServer
-}
-
-// VisitServiceApi implements from api.BaseApiParserVisitor
-func (v *ApiVisitor) VisitServiceApi(ctx *api.ServiceApiContext) any {
-	var serviceApi ServiceApi
-	serviceApi.ServiceToken = v.newExprWithToken(ctx.GetServiceToken())
-	serviceName := ctx.ServiceName()
-	serviceApi.Name = v.newExprWithText(serviceName.GetText(), serviceName.GetStart().GetLine(), serviceName.GetStart().GetColumn(), serviceName.GetStart().GetStart(), serviceName.GetStop().GetStop())
-	serviceApi.Lbrace = v.newExprWithToken(ctx.GetLbrace())
-	serviceApi.Rbrace = v.newExprWithToken(ctx.GetRbrace())
-
-	for _, each := range ctx.AllServiceRoute() {
-		serviceApi.ServiceRoute = append(serviceApi.ServiceRoute, each.Accept(v).(*ServiceRoute))
-	}
-
-	return &serviceApi
-}
-
-// VisitServiceRoute implements from api.BaseApiParserVisitor
-func (v *ApiVisitor) VisitServiceRoute(ctx *api.ServiceRouteContext) any {
-	var serviceRoute ServiceRoute
-	if ctx.AtDoc() != nil {
-		serviceRoute.AtDoc = ctx.AtDoc().Accept(v).(*AtDoc)
-	}
-
-	if ctx.AtServer() != nil {
-		serviceRoute.AtServer = ctx.AtServer().Accept(v).(*AtServer)
-	} else if ctx.AtHandler() != nil {
-		serviceRoute.AtHandler = ctx.AtHandler().Accept(v).(*AtHandler)
-	}
-
-	serviceRoute.Route = ctx.Route().Accept(v).(*Route)
-	return &serviceRoute
-}
-
-// VisitAtDoc implements from api.BaseApiParserVisitor
-func (v *ApiVisitor) VisitAtDoc(ctx *api.AtDocContext) any {
-	var atDoc AtDoc
-	atDoc.AtDocToken = v.newExprWithTerminalNode(ctx.ATDOC())
-
-	if ctx.STRING() != nil {
-		atDoc.LineDoc = v.newExprWithTerminalNode(ctx.STRING())
-	} else {
-		for _, each := range ctx.AllKvLit() {
-			atDoc.Kv = append(atDoc.Kv, each.Accept(v).(*KvExpr))
-		}
-	}
-	atDoc.Lp = v.newExprWithToken(ctx.GetLp())
-	atDoc.Rp = v.newExprWithToken(ctx.GetRp())
-
-	if ctx.GetLp() != nil {
-		if ctx.GetRp() == nil {
-			v.panic(atDoc.Lp, "mismatched ')'")
-		}
-	}
-
-	if ctx.GetRp() != nil {
-		if ctx.GetLp() == nil {
-			v.panic(atDoc.Rp, "mismatched '('")
-		}
-	}
-
-	return &atDoc
-}
-
-// VisitAtHandler implements from api.BaseApiParserVisitor
-func (v *ApiVisitor) VisitAtHandler(ctx *api.AtHandlerContext) any {
-	var atHandler AtHandler
-	astHandlerExpr := v.newExprWithTerminalNode(ctx.ATHANDLER())
-	atHandler.AtHandlerToken = astHandlerExpr
-	atHandler.Name = v.newExprWithTerminalNode(ctx.ID())
-	atHandler.DocExpr = v.getDoc(ctx)
-	atHandler.CommentExpr = v.getComment(ctx)
-	return &atHandler
-}
-
-// VisitRoute implements from api.BaseApiParserVisitor
-func (v *ApiVisitor) VisitRoute(ctx *api.RouteContext) any {
-	var route Route
-	path := ctx.Path()
-	methodExpr := v.newExprWithToken(ctx.GetHttpMethod())
-	route.Method = methodExpr
-	route.Path = v.newExprWithText(path.GetText(), path.GetStart().GetLine(), path.GetStart().GetColumn(), path.GetStart().GetStart(), path.GetStop().GetStop())
-
-	if ctx.GetRequest() != nil {
-		req := ctx.GetRequest().Accept(v)
-		if req != nil {
-			route.Req = req.(*Body)
-		}
-	}
-
-	if ctx.GetResponse() != nil {
-		reply := ctx.GetResponse().Accept(v)
-		if reply != nil {
-			resp := reply.(*Body)
-			route.ReturnToken = resp.ReturnExpr
-			resp.ReturnExpr = nil
-			route.Reply = resp
-		}
-	}
-
-	route.DocExpr = v.getDoc(ctx)
-	route.CommentExpr = v.getComment(ctx)
-	return &route
-}
-
-// VisitBody implements from api.BaseApiParserVisitor
-func (v *ApiVisitor) VisitBody(ctx *api.BodyContext) any {
-	if ctx.ID() == nil {
-		if v.debug {
-			msg := fmt.Sprintf(
-				`%s line %d:  expr "()" is deprecated, if there has no request body, please omit it`,
-				v.prefix,
-				ctx.GetStart().GetLine(),
-			)
-			v.log.Warning(msg)
-		}
-		return nil
-	}
-
-	idExpr := v.newExprWithTerminalNode(ctx.ID())
-	if api.IsGolangKeyWord(idExpr.Text()) {
-		v.panic(idExpr, fmt.Sprintf("expecting 'ID', but found golang keyword '%s'", idExpr.Text()))
-	}
-
-	return &Body{
-		Lp:   v.newExprWithToken(ctx.GetLp()),
-		Rp:   v.newExprWithToken(ctx.GetRp()),
-		Name: &Literal{Literal: idExpr},
-	}
-}
-
-// VisitReplybody implements from api.BaseApiParserVisitor
-func (v *ApiVisitor) VisitReplybody(ctx *api.ReplybodyContext) any {
-	if ctx.DataType() == nil {
-		if v.debug {
-			msg := fmt.Sprintf(
-				`%s line %d:  expr "returns ()" or "()" is deprecated, if there has no response body, please omit it`,
-				v.prefix,
-				ctx.GetStart().GetLine(),
-			)
-			v.log.Warning(msg)
-		}
-		return nil
-	}
-
-	var returnExpr Expr
-	if ctx.GetReturnToken() != nil {
-		returnExpr = v.newExprWithToken(ctx.GetReturnToken())
-		if ctx.GetReturnToken().GetText() != "returns" {
-			v.panic(returnExpr, fmt.Sprintf("expecting returns, found input '%s'", ctx.GetReturnToken().GetText()))
-		}
-	}
-
-	dt := ctx.DataType().Accept(v).(DataType)
-	if dt == nil {
-		return nil
-	}
-
-	switch dataType := dt.(type) {
-	case *Array:
-		lit := dataType.Literal
-		switch lit.(type) {
-		case *Literal, *Pointer:
-			if api.IsGolangKeyWord(lit.Expr().Text()) {
-				v.panic(lit.Expr(), fmt.Sprintf("expecting 'ID', but found golang keyword '%s'", lit.Expr().Text()))
-			}
-		default:
-			v.panic(dt.Expr(), fmt.Sprintf("unsupport %s", dt.Expr().Text()))
-		}
-	case *Literal:
-		lit := dataType.Literal.Text()
-		if api.IsGolangKeyWord(lit) {
-			v.panic(dataType.Literal, fmt.Sprintf("expecting 'ID', but found golang keyword '%s'", lit))
-		}
-	default:
-		v.panic(dt.Expr(), fmt.Sprintf("unsupport %s", dt.Expr().Text()))
-	}
-
-	return &Body{
-		ReturnExpr: returnExpr,
-		Lp:         v.newExprWithToken(ctx.GetLp()),
-		Rp:         v.newExprWithToken(ctx.GetRp()),
-		Name:       dt,
-	}
-}
-
-// Format provides a formatter for api command, now nothing to do
-func (b *Body) Format() error {
-	// todo
-	return nil
-}
-
-// Equal compares whether the element literals in two Body are equal
-func (b *Body) Equal(v any) bool {
-	if v == nil {
-		return false
-	}
-
-	body, ok := v.(*Body)
-	if !ok {
-		return false
-	}
-
-	if !b.Lp.Equal(body.Lp) {
-		return false
-	}
-
-	if !b.Rp.Equal(body.Rp) {
-		return false
-	}
-
-	return b.Name.Equal(body.Name)
-}
-
-// Format provides a formatter for api command, now nothing to do
-func (r *Route) Format() error {
-	// todo
-	return nil
-}
-
-// Doc returns the document of Route, like // some text
-func (r *Route) Doc() []Expr {
-	return r.DocExpr
-}
-
-// Comment returns the comment of Route, like // some text
-func (r *Route) Comment() Expr {
-	return r.CommentExpr
-}
-
-// Equal compares whether the element literals in two Route are equal
-func (r *Route) Equal(v any) bool {
-	if v == nil {
-		return false
-	}
-
-	route, ok := v.(*Route)
-	if !ok {
-		return false
-	}
-
-	if !r.Method.Equal(route.Method) {
-		return false
-	}
-
-	if !r.Path.Equal(route.Path) {
-		return false
-	}
-
-	if r.Req != nil {
-		if !r.Req.Equal(route.Req) {
-			return false
-		}
-	}
-
-	if r.ReturnToken != nil {
-		if !r.ReturnToken.Equal(route.ReturnToken) {
-			return false
-		}
-	}
-
-	if r.Reply != nil {
-		if !r.Reply.Equal(route.Reply) {
-			return false
-		}
-	}
-
-	return EqualDoc(r, route)
-}
-
-// Doc returns the document of AtHandler, like // some text
-func (a *AtHandler) Doc() []Expr {
-	return a.DocExpr
-}
-
-// Comment returns the comment of AtHandler, like // some text
-func (a *AtHandler) Comment() Expr {
-	return a.CommentExpr
-}
-
-// Format provides a formatter for api command, now nothing to do
-func (a *AtHandler) Format() error {
-	// todo
-	return nil
-}
-
-// Equal compares whether the element literals in two AtHandler are equal
-func (a *AtHandler) Equal(v any) bool {
-	if v == nil {
-		return false
-	}
-
-	atHandler, ok := v.(*AtHandler)
-	if !ok {
-		return false
-	}
-
-	if !a.AtHandlerToken.Equal(atHandler.AtHandlerToken) {
-		return false
-	}
-
-	if !a.Name.Equal(atHandler.Name) {
-		return false
-	}
-
-	return EqualDoc(a, atHandler)
-}
-
-// Format provides a formatter for api command, now nothing to do
-func (a *AtDoc) Format() error {
-	// todo
-	return nil
-}
-
-// Equal compares whether the element literals in two AtDoc are equal
-func (a *AtDoc) Equal(v any) bool {
-	if v == nil {
-		return false
-	}
-
-	atDoc, ok := v.(*AtDoc)
-	if !ok {
-		return false
-	}
-
-	if !a.AtDocToken.Equal(atDoc.AtDocToken) {
-		return false
-	}
-
-	if a.Lp.IsNotNil() {
-		if !a.Lp.Equal(atDoc.Lp) {
-			return false
-		}
-	}
-
-	if a.Rp.IsNotNil() {
-		if !a.Rp.Equal(atDoc.Rp) {
-			return false
-		}
-	}
-
-	if a.LineDoc != nil {
-		if !a.LineDoc.Equal(atDoc.LineDoc) {
-			return false
-		}
-	}
-
-	var expecting, actual []*KvExpr
-	expecting = append(expecting, a.Kv...)
-	actual = append(actual, atDoc.Kv...)
-
-	if len(expecting) != len(actual) {
-		return false
-	}
-
-	for index, each := range expecting {
-		ac := actual[index]
-		if !each.Equal(ac) {
-			return false
-		}
-	}
-
-	return true
-}
-
-// Format provides a formatter for api command, now nothing to do
-func (a *AtServer) Format() error {
-	// todo
-	return nil
-}
-
-// Equal compares whether the element literals in two AtServer are equal
-func (a *AtServer) Equal(v any) bool {
-	if v == nil {
-		return false
-	}
-
-	atServer, ok := v.(*AtServer)
-	if !ok {
-		return false
-	}
-
-	if !a.AtServerToken.Equal(atServer.AtServerToken) {
-		return false
-	}
-
-	if !a.Lp.Equal(atServer.Lp) {
-		return false
-	}
-
-	if !a.Rp.Equal(atServer.Rp) {
-		return false
-	}
-
-	var expecting, actual []*KvExpr
-	expecting = append(expecting, a.Kv...)
-	actual = append(actual, atServer.Kv...)
-	if len(expecting) != len(actual) {
-		return false
-	}
-
-	sort.Slice(expecting, func(i, j int) bool {
-		return expecting[i].Key.Text() < expecting[j].Key.Text()
-	})
-
-	sort.Slice(actual, func(i, j int) bool {
-		return actual[i].Key.Text() < actual[j].Key.Text()
-	})
-
-	for index, each := range expecting {
-		ac := actual[index]
-		if !each.Equal(ac) {
-			return false
-		}
-	}
-
-	return true
-}
-
-// Equal compares whether the element literals in two ServiceRoute are equal
-func (s *ServiceRoute) Equal(v any) bool {
-	if v == nil {
-		return false
-	}
-
-	sr, ok := v.(*ServiceRoute)
-	if !ok {
-		return false
-	}
-
-	if !s.AtDoc.Equal(sr.AtDoc) {
-		return false
-	}
-
-	if s.AtServer != nil {
-		if !s.AtServer.Equal(sr.AtServer) {
-			return false
-		}
-	}
-
-	if s.AtHandler != nil {
-		if !s.AtHandler.Equal(sr.AtHandler) {
-			return false
-		}
-	}
-
-	return s.Route.Equal(sr.Route)
-}
-
-// Format provides a formatter for api command, now nothing to do
-func (s *ServiceRoute) Format() error {
-	// todo
-	return nil
-}
-
-// GetHandler returns handler name of api route
-func (s *ServiceRoute) GetHandler() Expr {
-	if s.AtHandler != nil {
-		return s.AtHandler.Name
-	}
-
-	return s.AtServer.Kv.Get("handler")
-}
-
-// Format provides a formatter for api command, now nothing to do
-func (a *ServiceApi) Format() error {
-	// todo
-	return nil
-}
-
-// Equal compares whether the element literals in two ServiceApi are equal
-func (a *ServiceApi) Equal(v any) bool {
-	if v == nil {
-		return false
-	}
-
-	api, ok := v.(*ServiceApi)
-	if !ok {
-		return false
-	}
-
-	if !a.ServiceToken.Equal(api.ServiceToken) {
-		return false
-	}
-
-	if !a.Name.Equal(api.Name) {
-		return false
-	}
-
-	if !a.Lbrace.Equal(api.Lbrace) {
-		return false
-	}
-
-	if !a.Rbrace.Equal(api.Rbrace) {
-		return false
-	}
-
-	var expecting, acutal []*ServiceRoute
-	expecting = append(expecting, a.ServiceRoute...)
-	acutal = append(acutal, api.ServiceRoute...)
-	if len(expecting) != len(acutal) {
-		return false
-	}
-
-	sort.Slice(expecting, func(i, j int) bool {
-		return expecting[i].Route.Path.Text() < expecting[j].Route.Path.Text()
-	})
-
-	sort.Slice(acutal, func(i, j int) bool {
-		return acutal[i].Route.Path.Text() < acutal[j].Route.Path.Text()
-	})
-
-	for index, each := range expecting {
-		ac := acutal[index]
-		if !each.Equal(ac) {
-			return false
-		}
-	}
-
-	return true
-}
-
-// Format provides a formatter for api command, now nothing to do
-func (s *Service) Format() error {
-	// todo
-	return nil
-}
-
-// Equal compares whether the element literals in two Service are equal
-func (s *Service) Equal(v any) bool {
-	if v == nil {
-		return false
-	}
-
-	service, ok := v.(*Service)
-	if !ok {
-		return false
-	}
-
-	if s.AtServer != nil {
-		if !s.AtServer.Equal(service.AtServer) {
-			return false
-		}
-	}
-
-	return s.ServiceApi.Equal(service.ServiceApi)
-}
-
-// Get returns the target KV by specified key
-func (kv KV) Get(key string) Expr {
-	for _, each := range kv {
-		if each.Key.Text() == key {
-			return each.Value
-		}
-	}
-	return nil
-}

+ 0 - 64
tools/goctlwt/api/parser/g4/ast/syntax.go

@@ -1,64 +0,0 @@
-package ast
-
-import (
-	"github.com/wuntsong-org/go-zero-plus/tools/goctlwt/api/parser/g4/gen/api"
-)
-
-// SyntaxExpr describes syntax for api
-type SyntaxExpr struct {
-	Syntax      Expr
-	Assign      Expr
-	Version     Expr
-	DocExpr     []Expr
-	CommentExpr Expr
-}
-
-// VisitSyntaxLit implements from api.BaseApiParserVisitor
-func (v *ApiVisitor) VisitSyntaxLit(ctx *api.SyntaxLitContext) any {
-	syntax := v.newExprWithToken(ctx.GetSyntaxToken())
-	assign := v.newExprWithToken(ctx.GetAssign())
-	version := v.newExprWithToken(ctx.GetVersion())
-	return &SyntaxExpr{
-		Syntax:      syntax,
-		Assign:      assign,
-		Version:     version,
-		DocExpr:     v.getDoc(ctx),
-		CommentExpr: v.getComment(ctx),
-	}
-}
-
-// Format provides a formatter for api command, now nothing to do
-func (s *SyntaxExpr) Format() error {
-	// todo
-	return nil
-}
-
-// Equal compares whether the element literals in two SyntaxExpr are equal
-func (s *SyntaxExpr) Equal(v any) bool {
-	if v == nil {
-		return false
-	}
-
-	syntax, ok := v.(*SyntaxExpr)
-	if !ok {
-		return false
-	}
-
-	if !EqualDoc(s, syntax) {
-		return false
-	}
-
-	return s.Syntax.Equal(syntax.Syntax) &&
-		s.Assign.Equal(syntax.Assign) &&
-		s.Version.Equal(syntax.Version)
-}
-
-// Doc returns the document of SyntaxExpr, like // some text
-func (s *SyntaxExpr) Doc() []Expr {
-	return s.DocExpr
-}
-
-// Comment returns the comment of SyntaxExpr, like // some text
-func (s *SyntaxExpr) Comment() Expr {
-	return s.CommentExpr
-}

+ 0 - 731
tools/goctlwt/api/parser/g4/ast/type.go

@@ -1,731 +0,0 @@
-package ast
-
-import (
-	"fmt"
-	"sort"
-
-	"github.com/wuntsong-org/go-zero-plus/tools/goctlwt/api/parser/g4/gen/api"
-)
-
-type (
-	// TypeExpr describes an expression for TypeAlias and TypeStruct
-	TypeExpr interface {
-		Doc() []Expr
-		Format() error
-		Equal(v any) bool
-		NameExpr() Expr
-	}
-
-	// TypeAlias describes alias ast for api syntax
-	TypeAlias struct {
-		Name        Expr
-		Assign      Expr
-		DataType    DataType
-		DocExpr     []Expr
-		CommentExpr Expr
-	}
-
-	// TypeStruct describes structure ast for api syntax
-	TypeStruct struct {
-		Name    Expr
-		Struct  Expr
-		LBrace  Expr
-		RBrace  Expr
-		DocExpr []Expr
-		Fields  []*TypeField
-	}
-
-	// TypeField describes field ast for api syntax
-	TypeField struct {
-		IsAnonymous bool
-		// Name is nil if IsAnonymous
-		Name        Expr
-		DataType    DataType
-		Tag         Expr
-		DocExpr     []Expr
-		CommentExpr Expr
-	}
-
-	// DataType describes datatype for api syntax, the default implementation expressions are
-	// Literal, Interface, Map, Array, Time, Pointer
-	DataType interface {
-		Expr() Expr
-		Equal(dt DataType) bool
-		Format() error
-		IsNotNil() bool
-	}
-
-	// Literal describes the basic types of golang, non-reference types,
-	// such as int, bool, Foo,...
-	Literal struct {
-		Literal Expr
-	}
-
-	// Interface describes the interface type of golang,Its fixed value is interface{}
-	Interface struct {
-		Literal Expr
-	}
-
-	// Map describes the map ast for api syntax
-	Map struct {
-		MapExpr Expr
-		Map     Expr
-		LBrack  Expr
-		RBrack  Expr
-		Key     Expr
-		Value   DataType
-	}
-
-	// Array describes the slice ast for api syntax
-	Array struct {
-		ArrayExpr Expr
-		LBrack    Expr
-		RBrack    Expr
-		Literal   DataType
-	}
-
-	// Time describes the time ast for api syntax
-	Time struct {
-		Literal Expr
-	}
-
-	// Pointer describes the pointer ast for api syntax
-	Pointer struct {
-		PointerExpr Expr
-		Star        Expr
-		Name        Expr
-	}
-)
-
-// VisitTypeSpec implements from api.BaseApiParserVisitor
-func (v *ApiVisitor) VisitTypeSpec(ctx *api.TypeSpecContext) any {
-	if ctx.TypeLit() != nil {
-		return []TypeExpr{ctx.TypeLit().Accept(v).(TypeExpr)}
-	}
-	return ctx.TypeBlock().Accept(v)
-}
-
-// VisitTypeLit implements from api.BaseApiParserVisitor
-func (v *ApiVisitor) VisitTypeLit(ctx *api.TypeLitContext) any {
-	typeLit := ctx.TypeLitBody().Accept(v)
-	alias, ok := typeLit.(*TypeAlias)
-	if ok {
-		return alias
-	}
-
-	doc := v.getDoc(ctx)
-	st, ok := typeLit.(*TypeStruct)
-	if ok {
-		st.DocExpr = doc
-		return st
-	}
-
-	return typeLit
-}
-
-// VisitTypeBlock implements from api.BaseApiParserVisitor
-func (v *ApiVisitor) VisitTypeBlock(ctx *api.TypeBlockContext) any {
-	list := ctx.AllTypeBlockBody()
-	var types []TypeExpr
-	for _, each := range list {
-		types = append(types, each.Accept(v).(TypeExpr))
-	}
-	return types
-}
-
-// VisitTypeLitBody implements from api.BaseApiParserVisitor
-func (v *ApiVisitor) VisitTypeLitBody(ctx *api.TypeLitBodyContext) any {
-	if ctx.TypeAlias() != nil {
-		return ctx.TypeAlias().Accept(v)
-	}
-	return ctx.TypeStruct().Accept(v)
-}
-
-// VisitTypeBlockBody implements from api.BaseApiParserVisitor
-func (v *ApiVisitor) VisitTypeBlockBody(ctx *api.TypeBlockBodyContext) any {
-	if ctx.TypeBlockAlias() != nil {
-		return ctx.TypeBlockAlias().Accept(v).(*TypeAlias)
-	}
-	return ctx.TypeBlockStruct().Accept(v).(*TypeStruct)
-}
-
-// VisitTypeStruct implements from api.BaseApiParserVisitor
-func (v *ApiVisitor) VisitTypeStruct(ctx *api.TypeStructContext) any {
-	var st TypeStruct
-	st.Name = v.newExprWithToken(ctx.GetStructName())
-
-	if ctx.GetStructToken() != nil {
-		structExpr := v.newExprWithToken(ctx.GetStructToken())
-		structTokenText := ctx.GetStructToken().GetText()
-		if structTokenText != "struct" {
-			v.panic(structExpr, fmt.Sprintf("expecting 'struct', found input '%s'", structTokenText))
-		}
-
-		if api.IsGolangKeyWord(structTokenText, "struct") {
-			v.panic(structExpr, fmt.Sprintf("expecting 'struct', but found golang keyword '%s'", structTokenText))
-		}
-
-		st.Struct = structExpr
-	}
-
-	st.LBrace = v.newExprWithToken(ctx.GetLbrace())
-	st.RBrace = v.newExprWithToken(ctx.GetRbrace())
-	fields := ctx.AllField()
-	for _, each := range fields {
-		f := each.Accept(v)
-		if f == nil {
-			continue
-		}
-		st.Fields = append(st.Fields, f.(*TypeField))
-	}
-	return &st
-}
-
-// VisitTypeBlockStruct implements from api.BaseApiParserVisitor
-func (v *ApiVisitor) VisitTypeBlockStruct(ctx *api.TypeBlockStructContext) any {
-	var st TypeStruct
-	st.Name = v.newExprWithToken(ctx.GetStructName())
-
-	if ctx.GetStructToken() != nil {
-		structExpr := v.newExprWithToken(ctx.GetStructToken())
-		structTokenText := ctx.GetStructToken().GetText()
-		if structTokenText != "struct" {
-			v.panic(structExpr, fmt.Sprintf("expecting 'struct', found imput '%s'", structTokenText))
-		}
-
-		if api.IsGolangKeyWord(structTokenText, "struct") {
-			v.panic(structExpr, fmt.Sprintf("expecting 'struct', but found golang keyword '%s'", structTokenText))
-		}
-
-		st.Struct = structExpr
-	}
-	st.DocExpr = v.getDoc(ctx)
-	st.LBrace = v.newExprWithToken(ctx.GetLbrace())
-	st.RBrace = v.newExprWithToken(ctx.GetRbrace())
-	fields := ctx.AllField()
-	for _, each := range fields {
-		f := each.Accept(v)
-		if f == nil {
-			continue
-		}
-		st.Fields = append(st.Fields, f.(*TypeField))
-	}
-	return &st
-}
-
-// VisitTypeBlockAlias implements from api.BaseApiParserVisitor
-func (v *ApiVisitor) VisitTypeBlockAlias(ctx *api.TypeBlockAliasContext) any {
-	var alias TypeAlias
-	alias.Name = v.newExprWithToken(ctx.GetAlias())
-	alias.Assign = v.newExprWithToken(ctx.GetAssign())
-	alias.DataType = ctx.DataType().Accept(v).(DataType)
-	alias.DocExpr = v.getDoc(ctx)
-	alias.CommentExpr = v.getComment(ctx)
-	// todo: reopen if necessary
-	v.panic(alias.Name, "unsupported alias")
-	return &alias
-}
-
-// VisitTypeAlias implements from api.BaseApiParserVisitor
-func (v *ApiVisitor) VisitTypeAlias(ctx *api.TypeAliasContext) any {
-	var alias TypeAlias
-	alias.Name = v.newExprWithToken(ctx.GetAlias())
-	alias.Assign = v.newExprWithToken(ctx.GetAssign())
-	alias.DataType = ctx.DataType().Accept(v).(DataType)
-	alias.DocExpr = v.getDoc(ctx)
-	alias.CommentExpr = v.getComment(ctx)
-	// todo: reopen if necessary
-	v.panic(alias.Name, "unsupported alias")
-	return &alias
-}
-
-// VisitField implements from api.BaseApiParserVisitor
-func (v *ApiVisitor) VisitField(ctx *api.FieldContext) any {
-	iAnonymousFiled := ctx.AnonymousFiled()
-	iNormalFieldContext := ctx.NormalField()
-	if iAnonymousFiled != nil {
-		return iAnonymousFiled.Accept(v).(*TypeField)
-	}
-	if iNormalFieldContext != nil {
-		return iNormalFieldContext.Accept(v).(*TypeField)
-	}
-	return nil
-}
-
-// VisitNormalField implements from api.BaseApiParserVisitor
-func (v *ApiVisitor) VisitNormalField(ctx *api.NormalFieldContext) any {
-	var field TypeField
-	field.Name = v.newExprWithToken(ctx.GetFieldName())
-
-	iDataTypeContext := ctx.DataType()
-	if iDataTypeContext != nil {
-		field.DataType = iDataTypeContext.Accept(v).(DataType)
-		field.CommentExpr = v.getComment(ctx)
-	}
-	if ctx.GetTag() != nil {
-		tagText := ctx.GetTag().GetText()
-		tagExpr := v.newExprWithToken(ctx.GetTag())
-		if !api.MatchTag(tagText) {
-			v.panic(tagExpr, fmt.Sprintf("mismatched tag, found input '%s'", tagText))
-		}
-		field.Tag = tagExpr
-		field.CommentExpr = v.getComment(ctx)
-	}
-	field.DocExpr = v.getDoc(ctx)
-	return &field
-}
-
-// VisitAnonymousFiled implements from api.BaseApiParserVisitor
-func (v *ApiVisitor) VisitAnonymousFiled(ctx *api.AnonymousFiledContext) any {
-	start := ctx.GetStart()
-	stop := ctx.GetStop()
-	var field TypeField
-	field.IsAnonymous = true
-	if ctx.GetStar() != nil {
-		nameExpr := v.newExprWithTerminalNode(ctx.ID())
-		field.DataType = &Pointer{
-			PointerExpr: v.newExprWithText(ctx.GetStar().GetText()+ctx.ID().GetText(), start.GetLine(), start.GetColumn(), start.GetStart(), stop.GetStop()),
-			Star:        v.newExprWithToken(ctx.GetStar()),
-			Name:        nameExpr,
-		}
-	} else {
-		nameExpr := v.newExprWithTerminalNode(ctx.ID())
-		field.DataType = &Literal{Literal: nameExpr}
-	}
-	field.DocExpr = v.getDoc(ctx)
-	field.CommentExpr = v.getComment(ctx)
-	return &field
-}
-
-// VisitDataType implements from api.BaseApiParserVisitor
-func (v *ApiVisitor) VisitDataType(ctx *api.DataTypeContext) any {
-	if ctx.ID() != nil {
-		idExpr := v.newExprWithTerminalNode(ctx.ID())
-		return &Literal{Literal: idExpr}
-	}
-	if ctx.MapType() != nil {
-		t := ctx.MapType().Accept(v)
-		return t
-	}
-	if ctx.ArrayType() != nil {
-		return ctx.ArrayType().Accept(v)
-	}
-	if ctx.GetInter() != nil {
-		return &Interface{Literal: v.newExprWithToken(ctx.GetInter())}
-	}
-	if ctx.GetTime() != nil {
-		// todo: reopen if it is necessary
-		timeExpr := v.newExprWithToken(ctx.GetTime())
-		v.panic(timeExpr, "unsupported time.Time")
-		return &Time{Literal: timeExpr}
-	}
-	if ctx.PointerType() != nil {
-		return ctx.PointerType().Accept(v)
-	}
-	return ctx.TypeStruct().Accept(v)
-}
-
-// VisitPointerType implements from api.BaseApiParserVisitor
-func (v *ApiVisitor) VisitPointerType(ctx *api.PointerTypeContext) any {
-	nameExpr := v.newExprWithTerminalNode(ctx.ID())
-	return &Pointer{
-		PointerExpr: v.newExprWithText(ctx.GetText(), ctx.GetStar().GetLine(), ctx.GetStar().GetColumn(), ctx.GetStar().GetStart(), ctx.ID().GetSymbol().GetStop()),
-		Star:        v.newExprWithToken(ctx.GetStar()),
-		Name:        nameExpr,
-	}
-}
-
-// VisitMapType implements from api.BaseApiParserVisitor
-func (v *ApiVisitor) VisitMapType(ctx *api.MapTypeContext) any {
-	return &Map{
-		MapExpr: v.newExprWithText(ctx.GetText(), ctx.GetMapToken().GetLine(), ctx.GetMapToken().GetColumn(),
-			ctx.GetMapToken().GetStart(), ctx.GetValue().GetStop().GetStop()),
-		Map:    v.newExprWithToken(ctx.GetMapToken()),
-		LBrack: v.newExprWithToken(ctx.GetLbrack()),
-		RBrack: v.newExprWithToken(ctx.GetRbrack()),
-		Key:    v.newExprWithToken(ctx.GetKey()),
-		Value:  ctx.GetValue().Accept(v).(DataType),
-	}
-}
-
-// VisitArrayType implements from api.BaseApiParserVisitor
-func (v *ApiVisitor) VisitArrayType(ctx *api.ArrayTypeContext) any {
-	return &Array{
-		ArrayExpr: v.newExprWithText(ctx.GetText(), ctx.GetLbrack().GetLine(), ctx.GetLbrack().GetColumn(), ctx.GetLbrack().GetStart(), ctx.DataType().GetStop().GetStop()),
-		LBrack:    v.newExprWithToken(ctx.GetLbrack()),
-		RBrack:    v.newExprWithToken(ctx.GetRbrack()),
-		Literal:   ctx.DataType().Accept(v).(DataType),
-	}
-}
-
-// NameExpr returns the expression string of TypeAlias
-func (a *TypeAlias) NameExpr() Expr {
-	return a.Name
-}
-
-// Doc returns the document of TypeAlias, like // some text
-func (a *TypeAlias) Doc() []Expr {
-	return a.DocExpr
-}
-
-// Comment returns the comment of TypeAlias, like // some text
-func (a *TypeAlias) Comment() Expr {
-	return a.CommentExpr
-}
-
-// Format provides a formatter for api command, now nothing to do
-func (a *TypeAlias) Format() error {
-	return nil
-}
-
-// Equal compares whether the element literals in two TypeAlias are equal
-func (a *TypeAlias) Equal(v any) bool {
-	if v == nil {
-		return false
-	}
-
-	alias := v.(*TypeAlias)
-	if !a.Name.Equal(alias.Name) {
-		return false
-	}
-
-	if !a.Assign.Equal(alias.Assign) {
-		return false
-	}
-
-	if !a.DataType.Equal(alias.DataType) {
-		return false
-	}
-
-	return EqualDoc(a, alias)
-}
-
-// Expr returns the expression string of Literal
-func (l *Literal) Expr() Expr {
-	return l.Literal
-}
-
-// Format provides a formatter for api command, now nothing to do
-func (l *Literal) Format() error {
-	// todo
-	return nil
-}
-
-// Equal compares whether the element literals in two Literal are equal
-func (l *Literal) Equal(dt DataType) bool {
-	if dt == nil {
-		return false
-	}
-
-	v, ok := dt.(*Literal)
-	if !ok {
-		return false
-	}
-
-	return l.Literal.Equal(v.Literal)
-}
-
-// IsNotNil returns whether the instance is nil or not
-func (l *Literal) IsNotNil() bool {
-	return l != nil
-}
-
-// Expr returns the expression string of Interface
-func (i *Interface) Expr() Expr {
-	return i.Literal
-}
-
-// Format provides a formatter for api command, now nothing to do
-func (i *Interface) Format() error {
-	// todo
-	return nil
-}
-
-// Equal compares whether the element literals in two Interface are equal
-func (i *Interface) Equal(dt DataType) bool {
-	if dt == nil {
-		return false
-	}
-
-	v, ok := dt.(*Interface)
-	if !ok {
-		return false
-	}
-
-	return i.Literal.Equal(v.Literal)
-}
-
-// IsNotNil returns whether the instance is nil or not
-func (i *Interface) IsNotNil() bool {
-	return i != nil
-}
-
-// Expr returns the expression string of Map
-func (m *Map) Expr() Expr {
-	return m.MapExpr
-}
-
-// Format provides a formatter for api command, now nothing to do
-func (m *Map) Format() error {
-	// todo
-	return nil
-}
-
-// Equal compares whether the element literals in two Map are equal
-func (m *Map) Equal(dt DataType) bool {
-	if dt == nil {
-		return false
-	}
-
-	v, ok := dt.(*Map)
-	if !ok {
-		return false
-	}
-
-	if !m.Key.Equal(v.Key) {
-		return false
-	}
-
-	if !m.Value.Equal(v.Value) {
-		return false
-	}
-
-	if !m.MapExpr.Equal(v.MapExpr) {
-		return false
-	}
-
-	return m.Map.Equal(v.Map)
-}
-
-// IsNotNil returns whether the instance is nil or not
-func (m *Map) IsNotNil() bool {
-	return m != nil
-}
-
-// Expr returns the expression string of Array
-func (a *Array) Expr() Expr {
-	return a.ArrayExpr
-}
-
-// Format provides a formatter for api command, now nothing to do
-func (a *Array) Format() error {
-	// todo
-	return nil
-}
-
-// Equal compares whether the element literals in two Array are equal
-func (a *Array) Equal(dt DataType) bool {
-	if dt == nil {
-		return false
-	}
-
-	v, ok := dt.(*Array)
-	if !ok {
-		return false
-	}
-
-	if !a.ArrayExpr.Equal(v.ArrayExpr) {
-		return false
-	}
-
-	return a.Literal.Equal(v.Literal)
-}
-
-// IsNotNil returns whether the instance is nil or not
-func (a *Array) IsNotNil() bool {
-	return a != nil
-}
-
-// Expr returns the expression string of Time
-func (t *Time) Expr() Expr {
-	return t.Literal
-}
-
-// Format provides a formatter for api command, now nothing to do
-func (t *Time) Format() error {
-	// todo
-	return nil
-}
-
-// Equal compares whether the element literals in two Time are equal
-func (t *Time) Equal(dt DataType) bool {
-	if dt == nil {
-		return false
-	}
-
-	v, ok := dt.(*Time)
-	if !ok {
-		return false
-	}
-
-	return t.Literal.Equal(v.Literal)
-}
-
-// IsNotNil returns whether the instance is nil or not
-func (t *Time) IsNotNil() bool {
-	return t != nil
-}
-
-// Expr returns the expression string of Pointer
-func (p *Pointer) Expr() Expr {
-	return p.PointerExpr
-}
-
-// Format provides a formatter for api command, now nothing to do
-func (p *Pointer) Format() error {
-	return nil
-}
-
-// Equal compares whether the element literals in two Pointer are equal
-func (p *Pointer) Equal(dt DataType) bool {
-	if dt == nil {
-		return false
-	}
-
-	v, ok := dt.(*Pointer)
-	if !ok {
-		return false
-	}
-
-	if !p.PointerExpr.Equal(v.PointerExpr) {
-		return false
-	}
-
-	if !p.Star.Equal(v.Star) {
-		return false
-	}
-
-	return p.Name.Equal(v.Name)
-}
-
-// IsNotNil returns whether the instance is nil or not
-func (p *Pointer) IsNotNil() bool {
-	return p != nil
-}
-
-// NameExpr returns the expression string of TypeStruct
-func (s *TypeStruct) NameExpr() Expr {
-	return s.Name
-}
-
-// Equal compares whether the element literals in two TypeStruct are equal
-func (s *TypeStruct) Equal(dt any) bool {
-	if dt == nil {
-		return false
-	}
-
-	v, ok := dt.(*TypeStruct)
-	if !ok {
-		return false
-	}
-
-	if !s.Name.Equal(v.Name) {
-		return false
-	}
-
-	var expectDoc, actualDoc []Expr
-	expectDoc = append(expectDoc, s.DocExpr...)
-	actualDoc = append(actualDoc, v.DocExpr...)
-	sort.Slice(expectDoc, func(i, j int) bool {
-		return expectDoc[i].Line() < expectDoc[j].Line()
-	})
-
-	for index, each := range actualDoc {
-		if !each.Equal(actualDoc[index]) {
-			return false
-		}
-	}
-
-	if s.Struct != nil {
-		if s.Struct != nil {
-			if !s.Struct.Equal(v.Struct) {
-				return false
-			}
-		}
-	}
-
-	if len(s.Fields) != len(v.Fields) {
-		return false
-	}
-
-	var expected, actual []*TypeField
-	expected = append(expected, s.Fields...)
-	actual = append(actual, v.Fields...)
-
-	sort.Slice(expected, func(i, j int) bool {
-		return expected[i].DataType.Expr().Line() < expected[j].DataType.Expr().Line()
-	})
-	sort.Slice(actual, func(i, j int) bool {
-		return actual[i].DataType.Expr().Line() < actual[j].DataType.Expr().Line()
-	})
-
-	for index, each := range expected {
-		ac := actual[index]
-		if !each.Equal(ac) {
-			return false
-		}
-	}
-
-	return true
-}
-
-// Doc returns the document of TypeStruct, like // some text
-func (s *TypeStruct) Doc() []Expr {
-	return s.DocExpr
-}
-
-// Format provides a formatter for api command, now nothing to do
-func (s *TypeStruct) Format() error {
-	// todo
-	return nil
-}
-
-// Equal compares whether the element literals in two TypeField are equal
-func (t *TypeField) Equal(v any) bool {
-	if v == nil {
-		return false
-	}
-
-	f, ok := v.(*TypeField)
-	if !ok {
-		return false
-	}
-
-	if t.IsAnonymous != f.IsAnonymous {
-		return false
-	}
-
-	if !t.DataType.Equal(f.DataType) {
-		return false
-	}
-
-	if !t.IsAnonymous {
-		if !t.Name.Equal(f.Name) {
-			return false
-		}
-
-		if t.Tag != nil {
-			if !t.Tag.Equal(f.Tag) {
-				return false
-			}
-		}
-	}
-
-	return EqualDoc(t, f)
-}
-
-// Doc returns the document of TypeField, like // some text
-func (t *TypeField) Doc() []Expr {
-	return t.DocExpr
-}
-
-// Comment returns the comment of TypeField, like // some text
-func (t *TypeField) Comment() Expr {
-	return t.CommentExpr
-}
-
-// Format provides a formatter for api command, now nothing to do
-func (t *TypeField) Format() error {
-	// todo
-	return nil
-}

+ 0 - 158
tools/goctlwt/api/parser/g4/gen/api/apiparser_base_visitor.go

@@ -1,158 +0,0 @@
-package api // ApiParser
-import "github.com/zeromicro/antlr"
-
-type BaseApiParserVisitor struct {
-	*antlr.BaseParseTreeVisitor
-}
-
-func (v *BaseApiParserVisitor) VisitApi(ctx *ApiContext) any {
-	return v.VisitChildren(ctx)
-}
-
-func (v *BaseApiParserVisitor) VisitSpec(ctx *SpecContext) any {
-	return v.VisitChildren(ctx)
-}
-
-func (v *BaseApiParserVisitor) VisitSyntaxLit(ctx *SyntaxLitContext) any {
-	return v.VisitChildren(ctx)
-}
-
-func (v *BaseApiParserVisitor) VisitImportSpec(ctx *ImportSpecContext) any {
-	return v.VisitChildren(ctx)
-}
-
-func (v *BaseApiParserVisitor) VisitImportLit(ctx *ImportLitContext) any {
-	return v.VisitChildren(ctx)
-}
-
-func (v *BaseApiParserVisitor) VisitImportBlock(ctx *ImportBlockContext) any {
-	return v.VisitChildren(ctx)
-}
-
-func (v *BaseApiParserVisitor) VisitImportBlockValue(ctx *ImportBlockValueContext) any {
-	return v.VisitChildren(ctx)
-}
-
-func (v *BaseApiParserVisitor) VisitImportValue(ctx *ImportValueContext) any {
-	return v.VisitChildren(ctx)
-}
-
-func (v *BaseApiParserVisitor) VisitInfoSpec(ctx *InfoSpecContext) any {
-	return v.VisitChildren(ctx)
-}
-
-func (v *BaseApiParserVisitor) VisitTypeSpec(ctx *TypeSpecContext) any {
-	return v.VisitChildren(ctx)
-}
-
-func (v *BaseApiParserVisitor) VisitTypeLit(ctx *TypeLitContext) any {
-	return v.VisitChildren(ctx)
-}
-
-func (v *BaseApiParserVisitor) VisitTypeBlock(ctx *TypeBlockContext) any {
-	return v.VisitChildren(ctx)
-}
-
-func (v *BaseApiParserVisitor) VisitTypeLitBody(ctx *TypeLitBodyContext) any {
-	return v.VisitChildren(ctx)
-}
-
-func (v *BaseApiParserVisitor) VisitTypeBlockBody(ctx *TypeBlockBodyContext) any {
-	return v.VisitChildren(ctx)
-}
-
-func (v *BaseApiParserVisitor) VisitTypeStruct(ctx *TypeStructContext) any {
-	return v.VisitChildren(ctx)
-}
-
-func (v *BaseApiParserVisitor) VisitTypeAlias(ctx *TypeAliasContext) any {
-	return v.VisitChildren(ctx)
-}
-
-func (v *BaseApiParserVisitor) VisitTypeBlockStruct(ctx *TypeBlockStructContext) any {
-	return v.VisitChildren(ctx)
-}
-
-func (v *BaseApiParserVisitor) VisitTypeBlockAlias(ctx *TypeBlockAliasContext) any {
-	return v.VisitChildren(ctx)
-}
-
-func (v *BaseApiParserVisitor) VisitField(ctx *FieldContext) any {
-	return v.VisitChildren(ctx)
-}
-
-func (v *BaseApiParserVisitor) VisitNormalField(ctx *NormalFieldContext) any {
-	return v.VisitChildren(ctx)
-}
-
-func (v *BaseApiParserVisitor) VisitAnonymousFiled(ctx *AnonymousFiledContext) any {
-	return v.VisitChildren(ctx)
-}
-
-func (v *BaseApiParserVisitor) VisitDataType(ctx *DataTypeContext) any {
-	return v.VisitChildren(ctx)
-}
-
-func (v *BaseApiParserVisitor) VisitPointerType(ctx *PointerTypeContext) any {
-	return v.VisitChildren(ctx)
-}
-
-func (v *BaseApiParserVisitor) VisitMapType(ctx *MapTypeContext) any {
-	return v.VisitChildren(ctx)
-}
-
-func (v *BaseApiParserVisitor) VisitArrayType(ctx *ArrayTypeContext) any {
-	return v.VisitChildren(ctx)
-}
-
-func (v *BaseApiParserVisitor) VisitServiceSpec(ctx *ServiceSpecContext) any {
-	return v.VisitChildren(ctx)
-}
-
-func (v *BaseApiParserVisitor) VisitAtServer(ctx *AtServerContext) any {
-	return v.VisitChildren(ctx)
-}
-
-func (v *BaseApiParserVisitor) VisitServiceApi(ctx *ServiceApiContext) any {
-	return v.VisitChildren(ctx)
-}
-
-func (v *BaseApiParserVisitor) VisitServiceRoute(ctx *ServiceRouteContext) any {
-	return v.VisitChildren(ctx)
-}
-
-func (v *BaseApiParserVisitor) VisitAtDoc(ctx *AtDocContext) any {
-	return v.VisitChildren(ctx)
-}
-
-func (v *BaseApiParserVisitor) VisitAtHandler(ctx *AtHandlerContext) any {
-	return v.VisitChildren(ctx)
-}
-
-func (v *BaseApiParserVisitor) VisitRoute(ctx *RouteContext) any {
-	return v.VisitChildren(ctx)
-}
-
-func (v *BaseApiParserVisitor) VisitBody(ctx *BodyContext) any {
-	return v.VisitChildren(ctx)
-}
-
-func (v *BaseApiParserVisitor) VisitReplybody(ctx *ReplybodyContext) any {
-	return v.VisitChildren(ctx)
-}
-
-func (v *BaseApiParserVisitor) VisitKvLit(ctx *KvLitContext) any {
-	return v.VisitChildren(ctx)
-}
-
-func (v *BaseApiParserVisitor) VisitServiceName(ctx *ServiceNameContext) any {
-	return v.VisitChildren(ctx)
-}
-
-func (v *BaseApiParserVisitor) VisitPath(ctx *PathContext) any {
-	return v.VisitChildren(ctx)
-}
-
-func (v *BaseApiParserVisitor) VisitPathItem(ctx *PathItemContext) any {
-	return v.VisitChildren(ctx)
-}

+ 0 - 240
tools/goctlwt/api/parser/g4/gen/api/apiparser_lexer.go

@@ -1,240 +0,0 @@
-package api
-
-import (
-	"fmt"
-	"unicode"
-
-	"github.com/zeromicro/antlr"
-)
-
-// Suppress unused import error
-var _ = fmt.Printf
-var _ = unicode.IsLetter
-
-var serializedLexerAtn = []uint16{
-	3, 24715, 42794, 33075, 47597, 16764, 15335, 30598, 22884, 2, 27, 276,
-	8, 1, 4, 2, 9, 2, 4, 3, 9, 3, 4, 4, 9, 4, 4, 5, 9, 5, 4, 6, 9, 6, 4, 7,
-	9, 7, 4, 8, 9, 8, 4, 9, 9, 9, 4, 10, 9, 10, 4, 11, 9, 11, 4, 12, 9, 12,
-	4, 13, 9, 13, 4, 14, 9, 14, 4, 15, 9, 15, 4, 16, 9, 16, 4, 17, 9, 17, 4,
-	18, 9, 18, 4, 19, 9, 19, 4, 20, 9, 20, 4, 21, 9, 21, 4, 22, 9, 22, 4, 23,
-	9, 23, 4, 24, 9, 24, 4, 25, 9, 25, 4, 26, 9, 26, 4, 27, 9, 27, 4, 28, 9,
-	28, 4, 29, 9, 29, 4, 30, 9, 30, 4, 31, 9, 31, 4, 32, 9, 32, 3, 2, 3, 2,
-	3, 3, 3, 3, 3, 4, 3, 4, 3, 5, 3, 5, 3, 6, 3, 6, 3, 7, 3, 7, 3, 8, 3, 8,
-	3, 8, 3, 8, 3, 8, 3, 8, 3, 8, 3, 8, 3, 8, 3, 8, 3, 9, 3, 9, 3, 10, 3, 10,
-	3, 11, 3, 11, 3, 11, 3, 11, 3, 11, 3, 11, 3, 11, 3, 11, 3, 12, 3, 12, 3,
-	13, 3, 13, 3, 14, 3, 14, 3, 14, 3, 15, 3, 15, 3, 15, 3, 15, 3, 15, 3, 16,
-	3, 16, 3, 16, 3, 16, 3, 16, 3, 16, 3, 16, 3, 16, 3, 16, 3, 17, 3, 17, 3,
-	17, 3, 17, 3, 17, 3, 17, 3, 17, 3, 17, 3, 17, 3, 17, 3, 17, 3, 17, 3, 18,
-	3, 18, 3, 18, 3, 18, 3, 18, 3, 18, 3, 18, 3, 18, 3, 19, 6, 19, 142, 10,
-	19, 13, 19, 14, 19, 143, 3, 19, 3, 19, 3, 20, 3, 20, 3, 20, 3, 20, 7, 20,
-	152, 10, 20, 12, 20, 14, 20, 155, 11, 20, 3, 20, 3, 20, 3, 20, 3, 20, 3,
-	20, 3, 21, 3, 21, 3, 21, 3, 21, 7, 21, 166, 10, 21, 12, 21, 14, 21, 169,
-	11, 21, 3, 21, 3, 21, 3, 22, 3, 22, 3, 22, 7, 22, 176, 10, 22, 12, 22,
-	14, 22, 179, 11, 22, 3, 22, 3, 22, 3, 23, 3, 23, 3, 23, 6, 23, 186, 10,
-	23, 13, 23, 14, 23, 187, 3, 23, 3, 23, 3, 24, 3, 24, 7, 24, 194, 10, 24,
-	12, 24, 14, 24, 197, 11, 24, 3, 24, 3, 24, 7, 24, 201, 10, 24, 12, 24,
-	14, 24, 204, 11, 24, 5, 24, 206, 10, 24, 3, 25, 3, 25, 7, 25, 210, 10,
-	25, 12, 25, 14, 25, 213, 11, 25, 3, 26, 3, 26, 5, 26, 217, 10, 26, 3, 27,
-	3, 27, 5, 27, 221, 10, 27, 3, 27, 3, 27, 3, 28, 3, 28, 3, 28, 3, 28, 5,
-	28, 229, 10, 28, 3, 28, 5, 28, 232, 10, 28, 3, 28, 3, 28, 3, 28, 6, 28,
-	237, 10, 28, 13, 28, 14, 28, 238, 3, 28, 3, 28, 3, 28, 3, 28, 3, 28, 5,
-	28, 246, 10, 28, 3, 29, 3, 29, 3, 29, 7, 29, 251, 10, 29, 12, 29, 14, 29,
-	254, 11, 29, 3, 29, 5, 29, 257, 10, 29, 3, 30, 3, 30, 3, 31, 3, 31, 7,
-	31, 263, 10, 31, 12, 31, 14, 31, 266, 11, 31, 3, 31, 5, 31, 269, 10, 31,
-	3, 32, 3, 32, 3, 32, 3, 32, 5, 32, 275, 10, 32, 3, 153, 2, 33, 3, 3, 5,
-	4, 7, 5, 9, 6, 11, 7, 13, 8, 15, 9, 17, 10, 19, 11, 21, 12, 23, 13, 25,
-	14, 27, 15, 29, 16, 31, 17, 33, 18, 35, 19, 37, 20, 39, 21, 41, 22, 43,
-	23, 45, 24, 47, 25, 49, 26, 51, 27, 53, 2, 55, 2, 57, 2, 59, 2, 61, 2,
-	63, 2, 3, 2, 20, 5, 2, 11, 12, 14, 15, 34, 34, 4, 2, 12, 12, 15, 15, 4,
-	2, 36, 36, 94, 94, 6, 2, 12, 12, 15, 15, 94, 94, 98, 98, 4, 2, 11, 11,
-	34, 34, 6, 2, 12, 12, 15, 15, 36, 36, 98, 98, 3, 2, 50, 59, 4, 2, 71, 71,
-	103, 103, 4, 2, 45, 45, 47, 47, 10, 2, 36, 36, 41, 41, 94, 94, 100, 100,
-	104, 104, 112, 112, 116, 116, 118, 118, 3, 2, 50, 53, 3, 2, 50, 57, 5,
-	2, 50, 59, 67, 72, 99, 104, 4, 2, 50, 59, 97, 97, 6, 2, 38, 38, 67, 92,
-	97, 97, 99, 124, 4, 2, 2, 129, 55298, 56321, 3, 2, 55298, 56321, 3, 2,
-	56322, 57345, 2, 294, 2, 3, 3, 2, 2, 2, 2, 5, 3, 2, 2, 2, 2, 7, 3, 2, 2,
-	2, 2, 9, 3, 2, 2, 2, 2, 11, 3, 2, 2, 2, 2, 13, 3, 2, 2, 2, 2, 15, 3, 2,
-	2, 2, 2, 17, 3, 2, 2, 2, 2, 19, 3, 2, 2, 2, 2, 21, 3, 2, 2, 2, 2, 23, 3,
-	2, 2, 2, 2, 25, 3, 2, 2, 2, 2, 27, 3, 2, 2, 2, 2, 29, 3, 2, 2, 2, 2, 31,
-	3, 2, 2, 2, 2, 33, 3, 2, 2, 2, 2, 35, 3, 2, 2, 2, 2, 37, 3, 2, 2, 2, 2,
-	39, 3, 2, 2, 2, 2, 41, 3, 2, 2, 2, 2, 43, 3, 2, 2, 2, 2, 45, 3, 2, 2, 2,
-	2, 47, 3, 2, 2, 2, 2, 49, 3, 2, 2, 2, 2, 51, 3, 2, 2, 2, 3, 65, 3, 2, 2,
-	2, 5, 67, 3, 2, 2, 2, 7, 69, 3, 2, 2, 2, 9, 71, 3, 2, 2, 2, 11, 73, 3,
-	2, 2, 2, 13, 75, 3, 2, 2, 2, 15, 77, 3, 2, 2, 2, 17, 87, 3, 2, 2, 2, 19,
-	89, 3, 2, 2, 2, 21, 91, 3, 2, 2, 2, 23, 99, 3, 2, 2, 2, 25, 101, 3, 2,
-	2, 2, 27, 103, 3, 2, 2, 2, 29, 106, 3, 2, 2, 2, 31, 111, 3, 2, 2, 2, 33,
-	120, 3, 2, 2, 2, 35, 132, 3, 2, 2, 2, 37, 141, 3, 2, 2, 2, 39, 147, 3,
-	2, 2, 2, 41, 161, 3, 2, 2, 2, 43, 172, 3, 2, 2, 2, 45, 182, 3, 2, 2, 2,
-	47, 191, 3, 2, 2, 2, 49, 207, 3, 2, 2, 2, 51, 216, 3, 2, 2, 2, 53, 218,
-	3, 2, 2, 2, 55, 245, 3, 2, 2, 2, 57, 247, 3, 2, 2, 2, 59, 258, 3, 2, 2,
-	2, 61, 260, 3, 2, 2, 2, 63, 274, 3, 2, 2, 2, 65, 66, 7, 63, 2, 2, 66, 4,
-	3, 2, 2, 2, 67, 68, 7, 42, 2, 2, 68, 6, 3, 2, 2, 2, 69, 70, 7, 43, 2, 2,
-	70, 8, 3, 2, 2, 2, 71, 72, 7, 125, 2, 2, 72, 10, 3, 2, 2, 2, 73, 74, 7,
-	127, 2, 2, 74, 12, 3, 2, 2, 2, 75, 76, 7, 44, 2, 2, 76, 14, 3, 2, 2, 2,
-	77, 78, 7, 118, 2, 2, 78, 79, 7, 107, 2, 2, 79, 80, 7, 111, 2, 2, 80, 81,
-	7, 103, 2, 2, 81, 82, 7, 48, 2, 2, 82, 83, 7, 86, 2, 2, 83, 84, 7, 107,
-	2, 2, 84, 85, 7, 111, 2, 2, 85, 86, 7, 103, 2, 2, 86, 16, 3, 2, 2, 2, 87,
-	88, 7, 93, 2, 2, 88, 18, 3, 2, 2, 2, 89, 90, 7, 95, 2, 2, 90, 20, 3, 2,
-	2, 2, 91, 92, 7, 116, 2, 2, 92, 93, 7, 103, 2, 2, 93, 94, 7, 118, 2, 2,
-	94, 95, 7, 119, 2, 2, 95, 96, 7, 116, 2, 2, 96, 97, 7, 112, 2, 2, 97, 98,
-	7, 117, 2, 2, 98, 22, 3, 2, 2, 2, 99, 100, 7, 47, 2, 2, 100, 24, 3, 2,
-	2, 2, 101, 102, 7, 49, 2, 2, 102, 26, 3, 2, 2, 2, 103, 104, 7, 49, 2, 2,
-	104, 105, 7, 60, 2, 2, 105, 28, 3, 2, 2, 2, 106, 107, 7, 66, 2, 2, 107,
-	108, 7, 102, 2, 2, 108, 109, 7, 113, 2, 2, 109, 110, 7, 101, 2, 2, 110,
-	30, 3, 2, 2, 2, 111, 112, 7, 66, 2, 2, 112, 113, 7, 106, 2, 2, 113, 114,
-	7, 99, 2, 2, 114, 115, 7, 112, 2, 2, 115, 116, 7, 102, 2, 2, 116, 117,
-	7, 110, 2, 2, 117, 118, 7, 103, 2, 2, 118, 119, 7, 116, 2, 2, 119, 32,
-	3, 2, 2, 2, 120, 121, 7, 107, 2, 2, 121, 122, 7, 112, 2, 2, 122, 123, 7,
-	118, 2, 2, 123, 124, 7, 103, 2, 2, 124, 125, 7, 116, 2, 2, 125, 126, 7,
-	104, 2, 2, 126, 127, 7, 99, 2, 2, 127, 128, 7, 101, 2, 2, 128, 129, 7,
-	103, 2, 2, 129, 130, 7, 125, 2, 2, 130, 131, 7, 127, 2, 2, 131, 34, 3,
-	2, 2, 2, 132, 133, 7, 66, 2, 2, 133, 134, 7, 117, 2, 2, 134, 135, 7, 103,
-	2, 2, 135, 136, 7, 116, 2, 2, 136, 137, 7, 120, 2, 2, 137, 138, 7, 103,
-	2, 2, 138, 139, 7, 116, 2, 2, 139, 36, 3, 2, 2, 2, 140, 142, 9, 2, 2, 2,
-	141, 140, 3, 2, 2, 2, 142, 143, 3, 2, 2, 2, 143, 141, 3, 2, 2, 2, 143,
-	144, 3, 2, 2, 2, 144, 145, 3, 2, 2, 2, 145, 146, 8, 19, 2, 2, 146, 38,
-	3, 2, 2, 2, 147, 148, 7, 49, 2, 2, 148, 149, 7, 44, 2, 2, 149, 153, 3,
-	2, 2, 2, 150, 152, 11, 2, 2, 2, 151, 150, 3, 2, 2, 2, 152, 155, 3, 2, 2,
-	2, 153, 154, 3, 2, 2, 2, 153, 151, 3, 2, 2, 2, 154, 156, 3, 2, 2, 2, 155,
-	153, 3, 2, 2, 2, 156, 157, 7, 44, 2, 2, 157, 158, 7, 49, 2, 2, 158, 159,
-	3, 2, 2, 2, 159, 160, 8, 20, 3, 2, 160, 40, 3, 2, 2, 2, 161, 162, 7, 49,
-	2, 2, 162, 163, 7, 49, 2, 2, 163, 167, 3, 2, 2, 2, 164, 166, 10, 3, 2,
-	2, 165, 164, 3, 2, 2, 2, 166, 169, 3, 2, 2, 2, 167, 165, 3, 2, 2, 2, 167,
-	168, 3, 2, 2, 2, 168, 170, 3, 2, 2, 2, 169, 167, 3, 2, 2, 2, 170, 171,
-	8, 21, 3, 2, 171, 42, 3, 2, 2, 2, 172, 177, 7, 36, 2, 2, 173, 176, 10,
-	4, 2, 2, 174, 176, 5, 55, 28, 2, 175, 173, 3, 2, 2, 2, 175, 174, 3, 2,
-	2, 2, 176, 179, 3, 2, 2, 2, 177, 175, 3, 2, 2, 2, 177, 178, 3, 2, 2, 2,
-	178, 180, 3, 2, 2, 2, 179, 177, 3, 2, 2, 2, 180, 181, 7, 36, 2, 2, 181,
-	44, 3, 2, 2, 2, 182, 185, 7, 98, 2, 2, 183, 186, 10, 5, 2, 2, 184, 186,
-	5, 55, 28, 2, 185, 183, 3, 2, 2, 2, 185, 184, 3, 2, 2, 2, 186, 187, 3,
-	2, 2, 2, 187, 185, 3, 2, 2, 2, 187, 188, 3, 2, 2, 2, 188, 189, 3, 2, 2,
-	2, 189, 190, 7, 98, 2, 2, 190, 46, 3, 2, 2, 2, 191, 195, 7, 60, 2, 2, 192,
-	194, 9, 6, 2, 2, 193, 192, 3, 2, 2, 2, 194, 197, 3, 2, 2, 2, 195, 193,
-	3, 2, 2, 2, 195, 196, 3, 2, 2, 2, 196, 205, 3, 2, 2, 2, 197, 195, 3, 2,
-	2, 2, 198, 206, 5, 43, 22, 2, 199, 201, 10, 7, 2, 2, 200, 199, 3, 2, 2,
-	2, 201, 204, 3, 2, 2, 2, 202, 200, 3, 2, 2, 2, 202, 203, 3, 2, 2, 2, 203,
-	206, 3, 2, 2, 2, 204, 202, 3, 2, 2, 2, 205, 198, 3, 2, 2, 2, 205, 202,
-	3, 2, 2, 2, 206, 48, 3, 2, 2, 2, 207, 211, 5, 63, 32, 2, 208, 210, 5, 51,
-	26, 2, 209, 208, 3, 2, 2, 2, 210, 213, 3, 2, 2, 2, 211, 209, 3, 2, 2, 2,
-	211, 212, 3, 2, 2, 2, 212, 50, 3, 2, 2, 2, 213, 211, 3, 2, 2, 2, 214, 217,
-	5, 63, 32, 2, 215, 217, 9, 8, 2, 2, 216, 214, 3, 2, 2, 2, 216, 215, 3,
-	2, 2, 2, 217, 52, 3, 2, 2, 2, 218, 220, 9, 9, 2, 2, 219, 221, 9, 10, 2,
-	2, 220, 219, 3, 2, 2, 2, 220, 221, 3, 2, 2, 2, 221, 222, 3, 2, 2, 2, 222,
-	223, 5, 61, 31, 2, 223, 54, 3, 2, 2, 2, 224, 225, 7, 94, 2, 2, 225, 246,
-	9, 11, 2, 2, 226, 231, 7, 94, 2, 2, 227, 229, 9, 12, 2, 2, 228, 227, 3,
-	2, 2, 2, 228, 229, 3, 2, 2, 2, 229, 230, 3, 2, 2, 2, 230, 232, 9, 13, 2,
-	2, 231, 228, 3, 2, 2, 2, 231, 232, 3, 2, 2, 2, 232, 233, 3, 2, 2, 2, 233,
-	246, 9, 13, 2, 2, 234, 236, 7, 94, 2, 2, 235, 237, 7, 119, 2, 2, 236, 235,
-	3, 2, 2, 2, 237, 238, 3, 2, 2, 2, 238, 236, 3, 2, 2, 2, 238, 239, 3, 2,
-	2, 2, 239, 240, 3, 2, 2, 2, 240, 241, 5, 59, 30, 2, 241, 242, 5, 59, 30,
-	2, 242, 243, 5, 59, 30, 2, 243, 244, 5, 59, 30, 2, 244, 246, 3, 2, 2, 2,
-	245, 224, 3, 2, 2, 2, 245, 226, 3, 2, 2, 2, 245, 234, 3, 2, 2, 2, 246,
-	56, 3, 2, 2, 2, 247, 256, 5, 59, 30, 2, 248, 251, 5, 59, 30, 2, 249, 251,
-	7, 97, 2, 2, 250, 248, 3, 2, 2, 2, 250, 249, 3, 2, 2, 2, 251, 254, 3, 2,
-	2, 2, 252, 250, 3, 2, 2, 2, 252, 253, 3, 2, 2, 2, 253, 255, 3, 2, 2, 2,
-	254, 252, 3, 2, 2, 2, 255, 257, 5, 59, 30, 2, 256, 252, 3, 2, 2, 2, 256,
-	257, 3, 2, 2, 2, 257, 58, 3, 2, 2, 2, 258, 259, 9, 14, 2, 2, 259, 60, 3,
-	2, 2, 2, 260, 268, 9, 8, 2, 2, 261, 263, 9, 15, 2, 2, 262, 261, 3, 2, 2,
-	2, 263, 266, 3, 2, 2, 2, 264, 262, 3, 2, 2, 2, 264, 265, 3, 2, 2, 2, 265,
-	267, 3, 2, 2, 2, 266, 264, 3, 2, 2, 2, 267, 269, 9, 8, 2, 2, 268, 264,
-	3, 2, 2, 2, 268, 269, 3, 2, 2, 2, 269, 62, 3, 2, 2, 2, 270, 275, 9, 16,
-	2, 2, 271, 275, 10, 17, 2, 2, 272, 273, 9, 18, 2, 2, 273, 275, 9, 19, 2,
-	2, 274, 270, 3, 2, 2, 2, 274, 271, 3, 2, 2, 2, 274, 272, 3, 2, 2, 2, 275,
-	64, 3, 2, 2, 2, 26, 2, 143, 153, 167, 175, 177, 185, 187, 195, 202, 205,
-	211, 216, 220, 228, 231, 238, 245, 250, 252, 256, 264, 268, 274, 4, 2,
-	3, 2, 2, 90, 2,
-}
-
-var lexerChannelNames = []string{
-	"DEFAULT_TOKEN_CHANNEL", "HIDDEN",
-}
-
-var lexerModeNames = []string{
-	"DEFAULT_MODE",
-}
-
-var lexerLiteralNames = []string{
-	"", "'='", "'('", "')'", "'{'", "'}'", "'*'", "'time.Time'", "'['", "']'",
-	"'returns'", "'-'", "'/'", "'/:'", "'@doc'", "'@handler'", "'interface{}'",
-	"'@server'",
-}
-
-var lexerSymbolicNames = []string{
-	"", "", "", "", "", "", "", "", "", "", "", "", "", "", "ATDOC", "ATHANDLER",
-	"INTERFACE", "ATSERVER", "WS", "COMMENT", "LINE_COMMENT", "STRING", "RAW_STRING",
-	"LINE_VALUE", "ID", "LetterOrDigit",
-}
-
-var lexerRuleNames = []string{
-	"T__0", "T__1", "T__2", "T__3", "T__4", "T__5", "T__6", "T__7", "T__8",
-	"T__9", "T__10", "T__11", "T__12", "ATDOC", "ATHANDLER", "INTERFACE", "ATSERVER",
-	"WS", "COMMENT", "LINE_COMMENT", "STRING", "RAW_STRING", "LINE_VALUE",
-	"ID", "LetterOrDigit", "ExponentPart", "EscapeSequence", "HexDigits", "HexDigit",
-	"Digits", "Letter",
-}
-
-type ApiParserLexer struct {
-	*antlr.BaseLexer
-	channelNames []string
-	modeNames    []string
-	// TODO: EOF string
-}
-
-// NewApiParserLexer produces a new lexer instance for the optional input antlr.CharStream.
-//
-// The *ApiParserLexer instance produced may be reused by calling the SetInputStream method.
-// The initial lexer configuration is expensive to construct, and the object is not thread-safe;
-// however, if used within a Golang sync.Pool, the construction cost amortizes well and the
-// objects can be used in a thread-safe manner.
-func NewApiParserLexer(input antlr.CharStream) *ApiParserLexer {
-	l := new(ApiParserLexer)
-	lexerDeserializer := antlr.NewATNDeserializer(nil)
-	lexerAtn := lexerDeserializer.DeserializeFromUInt16(serializedLexerAtn)
-	lexerDecisionToDFA := make([]*antlr.DFA, len(lexerAtn.DecisionToState))
-	for index, ds := range lexerAtn.DecisionToState {
-		lexerDecisionToDFA[index] = antlr.NewDFA(ds, index)
-	}
-	l.BaseLexer = antlr.NewBaseLexer(input)
-	l.Interpreter = antlr.NewLexerATNSimulator(l, lexerAtn, lexerDecisionToDFA, antlr.NewPredictionContextCache())
-
-	l.channelNames = lexerChannelNames
-	l.modeNames = lexerModeNames
-	l.RuleNames = lexerRuleNames
-	l.LiteralNames = lexerLiteralNames
-	l.SymbolicNames = lexerSymbolicNames
-	l.GrammarFileName = "ApiParser.g4"
-	// TODO: l.EOF = antlr.TokenEOF
-
-	return l
-}
-
-// ApiParserLexer tokens.
-const (
-	ApiParserLexerT__0          = 1
-	ApiParserLexerT__1          = 2
-	ApiParserLexerT__2          = 3
-	ApiParserLexerT__3          = 4
-	ApiParserLexerT__4          = 5
-	ApiParserLexerT__5          = 6
-	ApiParserLexerT__6          = 7
-	ApiParserLexerT__7          = 8
-	ApiParserLexerT__8          = 9
-	ApiParserLexerT__9          = 10
-	ApiParserLexerT__10         = 11
-	ApiParserLexerT__11         = 12
-	ApiParserLexerT__12         = 13
-	ApiParserLexerATDOC         = 14
-	ApiParserLexerATHANDLER     = 15
-	ApiParserLexerINTERFACE     = 16
-	ApiParserLexerATSERVER      = 17
-	ApiParserLexerWS            = 18
-	ApiParserLexerCOMMENT       = 19
-	ApiParserLexerLINE_COMMENT  = 20
-	ApiParserLexerSTRING        = 21
-	ApiParserLexerRAW_STRING    = 22
-	ApiParserLexerLINE_VALUE    = 23
-	ApiParserLexerID            = 24
-	ApiParserLexerLetterOrDigit = 25
-)
-
-const COMMENTS = 88

+ 0 - 655
tools/goctlwt/api/parser/g4/gen/api/apiparser_parser.go

@@ -1,655 +0,0 @@
-package api // ApiParser
-import (
-	"fmt"
-	"reflect"
-	"strconv"
-
-	"github.com/zeromicro/antlr"
-)
-
-// Suppress unused import errors
-var _ = fmt.Printf
-var _ = reflect.Copy
-var _ = strconv.Itoa
-
-var parserATN = []uint16{
-	3, 24715, 42794, 33075, 47597, 16764, 15335, 30598, 22884, 3, 27, 356,
-	4, 2, 9, 2, 4, 3, 9, 3, 4, 4, 9, 4, 4, 5, 9, 5, 4, 6, 9, 6, 4, 7, 9, 7,
-	4, 8, 9, 8, 4, 9, 9, 9, 4, 10, 9, 10, 4, 11, 9, 11, 4, 12, 9, 12, 4, 13,
-	9, 13, 4, 14, 9, 14, 4, 15, 9, 15, 4, 16, 9, 16, 4, 17, 9, 17, 4, 18, 9,
-	18, 4, 19, 9, 19, 4, 20, 9, 20, 4, 21, 9, 21, 4, 22, 9, 22, 4, 23, 9, 23,
-	4, 24, 9, 24, 4, 25, 9, 25, 4, 26, 9, 26, 4, 27, 9, 27, 4, 28, 9, 28, 4,
-	29, 9, 29, 4, 30, 9, 30, 4, 31, 9, 31, 4, 32, 9, 32, 4, 33, 9, 33, 4, 34,
-	9, 34, 4, 35, 9, 35, 4, 36, 9, 36, 4, 37, 9, 37, 4, 38, 9, 38, 4, 39, 9,
-	39, 3, 2, 7, 2, 80, 10, 2, 12, 2, 14, 2, 83, 11, 2, 3, 3, 3, 3, 3, 3, 3,
-	3, 3, 3, 5, 3, 90, 10, 3, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 5, 3,
-	5, 5, 5, 100, 10, 5, 3, 6, 3, 6, 3, 6, 3, 6, 3, 7, 3, 7, 3, 7, 3, 7, 6,
-	7, 110, 10, 7, 13, 7, 14, 7, 111, 3, 7, 3, 7, 3, 8, 3, 8, 3, 9, 3, 9, 3,
-	9, 3, 10, 3, 10, 3, 10, 3, 10, 6, 10, 125, 10, 10, 13, 10, 14, 10, 126,
-	3, 10, 3, 10, 3, 11, 3, 11, 5, 11, 133, 10, 11, 3, 12, 3, 12, 3, 12, 3,
-	12, 3, 13, 3, 13, 3, 13, 3, 13, 7, 13, 143, 10, 13, 12, 13, 14, 13, 146,
-	11, 13, 3, 13, 3, 13, 3, 14, 3, 14, 5, 14, 152, 10, 14, 3, 15, 3, 15, 5,
-	15, 156, 10, 15, 3, 16, 3, 16, 3, 16, 5, 16, 161, 10, 16, 3, 16, 3, 16,
-	7, 16, 165, 10, 16, 12, 16, 14, 16, 168, 11, 16, 3, 16, 3, 16, 3, 17, 3,
-	17, 3, 17, 5, 17, 175, 10, 17, 3, 17, 3, 17, 3, 18, 3, 18, 3, 18, 5, 18,
-	182, 10, 18, 3, 18, 3, 18, 7, 18, 186, 10, 18, 12, 18, 14, 18, 189, 11,
-	18, 3, 18, 3, 18, 3, 19, 3, 19, 3, 19, 5, 19, 196, 10, 19, 3, 19, 3, 19,
-	3, 20, 3, 20, 3, 20, 5, 20, 203, 10, 20, 3, 21, 3, 21, 3, 21, 3, 21, 5,
-	21, 209, 10, 21, 3, 22, 5, 22, 212, 10, 22, 3, 22, 3, 22, 3, 23, 3, 23,
-	3, 23, 3, 23, 3, 23, 3, 23, 3, 23, 3, 23, 5, 23, 224, 10, 23, 3, 24, 3,
-	24, 3, 24, 3, 24, 3, 25, 3, 25, 3, 25, 3, 25, 3, 25, 3, 25, 3, 25, 3, 25,
-	3, 26, 3, 26, 3, 26, 3, 26, 3, 27, 5, 27, 243, 10, 27, 3, 27, 3, 27, 3,
-	28, 3, 28, 3, 28, 6, 28, 250, 10, 28, 13, 28, 14, 28, 251, 3, 28, 3, 28,
-	3, 29, 3, 29, 3, 29, 3, 29, 3, 29, 7, 29, 261, 10, 29, 12, 29, 14, 29,
-	264, 11, 29, 3, 29, 3, 29, 3, 30, 5, 30, 269, 10, 30, 3, 30, 3, 30, 5,
-	30, 273, 10, 30, 3, 30, 3, 30, 3, 31, 3, 31, 5, 31, 279, 10, 31, 3, 31,
-	6, 31, 282, 10, 31, 13, 31, 14, 31, 283, 3, 31, 5, 31, 287, 10, 31, 3,
-	31, 5, 31, 290, 10, 31, 3, 32, 3, 32, 3, 32, 3, 33, 3, 33, 3, 33, 3, 33,
-	5, 33, 299, 10, 33, 3, 33, 5, 33, 302, 10, 33, 3, 34, 3, 34, 5, 34, 306,
-	10, 34, 3, 34, 3, 34, 3, 35, 3, 35, 3, 35, 5, 35, 313, 10, 35, 3, 35, 3,
-	35, 3, 36, 3, 36, 3, 36, 3, 36, 3, 37, 3, 37, 5, 37, 323, 10, 37, 6, 37,
-	325, 10, 37, 13, 37, 14, 37, 326, 3, 38, 3, 38, 3, 38, 3, 38, 7, 38, 333,
-	10, 38, 12, 38, 14, 38, 336, 11, 38, 3, 38, 3, 38, 3, 38, 3, 38, 5, 38,
-	342, 10, 38, 6, 38, 344, 10, 38, 13, 38, 14, 38, 345, 3, 38, 5, 38, 349,
-	10, 38, 3, 39, 6, 39, 352, 10, 39, 13, 39, 14, 39, 353, 3, 39, 2, 2, 40,
-	2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38,
-	40, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60, 62, 64, 66, 68, 70, 72, 74,
-	76, 2, 3, 3, 2, 26, 27, 2, 365, 2, 81, 3, 2, 2, 2, 4, 89, 3, 2, 2, 2, 6,
-	91, 3, 2, 2, 2, 8, 99, 3, 2, 2, 2, 10, 101, 3, 2, 2, 2, 12, 105, 3, 2,
-	2, 2, 14, 115, 3, 2, 2, 2, 16, 117, 3, 2, 2, 2, 18, 120, 3, 2, 2, 2, 20,
-	132, 3, 2, 2, 2, 22, 134, 3, 2, 2, 2, 24, 138, 3, 2, 2, 2, 26, 151, 3,
-	2, 2, 2, 28, 155, 3, 2, 2, 2, 30, 157, 3, 2, 2, 2, 32, 171, 3, 2, 2, 2,
-	34, 178, 3, 2, 2, 2, 36, 192, 3, 2, 2, 2, 38, 202, 3, 2, 2, 2, 40, 204,
-	3, 2, 2, 2, 42, 211, 3, 2, 2, 2, 44, 223, 3, 2, 2, 2, 46, 225, 3, 2, 2,
-	2, 48, 229, 3, 2, 2, 2, 50, 237, 3, 2, 2, 2, 52, 242, 3, 2, 2, 2, 54, 246,
-	3, 2, 2, 2, 56, 255, 3, 2, 2, 2, 58, 268, 3, 2, 2, 2, 60, 276, 3, 2, 2,
-	2, 62, 291, 3, 2, 2, 2, 64, 294, 3, 2, 2, 2, 66, 303, 3, 2, 2, 2, 68, 309,
-	3, 2, 2, 2, 70, 316, 3, 2, 2, 2, 72, 324, 3, 2, 2, 2, 74, 348, 3, 2, 2,
-	2, 76, 351, 3, 2, 2, 2, 78, 80, 5, 4, 3, 2, 79, 78, 3, 2, 2, 2, 80, 83,
-	3, 2, 2, 2, 81, 79, 3, 2, 2, 2, 81, 82, 3, 2, 2, 2, 82, 3, 3, 2, 2, 2,
-	83, 81, 3, 2, 2, 2, 84, 90, 5, 6, 4, 2, 85, 90, 5, 8, 5, 2, 86, 90, 5,
-	18, 10, 2, 87, 90, 5, 20, 11, 2, 88, 90, 5, 52, 27, 2, 89, 84, 3, 2, 2,
-	2, 89, 85, 3, 2, 2, 2, 89, 86, 3, 2, 2, 2, 89, 87, 3, 2, 2, 2, 89, 88,
-	3, 2, 2, 2, 90, 5, 3, 2, 2, 2, 91, 92, 8, 4, 1, 2, 92, 93, 7, 26, 2, 2,
-	93, 94, 7, 3, 2, 2, 94, 95, 8, 4, 1, 2, 95, 96, 7, 23, 2, 2, 96, 7, 3,
-	2, 2, 2, 97, 100, 5, 10, 6, 2, 98, 100, 5, 12, 7, 2, 99, 97, 3, 2, 2, 2,
-	99, 98, 3, 2, 2, 2, 100, 9, 3, 2, 2, 2, 101, 102, 8, 6, 1, 2, 102, 103,
-	7, 26, 2, 2, 103, 104, 5, 16, 9, 2, 104, 11, 3, 2, 2, 2, 105, 106, 8, 7,
-	1, 2, 106, 107, 7, 26, 2, 2, 107, 109, 7, 4, 2, 2, 108, 110, 5, 14, 8,
-	2, 109, 108, 3, 2, 2, 2, 110, 111, 3, 2, 2, 2, 111, 109, 3, 2, 2, 2, 111,
-	112, 3, 2, 2, 2, 112, 113, 3, 2, 2, 2, 113, 114, 7, 5, 2, 2, 114, 13, 3,
-	2, 2, 2, 115, 116, 5, 16, 9, 2, 116, 15, 3, 2, 2, 2, 117, 118, 8, 9, 1,
-	2, 118, 119, 7, 23, 2, 2, 119, 17, 3, 2, 2, 2, 120, 121, 8, 10, 1, 2, 121,
-	122, 7, 26, 2, 2, 122, 124, 7, 4, 2, 2, 123, 125, 5, 70, 36, 2, 124, 123,
-	3, 2, 2, 2, 125, 126, 3, 2, 2, 2, 126, 124, 3, 2, 2, 2, 126, 127, 3, 2,
-	2, 2, 127, 128, 3, 2, 2, 2, 128, 129, 7, 5, 2, 2, 129, 19, 3, 2, 2, 2,
-	130, 133, 5, 22, 12, 2, 131, 133, 5, 24, 13, 2, 132, 130, 3, 2, 2, 2, 132,
-	131, 3, 2, 2, 2, 133, 21, 3, 2, 2, 2, 134, 135, 8, 12, 1, 2, 135, 136,
-	7, 26, 2, 2, 136, 137, 5, 26, 14, 2, 137, 23, 3, 2, 2, 2, 138, 139, 8,
-	13, 1, 2, 139, 140, 7, 26, 2, 2, 140, 144, 7, 4, 2, 2, 141, 143, 5, 28,
-	15, 2, 142, 141, 3, 2, 2, 2, 143, 146, 3, 2, 2, 2, 144, 142, 3, 2, 2, 2,
-	144, 145, 3, 2, 2, 2, 145, 147, 3, 2, 2, 2, 146, 144, 3, 2, 2, 2, 147,
-	148, 7, 5, 2, 2, 148, 25, 3, 2, 2, 2, 149, 152, 5, 30, 16, 2, 150, 152,
-	5, 32, 17, 2, 151, 149, 3, 2, 2, 2, 151, 150, 3, 2, 2, 2, 152, 27, 3, 2,
-	2, 2, 153, 156, 5, 34, 18, 2, 154, 156, 5, 36, 19, 2, 155, 153, 3, 2, 2,
-	2, 155, 154, 3, 2, 2, 2, 156, 29, 3, 2, 2, 2, 157, 158, 8, 16, 1, 2, 158,
-	160, 7, 26, 2, 2, 159, 161, 7, 26, 2, 2, 160, 159, 3, 2, 2, 2, 160, 161,
-	3, 2, 2, 2, 161, 162, 3, 2, 2, 2, 162, 166, 7, 6, 2, 2, 163, 165, 5, 38,
-	20, 2, 164, 163, 3, 2, 2, 2, 165, 168, 3, 2, 2, 2, 166, 164, 3, 2, 2, 2,
-	166, 167, 3, 2, 2, 2, 167, 169, 3, 2, 2, 2, 168, 166, 3, 2, 2, 2, 169,
-	170, 7, 7, 2, 2, 170, 31, 3, 2, 2, 2, 171, 172, 8, 17, 1, 2, 172, 174,
-	7, 26, 2, 2, 173, 175, 7, 3, 2, 2, 174, 173, 3, 2, 2, 2, 174, 175, 3, 2,
-	2, 2, 175, 176, 3, 2, 2, 2, 176, 177, 5, 44, 23, 2, 177, 33, 3, 2, 2, 2,
-	178, 179, 8, 18, 1, 2, 179, 181, 7, 26, 2, 2, 180, 182, 7, 26, 2, 2, 181,
-	180, 3, 2, 2, 2, 181, 182, 3, 2, 2, 2, 182, 183, 3, 2, 2, 2, 183, 187,
-	7, 6, 2, 2, 184, 186, 5, 38, 20, 2, 185, 184, 3, 2, 2, 2, 186, 189, 3,
-	2, 2, 2, 187, 185, 3, 2, 2, 2, 187, 188, 3, 2, 2, 2, 188, 190, 3, 2, 2,
-	2, 189, 187, 3, 2, 2, 2, 190, 191, 7, 7, 2, 2, 191, 35, 3, 2, 2, 2, 192,
-	193, 8, 19, 1, 2, 193, 195, 7, 26, 2, 2, 194, 196, 7, 3, 2, 2, 195, 194,
-	3, 2, 2, 2, 195, 196, 3, 2, 2, 2, 196, 197, 3, 2, 2, 2, 197, 198, 5, 44,
-	23, 2, 198, 37, 3, 2, 2, 2, 199, 200, 6, 20, 2, 2, 200, 203, 5, 40, 21,
-	2, 201, 203, 5, 42, 22, 2, 202, 199, 3, 2, 2, 2, 202, 201, 3, 2, 2, 2,
-	203, 39, 3, 2, 2, 2, 204, 205, 8, 21, 1, 2, 205, 206, 7, 26, 2, 2, 206,
-	208, 5, 44, 23, 2, 207, 209, 7, 24, 2, 2, 208, 207, 3, 2, 2, 2, 208, 209,
-	3, 2, 2, 2, 209, 41, 3, 2, 2, 2, 210, 212, 7, 8, 2, 2, 211, 210, 3, 2,
-	2, 2, 211, 212, 3, 2, 2, 2, 212, 213, 3, 2, 2, 2, 213, 214, 7, 26, 2, 2,
-	214, 43, 3, 2, 2, 2, 215, 216, 8, 23, 1, 2, 216, 224, 7, 26, 2, 2, 217,
-	224, 5, 48, 25, 2, 218, 224, 5, 50, 26, 2, 219, 224, 7, 18, 2, 2, 220,
-	224, 7, 9, 2, 2, 221, 224, 5, 46, 24, 2, 222, 224, 5, 30, 16, 2, 223, 215,
-	3, 2, 2, 2, 223, 217, 3, 2, 2, 2, 223, 218, 3, 2, 2, 2, 223, 219, 3, 2,
-	2, 2, 223, 220, 3, 2, 2, 2, 223, 221, 3, 2, 2, 2, 223, 222, 3, 2, 2, 2,
-	224, 45, 3, 2, 2, 2, 225, 226, 7, 8, 2, 2, 226, 227, 8, 24, 1, 2, 227,
-	228, 7, 26, 2, 2, 228, 47, 3, 2, 2, 2, 229, 230, 8, 25, 1, 2, 230, 231,
-	7, 26, 2, 2, 231, 232, 7, 10, 2, 2, 232, 233, 8, 25, 1, 2, 233, 234, 7,
-	26, 2, 2, 234, 235, 7, 11, 2, 2, 235, 236, 5, 44, 23, 2, 236, 49, 3, 2,
-	2, 2, 237, 238, 7, 10, 2, 2, 238, 239, 7, 11, 2, 2, 239, 240, 5, 44, 23,
-	2, 240, 51, 3, 2, 2, 2, 241, 243, 5, 54, 28, 2, 242, 241, 3, 2, 2, 2, 242,
-	243, 3, 2, 2, 2, 243, 244, 3, 2, 2, 2, 244, 245, 5, 56, 29, 2, 245, 53,
-	3, 2, 2, 2, 246, 247, 7, 19, 2, 2, 247, 249, 7, 4, 2, 2, 248, 250, 5, 70,
-	36, 2, 249, 248, 3, 2, 2, 2, 250, 251, 3, 2, 2, 2, 251, 249, 3, 2, 2, 2,
-	251, 252, 3, 2, 2, 2, 252, 253, 3, 2, 2, 2, 253, 254, 7, 5, 2, 2, 254,
-	55, 3, 2, 2, 2, 255, 256, 8, 29, 1, 2, 256, 257, 7, 26, 2, 2, 257, 258,
-	5, 72, 37, 2, 258, 262, 7, 6, 2, 2, 259, 261, 5, 58, 30, 2, 260, 259, 3,
-	2, 2, 2, 261, 264, 3, 2, 2, 2, 262, 260, 3, 2, 2, 2, 262, 263, 3, 2, 2,
-	2, 263, 265, 3, 2, 2, 2, 264, 262, 3, 2, 2, 2, 265, 266, 7, 7, 2, 2, 266,
-	57, 3, 2, 2, 2, 267, 269, 5, 60, 31, 2, 268, 267, 3, 2, 2, 2, 268, 269,
-	3, 2, 2, 2, 269, 272, 3, 2, 2, 2, 270, 273, 5, 54, 28, 2, 271, 273, 5,
-	62, 32, 2, 272, 270, 3, 2, 2, 2, 272, 271, 3, 2, 2, 2, 273, 274, 3, 2,
-	2, 2, 274, 275, 5, 64, 33, 2, 275, 59, 3, 2, 2, 2, 276, 278, 7, 16, 2,
-	2, 277, 279, 7, 4, 2, 2, 278, 277, 3, 2, 2, 2, 278, 279, 3, 2, 2, 2, 279,
-	286, 3, 2, 2, 2, 280, 282, 5, 70, 36, 2, 281, 280, 3, 2, 2, 2, 282, 283,
-	3, 2, 2, 2, 283, 281, 3, 2, 2, 2, 283, 284, 3, 2, 2, 2, 284, 287, 3, 2,
-	2, 2, 285, 287, 7, 23, 2, 2, 286, 281, 3, 2, 2, 2, 286, 285, 3, 2, 2, 2,
-	287, 289, 3, 2, 2, 2, 288, 290, 7, 5, 2, 2, 289, 288, 3, 2, 2, 2, 289,
-	290, 3, 2, 2, 2, 290, 61, 3, 2, 2, 2, 291, 292, 7, 17, 2, 2, 292, 293,
-	7, 26, 2, 2, 293, 63, 3, 2, 2, 2, 294, 295, 8, 33, 1, 2, 295, 296, 7, 26,
-	2, 2, 296, 298, 5, 74, 38, 2, 297, 299, 5, 66, 34, 2, 298, 297, 3, 2, 2,
-	2, 298, 299, 3, 2, 2, 2, 299, 301, 3, 2, 2, 2, 300, 302, 5, 68, 35, 2,
-	301, 300, 3, 2, 2, 2, 301, 302, 3, 2, 2, 2, 302, 65, 3, 2, 2, 2, 303, 305,
-	7, 4, 2, 2, 304, 306, 7, 26, 2, 2, 305, 304, 3, 2, 2, 2, 305, 306, 3, 2,
-	2, 2, 306, 307, 3, 2, 2, 2, 307, 308, 7, 5, 2, 2, 308, 67, 3, 2, 2, 2,
-	309, 310, 7, 12, 2, 2, 310, 312, 7, 4, 2, 2, 311, 313, 5, 44, 23, 2, 312,
-	311, 3, 2, 2, 2, 312, 313, 3, 2, 2, 2, 313, 314, 3, 2, 2, 2, 314, 315,
-	7, 5, 2, 2, 315, 69, 3, 2, 2, 2, 316, 317, 7, 26, 2, 2, 317, 318, 8, 36,
-	1, 2, 318, 319, 7, 25, 2, 2, 319, 71, 3, 2, 2, 2, 320, 322, 7, 26, 2, 2,
-	321, 323, 7, 13, 2, 2, 322, 321, 3, 2, 2, 2, 322, 323, 3, 2, 2, 2, 323,
-	325, 3, 2, 2, 2, 324, 320, 3, 2, 2, 2, 325, 326, 3, 2, 2, 2, 326, 324,
-	3, 2, 2, 2, 326, 327, 3, 2, 2, 2, 327, 73, 3, 2, 2, 2, 328, 329, 7, 14,
-	2, 2, 329, 334, 5, 76, 39, 2, 330, 331, 7, 13, 2, 2, 331, 333, 5, 76, 39,
-	2, 332, 330, 3, 2, 2, 2, 333, 336, 3, 2, 2, 2, 334, 332, 3, 2, 2, 2, 334,
-	335, 3, 2, 2, 2, 335, 344, 3, 2, 2, 2, 336, 334, 3, 2, 2, 2, 337, 338,
-	7, 15, 2, 2, 338, 341, 5, 76, 39, 2, 339, 340, 7, 13, 2, 2, 340, 342, 5,
-	76, 39, 2, 341, 339, 3, 2, 2, 2, 341, 342, 3, 2, 2, 2, 342, 344, 3, 2,
-	2, 2, 343, 328, 3, 2, 2, 2, 343, 337, 3, 2, 2, 2, 344, 345, 3, 2, 2, 2,
-	345, 343, 3, 2, 2, 2, 345, 346, 3, 2, 2, 2, 346, 349, 3, 2, 2, 2, 347,
-	349, 7, 14, 2, 2, 348, 343, 3, 2, 2, 2, 348, 347, 3, 2, 2, 2, 349, 75,
-	3, 2, 2, 2, 350, 352, 9, 2, 2, 2, 351, 350, 3, 2, 2, 2, 352, 353, 3, 2,
-	2, 2, 353, 351, 3, 2, 2, 2, 353, 354, 3, 2, 2, 2, 354, 77, 3, 2, 2, 2,
-	42, 81, 89, 99, 111, 126, 132, 144, 151, 155, 160, 166, 174, 181, 187,
-	195, 202, 208, 211, 223, 242, 251, 262, 268, 272, 278, 283, 286, 289, 298,
-	301, 305, 312, 322, 326, 334, 341, 343, 345, 348, 353,
-}
-var literalNames = []string{
-	"", "'='", "'('", "')'", "'{'", "'}'", "'*'", "'time.Time'", "'['", "']'",
-	"'returns'", "'-'", "'/'", "'/:'", "'@doc'", "'@handler'", "'interface{}'",
-	"'@server'",
-}
-var symbolicNames = []string{
-	"", "", "", "", "", "", "", "", "", "", "", "", "", "", "ATDOC", "ATHANDLER",
-	"INTERFACE", "ATSERVER", "WS", "COMMENT", "LINE_COMMENT", "STRING", "RAW_STRING",
-	"LINE_VALUE", "ID", "LetterOrDigit",
-}
-
-var ruleNames = []string{
-	"api", "spec", "syntaxLit", "importSpec", "importLit", "importBlock", "importBlockValue",
-	"importValue", "infoSpec", "typeSpec", "typeLit", "typeBlock", "typeLitBody",
-	"typeBlockBody", "typeStruct", "typeAlias", "typeBlockStruct", "typeBlockAlias",
-	"field", "normalField", "anonymousFiled", "dataType", "pointerType", "mapType",
-	"arrayType", "serviceSpec", "atServer", "serviceApi", "serviceRoute", "atDoc",
-	"atHandler", "route", "body", "replybody", "kvLit", "serviceName", "path",
-	"pathItem",
-}
-
-type ApiParserParser struct {
-	*antlr.BaseParser
-}
-
-// NewApiParserParser produces a new parser instance for the optional input antlr.TokenStream.
-//
-// The *ApiParserParser instance produced may be reused by calling the SetInputStream method.
-// The initial parser configuration is expensive to construct, and the object is not thread-safe;
-// however, if used within a Golang sync.Pool, the construction cost amortizes well and the
-// objects can be used in a thread-safe manner.
-func NewApiParserParser(input antlr.TokenStream) *ApiParserParser {
-	this := new(ApiParserParser)
-	deserializer := antlr.NewATNDeserializer(nil)
-	deserializedATN := deserializer.DeserializeFromUInt16(parserATN)
-	decisionToDFA := make([]*antlr.DFA, len(deserializedATN.DecisionToState))
-	for index, ds := range deserializedATN.DecisionToState {
-		decisionToDFA[index] = antlr.NewDFA(ds, index)
-	}
-	this.BaseParser = antlr.NewBaseParser(input)
-
-	this.Interpreter = antlr.NewParserATNSimulator(this, deserializedATN, decisionToDFA, antlr.NewPredictionContextCache())
-	this.RuleNames = ruleNames
-	this.LiteralNames = literalNames
-	this.SymbolicNames = symbolicNames
-	this.GrammarFileName = "ApiParser.g4"
-
-	return this
-}
-
-// ApiParserParser tokens.
-const (
-	ApiParserParserEOF           = antlr.TokenEOF
-	ApiParserParserT__0          = 1
-	ApiParserParserT__1          = 2
-	ApiParserParserT__2          = 3
-	ApiParserParserT__3          = 4
-	ApiParserParserT__4          = 5
-	ApiParserParserT__5          = 6
-	ApiParserParserT__6          = 7
-	ApiParserParserT__7          = 8
-	ApiParserParserT__8          = 9
-	ApiParserParserT__9          = 10
-	ApiParserParserT__10         = 11
-	ApiParserParserT__11         = 12
-	ApiParserParserT__12         = 13
-	ApiParserParserATDOC         = 14
-	ApiParserParserATHANDLER     = 15
-	ApiParserParserINTERFACE     = 16
-	ApiParserParserATSERVER      = 17
-	ApiParserParserWS            = 18
-	ApiParserParserCOMMENT       = 19
-	ApiParserParserLINE_COMMENT  = 20
-	ApiParserParserSTRING        = 21
-	ApiParserParserRAW_STRING    = 22
-	ApiParserParserLINE_VALUE    = 23
-	ApiParserParserID            = 24
-	ApiParserParserLetterOrDigit = 25
-)
-
-// ApiParserParser rules.
-const (
-	ApiParserParserRULE_api              = 0
-	ApiParserParserRULE_spec             = 1
-	ApiParserParserRULE_syntaxLit        = 2
-	ApiParserParserRULE_importSpec       = 3
-	ApiParserParserRULE_importLit        = 4
-	ApiParserParserRULE_importBlock      = 5
-	ApiParserParserRULE_importBlockValue = 6
-	ApiParserParserRULE_importValue      = 7
-	ApiParserParserRULE_infoSpec         = 8
-	ApiParserParserRULE_typeSpec         = 9
-	ApiParserParserRULE_typeLit          = 10
-	ApiParserParserRULE_typeBlock        = 11
-	ApiParserParserRULE_typeLitBody      = 12
-	ApiParserParserRULE_typeBlockBody    = 13
-	ApiParserParserRULE_typeStruct       = 14
-	ApiParserParserRULE_typeAlias        = 15
-	ApiParserParserRULE_typeBlockStruct  = 16
-	ApiParserParserRULE_typeBlockAlias   = 17
-	ApiParserParserRULE_field            = 18
-	ApiParserParserRULE_normalField      = 19
-	ApiParserParserRULE_anonymousFiled   = 20
-	ApiParserParserRULE_dataType         = 21
-	ApiParserParserRULE_pointerType      = 22
-	ApiParserParserRULE_mapType          = 23
-	ApiParserParserRULE_arrayType        = 24
-	ApiParserParserRULE_serviceSpec      = 25
-	ApiParserParserRULE_atServer         = 26
-	ApiParserParserRULE_serviceApi       = 27
-	ApiParserParserRULE_serviceRoute     = 28
-	ApiParserParserRULE_atDoc            = 29
-	ApiParserParserRULE_atHandler        = 30
-	ApiParserParserRULE_route            = 31
-	ApiParserParserRULE_body             = 32
-	ApiParserParserRULE_replybody        = 33
-	ApiParserParserRULE_kvLit            = 34
-	ApiParserParserRULE_serviceName      = 35
-	ApiParserParserRULE_path             = 36
-	ApiParserParserRULE_pathItem         = 37
-)
-
-// IApiContext is an interface to support dynamic dispatch.
-type IApiContext interface {
-	antlr.ParserRuleContext
-
-	// GetParser returns the parser.
-	GetParser() antlr.Parser
-
-	// IsApiContext differentiates from other interfaces.
-	IsApiContext()
-}
-
-type ApiContext struct {
-	*antlr.BaseParserRuleContext
-	parser antlr.Parser
-}
-
-func NewEmptyApiContext() *ApiContext {
-	var p = new(ApiContext)
-	p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1)
-	p.RuleIndex = ApiParserParserRULE_api
-	return p
-}
-
-func (*ApiContext) IsApiContext() {}
-
-func NewApiContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *ApiContext {
-	var p = new(ApiContext)
-
-	p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState)
-
-	p.parser = parser
-	p.RuleIndex = ApiParserParserRULE_api
-
-	return p
-}
-
-func (s *ApiContext) GetParser() antlr.Parser { return s.parser }
-
-func (s *ApiContext) AllSpec() []ISpecContext {
-	var ts = s.GetTypedRuleContexts(reflect.TypeOf((*ISpecContext)(nil)).Elem())
-	var tst = make([]ISpecContext, len(ts))
-
-	for i, t := range ts {
-		if t != nil {
-			tst[i] = t.(ISpecContext)
-		}
-	}
-
-	return tst
-}
-
-func (s *ApiContext) Spec(i int) ISpecContext {
-	var t = s.GetTypedRuleContext(reflect.TypeOf((*ISpecContext)(nil)).Elem(), i)
-
-	if t == nil {
-		return nil
-	}
-
-	return t.(ISpecContext)
-}
-
-func (s *ApiContext) GetRuleContext() antlr.RuleContext {
-	return s
-}
-
-func (s *ApiContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string {
-	return antlr.TreesStringTree(s, ruleNames, recog)
-}
-
-func (s *ApiContext) Accept(visitor antlr.ParseTreeVisitor) any {
-	switch t := visitor.(type) {
-	case ApiParserVisitor:
-		return t.VisitApi(s)
-
-	default:
-		return t.VisitChildren(s)
-	}
-}
-
-func (p *ApiParserParser) Api() (localctx IApiContext) {
-	localctx = NewApiContext(p, p.GetParserRuleContext(), p.GetState())
-	p.EnterRule(localctx, 0, ApiParserParserRULE_api)
-	var _la int
-
-	defer func() {
-		p.ExitRule()
-	}()
-
-	defer func() {
-		if err := recover(); err != nil {
-			if v, ok := err.(antlr.RecognitionException); ok {
-				localctx.SetException(v)
-				p.GetErrorHandler().ReportError(p, v)
-				p.GetErrorHandler().Recover(p, v)
-			} else {
-				panic(err)
-			}
-		}
-	}()
-
-	p.EnterOuterAlt(localctx, 1)
-	p.SetState(79)
-	p.GetErrorHandler().Sync(p)
-	_la = p.GetTokenStream().LA(1)
-
-	for _la == ApiParserParserATSERVER || _la == ApiParserParserID {
-		{
-			p.SetState(76)
-			p.Spec()
-		}
-
-		p.SetState(81)
-		p.GetErrorHandler().Sync(p)
-		_la = p.GetTokenStream().LA(1)
-	}
-
-	return localctx
-}
-
-// ISpecContext is an interface to support dynamic dispatch.
-type ISpecContext interface {
-	antlr.ParserRuleContext
-
-	// GetParser returns the parser.
-	GetParser() antlr.Parser
-
-	// IsSpecContext differentiates from other interfaces.
-	IsSpecContext()
-}
-
-type SpecContext struct {
-	*antlr.BaseParserRuleContext
-	parser antlr.Parser
-}
-
-func NewEmptySpecContext() *SpecContext {
-	var p = new(SpecContext)
-	p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1)
-	p.RuleIndex = ApiParserParserRULE_spec
-	return p
-}
-
-func (*SpecContext) IsSpecContext() {}
-
-func NewSpecContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *SpecContext {
-	var p = new(SpecContext)
-
-	p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState)
-
-	p.parser = parser
-	p.RuleIndex = ApiParserParserRULE_spec
-
-	return p
-}
-
-func (s *SpecContext) GetParser() antlr.Parser { return s.parser }
-
-func (s *SpecContext) SyntaxLit() ISyntaxLitContext {
-	var t = s.GetTypedRuleContext(reflect.TypeOf((*ISyntaxLitContext)(nil)).Elem(), 0)
-
-	if t == nil {
-		return nil
-	}
-
-	return t.(ISyntaxLitContext)
-}
-
-func (s *SpecContext) ImportSpec() IImportSpecContext {
-	var t = s.GetTypedRuleContext(reflect.TypeOf((*IImportSpecContext)(nil)).Elem(), 0)
-
-	if t == nil {
-		return nil
-	}
-
-	return t.(IImportSpecContext)
-}
-
-func (s *SpecContext) InfoSpec() IInfoSpecContext {
-	var t = s.GetTypedRuleContext(reflect.TypeOf((*IInfoSpecContext)(nil)).Elem(), 0)
-
-	if t == nil {
-		return nil
-	}
-
-	return t.(IInfoSpecContext)
-}
-
-func (s *SpecContext) TypeSpec() ITypeSpecContext {
-	var t = s.GetTypedRuleContext(reflect.TypeOf((*ITypeSpecContext)(nil)).Elem(), 0)
-
-	if t == nil {
-		return nil
-	}
-
-	return t.(ITypeSpecContext)
-}
-
-func (s *SpecContext) ServiceSpec() IServiceSpecContext {
-	var t = s.GetTypedRuleContext(reflect.TypeOf((*IServiceSpecContext)(nil)).Elem(), 0)
-
-	if t == nil {
-		return nil
-	}
-
-	return t.(IServiceSpecContext)
-}
-
-func (s *SpecContext) GetRuleContext() antlr.RuleContext {
-	return s
-}
-
-func (s *SpecContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string {
-	return antlr.TreesStringTree(s, ruleNames, recog)
-}
-
-func (s *SpecContext) Accept(visitor antlr.ParseTreeVisitor) any {
-	switch t := visitor.(type) {
-	case ApiParserVisitor:
-		return t.VisitSpec(s)
-
-	default:
-		return t.VisitChildren(s)
-	}
-}
-
-func (p *ApiParserParser) Spec() (localctx ISpecContext) {
-	localctx = NewSpecContext(p, p.GetParserRuleContext(), p.GetState())
-	p.EnterRule(localctx, 2, ApiParserParserRULE_spec)
-
-	defer func() {
-		p.ExitRule()
-	}()
-
-	defer func() {
-		if err := recover(); err != nil {
-			if v, ok := err.(antlr.RecognitionException); ok {
-				localctx.SetException(v)
-				p.GetErrorHandler().ReportError(p, v)
-				p.GetErrorHandler().Recover(p, v)
-			} else {
-				panic(err)
-			}
-		}
-	}()
-
-	p.SetState(87)
-	p.GetErrorHandler().Sync(p)
-	switch p.GetInterpreter().AdaptivePredict(p.GetTokenStream(), 1, p.GetParserRuleContext()) {
-	case 1:
-		p.EnterOuterAlt(localctx, 1)
-		{
-			p.SetState(82)
-			p.SyntaxLit()
-		}
-
-	case 2:
-		p.EnterOuterAlt(localctx, 2)
-		{
-			p.SetState(83)
-			p.ImportSpec()
-		}
-
-	case 3:
-		p.EnterOuterAlt(localctx, 3)
-		{
-			p.SetState(84)
-			p.InfoSpec()
-		}
-
-	case 4:
-		p.EnterOuterAlt(localctx, 4)
-		{
-			p.SetState(85)
-			p.TypeSpec()
-		}
-
-	case 5:
-		p.EnterOuterAlt(localctx, 5)
-		{
-			p.SetState(86)
-			p.ServiceSpec()
-		}
-
-	}
-
-	return localctx
-}
-
-// ISyntaxLitContext is an interface to support dynamic dispatch.
-type ISyntaxLitContext interface {
-	antlr.ParserRuleContext
-
-	// GetParser returns the parser.
-	GetParser() antlr.Parser
-
-	// GetSyntaxToken returns the syntaxToken token.
-	GetSyntaxToken() antlr.Token
-
-	// GetAssign returns the assign token.
-	GetAssign() antlr.Token
-
-	// GetVersion returns the version token.
-	GetVersion() antlr.Token
-
-	// SetSyntaxToken sets the syntaxToken token.
-	SetSyntaxToken(antlr.Token)
-
-	// SetAssign sets the assign token.
-	SetAssign(antlr.Token)
-
-	// SetVersion sets the version token.
-	SetVersion(antlr.Token)
-
-	// IsSyntaxLitContext differentiates from other interfaces.
-	IsSyntaxLitContext()
-}
-
-type SyntaxLitContext struct {
-	*antlr.BaseParserRuleContext
-	parser      antlr.Parser
-	syntaxToken antlr.Token
-	assign      antlr.Token
-	version     antlr.Token
-}
-
-func NewEmptySyntaxLitContext() *SyntaxLitContext {
-	var p = new(SyntaxLitContext)
-	p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1)
-	p.RuleIndex = ApiParserParserRULE_syntaxLit
-	return p
-}
-
-func (*SyntaxLitContext) IsSyntaxLitContext() {}
-
-func NewSyntaxLitContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *SyntaxLitContext {
-	var p = new(SyntaxLitContext)
-
-	p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState)
-
-	p.parser = parser
-	p.RuleIndex = ApiParserParserRULE_syntaxLit
-
-	return p
-}
-
-func (s *SyntaxLitContext) GetParser() antlr.Parser { return s.parser }
-
-func (s *SyntaxLitContext) GetSyntaxToken() antlr.Token { return s.syntaxToken }
-
-func (s *SyntaxLitContext) GetAssign() antlr.Token { return s.assign }
-
-func (s *SyntaxLitContext) GetVersion() antlr.Token { return s.version }
-
-func (s *SyntaxLitContext) SetSyntaxToken(v antlr.Token) { s.syntaxToken = v }
-
-func (s *SyntaxLitContext) SetAssign(v antlr.Token) { s.assign = v }
-
-func (s *SyntaxLitContext) SetVersion(v antlr.Token) { s.version = v }
-
-func (s *SyntaxLitContext) ID() antlr.TerminalNode {
-	return s.GetToken(ApiParserParserID, 0)
-}

+ 0 - 681
tools/goctlwt/api/parser/g4/gen/api/apiparser_parser1.go

@@ -1,681 +0,0 @@
-package api
-
-import (
-	"reflect"
-
-	"github.com/zeromicro/antlr"
-)
-
-// Part 1
-// The apiparser_parser.go file was split into multiple files because it
-// was too large and caused a possible memory overflow during goctlwt installation.
-
-func (s *SyntaxLitContext) STRING() antlr.TerminalNode {
-	return s.GetToken(ApiParserParserSTRING, 0)
-}
-
-func (s *SyntaxLitContext) GetRuleContext() antlr.RuleContext {
-	return s
-}
-
-func (s *SyntaxLitContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string {
-	return antlr.TreesStringTree(s, ruleNames, recog)
-}
-
-func (s *SyntaxLitContext) Accept(visitor antlr.ParseTreeVisitor) any {
-	switch t := visitor.(type) {
-	case ApiParserVisitor:
-		return t.VisitSyntaxLit(s)
-
-	default:
-		return t.VisitChildren(s)
-	}
-}
-
-func (p *ApiParserParser) SyntaxLit() (localctx ISyntaxLitContext) {
-	localctx = NewSyntaxLitContext(p, p.GetParserRuleContext(), p.GetState())
-	p.EnterRule(localctx, 4, ApiParserParserRULE_syntaxLit)
-
-	defer func() {
-		p.ExitRule()
-	}()
-
-	defer func() {
-		if err := recover(); err != nil {
-			if v, ok := err.(antlr.RecognitionException); ok {
-				localctx.SetException(v)
-				p.GetErrorHandler().ReportError(p, v)
-				p.GetErrorHandler().Recover(p, v)
-			} else {
-				panic(err)
-			}
-		}
-	}()
-
-	p.EnterOuterAlt(localctx, 1)
-	match(p, "syntax")
-	{
-		p.SetState(90)
-
-		var _m = p.Match(ApiParserParserID)
-
-		localctx.(*SyntaxLitContext).syntaxToken = _m
-	}
-	{
-		p.SetState(91)
-
-		var _m = p.Match(ApiParserParserT__0)
-
-		localctx.(*SyntaxLitContext).assign = _m
-	}
-	checkVersion(p)
-	{
-		p.SetState(93)
-
-		var _m = p.Match(ApiParserParserSTRING)
-
-		localctx.(*SyntaxLitContext).version = _m
-	}
-
-	return localctx
-}
-
-// IImportSpecContext is an interface to support dynamic dispatch.
-type IImportSpecContext interface {
-	antlr.ParserRuleContext
-
-	// GetParser returns the parser.
-	GetParser() antlr.Parser
-
-	// IsImportSpecContext differentiates from other interfaces.
-	IsImportSpecContext()
-}
-
-type ImportSpecContext struct {
-	*antlr.BaseParserRuleContext
-	parser antlr.Parser
-}
-
-func NewEmptyImportSpecContext() *ImportSpecContext {
-	var p = new(ImportSpecContext)
-	p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1)
-	p.RuleIndex = ApiParserParserRULE_importSpec
-	return p
-}
-
-func (*ImportSpecContext) IsImportSpecContext() {}
-
-func NewImportSpecContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *ImportSpecContext {
-	var p = new(ImportSpecContext)
-
-	p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState)
-
-	p.parser = parser
-	p.RuleIndex = ApiParserParserRULE_importSpec
-
-	return p
-}
-
-func (s *ImportSpecContext) GetParser() antlr.Parser { return s.parser }
-
-func (s *ImportSpecContext) ImportLit() IImportLitContext {
-	var t = s.GetTypedRuleContext(reflect.TypeOf((*IImportLitContext)(nil)).Elem(), 0)
-
-	if t == nil {
-		return nil
-	}
-
-	return t.(IImportLitContext)
-}
-
-func (s *ImportSpecContext) ImportBlock() IImportBlockContext {
-	var t = s.GetTypedRuleContext(reflect.TypeOf((*IImportBlockContext)(nil)).Elem(), 0)
-
-	if t == nil {
-		return nil
-	}
-
-	return t.(IImportBlockContext)
-}
-
-func (s *ImportSpecContext) GetRuleContext() antlr.RuleContext {
-	return s
-}
-
-func (s *ImportSpecContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string {
-	return antlr.TreesStringTree(s, ruleNames, recog)
-}
-
-func (s *ImportSpecContext) Accept(visitor antlr.ParseTreeVisitor) any {
-	switch t := visitor.(type) {
-	case ApiParserVisitor:
-		return t.VisitImportSpec(s)
-
-	default:
-		return t.VisitChildren(s)
-	}
-}
-
-func (p *ApiParserParser) ImportSpec() (localctx IImportSpecContext) {
-	localctx = NewImportSpecContext(p, p.GetParserRuleContext(), p.GetState())
-	p.EnterRule(localctx, 6, ApiParserParserRULE_importSpec)
-
-	defer func() {
-		p.ExitRule()
-	}()
-
-	defer func() {
-		if err := recover(); err != nil {
-			if v, ok := err.(antlr.RecognitionException); ok {
-				localctx.SetException(v)
-				p.GetErrorHandler().ReportError(p, v)
-				p.GetErrorHandler().Recover(p, v)
-			} else {
-				panic(err)
-			}
-		}
-	}()
-
-	p.SetState(97)
-	p.GetErrorHandler().Sync(p)
-	switch p.GetInterpreter().AdaptivePredict(p.GetTokenStream(), 2, p.GetParserRuleContext()) {
-	case 1:
-		p.EnterOuterAlt(localctx, 1)
-		{
-			p.SetState(95)
-			p.ImportLit()
-		}
-
-	case 2:
-		p.EnterOuterAlt(localctx, 2)
-		{
-			p.SetState(96)
-			p.ImportBlock()
-		}
-
-	}
-
-	return localctx
-}
-
-// IImportLitContext is an interface to support dynamic dispatch.
-type IImportLitContext interface {
-	antlr.ParserRuleContext
-
-	// GetParser returns the parser.
-	GetParser() antlr.Parser
-
-	// GetImportToken returns the importToken token.
-	GetImportToken() antlr.Token
-
-	// SetImportToken sets the importToken token.
-	SetImportToken(antlr.Token)
-
-	// IsImportLitContext differentiates from other interfaces.
-	IsImportLitContext()
-}
-
-type ImportLitContext struct {
-	*antlr.BaseParserRuleContext
-	parser      antlr.Parser
-	importToken antlr.Token
-}
-
-func NewEmptyImportLitContext() *ImportLitContext {
-	var p = new(ImportLitContext)
-	p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1)
-	p.RuleIndex = ApiParserParserRULE_importLit
-	return p
-}
-
-func (*ImportLitContext) IsImportLitContext() {}
-
-func NewImportLitContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *ImportLitContext {
-	var p = new(ImportLitContext)
-
-	p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState)
-
-	p.parser = parser
-	p.RuleIndex = ApiParserParserRULE_importLit
-
-	return p
-}
-
-func (s *ImportLitContext) GetParser() antlr.Parser { return s.parser }
-
-func (s *ImportLitContext) GetImportToken() antlr.Token { return s.importToken }
-
-func (s *ImportLitContext) SetImportToken(v antlr.Token) { s.importToken = v }
-
-func (s *ImportLitContext) ImportValue() IImportValueContext {
-	var t = s.GetTypedRuleContext(reflect.TypeOf((*IImportValueContext)(nil)).Elem(), 0)
-
-	if t == nil {
-		return nil
-	}
-
-	return t.(IImportValueContext)
-}
-
-func (s *ImportLitContext) ID() antlr.TerminalNode {
-	return s.GetToken(ApiParserParserID, 0)
-}
-
-func (s *ImportLitContext) GetRuleContext() antlr.RuleContext {
-	return s
-}
-
-func (s *ImportLitContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string {
-	return antlr.TreesStringTree(s, ruleNames, recog)
-}
-
-func (s *ImportLitContext) Accept(visitor antlr.ParseTreeVisitor) any {
-	switch t := visitor.(type) {
-	case ApiParserVisitor:
-		return t.VisitImportLit(s)
-
-	default:
-		return t.VisitChildren(s)
-	}
-}
-
-func (p *ApiParserParser) ImportLit() (localctx IImportLitContext) {
-	localctx = NewImportLitContext(p, p.GetParserRuleContext(), p.GetState())
-	p.EnterRule(localctx, 8, ApiParserParserRULE_importLit)
-
-	defer func() {
-		p.ExitRule()
-	}()
-
-	defer func() {
-		if err := recover(); err != nil {
-			if v, ok := err.(antlr.RecognitionException); ok {
-				localctx.SetException(v)
-				p.GetErrorHandler().ReportError(p, v)
-				p.GetErrorHandler().Recover(p, v)
-			} else {
-				panic(err)
-			}
-		}
-	}()
-
-	p.EnterOuterAlt(localctx, 1)
-	match(p, "import")
-	{
-		p.SetState(100)
-
-		var _m = p.Match(ApiParserParserID)
-
-		localctx.(*ImportLitContext).importToken = _m
-	}
-	{
-		p.SetState(101)
-		p.ImportValue()
-	}
-
-	return localctx
-}
-
-// IImportBlockContext is an interface to support dynamic dispatch.
-type IImportBlockContext interface {
-	antlr.ParserRuleContext
-
-	// GetParser returns the parser.
-	GetParser() antlr.Parser
-
-	// GetImportToken returns the importToken token.
-	GetImportToken() antlr.Token
-
-	// SetImportToken sets the importToken token.
-	SetImportToken(antlr.Token)
-
-	// IsImportBlockContext differentiates from other interfaces.
-	IsImportBlockContext()
-}
-
-type ImportBlockContext struct {
-	*antlr.BaseParserRuleContext
-	parser      antlr.Parser
-	importToken antlr.Token
-}
-
-func NewEmptyImportBlockContext() *ImportBlockContext {
-	var p = new(ImportBlockContext)
-	p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1)
-	p.RuleIndex = ApiParserParserRULE_importBlock
-	return p
-}
-
-func (*ImportBlockContext) IsImportBlockContext() {}
-
-func NewImportBlockContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *ImportBlockContext {
-	var p = new(ImportBlockContext)
-
-	p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState)
-
-	p.parser = parser
-	p.RuleIndex = ApiParserParserRULE_importBlock
-
-	return p
-}
-
-func (s *ImportBlockContext) GetParser() antlr.Parser { return s.parser }
-
-func (s *ImportBlockContext) GetImportToken() antlr.Token { return s.importToken }
-
-func (s *ImportBlockContext) SetImportToken(v antlr.Token) { s.importToken = v }
-
-func (s *ImportBlockContext) ID() antlr.TerminalNode {
-	return s.GetToken(ApiParserParserID, 0)
-}
-
-func (s *ImportBlockContext) AllImportBlockValue() []IImportBlockValueContext {
-	var ts = s.GetTypedRuleContexts(reflect.TypeOf((*IImportBlockValueContext)(nil)).Elem())
-	var tst = make([]IImportBlockValueContext, len(ts))
-
-	for i, t := range ts {
-		if t != nil {
-			tst[i] = t.(IImportBlockValueContext)
-		}
-	}
-
-	return tst
-}
-
-func (s *ImportBlockContext) ImportBlockValue(i int) IImportBlockValueContext {
-	var t = s.GetTypedRuleContext(reflect.TypeOf((*IImportBlockValueContext)(nil)).Elem(), i)
-
-	if t == nil {
-		return nil
-	}
-
-	return t.(IImportBlockValueContext)
-}
-
-func (s *ImportBlockContext) GetRuleContext() antlr.RuleContext {
-	return s
-}
-
-func (s *ImportBlockContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string {
-	return antlr.TreesStringTree(s, ruleNames, recog)
-}
-
-func (s *ImportBlockContext) Accept(visitor antlr.ParseTreeVisitor) any {
-	switch t := visitor.(type) {
-	case ApiParserVisitor:
-		return t.VisitImportBlock(s)
-
-	default:
-		return t.VisitChildren(s)
-	}
-}
-
-func (p *ApiParserParser) ImportBlock() (localctx IImportBlockContext) {
-	localctx = NewImportBlockContext(p, p.GetParserRuleContext(), p.GetState())
-	p.EnterRule(localctx, 10, ApiParserParserRULE_importBlock)
-	var _la int
-
-	defer func() {
-		p.ExitRule()
-	}()
-
-	defer func() {
-		if err := recover(); err != nil {
-			if v, ok := err.(antlr.RecognitionException); ok {
-				localctx.SetException(v)
-				p.GetErrorHandler().ReportError(p, v)
-				p.GetErrorHandler().Recover(p, v)
-			} else {
-				panic(err)
-			}
-		}
-	}()
-
-	p.EnterOuterAlt(localctx, 1)
-	match(p, "import")
-	{
-		p.SetState(104)
-
-		var _m = p.Match(ApiParserParserID)
-
-		localctx.(*ImportBlockContext).importToken = _m
-	}
-	{
-		p.SetState(105)
-		p.Match(ApiParserParserT__1)
-	}
-	p.SetState(107)
-	p.GetErrorHandler().Sync(p)
-	_la = p.GetTokenStream().LA(1)
-
-	for ok := true; ok; ok = _la == ApiParserParserSTRING {
-		{
-			p.SetState(106)
-			p.ImportBlockValue()
-		}
-
-		p.SetState(109)
-		p.GetErrorHandler().Sync(p)
-		_la = p.GetTokenStream().LA(1)
-	}
-	{
-		p.SetState(111)
-		p.Match(ApiParserParserT__2)
-	}
-
-	return localctx
-}
-
-// IImportBlockValueContext is an interface to support dynamic dispatch.
-type IImportBlockValueContext interface {
-	antlr.ParserRuleContext
-
-	// GetParser returns the parser.
-	GetParser() antlr.Parser
-
-	// IsImportBlockValueContext differentiates from other interfaces.
-	IsImportBlockValueContext()
-}
-
-type ImportBlockValueContext struct {
-	*antlr.BaseParserRuleContext
-	parser antlr.Parser
-}
-
-func NewEmptyImportBlockValueContext() *ImportBlockValueContext {
-	var p = new(ImportBlockValueContext)
-	p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1)
-	p.RuleIndex = ApiParserParserRULE_importBlockValue
-	return p
-}
-
-func (*ImportBlockValueContext) IsImportBlockValueContext() {}
-
-func NewImportBlockValueContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *ImportBlockValueContext {
-	var p = new(ImportBlockValueContext)
-
-	p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState)
-
-	p.parser = parser
-	p.RuleIndex = ApiParserParserRULE_importBlockValue
-
-	return p
-}
-
-func (s *ImportBlockValueContext) GetParser() antlr.Parser { return s.parser }
-
-func (s *ImportBlockValueContext) ImportValue() IImportValueContext {
-	var t = s.GetTypedRuleContext(reflect.TypeOf((*IImportValueContext)(nil)).Elem(), 0)
-
-	if t == nil {
-		return nil
-	}
-
-	return t.(IImportValueContext)
-}
-
-func (s *ImportBlockValueContext) GetRuleContext() antlr.RuleContext {
-	return s
-}
-
-func (s *ImportBlockValueContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string {
-	return antlr.TreesStringTree(s, ruleNames, recog)
-}
-
-func (s *ImportBlockValueContext) Accept(visitor antlr.ParseTreeVisitor) any {
-	switch t := visitor.(type) {
-	case ApiParserVisitor:
-		return t.VisitImportBlockValue(s)
-
-	default:
-		return t.VisitChildren(s)
-	}
-}
-
-func (p *ApiParserParser) ImportBlockValue() (localctx IImportBlockValueContext) {
-	localctx = NewImportBlockValueContext(p, p.GetParserRuleContext(), p.GetState())
-	p.EnterRule(localctx, 12, ApiParserParserRULE_importBlockValue)
-
-	defer func() {
-		p.ExitRule()
-	}()
-
-	defer func() {
-		if err := recover(); err != nil {
-			if v, ok := err.(antlr.RecognitionException); ok {
-				localctx.SetException(v)
-				p.GetErrorHandler().ReportError(p, v)
-				p.GetErrorHandler().Recover(p, v)
-			} else {
-				panic(err)
-			}
-		}
-	}()
-
-	p.EnterOuterAlt(localctx, 1)
-	{
-		p.SetState(113)
-		p.ImportValue()
-	}
-
-	return localctx
-}
-
-// IImportValueContext is an interface to support dynamic dispatch.
-type IImportValueContext interface {
-	antlr.ParserRuleContext
-
-	// GetParser returns the parser.
-	GetParser() antlr.Parser
-
-	// IsImportValueContext differentiates from other interfaces.
-	IsImportValueContext()
-}
-
-type ImportValueContext struct {
-	*antlr.BaseParserRuleContext
-	parser antlr.Parser
-}
-
-func NewEmptyImportValueContext() *ImportValueContext {
-	var p = new(ImportValueContext)
-	p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1)
-	p.RuleIndex = ApiParserParserRULE_importValue
-	return p
-}
-
-func (*ImportValueContext) IsImportValueContext() {}
-
-func NewImportValueContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *ImportValueContext {
-	var p = new(ImportValueContext)
-
-	p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState)
-
-	p.parser = parser
-	p.RuleIndex = ApiParserParserRULE_importValue
-
-	return p
-}
-
-func (s *ImportValueContext) GetParser() antlr.Parser { return s.parser }
-
-func (s *ImportValueContext) STRING() antlr.TerminalNode {
-	return s.GetToken(ApiParserParserSTRING, 0)
-}
-
-func (s *ImportValueContext) GetRuleContext() antlr.RuleContext {
-	return s
-}
-
-func (s *ImportValueContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string {
-	return antlr.TreesStringTree(s, ruleNames, recog)
-}
-
-func (s *ImportValueContext) Accept(visitor antlr.ParseTreeVisitor) any {
-	switch t := visitor.(type) {
-	case ApiParserVisitor:
-		return t.VisitImportValue(s)
-
-	default:
-		return t.VisitChildren(s)
-	}
-}
-
-func (p *ApiParserParser) ImportValue() (localctx IImportValueContext) {
-	localctx = NewImportValueContext(p, p.GetParserRuleContext(), p.GetState())
-	p.EnterRule(localctx, 14, ApiParserParserRULE_importValue)
-
-	defer func() {
-		p.ExitRule()
-	}()
-
-	defer func() {
-		if err := recover(); err != nil {
-			if v, ok := err.(antlr.RecognitionException); ok {
-				localctx.SetException(v)
-				p.GetErrorHandler().ReportError(p, v)
-				p.GetErrorHandler().Recover(p, v)
-			} else {
-				panic(err)
-			}
-		}
-	}()
-
-	p.EnterOuterAlt(localctx, 1)
-	checkImportValue(p)
-	{
-		p.SetState(116)
-		p.Match(ApiParserParserSTRING)
-	}
-
-	return localctx
-}
-
-// IInfoSpecContext is an interface to support dynamic dispatch.
-type IInfoSpecContext interface {
-	antlr.ParserRuleContext
-
-	// GetParser returns the parser.
-	GetParser() antlr.Parser
-
-	// GetInfoToken returns the infoToken token.
-	GetInfoToken() antlr.Token
-
-	// GetLp returns the lp token.
-	GetLp() antlr.Token
-
-	// GetRp returns the rp token.
-	GetRp() antlr.Token
-
-	// SetInfoToken sets the infoToken token.
-	SetInfoToken(antlr.Token)
-
-	// SetLp sets the lp token.
-	SetLp(antlr.Token)
-
-	// SetRp sets the rp token.
-	SetRp(antlr.Token)
-
-	// IsInfoSpecContext differentiates from other interfaces.
-	IsInfoSpecContext()
-}

+ 0 - 692
tools/goctlwt/api/parser/g4/gen/api/apiparser_parser2.go

@@ -1,692 +0,0 @@
-package api
-
-import (
-	"reflect"
-
-	"github.com/zeromicro/antlr"
-)
-
-// Part 2
-// The apiparser_parser.go file was split into multiple files because it
-// was too large and caused a possible memory overflow during goctlwt installation.
-
-type InfoSpecContext struct {
-	*antlr.BaseParserRuleContext
-	parser    antlr.Parser
-	infoToken antlr.Token
-	lp        antlr.Token
-	rp        antlr.Token
-}
-
-func NewEmptyInfoSpecContext() *InfoSpecContext {
-	var p = new(InfoSpecContext)
-	p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1)
-	p.RuleIndex = ApiParserParserRULE_infoSpec
-	return p
-}
-
-func (*InfoSpecContext) IsInfoSpecContext() {}
-
-func NewInfoSpecContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *InfoSpecContext {
-	var p = new(InfoSpecContext)
-
-	p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState)
-
-	p.parser = parser
-	p.RuleIndex = ApiParserParserRULE_infoSpec
-
-	return p
-}
-
-func (s *InfoSpecContext) GetParser() antlr.Parser { return s.parser }
-
-func (s *InfoSpecContext) GetInfoToken() antlr.Token { return s.infoToken }
-
-func (s *InfoSpecContext) GetLp() antlr.Token { return s.lp }
-
-func (s *InfoSpecContext) GetRp() antlr.Token { return s.rp }
-
-func (s *InfoSpecContext) SetInfoToken(v antlr.Token) { s.infoToken = v }
-
-func (s *InfoSpecContext) SetLp(v antlr.Token) { s.lp = v }
-
-func (s *InfoSpecContext) SetRp(v antlr.Token) { s.rp = v }
-
-func (s *InfoSpecContext) ID() antlr.TerminalNode {
-	return s.GetToken(ApiParserParserID, 0)
-}
-
-func (s *InfoSpecContext) AllKvLit() []IKvLitContext {
-	var ts = s.GetTypedRuleContexts(reflect.TypeOf((*IKvLitContext)(nil)).Elem())
-	var tst = make([]IKvLitContext, len(ts))
-
-	for i, t := range ts {
-		if t != nil {
-			tst[i] = t.(IKvLitContext)
-		}
-	}
-
-	return tst
-}
-
-func (s *InfoSpecContext) KvLit(i int) IKvLitContext {
-	var t = s.GetTypedRuleContext(reflect.TypeOf((*IKvLitContext)(nil)).Elem(), i)
-
-	if t == nil {
-		return nil
-	}
-
-	return t.(IKvLitContext)
-}
-
-func (s *InfoSpecContext) GetRuleContext() antlr.RuleContext {
-	return s
-}
-
-func (s *InfoSpecContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string {
-	return antlr.TreesStringTree(s, ruleNames, recog)
-}
-
-func (s *InfoSpecContext) Accept(visitor antlr.ParseTreeVisitor) any {
-	switch t := visitor.(type) {
-	case ApiParserVisitor:
-		return t.VisitInfoSpec(s)
-
-	default:
-		return t.VisitChildren(s)
-	}
-}
-
-func (p *ApiParserParser) InfoSpec() (localctx IInfoSpecContext) {
-	localctx = NewInfoSpecContext(p, p.GetParserRuleContext(), p.GetState())
-	p.EnterRule(localctx, 16, ApiParserParserRULE_infoSpec)
-	var _la int
-
-	defer func() {
-		p.ExitRule()
-	}()
-
-	defer func() {
-		if err := recover(); err != nil {
-			if v, ok := err.(antlr.RecognitionException); ok {
-				localctx.SetException(v)
-				p.GetErrorHandler().ReportError(p, v)
-				p.GetErrorHandler().Recover(p, v)
-			} else {
-				panic(err)
-			}
-		}
-	}()
-
-	p.EnterOuterAlt(localctx, 1)
-	match(p, "info")
-	{
-		p.SetState(119)
-
-		var _m = p.Match(ApiParserParserID)
-
-		localctx.(*InfoSpecContext).infoToken = _m
-	}
-	{
-		p.SetState(120)
-
-		var _m = p.Match(ApiParserParserT__1)
-
-		localctx.(*InfoSpecContext).lp = _m
-	}
-	p.SetState(122)
-	p.GetErrorHandler().Sync(p)
-	_la = p.GetTokenStream().LA(1)
-
-	for ok := true; ok; ok = _la == ApiParserParserID {
-		{
-			p.SetState(121)
-			p.KvLit()
-		}
-
-		p.SetState(124)
-		p.GetErrorHandler().Sync(p)
-		_la = p.GetTokenStream().LA(1)
-	}
-	{
-		p.SetState(126)
-
-		var _m = p.Match(ApiParserParserT__2)
-
-		localctx.(*InfoSpecContext).rp = _m
-	}
-
-	return localctx
-}
-
-// ITypeSpecContext is an interface to support dynamic dispatch.
-type ITypeSpecContext interface {
-	antlr.ParserRuleContext
-
-	// GetParser returns the parser.
-	GetParser() antlr.Parser
-
-	// IsTypeSpecContext differentiates from other interfaces.
-	IsTypeSpecContext()
-}
-
-type TypeSpecContext struct {
-	*antlr.BaseParserRuleContext
-	parser antlr.Parser
-}
-
-func NewEmptyTypeSpecContext() *TypeSpecContext {
-	var p = new(TypeSpecContext)
-	p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1)
-	p.RuleIndex = ApiParserParserRULE_typeSpec
-	return p
-}
-
-func (*TypeSpecContext) IsTypeSpecContext() {}
-
-func NewTypeSpecContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *TypeSpecContext {
-	var p = new(TypeSpecContext)
-
-	p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState)
-
-	p.parser = parser
-	p.RuleIndex = ApiParserParserRULE_typeSpec
-
-	return p
-}
-
-func (s *TypeSpecContext) GetParser() antlr.Parser { return s.parser }
-
-func (s *TypeSpecContext) TypeLit() ITypeLitContext {
-	var t = s.GetTypedRuleContext(reflect.TypeOf((*ITypeLitContext)(nil)).Elem(), 0)
-
-	if t == nil {
-		return nil
-	}
-
-	return t.(ITypeLitContext)
-}
-
-func (s *TypeSpecContext) TypeBlock() ITypeBlockContext {
-	var t = s.GetTypedRuleContext(reflect.TypeOf((*ITypeBlockContext)(nil)).Elem(), 0)
-
-	if t == nil {
-		return nil
-	}
-
-	return t.(ITypeBlockContext)
-}
-
-func (s *TypeSpecContext) GetRuleContext() antlr.RuleContext {
-	return s
-}
-
-func (s *TypeSpecContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string {
-	return antlr.TreesStringTree(s, ruleNames, recog)
-}
-
-func (s *TypeSpecContext) Accept(visitor antlr.ParseTreeVisitor) any {
-	switch t := visitor.(type) {
-	case ApiParserVisitor:
-		return t.VisitTypeSpec(s)
-
-	default:
-		return t.VisitChildren(s)
-	}
-}
-
-func (p *ApiParserParser) TypeSpec() (localctx ITypeSpecContext) {
-	localctx = NewTypeSpecContext(p, p.GetParserRuleContext(), p.GetState())
-	p.EnterRule(localctx, 18, ApiParserParserRULE_typeSpec)
-
-	defer func() {
-		p.ExitRule()
-	}()
-
-	defer func() {
-		if err := recover(); err != nil {
-			if v, ok := err.(antlr.RecognitionException); ok {
-				localctx.SetException(v)
-				p.GetErrorHandler().ReportError(p, v)
-				p.GetErrorHandler().Recover(p, v)
-			} else {
-				panic(err)
-			}
-		}
-	}()
-
-	p.SetState(130)
-	p.GetErrorHandler().Sync(p)
-	switch p.GetInterpreter().AdaptivePredict(p.GetTokenStream(), 5, p.GetParserRuleContext()) {
-	case 1:
-		p.EnterOuterAlt(localctx, 1)
-		{
-			p.SetState(128)
-			p.TypeLit()
-		}
-
-	case 2:
-		p.EnterOuterAlt(localctx, 2)
-		{
-			p.SetState(129)
-			p.TypeBlock()
-		}
-
-	}
-
-	return localctx
-}
-
-// ITypeLitContext is an interface to support dynamic dispatch.
-type ITypeLitContext interface {
-	antlr.ParserRuleContext
-
-	// GetParser returns the parser.
-	GetParser() antlr.Parser
-
-	// GetTypeToken returns the typeToken token.
-	GetTypeToken() antlr.Token
-
-	// SetTypeToken sets the typeToken token.
-	SetTypeToken(antlr.Token)
-
-	// IsTypeLitContext differentiates from other interfaces.
-	IsTypeLitContext()
-}
-
-type TypeLitContext struct {
-	*antlr.BaseParserRuleContext
-	parser    antlr.Parser
-	typeToken antlr.Token
-}
-
-func NewEmptyTypeLitContext() *TypeLitContext {
-	var p = new(TypeLitContext)
-	p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1)
-	p.RuleIndex = ApiParserParserRULE_typeLit
-	return p
-}
-
-func (*TypeLitContext) IsTypeLitContext() {}
-
-func NewTypeLitContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *TypeLitContext {
-	var p = new(TypeLitContext)
-
-	p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState)
-
-	p.parser = parser
-	p.RuleIndex = ApiParserParserRULE_typeLit
-
-	return p
-}
-
-func (s *TypeLitContext) GetParser() antlr.Parser { return s.parser }
-
-func (s *TypeLitContext) GetTypeToken() antlr.Token { return s.typeToken }
-
-func (s *TypeLitContext) SetTypeToken(v antlr.Token) { s.typeToken = v }
-
-func (s *TypeLitContext) TypeLitBody() ITypeLitBodyContext {
-	var t = s.GetTypedRuleContext(reflect.TypeOf((*ITypeLitBodyContext)(nil)).Elem(), 0)
-
-	if t == nil {
-		return nil
-	}
-
-	return t.(ITypeLitBodyContext)
-}
-
-func (s *TypeLitContext) ID() antlr.TerminalNode {
-	return s.GetToken(ApiParserParserID, 0)
-}
-
-func (s *TypeLitContext) GetRuleContext() antlr.RuleContext {
-	return s
-}
-
-func (s *TypeLitContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string {
-	return antlr.TreesStringTree(s, ruleNames, recog)
-}
-
-func (s *TypeLitContext) Accept(visitor antlr.ParseTreeVisitor) any {
-	switch t := visitor.(type) {
-	case ApiParserVisitor:
-		return t.VisitTypeLit(s)
-
-	default:
-		return t.VisitChildren(s)
-	}
-}
-
-func (p *ApiParserParser) TypeLit() (localctx ITypeLitContext) {
-	localctx = NewTypeLitContext(p, p.GetParserRuleContext(), p.GetState())
-	p.EnterRule(localctx, 20, ApiParserParserRULE_typeLit)
-
-	defer func() {
-		p.ExitRule()
-	}()
-
-	defer func() {
-		if err := recover(); err != nil {
-			if v, ok := err.(antlr.RecognitionException); ok {
-				localctx.SetException(v)
-				p.GetErrorHandler().ReportError(p, v)
-				p.GetErrorHandler().Recover(p, v)
-			} else {
-				panic(err)
-			}
-		}
-	}()
-
-	p.EnterOuterAlt(localctx, 1)
-	match(p, "type")
-	{
-		p.SetState(133)
-
-		var _m = p.Match(ApiParserParserID)
-
-		localctx.(*TypeLitContext).typeToken = _m
-	}
-	{
-		p.SetState(134)
-		p.TypeLitBody()
-	}
-
-	return localctx
-}
-
-// ITypeBlockContext is an interface to support dynamic dispatch.
-type ITypeBlockContext interface {
-	antlr.ParserRuleContext
-
-	// GetParser returns the parser.
-	GetParser() antlr.Parser
-
-	// GetTypeToken returns the typeToken token.
-	GetTypeToken() antlr.Token
-
-	// GetLp returns the lp token.
-	GetLp() antlr.Token
-
-	// GetRp returns the rp token.
-	GetRp() antlr.Token
-
-	// SetTypeToken sets the typeToken token.
-	SetTypeToken(antlr.Token)
-
-	// SetLp sets the lp token.
-	SetLp(antlr.Token)
-
-	// SetRp sets the rp token.
-	SetRp(antlr.Token)
-
-	// IsTypeBlockContext differentiates from other interfaces.
-	IsTypeBlockContext()
-}
-
-type TypeBlockContext struct {
-	*antlr.BaseParserRuleContext
-	parser    antlr.Parser
-	typeToken antlr.Token
-	lp        antlr.Token
-	rp        antlr.Token
-}
-
-func NewEmptyTypeBlockContext() *TypeBlockContext {
-	var p = new(TypeBlockContext)
-	p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1)
-	p.RuleIndex = ApiParserParserRULE_typeBlock
-	return p
-}
-
-func (*TypeBlockContext) IsTypeBlockContext() {}
-
-func NewTypeBlockContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *TypeBlockContext {
-	var p = new(TypeBlockContext)
-
-	p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState)
-
-	p.parser = parser
-	p.RuleIndex = ApiParserParserRULE_typeBlock
-
-	return p
-}
-
-func (s *TypeBlockContext) GetParser() antlr.Parser { return s.parser }
-
-func (s *TypeBlockContext) GetTypeToken() antlr.Token { return s.typeToken }
-
-func (s *TypeBlockContext) GetLp() antlr.Token { return s.lp }
-
-func (s *TypeBlockContext) GetRp() antlr.Token { return s.rp }
-
-func (s *TypeBlockContext) SetTypeToken(v antlr.Token) { s.typeToken = v }
-
-func (s *TypeBlockContext) SetLp(v antlr.Token) { s.lp = v }
-
-func (s *TypeBlockContext) SetRp(v antlr.Token) { s.rp = v }
-
-func (s *TypeBlockContext) ID() antlr.TerminalNode {
-	return s.GetToken(ApiParserParserID, 0)
-}
-
-func (s *TypeBlockContext) AllTypeBlockBody() []ITypeBlockBodyContext {
-	var ts = s.GetTypedRuleContexts(reflect.TypeOf((*ITypeBlockBodyContext)(nil)).Elem())
-	var tst = make([]ITypeBlockBodyContext, len(ts))
-
-	for i, t := range ts {
-		if t != nil {
-			tst[i] = t.(ITypeBlockBodyContext)
-		}
-	}
-
-	return tst
-}
-
-func (s *TypeBlockContext) TypeBlockBody(i int) ITypeBlockBodyContext {
-	var t = s.GetTypedRuleContext(reflect.TypeOf((*ITypeBlockBodyContext)(nil)).Elem(), i)
-
-	if t == nil {
-		return nil
-	}
-
-	return t.(ITypeBlockBodyContext)
-}
-
-func (s *TypeBlockContext) GetRuleContext() antlr.RuleContext {
-	return s
-}
-
-func (s *TypeBlockContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string {
-	return antlr.TreesStringTree(s, ruleNames, recog)
-}
-
-func (s *TypeBlockContext) Accept(visitor antlr.ParseTreeVisitor) any {
-	switch t := visitor.(type) {
-	case ApiParserVisitor:
-		return t.VisitTypeBlock(s)
-
-	default:
-		return t.VisitChildren(s)
-	}
-}
-
-func (p *ApiParserParser) TypeBlock() (localctx ITypeBlockContext) {
-	localctx = NewTypeBlockContext(p, p.GetParserRuleContext(), p.GetState())
-	p.EnterRule(localctx, 22, ApiParserParserRULE_typeBlock)
-	var _la int
-
-	defer func() {
-		p.ExitRule()
-	}()
-
-	defer func() {
-		if err := recover(); err != nil {
-			if v, ok := err.(antlr.RecognitionException); ok {
-				localctx.SetException(v)
-				p.GetErrorHandler().ReportError(p, v)
-				p.GetErrorHandler().Recover(p, v)
-			} else {
-				panic(err)
-			}
-		}
-	}()
-
-	p.EnterOuterAlt(localctx, 1)
-	match(p, "type")
-	{
-		p.SetState(137)
-
-		var _m = p.Match(ApiParserParserID)
-
-		localctx.(*TypeBlockContext).typeToken = _m
-	}
-	{
-		p.SetState(138)
-
-		var _m = p.Match(ApiParserParserT__1)
-
-		localctx.(*TypeBlockContext).lp = _m
-	}
-	p.SetState(142)
-	p.GetErrorHandler().Sync(p)
-	_la = p.GetTokenStream().LA(1)
-
-	for _la == ApiParserParserID {
-		{
-			p.SetState(139)
-			p.TypeBlockBody()
-		}
-
-		p.SetState(144)
-		p.GetErrorHandler().Sync(p)
-		_la = p.GetTokenStream().LA(1)
-	}
-	{
-		p.SetState(145)
-
-		var _m = p.Match(ApiParserParserT__2)
-
-		localctx.(*TypeBlockContext).rp = _m
-	}
-
-	return localctx
-}
-
-// ITypeLitBodyContext is an interface to support dynamic dispatch.
-type ITypeLitBodyContext interface {
-	antlr.ParserRuleContext
-
-	// GetParser returns the parser.
-	GetParser() antlr.Parser
-
-	// IsTypeLitBodyContext differentiates from other interfaces.
-	IsTypeLitBodyContext()
-}
-
-type TypeLitBodyContext struct {
-	*antlr.BaseParserRuleContext
-	parser antlr.Parser
-}
-
-func NewEmptyTypeLitBodyContext() *TypeLitBodyContext {
-	var p = new(TypeLitBodyContext)
-	p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1)
-	p.RuleIndex = ApiParserParserRULE_typeLitBody
-	return p
-}
-
-func (*TypeLitBodyContext) IsTypeLitBodyContext() {}
-
-func NewTypeLitBodyContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *TypeLitBodyContext {
-	var p = new(TypeLitBodyContext)
-
-	p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState)
-
-	p.parser = parser
-	p.RuleIndex = ApiParserParserRULE_typeLitBody
-
-	return p
-}
-
-func (s *TypeLitBodyContext) GetParser() antlr.Parser { return s.parser }
-
-func (s *TypeLitBodyContext) TypeStruct() ITypeStructContext {
-	var t = s.GetTypedRuleContext(reflect.TypeOf((*ITypeStructContext)(nil)).Elem(), 0)
-
-	if t == nil {
-		return nil
-	}
-
-	return t.(ITypeStructContext)
-}
-
-func (s *TypeLitBodyContext) TypeAlias() ITypeAliasContext {
-	var t = s.GetTypedRuleContext(reflect.TypeOf((*ITypeAliasContext)(nil)).Elem(), 0)
-
-	if t == nil {
-		return nil
-	}
-
-	return t.(ITypeAliasContext)
-}
-
-func (s *TypeLitBodyContext) GetRuleContext() antlr.RuleContext {
-	return s
-}
-
-func (s *TypeLitBodyContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string {
-	return antlr.TreesStringTree(s, ruleNames, recog)
-}
-
-func (s *TypeLitBodyContext) Accept(visitor antlr.ParseTreeVisitor) any {
-	switch t := visitor.(type) {
-	case ApiParserVisitor:
-		return t.VisitTypeLitBody(s)
-
-	default:
-		return t.VisitChildren(s)
-	}
-}
-
-func (p *ApiParserParser) TypeLitBody() (localctx ITypeLitBodyContext) {
-	localctx = NewTypeLitBodyContext(p, p.GetParserRuleContext(), p.GetState())
-	p.EnterRule(localctx, 24, ApiParserParserRULE_typeLitBody)
-
-	defer func() {
-		p.ExitRule()
-	}()
-
-	defer func() {
-		if err := recover(); err != nil {
-			if v, ok := err.(antlr.RecognitionException); ok {
-				localctx.SetException(v)
-				p.GetErrorHandler().ReportError(p, v)
-				p.GetErrorHandler().Recover(p, v)
-			} else {
-				panic(err)
-			}
-		}
-	}()
-
-	p.SetState(149)
-	p.GetErrorHandler().Sync(p)
-	switch p.GetInterpreter().AdaptivePredict(p.GetTokenStream(), 7, p.GetParserRuleContext()) {
-	case 1:
-		p.EnterOuterAlt(localctx, 1)
-		{
-			p.SetState(147)
-			p.TypeStruct()
-		}
-
-	case 2:
-		p.EnterOuterAlt(localctx, 2)
-		{
-			p.SetState(148)
-			p.TypeAlias()
-		}
-
-	}
-
-	return localctx
-}

+ 0 - 695
tools/goctlwt/api/parser/g4/gen/api/apiparser_parser3.go

@@ -1,695 +0,0 @@
-package api
-
-import (
-	"reflect"
-
-	"github.com/zeromicro/antlr"
-)
-
-// Part 3
-// The apiparser_parser.go file was split into multiple files because it
-// was too large and caused a possible memory overflow during goctlwt installation.
-
-// ITypeBlockBodyContext is an interface to support dynamic dispatch.
-type ITypeBlockBodyContext interface {
-	antlr.ParserRuleContext
-
-	// GetParser returns the parser.
-	GetParser() antlr.Parser
-
-	// IsTypeBlockBodyContext differentiates from other interfaces.
-	IsTypeBlockBodyContext()
-}
-
-type TypeBlockBodyContext struct {
-	*antlr.BaseParserRuleContext
-	parser antlr.Parser
-}
-
-func NewEmptyTypeBlockBodyContext() *TypeBlockBodyContext {
-	var p = new(TypeBlockBodyContext)
-	p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1)
-	p.RuleIndex = ApiParserParserRULE_typeBlockBody
-	return p
-}
-
-func (*TypeBlockBodyContext) IsTypeBlockBodyContext() {}
-
-func NewTypeBlockBodyContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *TypeBlockBodyContext {
-	var p = new(TypeBlockBodyContext)
-
-	p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState)
-
-	p.parser = parser
-	p.RuleIndex = ApiParserParserRULE_typeBlockBody
-
-	return p
-}
-
-func (s *TypeBlockBodyContext) GetParser() antlr.Parser { return s.parser }
-
-func (s *TypeBlockBodyContext) TypeBlockStruct() ITypeBlockStructContext {
-	var t = s.GetTypedRuleContext(reflect.TypeOf((*ITypeBlockStructContext)(nil)).Elem(), 0)
-
-	if t == nil {
-		return nil
-	}
-
-	return t.(ITypeBlockStructContext)
-}
-
-func (s *TypeBlockBodyContext) TypeBlockAlias() ITypeBlockAliasContext {
-	var t = s.GetTypedRuleContext(reflect.TypeOf((*ITypeBlockAliasContext)(nil)).Elem(), 0)
-
-	if t == nil {
-		return nil
-	}
-
-	return t.(ITypeBlockAliasContext)
-}
-
-func (s *TypeBlockBodyContext) GetRuleContext() antlr.RuleContext {
-	return s
-}
-
-func (s *TypeBlockBodyContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string {
-	return antlr.TreesStringTree(s, ruleNames, recog)
-}
-
-func (s *TypeBlockBodyContext) Accept(visitor antlr.ParseTreeVisitor) any {
-	switch t := visitor.(type) {
-	case ApiParserVisitor:
-		return t.VisitTypeBlockBody(s)
-
-	default:
-		return t.VisitChildren(s)
-	}
-}
-
-func (p *ApiParserParser) TypeBlockBody() (localctx ITypeBlockBodyContext) {
-	localctx = NewTypeBlockBodyContext(p, p.GetParserRuleContext(), p.GetState())
-	p.EnterRule(localctx, 26, ApiParserParserRULE_typeBlockBody)
-
-	defer func() {
-		p.ExitRule()
-	}()
-
-	defer func() {
-		if err := recover(); err != nil {
-			if v, ok := err.(antlr.RecognitionException); ok {
-				localctx.SetException(v)
-				p.GetErrorHandler().ReportError(p, v)
-				p.GetErrorHandler().Recover(p, v)
-			} else {
-				panic(err)
-			}
-		}
-	}()
-
-	p.SetState(153)
-	p.GetErrorHandler().Sync(p)
-	switch p.GetInterpreter().AdaptivePredict(p.GetTokenStream(), 8, p.GetParserRuleContext()) {
-	case 1:
-		p.EnterOuterAlt(localctx, 1)
-		{
-			p.SetState(151)
-			p.TypeBlockStruct()
-		}
-
-	case 2:
-		p.EnterOuterAlt(localctx, 2)
-		{
-			p.SetState(152)
-			p.TypeBlockAlias()
-		}
-
-	}
-
-	return localctx
-}
-
-// ITypeStructContext is an interface to support dynamic dispatch.
-type ITypeStructContext interface {
-	antlr.ParserRuleContext
-
-	// GetParser returns the parser.
-	GetParser() antlr.Parser
-
-	// GetStructName returns the structName token.
-	GetStructName() antlr.Token
-
-	// GetStructToken returns the structToken token.
-	GetStructToken() antlr.Token
-
-	// GetLbrace returns the lbrace token.
-	GetLbrace() antlr.Token
-
-	// GetRbrace returns the rbrace token.
-	GetRbrace() antlr.Token
-
-	// SetStructName sets the structName token.
-	SetStructName(antlr.Token)
-
-	// SetStructToken sets the structToken token.
-	SetStructToken(antlr.Token)
-
-	// SetLbrace sets the lbrace token.
-	SetLbrace(antlr.Token)
-
-	// SetRbrace sets the rbrace token.
-	SetRbrace(antlr.Token)
-
-	// IsTypeStructContext differentiates from other interfaces.
-	IsTypeStructContext()
-}
-
-type TypeStructContext struct {
-	*antlr.BaseParserRuleContext
-	parser      antlr.Parser
-	structName  antlr.Token
-	structToken antlr.Token
-	lbrace      antlr.Token
-	rbrace      antlr.Token
-}
-
-func NewEmptyTypeStructContext() *TypeStructContext {
-	var p = new(TypeStructContext)
-	p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1)
-	p.RuleIndex = ApiParserParserRULE_typeStruct
-	return p
-}
-
-func (*TypeStructContext) IsTypeStructContext() {}
-
-func NewTypeStructContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *TypeStructContext {
-	var p = new(TypeStructContext)
-
-	p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState)
-
-	p.parser = parser
-	p.RuleIndex = ApiParserParserRULE_typeStruct
-
-	return p
-}
-
-func (s *TypeStructContext) GetParser() antlr.Parser { return s.parser }
-
-func (s *TypeStructContext) GetStructName() antlr.Token { return s.structName }
-
-func (s *TypeStructContext) GetStructToken() antlr.Token { return s.structToken }
-
-func (s *TypeStructContext) GetLbrace() antlr.Token { return s.lbrace }
-
-func (s *TypeStructContext) GetRbrace() antlr.Token { return s.rbrace }
-
-func (s *TypeStructContext) SetStructName(v antlr.Token) { s.structName = v }
-
-func (s *TypeStructContext) SetStructToken(v antlr.Token) { s.structToken = v }
-
-func (s *TypeStructContext) SetLbrace(v antlr.Token) { s.lbrace = v }
-
-func (s *TypeStructContext) SetRbrace(v antlr.Token) { s.rbrace = v }
-
-func (s *TypeStructContext) AllID() []antlr.TerminalNode {
-	return s.GetTokens(ApiParserParserID)
-}
-
-func (s *TypeStructContext) ID(i int) antlr.TerminalNode {
-	return s.GetToken(ApiParserParserID, i)
-}
-
-func (s *TypeStructContext) AllField() []IFieldContext {
-	var ts = s.GetTypedRuleContexts(reflect.TypeOf((*IFieldContext)(nil)).Elem())
-	var tst = make([]IFieldContext, len(ts))
-
-	for i, t := range ts {
-		if t != nil {
-			tst[i] = t.(IFieldContext)
-		}
-	}
-
-	return tst
-}
-
-func (s *TypeStructContext) Field(i int) IFieldContext {
-	var t = s.GetTypedRuleContext(reflect.TypeOf((*IFieldContext)(nil)).Elem(), i)
-
-	if t == nil {
-		return nil
-	}
-
-	return t.(IFieldContext)
-}
-
-func (s *TypeStructContext) GetRuleContext() antlr.RuleContext {
-	return s
-}
-
-func (s *TypeStructContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string {
-	return antlr.TreesStringTree(s, ruleNames, recog)
-}
-
-func (s *TypeStructContext) Accept(visitor antlr.ParseTreeVisitor) any {
-	switch t := visitor.(type) {
-	case ApiParserVisitor:
-		return t.VisitTypeStruct(s)
-
-	default:
-		return t.VisitChildren(s)
-	}
-}
-
-func (p *ApiParserParser) TypeStruct() (localctx ITypeStructContext) {
-	localctx = NewTypeStructContext(p, p.GetParserRuleContext(), p.GetState())
-	p.EnterRule(localctx, 28, ApiParserParserRULE_typeStruct)
-	var _la int
-
-	defer func() {
-		p.ExitRule()
-	}()
-
-	defer func() {
-		if err := recover(); err != nil {
-			if v, ok := err.(antlr.RecognitionException); ok {
-				localctx.SetException(v)
-				p.GetErrorHandler().ReportError(p, v)
-				p.GetErrorHandler().Recover(p, v)
-			} else {
-				panic(err)
-			}
-		}
-	}()
-
-	var _alt int
-
-	p.EnterOuterAlt(localctx, 1)
-	checkKeyword(p)
-	{
-		p.SetState(156)
-
-		var _m = p.Match(ApiParserParserID)
-
-		localctx.(*TypeStructContext).structName = _m
-	}
-	p.SetState(158)
-	p.GetErrorHandler().Sync(p)
-	_la = p.GetTokenStream().LA(1)
-
-	if _la == ApiParserParserID {
-		{
-			p.SetState(157)
-
-			var _m = p.Match(ApiParserParserID)
-
-			localctx.(*TypeStructContext).structToken = _m
-		}
-
-	}
-	{
-		p.SetState(160)
-
-		var _m = p.Match(ApiParserParserT__3)
-
-		localctx.(*TypeStructContext).lbrace = _m
-	}
-	p.SetState(164)
-	p.GetErrorHandler().Sync(p)
-	_alt = p.GetInterpreter().AdaptivePredict(p.GetTokenStream(), 10, p.GetParserRuleContext())
-
-	for _alt != 2 && _alt != antlr.ATNInvalidAltNumber {
-		if _alt == 1 {
-			{
-				p.SetState(161)
-				p.Field()
-			}
-
-		}
-		p.SetState(166)
-		p.GetErrorHandler().Sync(p)
-		_alt = p.GetInterpreter().AdaptivePredict(p.GetTokenStream(), 10, p.GetParserRuleContext())
-	}
-	{
-		p.SetState(167)
-
-		var _m = p.Match(ApiParserParserT__4)
-
-		localctx.(*TypeStructContext).rbrace = _m
-	}
-
-	return localctx
-}
-
-// ITypeAliasContext is an interface to support dynamic dispatch.
-type ITypeAliasContext interface {
-	antlr.ParserRuleContext
-
-	// GetParser returns the parser.
-	GetParser() antlr.Parser
-
-	// GetAlias returns the alias token.
-	GetAlias() antlr.Token
-
-	// GetAssign returns the assign token.
-	GetAssign() antlr.Token
-
-	// SetAlias sets the alias token.
-	SetAlias(antlr.Token)
-
-	// SetAssign sets the assign token.
-	SetAssign(antlr.Token)
-
-	// IsTypeAliasContext differentiates from other interfaces.
-	IsTypeAliasContext()
-}
-
-type TypeAliasContext struct {
-	*antlr.BaseParserRuleContext
-	parser antlr.Parser
-	alias  antlr.Token
-	assign antlr.Token
-}
-
-func NewEmptyTypeAliasContext() *TypeAliasContext {
-	var p = new(TypeAliasContext)
-	p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1)
-	p.RuleIndex = ApiParserParserRULE_typeAlias
-	return p
-}
-
-func (*TypeAliasContext) IsTypeAliasContext() {}
-
-func NewTypeAliasContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *TypeAliasContext {
-	var p = new(TypeAliasContext)
-
-	p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState)
-
-	p.parser = parser
-	p.RuleIndex = ApiParserParserRULE_typeAlias
-
-	return p
-}
-
-func (s *TypeAliasContext) GetParser() antlr.Parser { return s.parser }
-
-func (s *TypeAliasContext) GetAlias() antlr.Token { return s.alias }
-
-func (s *TypeAliasContext) GetAssign() antlr.Token { return s.assign }
-
-func (s *TypeAliasContext) SetAlias(v antlr.Token) { s.alias = v }
-
-func (s *TypeAliasContext) SetAssign(v antlr.Token) { s.assign = v }
-
-func (s *TypeAliasContext) DataType() IDataTypeContext {
-	var t = s.GetTypedRuleContext(reflect.TypeOf((*IDataTypeContext)(nil)).Elem(), 0)
-
-	if t == nil {
-		return nil
-	}
-
-	return t.(IDataTypeContext)
-}
-
-func (s *TypeAliasContext) ID() antlr.TerminalNode {
-	return s.GetToken(ApiParserParserID, 0)
-}
-
-func (s *TypeAliasContext) GetRuleContext() antlr.RuleContext {
-	return s
-}
-
-func (s *TypeAliasContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string {
-	return antlr.TreesStringTree(s, ruleNames, recog)
-}
-
-func (s *TypeAliasContext) Accept(visitor antlr.ParseTreeVisitor) any {
-	switch t := visitor.(type) {
-	case ApiParserVisitor:
-		return t.VisitTypeAlias(s)
-
-	default:
-		return t.VisitChildren(s)
-	}
-}
-
-func (p *ApiParserParser) TypeAlias() (localctx ITypeAliasContext) {
-	localctx = NewTypeAliasContext(p, p.GetParserRuleContext(), p.GetState())
-	p.EnterRule(localctx, 30, ApiParserParserRULE_typeAlias)
-	var _la int
-
-	defer func() {
-		p.ExitRule()
-	}()
-
-	defer func() {
-		if err := recover(); err != nil {
-			if v, ok := err.(antlr.RecognitionException); ok {
-				localctx.SetException(v)
-				p.GetErrorHandler().ReportError(p, v)
-				p.GetErrorHandler().Recover(p, v)
-			} else {
-				panic(err)
-			}
-		}
-	}()
-
-	p.EnterOuterAlt(localctx, 1)
-	checkKeyword(p)
-	{
-		p.SetState(170)
-
-		var _m = p.Match(ApiParserParserID)
-
-		localctx.(*TypeAliasContext).alias = _m
-	}
-	p.SetState(172)
-	p.GetErrorHandler().Sync(p)
-	_la = p.GetTokenStream().LA(1)
-
-	if _la == ApiParserParserT__0 {
-		{
-			p.SetState(171)
-
-			var _m = p.Match(ApiParserParserT__0)
-
-			localctx.(*TypeAliasContext).assign = _m
-		}
-
-	}
-	{
-		p.SetState(174)
-		p.DataType()
-	}
-
-	return localctx
-}
-
-// ITypeBlockStructContext is an interface to support dynamic dispatch.
-type ITypeBlockStructContext interface {
-	antlr.ParserRuleContext
-
-	// GetParser returns the parser.
-	GetParser() antlr.Parser
-
-	// GetStructName returns the structName token.
-	GetStructName() antlr.Token
-
-	// GetStructToken returns the structToken token.
-	GetStructToken() antlr.Token
-
-	// GetLbrace returns the lbrace token.
-	GetLbrace() antlr.Token
-
-	// GetRbrace returns the rbrace token.
-	GetRbrace() antlr.Token
-
-	// SetStructName sets the structName token.
-	SetStructName(antlr.Token)
-
-	// SetStructToken sets the structToken token.
-	SetStructToken(antlr.Token)
-
-	// SetLbrace sets the lbrace token.
-	SetLbrace(antlr.Token)
-
-	// SetRbrace sets the rbrace token.
-	SetRbrace(antlr.Token)
-
-	// IsTypeBlockStructContext differentiates from other interfaces.
-	IsTypeBlockStructContext()
-}
-
-type TypeBlockStructContext struct {
-	*antlr.BaseParserRuleContext
-	parser      antlr.Parser
-	structName  antlr.Token
-	structToken antlr.Token
-	lbrace      antlr.Token
-	rbrace      antlr.Token
-}
-
-func NewEmptyTypeBlockStructContext() *TypeBlockStructContext {
-	var p = new(TypeBlockStructContext)
-	p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1)
-	p.RuleIndex = ApiParserParserRULE_typeBlockStruct
-	return p
-}
-
-func (*TypeBlockStructContext) IsTypeBlockStructContext() {}
-
-func NewTypeBlockStructContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *TypeBlockStructContext {
-	var p = new(TypeBlockStructContext)
-
-	p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState)
-
-	p.parser = parser
-	p.RuleIndex = ApiParserParserRULE_typeBlockStruct
-
-	return p
-}
-
-func (s *TypeBlockStructContext) GetParser() antlr.Parser { return s.parser }
-
-func (s *TypeBlockStructContext) GetStructName() antlr.Token { return s.structName }
-
-func (s *TypeBlockStructContext) GetStructToken() antlr.Token { return s.structToken }
-
-func (s *TypeBlockStructContext) GetLbrace() antlr.Token { return s.lbrace }
-
-func (s *TypeBlockStructContext) GetRbrace() antlr.Token { return s.rbrace }
-
-func (s *TypeBlockStructContext) SetStructName(v antlr.Token) { s.structName = v }
-
-func (s *TypeBlockStructContext) SetStructToken(v antlr.Token) { s.structToken = v }
-
-func (s *TypeBlockStructContext) SetLbrace(v antlr.Token) { s.lbrace = v }
-
-func (s *TypeBlockStructContext) SetRbrace(v antlr.Token) { s.rbrace = v }
-
-func (s *TypeBlockStructContext) AllID() []antlr.TerminalNode {
-	return s.GetTokens(ApiParserParserID)
-}
-
-func (s *TypeBlockStructContext) ID(i int) antlr.TerminalNode {
-	return s.GetToken(ApiParserParserID, i)
-}
-
-func (s *TypeBlockStructContext) AllField() []IFieldContext {
-	var ts = s.GetTypedRuleContexts(reflect.TypeOf((*IFieldContext)(nil)).Elem())
-	var tst = make([]IFieldContext, len(ts))
-
-	for i, t := range ts {
-		if t != nil {
-			tst[i] = t.(IFieldContext)
-		}
-	}
-
-	return tst
-}
-
-func (s *TypeBlockStructContext) Field(i int) IFieldContext {
-	var t = s.GetTypedRuleContext(reflect.TypeOf((*IFieldContext)(nil)).Elem(), i)
-
-	if t == nil {
-		return nil
-	}
-
-	return t.(IFieldContext)
-}
-
-func (s *TypeBlockStructContext) GetRuleContext() antlr.RuleContext {
-	return s
-}
-
-func (s *TypeBlockStructContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string {
-	return antlr.TreesStringTree(s, ruleNames, recog)
-}
-
-func (s *TypeBlockStructContext) Accept(visitor antlr.ParseTreeVisitor) any {
-	switch t := visitor.(type) {
-	case ApiParserVisitor:
-		return t.VisitTypeBlockStruct(s)
-
-	default:
-		return t.VisitChildren(s)
-	}
-}
-
-func (p *ApiParserParser) TypeBlockStruct() (localctx ITypeBlockStructContext) {
-	localctx = NewTypeBlockStructContext(p, p.GetParserRuleContext(), p.GetState())
-	p.EnterRule(localctx, 32, ApiParserParserRULE_typeBlockStruct)
-	var _la int
-
-	defer func() {
-		p.ExitRule()
-	}()
-
-	defer func() {
-		if err := recover(); err != nil {
-			if v, ok := err.(antlr.RecognitionException); ok {
-				localctx.SetException(v)
-				p.GetErrorHandler().ReportError(p, v)
-				p.GetErrorHandler().Recover(p, v)
-			} else {
-				panic(err)
-			}
-		}
-	}()
-
-	var _alt int
-
-	p.EnterOuterAlt(localctx, 1)
-	checkKeyword(p)
-	{
-		p.SetState(177)
-
-		var _m = p.Match(ApiParserParserID)
-
-		localctx.(*TypeBlockStructContext).structName = _m
-	}
-	p.SetState(179)
-	p.GetErrorHandler().Sync(p)
-	_la = p.GetTokenStream().LA(1)
-
-	if _la == ApiParserParserID {
-		{
-			p.SetState(178)
-
-			var _m = p.Match(ApiParserParserID)
-
-			localctx.(*TypeBlockStructContext).structToken = _m
-		}
-
-	}
-	{
-		p.SetState(181)
-
-		var _m = p.Match(ApiParserParserT__3)
-
-		localctx.(*TypeBlockStructContext).lbrace = _m
-	}
-	p.SetState(185)
-	p.GetErrorHandler().Sync(p)
-	_alt = p.GetInterpreter().AdaptivePredict(p.GetTokenStream(), 13, p.GetParserRuleContext())
-
-	for _alt != 2 && _alt != antlr.ATNInvalidAltNumber {
-		if _alt == 1 {
-			{
-				p.SetState(182)
-				p.Field()
-			}
-
-		}
-		p.SetState(187)
-		p.GetErrorHandler().Sync(p)
-		_alt = p.GetInterpreter().AdaptivePredict(p.GetTokenStream(), 13, p.GetParserRuleContext())
-	}
-	{
-		p.SetState(188)
-
-		var _m = p.Match(ApiParserParserT__4)
-
-		localctx.(*TypeBlockStructContext).rbrace = _m
-	}
-
-	return localctx
-}

+ 0 - 665
tools/goctlwt/api/parser/g4/gen/api/apiparser_parser4.go

@@ -1,665 +0,0 @@
-package api
-
-import (
-	"reflect"
-
-	"github.com/zeromicro/antlr"
-)
-
-// Part 4
-// The apiparser_parser.go file was split into multiple files because it
-// was too large and caused a possible memory overflow during goctlwt installation.
-
-// ITypeBlockAliasContext is an interface to support dynamic dispatch.
-type ITypeBlockAliasContext interface {
-	antlr.ParserRuleContext
-
-	// GetParser returns the parser.
-	GetParser() antlr.Parser
-
-	// GetAlias returns the alias token.
-	GetAlias() antlr.Token
-
-	// GetAssign returns the assign token.
-	GetAssign() antlr.Token
-
-	// SetAlias sets the alias token.
-	SetAlias(antlr.Token)
-
-	// SetAssign sets the assign token.
-	SetAssign(antlr.Token)
-
-	// IsTypeBlockAliasContext differentiates from other interfaces.
-	IsTypeBlockAliasContext()
-}
-
-type TypeBlockAliasContext struct {
-	*antlr.BaseParserRuleContext
-	parser antlr.Parser
-	alias  antlr.Token
-	assign antlr.Token
-}
-
-func NewEmptyTypeBlockAliasContext() *TypeBlockAliasContext {
-	var p = new(TypeBlockAliasContext)
-	p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1)
-	p.RuleIndex = ApiParserParserRULE_typeBlockAlias
-	return p
-}
-
-func (*TypeBlockAliasContext) IsTypeBlockAliasContext() {}
-
-func NewTypeBlockAliasContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *TypeBlockAliasContext {
-	var p = new(TypeBlockAliasContext)
-
-	p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState)
-
-	p.parser = parser
-	p.RuleIndex = ApiParserParserRULE_typeBlockAlias
-
-	return p
-}
-
-func (s *TypeBlockAliasContext) GetParser() antlr.Parser { return s.parser }
-
-func (s *TypeBlockAliasContext) GetAlias() antlr.Token { return s.alias }
-
-func (s *TypeBlockAliasContext) GetAssign() antlr.Token { return s.assign }
-
-func (s *TypeBlockAliasContext) SetAlias(v antlr.Token) { s.alias = v }
-
-func (s *TypeBlockAliasContext) SetAssign(v antlr.Token) { s.assign = v }
-
-func (s *TypeBlockAliasContext) DataType() IDataTypeContext {
-	var t = s.GetTypedRuleContext(reflect.TypeOf((*IDataTypeContext)(nil)).Elem(), 0)
-
-	if t == nil {
-		return nil
-	}
-
-	return t.(IDataTypeContext)
-}
-
-func (s *TypeBlockAliasContext) ID() antlr.TerminalNode {
-	return s.GetToken(ApiParserParserID, 0)
-}
-
-func (s *TypeBlockAliasContext) GetRuleContext() antlr.RuleContext {
-	return s
-}
-
-func (s *TypeBlockAliasContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string {
-	return antlr.TreesStringTree(s, ruleNames, recog)
-}
-
-func (s *TypeBlockAliasContext) Accept(visitor antlr.ParseTreeVisitor) any {
-	switch t := visitor.(type) {
-	case ApiParserVisitor:
-		return t.VisitTypeBlockAlias(s)
-
-	default:
-		return t.VisitChildren(s)
-	}
-}
-
-func (p *ApiParserParser) TypeBlockAlias() (localctx ITypeBlockAliasContext) {
-	localctx = NewTypeBlockAliasContext(p, p.GetParserRuleContext(), p.GetState())
-	p.EnterRule(localctx, 34, ApiParserParserRULE_typeBlockAlias)
-	var _la int
-
-	defer func() {
-		p.ExitRule()
-	}()
-
-	defer func() {
-		if err := recover(); err != nil {
-			if v, ok := err.(antlr.RecognitionException); ok {
-				localctx.SetException(v)
-				p.GetErrorHandler().ReportError(p, v)
-				p.GetErrorHandler().Recover(p, v)
-			} else {
-				panic(err)
-			}
-		}
-	}()
-
-	p.EnterOuterAlt(localctx, 1)
-	checkKeyword(p)
-	{
-		p.SetState(191)
-
-		var _m = p.Match(ApiParserParserID)
-
-		localctx.(*TypeBlockAliasContext).alias = _m
-	}
-	p.SetState(193)
-	p.GetErrorHandler().Sync(p)
-	_la = p.GetTokenStream().LA(1)
-
-	if _la == ApiParserParserT__0 {
-		{
-			p.SetState(192)
-
-			var _m = p.Match(ApiParserParserT__0)
-
-			localctx.(*TypeBlockAliasContext).assign = _m
-		}
-
-	}
-	{
-		p.SetState(195)
-		p.DataType()
-	}
-
-	return localctx
-}
-
-// IFieldContext is an interface to support dynamic dispatch.
-type IFieldContext interface {
-	antlr.ParserRuleContext
-
-	// GetParser returns the parser.
-	GetParser() antlr.Parser
-
-	// IsFieldContext differentiates from other interfaces.
-	IsFieldContext()
-}
-
-type FieldContext struct {
-	*antlr.BaseParserRuleContext
-	parser antlr.Parser
-}
-
-func NewEmptyFieldContext() *FieldContext {
-	var p = new(FieldContext)
-	p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1)
-	p.RuleIndex = ApiParserParserRULE_field
-	return p
-}
-
-func (*FieldContext) IsFieldContext() {}
-
-func NewFieldContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *FieldContext {
-	var p = new(FieldContext)
-
-	p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState)
-
-	p.parser = parser
-	p.RuleIndex = ApiParserParserRULE_field
-
-	return p
-}
-
-func (s *FieldContext) GetParser() antlr.Parser { return s.parser }
-
-func (s *FieldContext) NormalField() INormalFieldContext {
-	var t = s.GetTypedRuleContext(reflect.TypeOf((*INormalFieldContext)(nil)).Elem(), 0)
-
-	if t == nil {
-		return nil
-	}
-
-	return t.(INormalFieldContext)
-}
-
-func (s *FieldContext) AnonymousFiled() IAnonymousFiledContext {
-	var t = s.GetTypedRuleContext(reflect.TypeOf((*IAnonymousFiledContext)(nil)).Elem(), 0)
-
-	if t == nil {
-		return nil
-	}
-
-	return t.(IAnonymousFiledContext)
-}
-
-func (s *FieldContext) GetRuleContext() antlr.RuleContext {
-	return s
-}
-
-func (s *FieldContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string {
-	return antlr.TreesStringTree(s, ruleNames, recog)
-}
-
-func (s *FieldContext) Accept(visitor antlr.ParseTreeVisitor) any {
-	switch t := visitor.(type) {
-	case ApiParserVisitor:
-		return t.VisitField(s)
-
-	default:
-		return t.VisitChildren(s)
-	}
-}
-
-func (p *ApiParserParser) Field() (localctx IFieldContext) {
-	localctx = NewFieldContext(p, p.GetParserRuleContext(), p.GetState())
-	p.EnterRule(localctx, 36, ApiParserParserRULE_field)
-
-	defer func() {
-		p.ExitRule()
-	}()
-
-	defer func() {
-		if err := recover(); err != nil {
-			if v, ok := err.(antlr.RecognitionException); ok {
-				localctx.SetException(v)
-				p.GetErrorHandler().ReportError(p, v)
-				p.GetErrorHandler().Recover(p, v)
-			} else {
-				panic(err)
-			}
-		}
-	}()
-
-	p.SetState(200)
-	p.GetErrorHandler().Sync(p)
-	switch p.GetInterpreter().AdaptivePredict(p.GetTokenStream(), 15, p.GetParserRuleContext()) {
-	case 1:
-		p.EnterOuterAlt(localctx, 1)
-		p.SetState(197)
-
-		if !(isNormal(p)) {
-			panic(antlr.NewFailedPredicateException(p, "isNormal(p)", ""))
-		}
-		{
-			p.SetState(198)
-			p.NormalField()
-		}
-
-	case 2:
-		p.EnterOuterAlt(localctx, 2)
-		{
-			p.SetState(199)
-			p.AnonymousFiled()
-		}
-
-	}
-
-	return localctx
-}
-
-// INormalFieldContext is an interface to support dynamic dispatch.
-type INormalFieldContext interface {
-	antlr.ParserRuleContext
-
-	// GetParser returns the parser.
-	GetParser() antlr.Parser
-
-	// GetFieldName returns the fieldName token.
-	GetFieldName() antlr.Token
-
-	// GetTag returns the tag token.
-	GetTag() antlr.Token
-
-	// SetFieldName sets the fieldName token.
-	SetFieldName(antlr.Token)
-
-	// SetTag sets the tag token.
-	SetTag(antlr.Token)
-
-	// IsNormalFieldContext differentiates from other interfaces.
-	IsNormalFieldContext()
-}
-
-type NormalFieldContext struct {
-	*antlr.BaseParserRuleContext
-	parser    antlr.Parser
-	fieldName antlr.Token
-	tag       antlr.Token
-}
-
-func NewEmptyNormalFieldContext() *NormalFieldContext {
-	var p = new(NormalFieldContext)
-	p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1)
-	p.RuleIndex = ApiParserParserRULE_normalField
-	return p
-}
-
-func (*NormalFieldContext) IsNormalFieldContext() {}
-
-func NewNormalFieldContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *NormalFieldContext {
-	var p = new(NormalFieldContext)
-
-	p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState)
-
-	p.parser = parser
-	p.RuleIndex = ApiParserParserRULE_normalField
-
-	return p
-}
-
-func (s *NormalFieldContext) GetParser() antlr.Parser { return s.parser }
-
-func (s *NormalFieldContext) GetFieldName() antlr.Token { return s.fieldName }
-
-func (s *NormalFieldContext) GetTag() antlr.Token { return s.tag }
-
-func (s *NormalFieldContext) SetFieldName(v antlr.Token) { s.fieldName = v }
-
-func (s *NormalFieldContext) SetTag(v antlr.Token) { s.tag = v }
-
-func (s *NormalFieldContext) DataType() IDataTypeContext {
-	var t = s.GetTypedRuleContext(reflect.TypeOf((*IDataTypeContext)(nil)).Elem(), 0)
-
-	if t == nil {
-		return nil
-	}
-
-	return t.(IDataTypeContext)
-}
-
-func (s *NormalFieldContext) ID() antlr.TerminalNode {
-	return s.GetToken(ApiParserParserID, 0)
-}
-
-func (s *NormalFieldContext) RAW_STRING() antlr.TerminalNode {
-	return s.GetToken(ApiParserParserRAW_STRING, 0)
-}
-
-func (s *NormalFieldContext) GetRuleContext() antlr.RuleContext {
-	return s
-}
-
-func (s *NormalFieldContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string {
-	return antlr.TreesStringTree(s, ruleNames, recog)
-}
-
-func (s *NormalFieldContext) Accept(visitor antlr.ParseTreeVisitor) any {
-	switch t := visitor.(type) {
-	case ApiParserVisitor:
-		return t.VisitNormalField(s)
-
-	default:
-		return t.VisitChildren(s)
-	}
-}
-
-func (p *ApiParserParser) NormalField() (localctx INormalFieldContext) {
-	localctx = NewNormalFieldContext(p, p.GetParserRuleContext(), p.GetState())
-	p.EnterRule(localctx, 38, ApiParserParserRULE_normalField)
-
-	defer func() {
-		p.ExitRule()
-	}()
-
-	defer func() {
-		if err := recover(); err != nil {
-			if v, ok := err.(antlr.RecognitionException); ok {
-				localctx.SetException(v)
-				p.GetErrorHandler().ReportError(p, v)
-				p.GetErrorHandler().Recover(p, v)
-			} else {
-				panic(err)
-			}
-		}
-	}()
-
-	p.EnterOuterAlt(localctx, 1)
-	checkKeyword(p)
-	{
-		p.SetState(203)
-
-		var _m = p.Match(ApiParserParserID)
-
-		localctx.(*NormalFieldContext).fieldName = _m
-	}
-	{
-		p.SetState(204)
-		p.DataType()
-	}
-	p.SetState(206)
-	p.GetErrorHandler().Sync(p)
-
-	if p.GetInterpreter().AdaptivePredict(p.GetTokenStream(), 16, p.GetParserRuleContext()) == 1 {
-		{
-			p.SetState(205)
-
-			var _m = p.Match(ApiParserParserRAW_STRING)
-
-			localctx.(*NormalFieldContext).tag = _m
-		}
-
-	}
-
-	return localctx
-}
-
-// IAnonymousFiledContext is an interface to support dynamic dispatch.
-type IAnonymousFiledContext interface {
-	antlr.ParserRuleContext
-
-	// GetParser returns the parser.
-	GetParser() antlr.Parser
-
-	// GetStar returns the star token.
-	GetStar() antlr.Token
-
-	// SetStar sets the star token.
-	SetStar(antlr.Token)
-
-	// IsAnonymousFiledContext differentiates from other interfaces.
-	IsAnonymousFiledContext()
-}
-
-type AnonymousFiledContext struct {
-	*antlr.BaseParserRuleContext
-	parser antlr.Parser
-	star   antlr.Token
-}
-
-func NewEmptyAnonymousFiledContext() *AnonymousFiledContext {
-	var p = new(AnonymousFiledContext)
-	p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1)
-	p.RuleIndex = ApiParserParserRULE_anonymousFiled
-	return p
-}
-
-func (*AnonymousFiledContext) IsAnonymousFiledContext() {}
-
-func NewAnonymousFiledContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *AnonymousFiledContext {
-	var p = new(AnonymousFiledContext)
-
-	p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState)
-
-	p.parser = parser
-	p.RuleIndex = ApiParserParserRULE_anonymousFiled
-
-	return p
-}
-
-func (s *AnonymousFiledContext) GetParser() antlr.Parser { return s.parser }
-
-func (s *AnonymousFiledContext) GetStar() antlr.Token { return s.star }
-
-func (s *AnonymousFiledContext) SetStar(v antlr.Token) { s.star = v }
-
-func (s *AnonymousFiledContext) ID() antlr.TerminalNode {
-	return s.GetToken(ApiParserParserID, 0)
-}
-
-func (s *AnonymousFiledContext) GetRuleContext() antlr.RuleContext {
-	return s
-}
-
-func (s *AnonymousFiledContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string {
-	return antlr.TreesStringTree(s, ruleNames, recog)
-}
-
-func (s *AnonymousFiledContext) Accept(visitor antlr.ParseTreeVisitor) any {
-	switch t := visitor.(type) {
-	case ApiParserVisitor:
-		return t.VisitAnonymousFiled(s)
-
-	default:
-		return t.VisitChildren(s)
-	}
-}
-
-func (p *ApiParserParser) AnonymousFiled() (localctx IAnonymousFiledContext) {
-	localctx = NewAnonymousFiledContext(p, p.GetParserRuleContext(), p.GetState())
-	p.EnterRule(localctx, 40, ApiParserParserRULE_anonymousFiled)
-	var _la int
-
-	defer func() {
-		p.ExitRule()
-	}()
-
-	defer func() {
-		if err := recover(); err != nil {
-			if v, ok := err.(antlr.RecognitionException); ok {
-				localctx.SetException(v)
-				p.GetErrorHandler().ReportError(p, v)
-				p.GetErrorHandler().Recover(p, v)
-			} else {
-				panic(err)
-			}
-		}
-	}()
-
-	p.EnterOuterAlt(localctx, 1)
-	p.SetState(209)
-	p.GetErrorHandler().Sync(p)
-	_la = p.GetTokenStream().LA(1)
-
-	if _la == ApiParserParserT__5 {
-		{
-			p.SetState(208)
-
-			var _m = p.Match(ApiParserParserT__5)
-
-			localctx.(*AnonymousFiledContext).star = _m
-		}
-
-	}
-	{
-		p.SetState(211)
-		p.Match(ApiParserParserID)
-	}
-
-	return localctx
-}
-
-// IDataTypeContext is an interface to support dynamic dispatch.
-type IDataTypeContext interface {
-	antlr.ParserRuleContext
-
-	// GetParser returns the parser.
-	GetParser() antlr.Parser
-
-	// GetInter returns the inter token.
-	GetInter() antlr.Token
-
-	// GetTime returns the time token.
-	GetTime() antlr.Token
-
-	// SetInter sets the inter token.
-	SetInter(antlr.Token)
-
-	// SetTime sets the time token.
-	SetTime(antlr.Token)
-
-	// IsDataTypeContext differentiates from other interfaces.
-	IsDataTypeContext()
-}
-
-type DataTypeContext struct {
-	*antlr.BaseParserRuleContext
-	parser antlr.Parser
-	inter  antlr.Token
-	time   antlr.Token
-}
-
-func NewEmptyDataTypeContext() *DataTypeContext {
-	var p = new(DataTypeContext)
-	p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1)
-	p.RuleIndex = ApiParserParserRULE_dataType
-	return p
-}
-
-func (*DataTypeContext) IsDataTypeContext() {}
-
-func NewDataTypeContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *DataTypeContext {
-	var p = new(DataTypeContext)
-
-	p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState)
-
-	p.parser = parser
-	p.RuleIndex = ApiParserParserRULE_dataType
-
-	return p
-}
-
-func (s *DataTypeContext) GetParser() antlr.Parser { return s.parser }
-
-func (s *DataTypeContext) GetInter() antlr.Token { return s.inter }
-
-func (s *DataTypeContext) GetTime() antlr.Token { return s.time }
-
-func (s *DataTypeContext) SetInter(v antlr.Token) { s.inter = v }
-
-func (s *DataTypeContext) SetTime(v antlr.Token) { s.time = v }
-
-func (s *DataTypeContext) ID() antlr.TerminalNode {
-	return s.GetToken(ApiParserParserID, 0)
-}
-
-func (s *DataTypeContext) MapType() IMapTypeContext {
-	var t = s.GetTypedRuleContext(reflect.TypeOf((*IMapTypeContext)(nil)).Elem(), 0)
-
-	if t == nil {
-		return nil
-	}
-
-	return t.(IMapTypeContext)
-}
-
-func (s *DataTypeContext) ArrayType() IArrayTypeContext {
-	var t = s.GetTypedRuleContext(reflect.TypeOf((*IArrayTypeContext)(nil)).Elem(), 0)
-
-	if t == nil {
-		return nil
-	}
-
-	return t.(IArrayTypeContext)
-}
-
-func (s *DataTypeContext) INTERFACE() antlr.TerminalNode {
-	return s.GetToken(ApiParserParserINTERFACE, 0)
-}
-
-func (s *DataTypeContext) PointerType() IPointerTypeContext {
-	var t = s.GetTypedRuleContext(reflect.TypeOf((*IPointerTypeContext)(nil)).Elem(), 0)
-
-	if t == nil {
-		return nil
-	}
-
-	return t.(IPointerTypeContext)
-}
-
-func (s *DataTypeContext) TypeStruct() ITypeStructContext {
-	var t = s.GetTypedRuleContext(reflect.TypeOf((*ITypeStructContext)(nil)).Elem(), 0)
-
-	if t == nil {
-		return nil
-	}
-
-	return t.(ITypeStructContext)
-}
-
-func (s *DataTypeContext) GetRuleContext() antlr.RuleContext {
-	return s
-}
-
-func (s *DataTypeContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string {
-	return antlr.TreesStringTree(s, ruleNames, recog)
-}
-
-func (s *DataTypeContext) Accept(visitor antlr.ParseTreeVisitor) any {
-	switch t := visitor.(type) {
-	case ApiParserVisitor:
-		return t.VisitDataType(s)
-
-	default:
-		return t.VisitChildren(s)
-	}
-}

+ 0 - 665
tools/goctlwt/api/parser/g4/gen/api/apiparser_parser5.go

@@ -1,665 +0,0 @@
-package api
-
-import (
-	"reflect"
-
-	"github.com/zeromicro/antlr"
-)
-
-// Part 5
-// The apiparser_parser.go file was split into multiple files because it
-// was too large and caused a possible memory overflow during goctlwt installation.
-
-func (p *ApiParserParser) DataType() (localctx IDataTypeContext) {
-	localctx = NewDataTypeContext(p, p.GetParserRuleContext(), p.GetState())
-	p.EnterRule(localctx, 42, ApiParserParserRULE_dataType)
-
-	defer func() {
-		p.ExitRule()
-	}()
-
-	defer func() {
-		if err := recover(); err != nil {
-			if v, ok := err.(antlr.RecognitionException); ok {
-				localctx.SetException(v)
-				p.GetErrorHandler().ReportError(p, v)
-				p.GetErrorHandler().Recover(p, v)
-			} else {
-				panic(err)
-			}
-		}
-	}()
-
-	p.SetState(221)
-	p.GetErrorHandler().Sync(p)
-	switch p.GetInterpreter().AdaptivePredict(p.GetTokenStream(), 18, p.GetParserRuleContext()) {
-	case 1:
-		p.EnterOuterAlt(localctx, 1)
-		isInterface(p)
-		{
-			p.SetState(214)
-			p.Match(ApiParserParserID)
-		}
-
-	case 2:
-		p.EnterOuterAlt(localctx, 2)
-		{
-			p.SetState(215)
-			p.MapType()
-		}
-
-	case 3:
-		p.EnterOuterAlt(localctx, 3)
-		{
-			p.SetState(216)
-			p.ArrayType()
-		}
-
-	case 4:
-		p.EnterOuterAlt(localctx, 4)
-		{
-			p.SetState(217)
-
-			var _m = p.Match(ApiParserParserINTERFACE)
-
-			localctx.(*DataTypeContext).inter = _m
-		}
-
-	case 5:
-		p.EnterOuterAlt(localctx, 5)
-		{
-			p.SetState(218)
-
-			var _m = p.Match(ApiParserParserT__6)
-
-			localctx.(*DataTypeContext).time = _m
-		}
-
-	case 6:
-		p.EnterOuterAlt(localctx, 6)
-		{
-			p.SetState(219)
-			p.PointerType()
-		}
-
-	case 7:
-		p.EnterOuterAlt(localctx, 7)
-		{
-			p.SetState(220)
-			p.TypeStruct()
-		}
-
-	}
-
-	return localctx
-}
-
-// IPointerTypeContext is an interface to support dynamic dispatch.
-type IPointerTypeContext interface {
-	antlr.ParserRuleContext
-
-	// GetParser returns the parser.
-	GetParser() antlr.Parser
-
-	// GetStar returns the star token.
-	GetStar() antlr.Token
-
-	// SetStar sets the star token.
-	SetStar(antlr.Token)
-
-	// IsPointerTypeContext differentiates from other interfaces.
-	IsPointerTypeContext()
-}
-
-type PointerTypeContext struct {
-	*antlr.BaseParserRuleContext
-	parser antlr.Parser
-	star   antlr.Token
-}
-
-func NewEmptyPointerTypeContext() *PointerTypeContext {
-	var p = new(PointerTypeContext)
-	p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1)
-	p.RuleIndex = ApiParserParserRULE_pointerType
-	return p
-}
-
-func (*PointerTypeContext) IsPointerTypeContext() {}
-
-func NewPointerTypeContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *PointerTypeContext {
-	var p = new(PointerTypeContext)
-
-	p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState)
-
-	p.parser = parser
-	p.RuleIndex = ApiParserParserRULE_pointerType
-
-	return p
-}
-
-func (s *PointerTypeContext) GetParser() antlr.Parser { return s.parser }
-
-func (s *PointerTypeContext) GetStar() antlr.Token { return s.star }
-
-func (s *PointerTypeContext) SetStar(v antlr.Token) { s.star = v }
-
-func (s *PointerTypeContext) ID() antlr.TerminalNode {
-	return s.GetToken(ApiParserParserID, 0)
-}
-
-func (s *PointerTypeContext) GetRuleContext() antlr.RuleContext {
-	return s
-}
-
-func (s *PointerTypeContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string {
-	return antlr.TreesStringTree(s, ruleNames, recog)
-}
-
-func (s *PointerTypeContext) Accept(visitor antlr.ParseTreeVisitor) any {
-	switch t := visitor.(type) {
-	case ApiParserVisitor:
-		return t.VisitPointerType(s)
-
-	default:
-		return t.VisitChildren(s)
-	}
-}
-
-func (p *ApiParserParser) PointerType() (localctx IPointerTypeContext) {
-	localctx = NewPointerTypeContext(p, p.GetParserRuleContext(), p.GetState())
-	p.EnterRule(localctx, 44, ApiParserParserRULE_pointerType)
-
-	defer func() {
-		p.ExitRule()
-	}()
-
-	defer func() {
-		if err := recover(); err != nil {
-			if v, ok := err.(antlr.RecognitionException); ok {
-				localctx.SetException(v)
-				p.GetErrorHandler().ReportError(p, v)
-				p.GetErrorHandler().Recover(p, v)
-			} else {
-				panic(err)
-			}
-		}
-	}()
-
-	p.EnterOuterAlt(localctx, 1)
-	{
-		p.SetState(223)
-
-		var _m = p.Match(ApiParserParserT__5)
-
-		localctx.(*PointerTypeContext).star = _m
-	}
-	checkKeyword(p)
-	{
-		p.SetState(225)
-		p.Match(ApiParserParserID)
-	}
-
-	return localctx
-}
-
-// IMapTypeContext is an interface to support dynamic dispatch.
-type IMapTypeContext interface {
-	antlr.ParserRuleContext
-
-	// GetParser returns the parser.
-	GetParser() antlr.Parser
-
-	// GetMapToken returns the mapToken token.
-	GetMapToken() antlr.Token
-
-	// GetLbrack returns the lbrack token.
-	GetLbrack() antlr.Token
-
-	// GetKey returns the key token.
-	GetKey() antlr.Token
-
-	// GetRbrack returns the rbrack token.
-	GetRbrack() antlr.Token
-
-	// SetMapToken sets the mapToken token.
-	SetMapToken(antlr.Token)
-
-	// SetLbrack sets the lbrack token.
-	SetLbrack(antlr.Token)
-
-	// SetKey sets the key token.
-	SetKey(antlr.Token)
-
-	// SetRbrack sets the rbrack token.
-	SetRbrack(antlr.Token)
-
-	// GetValue returns the value rule contexts.
-	GetValue() IDataTypeContext
-
-	// SetValue sets the value rule contexts.
-	SetValue(IDataTypeContext)
-
-	// IsMapTypeContext differentiates from other interfaces.
-	IsMapTypeContext()
-}
-
-type MapTypeContext struct {
-	*antlr.BaseParserRuleContext
-	parser   antlr.Parser
-	mapToken antlr.Token
-	lbrack   antlr.Token
-	key      antlr.Token
-	rbrack   antlr.Token
-	value    IDataTypeContext
-}
-
-func NewEmptyMapTypeContext() *MapTypeContext {
-	var p = new(MapTypeContext)
-	p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1)
-	p.RuleIndex = ApiParserParserRULE_mapType
-	return p
-}
-
-func (*MapTypeContext) IsMapTypeContext() {}
-
-func NewMapTypeContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *MapTypeContext {
-	var p = new(MapTypeContext)
-
-	p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState)
-
-	p.parser = parser
-	p.RuleIndex = ApiParserParserRULE_mapType
-
-	return p
-}
-
-func (s *MapTypeContext) GetParser() antlr.Parser { return s.parser }
-
-func (s *MapTypeContext) GetMapToken() antlr.Token { return s.mapToken }
-
-func (s *MapTypeContext) GetLbrack() antlr.Token { return s.lbrack }
-
-func (s *MapTypeContext) GetKey() antlr.Token { return s.key }
-
-func (s *MapTypeContext) GetRbrack() antlr.Token { return s.rbrack }
-
-func (s *MapTypeContext) SetMapToken(v antlr.Token) { s.mapToken = v }
-
-func (s *MapTypeContext) SetLbrack(v antlr.Token) { s.lbrack = v }
-
-func (s *MapTypeContext) SetKey(v antlr.Token) { s.key = v }
-
-func (s *MapTypeContext) SetRbrack(v antlr.Token) { s.rbrack = v }
-
-func (s *MapTypeContext) GetValue() IDataTypeContext { return s.value }
-
-func (s *MapTypeContext) SetValue(v IDataTypeContext) { s.value = v }
-
-func (s *MapTypeContext) AllID() []antlr.TerminalNode {
-	return s.GetTokens(ApiParserParserID)
-}
-
-func (s *MapTypeContext) ID(i int) antlr.TerminalNode {
-	return s.GetToken(ApiParserParserID, i)
-}
-
-func (s *MapTypeContext) DataType() IDataTypeContext {
-	var t = s.GetTypedRuleContext(reflect.TypeOf((*IDataTypeContext)(nil)).Elem(), 0)
-
-	if t == nil {
-		return nil
-	}
-
-	return t.(IDataTypeContext)
-}
-
-func (s *MapTypeContext) GetRuleContext() antlr.RuleContext {
-	return s
-}
-
-func (s *MapTypeContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string {
-	return antlr.TreesStringTree(s, ruleNames, recog)
-}
-
-func (s *MapTypeContext) Accept(visitor antlr.ParseTreeVisitor) any {
-	switch t := visitor.(type) {
-	case ApiParserVisitor:
-		return t.VisitMapType(s)
-
-	default:
-		return t.VisitChildren(s)
-	}
-}
-
-func (p *ApiParserParser) MapType() (localctx IMapTypeContext) {
-	localctx = NewMapTypeContext(p, p.GetParserRuleContext(), p.GetState())
-	p.EnterRule(localctx, 46, ApiParserParserRULE_mapType)
-
-	defer func() {
-		p.ExitRule()
-	}()
-
-	defer func() {
-		if err := recover(); err != nil {
-			if v, ok := err.(antlr.RecognitionException); ok {
-				localctx.SetException(v)
-				p.GetErrorHandler().ReportError(p, v)
-				p.GetErrorHandler().Recover(p, v)
-			} else {
-				panic(err)
-			}
-		}
-	}()
-
-	p.EnterOuterAlt(localctx, 1)
-	match(p, "map")
-	{
-		p.SetState(228)
-
-		var _m = p.Match(ApiParserParserID)
-
-		localctx.(*MapTypeContext).mapToken = _m
-	}
-	{
-		p.SetState(229)
-
-		var _m = p.Match(ApiParserParserT__7)
-
-		localctx.(*MapTypeContext).lbrack = _m
-	}
-	checkKey(p)
-	{
-		p.SetState(231)
-
-		var _m = p.Match(ApiParserParserID)
-
-		localctx.(*MapTypeContext).key = _m
-	}
-	{
-		p.SetState(232)
-
-		var _m = p.Match(ApiParserParserT__8)
-
-		localctx.(*MapTypeContext).rbrack = _m
-	}
-	{
-		p.SetState(233)
-
-		var _x = p.DataType()
-
-		localctx.(*MapTypeContext).value = _x
-	}
-
-	return localctx
-}
-
-// IArrayTypeContext is an interface to support dynamic dispatch.
-type IArrayTypeContext interface {
-	antlr.ParserRuleContext
-
-	// GetParser returns the parser.
-	GetParser() antlr.Parser
-
-	// GetLbrack returns the lbrack token.
-	GetLbrack() antlr.Token
-
-	// GetRbrack returns the rbrack token.
-	GetRbrack() antlr.Token
-
-	// SetLbrack sets the lbrack token.
-	SetLbrack(antlr.Token)
-
-	// SetRbrack sets the rbrack token.
-	SetRbrack(antlr.Token)
-
-	// IsArrayTypeContext differentiates from other interfaces.
-	IsArrayTypeContext()
-}
-
-type ArrayTypeContext struct {
-	*antlr.BaseParserRuleContext
-	parser antlr.Parser
-	lbrack antlr.Token
-	rbrack antlr.Token
-}
-
-func NewEmptyArrayTypeContext() *ArrayTypeContext {
-	var p = new(ArrayTypeContext)
-	p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1)
-	p.RuleIndex = ApiParserParserRULE_arrayType
-	return p
-}
-
-func (*ArrayTypeContext) IsArrayTypeContext() {}
-
-func NewArrayTypeContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *ArrayTypeContext {
-	var p = new(ArrayTypeContext)
-
-	p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState)
-
-	p.parser = parser
-	p.RuleIndex = ApiParserParserRULE_arrayType
-
-	return p
-}
-
-func (s *ArrayTypeContext) GetParser() antlr.Parser { return s.parser }
-
-func (s *ArrayTypeContext) GetLbrack() antlr.Token { return s.lbrack }
-
-func (s *ArrayTypeContext) GetRbrack() antlr.Token { return s.rbrack }
-
-func (s *ArrayTypeContext) SetLbrack(v antlr.Token) { s.lbrack = v }
-
-func (s *ArrayTypeContext) SetRbrack(v antlr.Token) { s.rbrack = v }
-
-func (s *ArrayTypeContext) DataType() IDataTypeContext {
-	var t = s.GetTypedRuleContext(reflect.TypeOf((*IDataTypeContext)(nil)).Elem(), 0)
-
-	if t == nil {
-		return nil
-	}
-
-	return t.(IDataTypeContext)
-}
-
-func (s *ArrayTypeContext) GetRuleContext() antlr.RuleContext {
-	return s
-}
-
-func (s *ArrayTypeContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string {
-	return antlr.TreesStringTree(s, ruleNames, recog)
-}
-
-func (s *ArrayTypeContext) Accept(visitor antlr.ParseTreeVisitor) any {
-	switch t := visitor.(type) {
-	case ApiParserVisitor:
-		return t.VisitArrayType(s)
-
-	default:
-		return t.VisitChildren(s)
-	}
-}
-
-func (p *ApiParserParser) ArrayType() (localctx IArrayTypeContext) {
-	localctx = NewArrayTypeContext(p, p.GetParserRuleContext(), p.GetState())
-	p.EnterRule(localctx, 48, ApiParserParserRULE_arrayType)
-
-	defer func() {
-		p.ExitRule()
-	}()
-
-	defer func() {
-		if err := recover(); err != nil {
-			if v, ok := err.(antlr.RecognitionException); ok {
-				localctx.SetException(v)
-				p.GetErrorHandler().ReportError(p, v)
-				p.GetErrorHandler().Recover(p, v)
-			} else {
-				panic(err)
-			}
-		}
-	}()
-
-	p.EnterOuterAlt(localctx, 1)
-	{
-		p.SetState(235)
-
-		var _m = p.Match(ApiParserParserT__7)
-
-		localctx.(*ArrayTypeContext).lbrack = _m
-	}
-	{
-		p.SetState(236)
-
-		var _m = p.Match(ApiParserParserT__8)
-
-		localctx.(*ArrayTypeContext).rbrack = _m
-	}
-	{
-		p.SetState(237)
-		p.DataType()
-	}
-
-	return localctx
-}
-
-// IServiceSpecContext is an interface to support dynamic dispatch.
-type IServiceSpecContext interface {
-	antlr.ParserRuleContext
-
-	// GetParser returns the parser.
-	GetParser() antlr.Parser
-
-	// IsServiceSpecContext differentiates from other interfaces.
-	IsServiceSpecContext()
-}
-
-type ServiceSpecContext struct {
-	*antlr.BaseParserRuleContext
-	parser antlr.Parser
-}
-
-func NewEmptyServiceSpecContext() *ServiceSpecContext {
-	var p = new(ServiceSpecContext)
-	p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1)
-	p.RuleIndex = ApiParserParserRULE_serviceSpec
-	return p
-}
-
-func (*ServiceSpecContext) IsServiceSpecContext() {}
-
-func NewServiceSpecContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *ServiceSpecContext {
-	var p = new(ServiceSpecContext)
-
-	p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState)
-
-	p.parser = parser
-	p.RuleIndex = ApiParserParserRULE_serviceSpec
-
-	return p
-}
-
-func (s *ServiceSpecContext) GetParser() antlr.Parser { return s.parser }
-
-func (s *ServiceSpecContext) ServiceApi() IServiceApiContext {
-	var t = s.GetTypedRuleContext(reflect.TypeOf((*IServiceApiContext)(nil)).Elem(), 0)
-
-	if t == nil {
-		return nil
-	}
-
-	return t.(IServiceApiContext)
-}
-
-func (s *ServiceSpecContext) AtServer() IAtServerContext {
-	var t = s.GetTypedRuleContext(reflect.TypeOf((*IAtServerContext)(nil)).Elem(), 0)
-
-	if t == nil {
-		return nil
-	}
-
-	return t.(IAtServerContext)
-}
-
-func (s *ServiceSpecContext) GetRuleContext() antlr.RuleContext {
-	return s
-}
-
-func (s *ServiceSpecContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string {
-	return antlr.TreesStringTree(s, ruleNames, recog)
-}
-
-func (s *ServiceSpecContext) Accept(visitor antlr.ParseTreeVisitor) any {
-	switch t := visitor.(type) {
-	case ApiParserVisitor:
-		return t.VisitServiceSpec(s)
-
-	default:
-		return t.VisitChildren(s)
-	}
-}
-
-func (p *ApiParserParser) ServiceSpec() (localctx IServiceSpecContext) {
-	localctx = NewServiceSpecContext(p, p.GetParserRuleContext(), p.GetState())
-	p.EnterRule(localctx, 50, ApiParserParserRULE_serviceSpec)
-	var _la int
-
-	defer func() {
-		p.ExitRule()
-	}()
-
-	defer func() {
-		if err := recover(); err != nil {
-			if v, ok := err.(antlr.RecognitionException); ok {
-				localctx.SetException(v)
-				p.GetErrorHandler().ReportError(p, v)
-				p.GetErrorHandler().Recover(p, v)
-			} else {
-				panic(err)
-			}
-		}
-	}()
-
-	p.EnterOuterAlt(localctx, 1)
-	p.SetState(240)
-	p.GetErrorHandler().Sync(p)
-	_la = p.GetTokenStream().LA(1)
-
-	if _la == ApiParserParserATSERVER {
-		{
-			p.SetState(239)
-			p.AtServer()
-		}
-
-	}
-	{
-		p.SetState(242)
-		p.ServiceApi()
-	}
-
-	return localctx
-}
-
-// IAtServerContext is an interface to support dynamic dispatch.
-type IAtServerContext interface {
-	antlr.ParserRuleContext
-
-	// GetParser returns the parser.
-	GetParser() antlr.Parser
-
-	// GetLp returns the lp token.
-	GetLp() antlr.Token
-
-	// GetRp returns the rp token.
-	GetRp() antlr.Token
-
-	// SetLp sets the lp token.
-	SetLp(antlr.Token)
-
-	// SetRp sets the rp token.
-	SetRp(antlr.Token)
-
-	// IsAtServerContext differentiates from other interfaces.
-	IsAtServerContext()
-}

+ 0 - 695
tools/goctlwt/api/parser/g4/gen/api/apiparser_parser6.go

@@ -1,695 +0,0 @@
-package api
-
-import (
-	"reflect"
-
-	"github.com/zeromicro/antlr"
-)
-
-// Part 6
-// The apiparser_parser.go file was split into multiple files because it
-// was too large and caused a possible memory overflow during goctlwt installation.
-
-type AtServerContext struct {
-	*antlr.BaseParserRuleContext
-	parser antlr.Parser
-	lp     antlr.Token
-	rp     antlr.Token
-}
-
-func NewEmptyAtServerContext() *AtServerContext {
-	var p = new(AtServerContext)
-	p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1)
-	p.RuleIndex = ApiParserParserRULE_atServer
-	return p
-}
-
-func (*AtServerContext) IsAtServerContext() {}
-
-func NewAtServerContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *AtServerContext {
-	var p = new(AtServerContext)
-
-	p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState)
-
-	p.parser = parser
-	p.RuleIndex = ApiParserParserRULE_atServer
-
-	return p
-}
-
-func (s *AtServerContext) GetParser() antlr.Parser { return s.parser }
-
-func (s *AtServerContext) GetLp() antlr.Token { return s.lp }
-
-func (s *AtServerContext) GetRp() antlr.Token { return s.rp }
-
-func (s *AtServerContext) SetLp(v antlr.Token) { s.lp = v }
-
-func (s *AtServerContext) SetRp(v antlr.Token) { s.rp = v }
-
-func (s *AtServerContext) ATSERVER() antlr.TerminalNode {
-	return s.GetToken(ApiParserParserATSERVER, 0)
-}
-
-func (s *AtServerContext) AllKvLit() []IKvLitContext {
-	var ts = s.GetTypedRuleContexts(reflect.TypeOf((*IKvLitContext)(nil)).Elem())
-	var tst = make([]IKvLitContext, len(ts))
-
-	for i, t := range ts {
-		if t != nil {
-			tst[i] = t.(IKvLitContext)
-		}
-	}
-
-	return tst
-}
-
-func (s *AtServerContext) KvLit(i int) IKvLitContext {
-	var t = s.GetTypedRuleContext(reflect.TypeOf((*IKvLitContext)(nil)).Elem(), i)
-
-	if t == nil {
-		return nil
-	}
-
-	return t.(IKvLitContext)
-}
-
-func (s *AtServerContext) GetRuleContext() antlr.RuleContext {
-	return s
-}
-
-func (s *AtServerContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string {
-	return antlr.TreesStringTree(s, ruleNames, recog)
-}
-
-func (s *AtServerContext) Accept(visitor antlr.ParseTreeVisitor) any {
-	switch t := visitor.(type) {
-	case ApiParserVisitor:
-		return t.VisitAtServer(s)
-
-	default:
-		return t.VisitChildren(s)
-	}
-}
-
-func (p *ApiParserParser) AtServer() (localctx IAtServerContext) {
-	localctx = NewAtServerContext(p, p.GetParserRuleContext(), p.GetState())
-	p.EnterRule(localctx, 52, ApiParserParserRULE_atServer)
-	var _la int
-
-	defer func() {
-		p.ExitRule()
-	}()
-
-	defer func() {
-		if err := recover(); err != nil {
-			if v, ok := err.(antlr.RecognitionException); ok {
-				localctx.SetException(v)
-				p.GetErrorHandler().ReportError(p, v)
-				p.GetErrorHandler().Recover(p, v)
-			} else {
-				panic(err)
-			}
-		}
-	}()
-
-	p.EnterOuterAlt(localctx, 1)
-	{
-		p.SetState(244)
-		p.Match(ApiParserParserATSERVER)
-	}
-	{
-		p.SetState(245)
-
-		var _m = p.Match(ApiParserParserT__1)
-
-		localctx.(*AtServerContext).lp = _m
-	}
-	p.SetState(247)
-	p.GetErrorHandler().Sync(p)
-	_la = p.GetTokenStream().LA(1)
-
-	for ok := true; ok; ok = _la == ApiParserParserID {
-		{
-			p.SetState(246)
-			p.KvLit()
-		}
-
-		p.SetState(249)
-		p.GetErrorHandler().Sync(p)
-		_la = p.GetTokenStream().LA(1)
-	}
-	{
-		p.SetState(251)
-
-		var _m = p.Match(ApiParserParserT__2)
-
-		localctx.(*AtServerContext).rp = _m
-	}
-
-	return localctx
-}
-
-// IServiceApiContext is an interface to support dynamic dispatch.
-type IServiceApiContext interface {
-	antlr.ParserRuleContext
-
-	// GetParser returns the parser.
-	GetParser() antlr.Parser
-
-	// GetServiceToken returns the serviceToken token.
-	GetServiceToken() antlr.Token
-
-	// GetLbrace returns the lbrace token.
-	GetLbrace() antlr.Token
-
-	// GetRbrace returns the rbrace token.
-	GetRbrace() antlr.Token
-
-	// SetServiceToken sets the serviceToken token.
-	SetServiceToken(antlr.Token)
-
-	// SetLbrace sets the lbrace token.
-	SetLbrace(antlr.Token)
-
-	// SetRbrace sets the rbrace token.
-	SetRbrace(antlr.Token)
-
-	// IsServiceApiContext differentiates from other interfaces.
-	IsServiceApiContext()
-}
-
-type ServiceApiContext struct {
-	*antlr.BaseParserRuleContext
-	parser       antlr.Parser
-	serviceToken antlr.Token
-	lbrace       antlr.Token
-	rbrace       antlr.Token
-}
-
-func NewEmptyServiceApiContext() *ServiceApiContext {
-	var p = new(ServiceApiContext)
-	p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1)
-	p.RuleIndex = ApiParserParserRULE_serviceApi
-	return p
-}
-
-func (*ServiceApiContext) IsServiceApiContext() {}
-
-func NewServiceApiContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *ServiceApiContext {
-	var p = new(ServiceApiContext)
-
-	p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState)
-
-	p.parser = parser
-	p.RuleIndex = ApiParserParserRULE_serviceApi
-
-	return p
-}
-
-func (s *ServiceApiContext) GetParser() antlr.Parser { return s.parser }
-
-func (s *ServiceApiContext) GetServiceToken() antlr.Token { return s.serviceToken }
-
-func (s *ServiceApiContext) GetLbrace() antlr.Token { return s.lbrace }
-
-func (s *ServiceApiContext) GetRbrace() antlr.Token { return s.rbrace }
-
-func (s *ServiceApiContext) SetServiceToken(v antlr.Token) { s.serviceToken = v }
-
-func (s *ServiceApiContext) SetLbrace(v antlr.Token) { s.lbrace = v }
-
-func (s *ServiceApiContext) SetRbrace(v antlr.Token) { s.rbrace = v }
-
-func (s *ServiceApiContext) ServiceName() IServiceNameContext {
-	var t = s.GetTypedRuleContext(reflect.TypeOf((*IServiceNameContext)(nil)).Elem(), 0)
-
-	if t == nil {
-		return nil
-	}
-
-	return t.(IServiceNameContext)
-}
-
-func (s *ServiceApiContext) ID() antlr.TerminalNode {
-	return s.GetToken(ApiParserParserID, 0)
-}
-
-func (s *ServiceApiContext) AllServiceRoute() []IServiceRouteContext {
-	var ts = s.GetTypedRuleContexts(reflect.TypeOf((*IServiceRouteContext)(nil)).Elem())
-	var tst = make([]IServiceRouteContext, len(ts))
-
-	for i, t := range ts {
-		if t != nil {
-			tst[i] = t.(IServiceRouteContext)
-		}
-	}
-
-	return tst
-}
-
-func (s *ServiceApiContext) ServiceRoute(i int) IServiceRouteContext {
-	var t = s.GetTypedRuleContext(reflect.TypeOf((*IServiceRouteContext)(nil)).Elem(), i)
-
-	if t == nil {
-		return nil
-	}
-
-	return t.(IServiceRouteContext)
-}
-
-func (s *ServiceApiContext) GetRuleContext() antlr.RuleContext {
-	return s
-}
-
-func (s *ServiceApiContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string {
-	return antlr.TreesStringTree(s, ruleNames, recog)
-}
-
-func (s *ServiceApiContext) Accept(visitor antlr.ParseTreeVisitor) any {
-	switch t := visitor.(type) {
-	case ApiParserVisitor:
-		return t.VisitServiceApi(s)
-
-	default:
-		return t.VisitChildren(s)
-	}
-}
-
-func (p *ApiParserParser) ServiceApi() (localctx IServiceApiContext) {
-	localctx = NewServiceApiContext(p, p.GetParserRuleContext(), p.GetState())
-	p.EnterRule(localctx, 54, ApiParserParserRULE_serviceApi)
-	var _la int
-
-	defer func() {
-		p.ExitRule()
-	}()
-
-	defer func() {
-		if err := recover(); err != nil {
-			if v, ok := err.(antlr.RecognitionException); ok {
-				localctx.SetException(v)
-				p.GetErrorHandler().ReportError(p, v)
-				p.GetErrorHandler().Recover(p, v)
-			} else {
-				panic(err)
-			}
-		}
-	}()
-
-	p.EnterOuterAlt(localctx, 1)
-	match(p, "service")
-	{
-		p.SetState(254)
-
-		var _m = p.Match(ApiParserParserID)
-
-		localctx.(*ServiceApiContext).serviceToken = _m
-	}
-	{
-		p.SetState(255)
-		p.ServiceName()
-	}
-	{
-		p.SetState(256)
-
-		var _m = p.Match(ApiParserParserT__3)
-
-		localctx.(*ServiceApiContext).lbrace = _m
-	}
-	p.SetState(260)
-	p.GetErrorHandler().Sync(p)
-	_la = p.GetTokenStream().LA(1)
-
-	for ((_la)&-(0x1f+1)) == 0 && ((1<<uint(_la))&((1<<ApiParserParserATDOC)|(1<<ApiParserParserATHANDLER)|(1<<ApiParserParserATSERVER))) != 0 {
-		{
-			p.SetState(257)
-			p.ServiceRoute()
-		}
-
-		p.SetState(262)
-		p.GetErrorHandler().Sync(p)
-		_la = p.GetTokenStream().LA(1)
-	}
-	{
-		p.SetState(263)
-
-		var _m = p.Match(ApiParserParserT__4)
-
-		localctx.(*ServiceApiContext).rbrace = _m
-	}
-
-	return localctx
-}
-
-// IServiceRouteContext is an interface to support dynamic dispatch.
-type IServiceRouteContext interface {
-	antlr.ParserRuleContext
-
-	// GetParser returns the parser.
-	GetParser() antlr.Parser
-
-	// IsServiceRouteContext differentiates from other interfaces.
-	IsServiceRouteContext()
-}
-
-type ServiceRouteContext struct {
-	*antlr.BaseParserRuleContext
-	parser antlr.Parser
-}
-
-func NewEmptyServiceRouteContext() *ServiceRouteContext {
-	var p = new(ServiceRouteContext)
-	p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1)
-	p.RuleIndex = ApiParserParserRULE_serviceRoute
-	return p
-}
-
-func (*ServiceRouteContext) IsServiceRouteContext() {}
-
-func NewServiceRouteContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *ServiceRouteContext {
-	var p = new(ServiceRouteContext)
-
-	p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState)
-
-	p.parser = parser
-	p.RuleIndex = ApiParserParserRULE_serviceRoute
-
-	return p
-}
-
-func (s *ServiceRouteContext) GetParser() antlr.Parser { return s.parser }
-
-func (s *ServiceRouteContext) Route() IRouteContext {
-	var t = s.GetTypedRuleContext(reflect.TypeOf((*IRouteContext)(nil)).Elem(), 0)
-
-	if t == nil {
-		return nil
-	}
-
-	return t.(IRouteContext)
-}
-
-func (s *ServiceRouteContext) AtServer() IAtServerContext {
-	var t = s.GetTypedRuleContext(reflect.TypeOf((*IAtServerContext)(nil)).Elem(), 0)
-
-	if t == nil {
-		return nil
-	}
-
-	return t.(IAtServerContext)
-}
-
-func (s *ServiceRouteContext) AtHandler() IAtHandlerContext {
-	var t = s.GetTypedRuleContext(reflect.TypeOf((*IAtHandlerContext)(nil)).Elem(), 0)
-
-	if t == nil {
-		return nil
-	}
-
-	return t.(IAtHandlerContext)
-}
-
-func (s *ServiceRouteContext) AtDoc() IAtDocContext {
-	var t = s.GetTypedRuleContext(reflect.TypeOf((*IAtDocContext)(nil)).Elem(), 0)
-
-	if t == nil {
-		return nil
-	}
-
-	return t.(IAtDocContext)
-}
-
-func (s *ServiceRouteContext) GetRuleContext() antlr.RuleContext {
-	return s
-}
-
-func (s *ServiceRouteContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string {
-	return antlr.TreesStringTree(s, ruleNames, recog)
-}
-
-func (s *ServiceRouteContext) Accept(visitor antlr.ParseTreeVisitor) any {
-	switch t := visitor.(type) {
-	case ApiParserVisitor:
-		return t.VisitServiceRoute(s)
-
-	default:
-		return t.VisitChildren(s)
-	}
-}
-
-func (p *ApiParserParser) ServiceRoute() (localctx IServiceRouteContext) {
-	localctx = NewServiceRouteContext(p, p.GetParserRuleContext(), p.GetState())
-	p.EnterRule(localctx, 56, ApiParserParserRULE_serviceRoute)
-	var _la int
-
-	defer func() {
-		p.ExitRule()
-	}()
-
-	defer func() {
-		if err := recover(); err != nil {
-			if v, ok := err.(antlr.RecognitionException); ok {
-				localctx.SetException(v)
-				p.GetErrorHandler().ReportError(p, v)
-				p.GetErrorHandler().Recover(p, v)
-			} else {
-				panic(err)
-			}
-		}
-	}()
-
-	p.EnterOuterAlt(localctx, 1)
-	p.SetState(266)
-	p.GetErrorHandler().Sync(p)
-	_la = p.GetTokenStream().LA(1)
-
-	if _la == ApiParserParserATDOC {
-		{
-			p.SetState(265)
-			p.AtDoc()
-		}
-
-	}
-	p.SetState(270)
-	p.GetErrorHandler().Sync(p)
-
-	switch p.GetTokenStream().LA(1) {
-	case ApiParserParserATSERVER:
-		{
-			p.SetState(268)
-			p.AtServer()
-		}
-
-	case ApiParserParserATHANDLER:
-		{
-			p.SetState(269)
-			p.AtHandler()
-		}
-
-	default:
-		panic(antlr.NewNoViableAltException(p, nil, nil, nil, nil, nil))
-	}
-	{
-		p.SetState(272)
-		p.Route()
-	}
-
-	return localctx
-}
-
-// IAtDocContext is an interface to support dynamic dispatch.
-type IAtDocContext interface {
-	antlr.ParserRuleContext
-
-	// GetParser returns the parser.
-	GetParser() antlr.Parser
-
-	// GetLp returns the lp token.
-	GetLp() antlr.Token
-
-	// GetRp returns the rp token.
-	GetRp() antlr.Token
-
-	// SetLp sets the lp token.
-	SetLp(antlr.Token)
-
-	// SetRp sets the rp token.
-	SetRp(antlr.Token)
-
-	// IsAtDocContext differentiates from other interfaces.
-	IsAtDocContext()
-}
-
-type AtDocContext struct {
-	*antlr.BaseParserRuleContext
-	parser antlr.Parser
-	lp     antlr.Token
-	rp     antlr.Token
-}
-
-func NewEmptyAtDocContext() *AtDocContext {
-	var p = new(AtDocContext)
-	p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1)
-	p.RuleIndex = ApiParserParserRULE_atDoc
-	return p
-}
-
-func (*AtDocContext) IsAtDocContext() {}
-
-func NewAtDocContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *AtDocContext {
-	var p = new(AtDocContext)
-
-	p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState)
-
-	p.parser = parser
-	p.RuleIndex = ApiParserParserRULE_atDoc
-
-	return p
-}
-
-func (s *AtDocContext) GetParser() antlr.Parser { return s.parser }
-
-func (s *AtDocContext) GetLp() antlr.Token { return s.lp }
-
-func (s *AtDocContext) GetRp() antlr.Token { return s.rp }
-
-func (s *AtDocContext) SetLp(v antlr.Token) { s.lp = v }
-
-func (s *AtDocContext) SetRp(v antlr.Token) { s.rp = v }
-
-func (s *AtDocContext) ATDOC() antlr.TerminalNode {
-	return s.GetToken(ApiParserParserATDOC, 0)
-}
-
-func (s *AtDocContext) STRING() antlr.TerminalNode {
-	return s.GetToken(ApiParserParserSTRING, 0)
-}
-
-func (s *AtDocContext) AllKvLit() []IKvLitContext {
-	var ts = s.GetTypedRuleContexts(reflect.TypeOf((*IKvLitContext)(nil)).Elem())
-	var tst = make([]IKvLitContext, len(ts))
-
-	for i, t := range ts {
-		if t != nil {
-			tst[i] = t.(IKvLitContext)
-		}
-	}
-
-	return tst
-}
-
-func (s *AtDocContext) KvLit(i int) IKvLitContext {
-	var t = s.GetTypedRuleContext(reflect.TypeOf((*IKvLitContext)(nil)).Elem(), i)
-
-	if t == nil {
-		return nil
-	}
-
-	return t.(IKvLitContext)
-}
-
-func (s *AtDocContext) GetRuleContext() antlr.RuleContext {
-	return s
-}
-
-func (s *AtDocContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string {
-	return antlr.TreesStringTree(s, ruleNames, recog)
-}
-
-func (s *AtDocContext) Accept(visitor antlr.ParseTreeVisitor) any {
-	switch t := visitor.(type) {
-	case ApiParserVisitor:
-		return t.VisitAtDoc(s)
-
-	default:
-		return t.VisitChildren(s)
-	}
-}
-
-func (p *ApiParserParser) AtDoc() (localctx IAtDocContext) {
-	localctx = NewAtDocContext(p, p.GetParserRuleContext(), p.GetState())
-	p.EnterRule(localctx, 58, ApiParserParserRULE_atDoc)
-	var _la int
-
-	defer func() {
-		p.ExitRule()
-	}()
-
-	defer func() {
-		if err := recover(); err != nil {
-			if v, ok := err.(antlr.RecognitionException); ok {
-				localctx.SetException(v)
-				p.GetErrorHandler().ReportError(p, v)
-				p.GetErrorHandler().Recover(p, v)
-			} else {
-				panic(err)
-			}
-		}
-	}()
-
-	p.EnterOuterAlt(localctx, 1)
-	{
-		p.SetState(274)
-		p.Match(ApiParserParserATDOC)
-	}
-	p.SetState(276)
-	p.GetErrorHandler().Sync(p)
-	_la = p.GetTokenStream().LA(1)
-
-	if _la == ApiParserParserT__1 {
-		{
-			p.SetState(275)
-
-			var _m = p.Match(ApiParserParserT__1)
-
-			localctx.(*AtDocContext).lp = _m
-		}
-
-	}
-	p.SetState(284)
-	p.GetErrorHandler().Sync(p)
-
-	switch p.GetTokenStream().LA(1) {
-	case ApiParserParserID:
-		p.SetState(279)
-		p.GetErrorHandler().Sync(p)
-		_la = p.GetTokenStream().LA(1)
-
-		for ok := true; ok; ok = _la == ApiParserParserID {
-			{
-				p.SetState(278)
-				p.KvLit()
-			}
-
-			p.SetState(281)
-			p.GetErrorHandler().Sync(p)
-			_la = p.GetTokenStream().LA(1)
-		}
-
-	case ApiParserParserSTRING:
-		{
-			p.SetState(283)
-			p.Match(ApiParserParserSTRING)
-		}
-
-	default:
-		panic(antlr.NewNoViableAltException(p, nil, nil, nil, nil, nil))
-	}
-	p.SetState(287)
-	p.GetErrorHandler().Sync(p)
-	_la = p.GetTokenStream().LA(1)
-
-	if _la == ApiParserParserT__2 {
-		{
-			p.SetState(286)
-
-			var _m = p.Match(ApiParserParserT__2)
-
-			localctx.(*AtDocContext).rp = _m
-		}
-
-	}
-
-	return localctx
-}

+ 0 - 663
tools/goctlwt/api/parser/g4/gen/api/apiparser_parser7.go

@@ -1,663 +0,0 @@
-package api
-
-import (
-	"reflect"
-
-	"github.com/zeromicro/antlr"
-)
-
-// Part 7
-// The apiparser_parser.go file was split into multiple files because it
-// was too large and caused a possible memory overflow during goctlwt installation.
-
-// IAtHandlerContext is an interface to support dynamic dispatch.
-type IAtHandlerContext interface {
-	antlr.ParserRuleContext
-
-	// GetParser returns the parser.
-	GetParser() antlr.Parser
-
-	// IsAtHandlerContext differentiates from other interfaces.
-	IsAtHandlerContext()
-}
-
-type AtHandlerContext struct {
-	*antlr.BaseParserRuleContext
-	parser antlr.Parser
-}
-
-func NewEmptyAtHandlerContext() *AtHandlerContext {
-	var p = new(AtHandlerContext)
-	p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1)
-	p.RuleIndex = ApiParserParserRULE_atHandler
-	return p
-}
-
-func (*AtHandlerContext) IsAtHandlerContext() {}
-
-func NewAtHandlerContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *AtHandlerContext {
-	var p = new(AtHandlerContext)
-
-	p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState)
-
-	p.parser = parser
-	p.RuleIndex = ApiParserParserRULE_atHandler
-
-	return p
-}
-
-func (s *AtHandlerContext) GetParser() antlr.Parser { return s.parser }
-
-func (s *AtHandlerContext) ATHANDLER() antlr.TerminalNode {
-	return s.GetToken(ApiParserParserATHANDLER, 0)
-}
-
-func (s *AtHandlerContext) ID() antlr.TerminalNode {
-	return s.GetToken(ApiParserParserID, 0)
-}
-
-func (s *AtHandlerContext) GetRuleContext() antlr.RuleContext {
-	return s
-}
-
-func (s *AtHandlerContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string {
-	return antlr.TreesStringTree(s, ruleNames, recog)
-}
-
-func (s *AtHandlerContext) Accept(visitor antlr.ParseTreeVisitor) any {
-	switch t := visitor.(type) {
-	case ApiParserVisitor:
-		return t.VisitAtHandler(s)
-
-	default:
-		return t.VisitChildren(s)
-	}
-}
-
-func (p *ApiParserParser) AtHandler() (localctx IAtHandlerContext) {
-	localctx = NewAtHandlerContext(p, p.GetParserRuleContext(), p.GetState())
-	p.EnterRule(localctx, 60, ApiParserParserRULE_atHandler)
-
-	defer func() {
-		p.ExitRule()
-	}()
-
-	defer func() {
-		if err := recover(); err != nil {
-			if v, ok := err.(antlr.RecognitionException); ok {
-				localctx.SetException(v)
-				p.GetErrorHandler().ReportError(p, v)
-				p.GetErrorHandler().Recover(p, v)
-			} else {
-				panic(err)
-			}
-		}
-	}()
-
-	p.EnterOuterAlt(localctx, 1)
-	{
-		p.SetState(289)
-		p.Match(ApiParserParserATHANDLER)
-	}
-	{
-		p.SetState(290)
-		p.Match(ApiParserParserID)
-	}
-
-	return localctx
-}
-
-// IRouteContext is an interface to support dynamic dispatch.
-type IRouteContext interface {
-	antlr.ParserRuleContext
-
-	// GetParser returns the parser.
-	GetParser() antlr.Parser
-
-	// GetHttpMethod returns the httpMethod token.
-	GetHttpMethod() antlr.Token
-
-	// SetHttpMethod sets the httpMethod token.
-	SetHttpMethod(antlr.Token)
-
-	// GetRequest returns the request rule contexts.
-	GetRequest() IBodyContext
-
-	// GetResponse returns the response rule contexts.
-	GetResponse() IReplybodyContext
-
-	// SetRequest sets the request rule contexts.
-	SetRequest(IBodyContext)
-
-	// SetResponse sets the response rule contexts.
-	SetResponse(IReplybodyContext)
-
-	// IsRouteContext differentiates from other interfaces.
-	IsRouteContext()
-}
-
-type RouteContext struct {
-	*antlr.BaseParserRuleContext
-	parser     antlr.Parser
-	httpMethod antlr.Token
-	request    IBodyContext
-	response   IReplybodyContext
-}
-
-func NewEmptyRouteContext() *RouteContext {
-	var p = new(RouteContext)
-	p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1)
-	p.RuleIndex = ApiParserParserRULE_route
-	return p
-}
-
-func (*RouteContext) IsRouteContext() {}
-
-func NewRouteContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *RouteContext {
-	var p = new(RouteContext)
-
-	p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState)
-
-	p.parser = parser
-	p.RuleIndex = ApiParserParserRULE_route
-
-	return p
-}
-
-func (s *RouteContext) GetParser() antlr.Parser { return s.parser }
-
-func (s *RouteContext) GetHttpMethod() antlr.Token { return s.httpMethod }
-
-func (s *RouteContext) SetHttpMethod(v antlr.Token) { s.httpMethod = v }
-
-func (s *RouteContext) GetRequest() IBodyContext { return s.request }
-
-func (s *RouteContext) GetResponse() IReplybodyContext { return s.response }
-
-func (s *RouteContext) SetRequest(v IBodyContext) { s.request = v }
-
-func (s *RouteContext) SetResponse(v IReplybodyContext) { s.response = v }
-
-func (s *RouteContext) Path() IPathContext {
-	var t = s.GetTypedRuleContext(reflect.TypeOf((*IPathContext)(nil)).Elem(), 0)
-
-	if t == nil {
-		return nil
-	}
-
-	return t.(IPathContext)
-}
-
-func (s *RouteContext) ID() antlr.TerminalNode {
-	return s.GetToken(ApiParserParserID, 0)
-}
-
-func (s *RouteContext) Body() IBodyContext {
-	var t = s.GetTypedRuleContext(reflect.TypeOf((*IBodyContext)(nil)).Elem(), 0)
-
-	if t == nil {
-		return nil
-	}
-
-	return t.(IBodyContext)
-}
-
-func (s *RouteContext) Replybody() IReplybodyContext {
-	var t = s.GetTypedRuleContext(reflect.TypeOf((*IReplybodyContext)(nil)).Elem(), 0)
-
-	if t == nil {
-		return nil
-	}
-
-	return t.(IReplybodyContext)
-}
-
-func (s *RouteContext) GetRuleContext() antlr.RuleContext {
-	return s
-}
-
-func (s *RouteContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string {
-	return antlr.TreesStringTree(s, ruleNames, recog)
-}
-
-func (s *RouteContext) Accept(visitor antlr.ParseTreeVisitor) any {
-	switch t := visitor.(type) {
-	case ApiParserVisitor:
-		return t.VisitRoute(s)
-
-	default:
-		return t.VisitChildren(s)
-	}
-}
-
-func (p *ApiParserParser) Route() (localctx IRouteContext) {
-	localctx = NewRouteContext(p, p.GetParserRuleContext(), p.GetState())
-	p.EnterRule(localctx, 62, ApiParserParserRULE_route)
-	var _la int
-
-	defer func() {
-		p.ExitRule()
-	}()
-
-	defer func() {
-		if err := recover(); err != nil {
-			if v, ok := err.(antlr.RecognitionException); ok {
-				localctx.SetException(v)
-				p.GetErrorHandler().ReportError(p, v)
-				p.GetErrorHandler().Recover(p, v)
-			} else {
-				panic(err)
-			}
-		}
-	}()
-
-	p.EnterOuterAlt(localctx, 1)
-	checkHTTPMethod(p)
-	{
-		p.SetState(293)
-
-		var _m = p.Match(ApiParserParserID)
-
-		localctx.(*RouteContext).httpMethod = _m
-	}
-	{
-		p.SetState(294)
-		p.Path()
-	}
-	p.SetState(296)
-	p.GetErrorHandler().Sync(p)
-	_la = p.GetTokenStream().LA(1)
-
-	if _la == ApiParserParserT__1 {
-		{
-			p.SetState(295)
-
-			var _x = p.Body()
-
-			localctx.(*RouteContext).request = _x
-		}
-
-	}
-	p.SetState(299)
-	p.GetErrorHandler().Sync(p)
-	_la = p.GetTokenStream().LA(1)
-
-	if _la == ApiParserParserT__9 {
-		{
-			p.SetState(298)
-
-			var _x = p.Replybody()
-
-			localctx.(*RouteContext).response = _x
-		}
-
-	}
-
-	return localctx
-}
-
-// IBodyContext is an interface to support dynamic dispatch.
-type IBodyContext interface {
-	antlr.ParserRuleContext
-
-	// GetParser returns the parser.
-	GetParser() antlr.Parser
-
-	// GetLp returns the lp token.
-	GetLp() antlr.Token
-
-	// GetRp returns the rp token.
-	GetRp() antlr.Token
-
-	// SetLp sets the lp token.
-	SetLp(antlr.Token)
-
-	// SetRp sets the rp token.
-	SetRp(antlr.Token)
-
-	// IsBodyContext differentiates from other interfaces.
-	IsBodyContext()
-}
-
-type BodyContext struct {
-	*antlr.BaseParserRuleContext
-	parser antlr.Parser
-	lp     antlr.Token
-	rp     antlr.Token
-}
-
-func NewEmptyBodyContext() *BodyContext {
-	var p = new(BodyContext)
-	p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1)
-	p.RuleIndex = ApiParserParserRULE_body
-	return p
-}
-
-func (*BodyContext) IsBodyContext() {}
-
-func NewBodyContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *BodyContext {
-	var p = new(BodyContext)
-
-	p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState)
-
-	p.parser = parser
-	p.RuleIndex = ApiParserParserRULE_body
-
-	return p
-}
-
-func (s *BodyContext) GetParser() antlr.Parser { return s.parser }
-
-func (s *BodyContext) GetLp() antlr.Token { return s.lp }
-
-func (s *BodyContext) GetRp() antlr.Token { return s.rp }
-
-func (s *BodyContext) SetLp(v antlr.Token) { s.lp = v }
-
-func (s *BodyContext) SetRp(v antlr.Token) { s.rp = v }
-
-func (s *BodyContext) ID() antlr.TerminalNode {
-	return s.GetToken(ApiParserParserID, 0)
-}
-
-func (s *BodyContext) GetRuleContext() antlr.RuleContext {
-	return s
-}
-
-func (s *BodyContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string {
-	return antlr.TreesStringTree(s, ruleNames, recog)
-}
-
-func (s *BodyContext) Accept(visitor antlr.ParseTreeVisitor) any {
-	switch t := visitor.(type) {
-	case ApiParserVisitor:
-		return t.VisitBody(s)
-
-	default:
-		return t.VisitChildren(s)
-	}
-}
-
-func (p *ApiParserParser) Body() (localctx IBodyContext) {
-	localctx = NewBodyContext(p, p.GetParserRuleContext(), p.GetState())
-	p.EnterRule(localctx, 64, ApiParserParserRULE_body)
-	var _la int
-
-	defer func() {
-		p.ExitRule()
-	}()
-
-	defer func() {
-		if err := recover(); err != nil {
-			if v, ok := err.(antlr.RecognitionException); ok {
-				localctx.SetException(v)
-				p.GetErrorHandler().ReportError(p, v)
-				p.GetErrorHandler().Recover(p, v)
-			} else {
-				panic(err)
-			}
-		}
-	}()
-
-	p.EnterOuterAlt(localctx, 1)
-	{
-		p.SetState(301)
-
-		var _m = p.Match(ApiParserParserT__1)
-
-		localctx.(*BodyContext).lp = _m
-	}
-	p.SetState(303)
-	p.GetErrorHandler().Sync(p)
-	_la = p.GetTokenStream().LA(1)
-
-	if _la == ApiParserParserID {
-		{
-			p.SetState(302)
-			p.Match(ApiParserParserID)
-		}
-
-	}
-	{
-		p.SetState(305)
-
-		var _m = p.Match(ApiParserParserT__2)
-
-		localctx.(*BodyContext).rp = _m
-	}
-
-	return localctx
-}
-
-// IReplybodyContext is an interface to support dynamic dispatch.
-type IReplybodyContext interface {
-	antlr.ParserRuleContext
-
-	// GetParser returns the parser.
-	GetParser() antlr.Parser
-
-	// GetReturnToken returns the returnToken token.
-	GetReturnToken() antlr.Token
-
-	// GetLp returns the lp token.
-	GetLp() antlr.Token
-
-	// GetRp returns the rp token.
-	GetRp() antlr.Token
-
-	// SetReturnToken sets the returnToken token.
-	SetReturnToken(antlr.Token)
-
-	// SetLp sets the lp token.
-	SetLp(antlr.Token)
-
-	// SetRp sets the rp token.
-	SetRp(antlr.Token)
-
-	// IsReplybodyContext differentiates from other interfaces.
-	IsReplybodyContext()
-}
-
-type ReplybodyContext struct {
-	*antlr.BaseParserRuleContext
-	parser      antlr.Parser
-	returnToken antlr.Token
-	lp          antlr.Token
-	rp          antlr.Token
-}
-
-func NewEmptyReplybodyContext() *ReplybodyContext {
-	var p = new(ReplybodyContext)
-	p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1)
-	p.RuleIndex = ApiParserParserRULE_replybody
-	return p
-}
-
-func (*ReplybodyContext) IsReplybodyContext() {}
-
-func NewReplybodyContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *ReplybodyContext {
-	var p = new(ReplybodyContext)
-
-	p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState)
-
-	p.parser = parser
-	p.RuleIndex = ApiParserParserRULE_replybody
-
-	return p
-}
-
-func (s *ReplybodyContext) GetParser() antlr.Parser { return s.parser }
-
-func (s *ReplybodyContext) GetReturnToken() antlr.Token { return s.returnToken }
-
-func (s *ReplybodyContext) GetLp() antlr.Token { return s.lp }
-
-func (s *ReplybodyContext) GetRp() antlr.Token { return s.rp }
-
-func (s *ReplybodyContext) SetReturnToken(v antlr.Token) { s.returnToken = v }
-
-func (s *ReplybodyContext) SetLp(v antlr.Token) { s.lp = v }
-
-func (s *ReplybodyContext) SetRp(v antlr.Token) { s.rp = v }
-
-func (s *ReplybodyContext) DataType() IDataTypeContext {
-	var t = s.GetTypedRuleContext(reflect.TypeOf((*IDataTypeContext)(nil)).Elem(), 0)
-
-	if t == nil {
-		return nil
-	}
-
-	return t.(IDataTypeContext)
-}
-
-func (s *ReplybodyContext) GetRuleContext() antlr.RuleContext {
-	return s
-}
-
-func (s *ReplybodyContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string {
-	return antlr.TreesStringTree(s, ruleNames, recog)
-}
-
-func (s *ReplybodyContext) Accept(visitor antlr.ParseTreeVisitor) any {
-	switch t := visitor.(type) {
-	case ApiParserVisitor:
-		return t.VisitReplybody(s)
-
-	default:
-		return t.VisitChildren(s)
-	}
-}
-
-func (p *ApiParserParser) Replybody() (localctx IReplybodyContext) {
-	localctx = NewReplybodyContext(p, p.GetParserRuleContext(), p.GetState())
-	p.EnterRule(localctx, 66, ApiParserParserRULE_replybody)
-	var _la int
-
-	defer func() {
-		p.ExitRule()
-	}()
-
-	defer func() {
-		if err := recover(); err != nil {
-			if v, ok := err.(antlr.RecognitionException); ok {
-				localctx.SetException(v)
-				p.GetErrorHandler().ReportError(p, v)
-				p.GetErrorHandler().Recover(p, v)
-			} else {
-				panic(err)
-			}
-		}
-	}()
-
-	p.EnterOuterAlt(localctx, 1)
-	{
-		p.SetState(307)
-
-		var _m = p.Match(ApiParserParserT__9)
-
-		localctx.(*ReplybodyContext).returnToken = _m
-	}
-	{
-		p.SetState(308)
-
-		var _m = p.Match(ApiParserParserT__1)
-
-		localctx.(*ReplybodyContext).lp = _m
-	}
-	p.SetState(310)
-	p.GetErrorHandler().Sync(p)
-	_la = p.GetTokenStream().LA(1)
-
-	if ((_la)&-(0x1f+1)) == 0 && ((1<<uint(_la))&((1<<ApiParserParserT__5)|(1<<ApiParserParserT__6)|(1<<ApiParserParserT__7)|(1<<ApiParserParserINTERFACE)|(1<<ApiParserParserID))) != 0 {
-		{
-			p.SetState(309)
-			p.DataType()
-		}
-
-	}
-	{
-		p.SetState(312)
-
-		var _m = p.Match(ApiParserParserT__2)
-
-		localctx.(*ReplybodyContext).rp = _m
-	}
-
-	return localctx
-}
-
-// IKvLitContext is an interface to support dynamic dispatch.
-type IKvLitContext interface {
-	antlr.ParserRuleContext
-
-	// GetParser returns the parser.
-	GetParser() antlr.Parser
-
-	// GetKey returns the key token.
-	GetKey() antlr.Token
-
-	// GetValue returns the value token.
-	GetValue() antlr.Token
-
-	// SetKey sets the key token.
-	SetKey(antlr.Token)
-
-	// SetValue sets the value token.
-	SetValue(antlr.Token)
-
-	// IsKvLitContext differentiates from other interfaces.
-	IsKvLitContext()
-}
-
-type KvLitContext struct {
-	*antlr.BaseParserRuleContext
-	parser antlr.Parser
-	key    antlr.Token
-	value  antlr.Token
-}
-
-func NewEmptyKvLitContext() *KvLitContext {
-	var p = new(KvLitContext)
-	p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(nil, -1)
-	p.RuleIndex = ApiParserParserRULE_kvLit
-	return p
-}
-
-func (*KvLitContext) IsKvLitContext() {}
-
-func NewKvLitContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *KvLitContext {
-	var p = new(KvLitContext)
-
-	p.BaseParserRuleContext = antlr.NewBaseParserRuleContext(parent, invokingState)
-
-	p.parser = parser
-	p.RuleIndex = ApiParserParserRULE_kvLit
-
-	return p
-}
-
-func (s *KvLitContext) GetParser() antlr.Parser { return s.parser }
-
-func (s *KvLitContext) GetKey() antlr.Token { return s.key }
-
-func (s *KvLitContext) GetValue() antlr.Token { return s.value }
-
-func (s *KvLitContext) SetKey(v antlr.Token) { s.key = v }
-
-func (s *KvLitContext) SetValue(v antlr.Token) { s.value = v }
-
-func (s *KvLitContext) ID() antlr.TerminalNode {
-	return s.GetToken(ApiParserParserID, 0)
-}
-
-func (s *KvLitContext) LINE_VALUE() antlr.TerminalNode {
-	return s.GetToken(ApiParserParserLINE_VALUE, 0)
-}
-
-func (s *KvLitContext) GetRuleContext() antlr.RuleContext {
-	return s
-}
-
-func (s *KvLitContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string {
-	return antlr.TreesStringTree(s, ruleNames, recog)
-}

Algúns arquivos non se mostraron porque demasiados arquivos cambiaron neste cambio