a lil bit refactoring

This commit is contained in:
Egor Aristov 2025-11-08 10:41:17 +03:00
parent 2759bec46c
commit 10ac5dfae8
Signed by: egor3f
GPG Key ID: 40482A264AAEC85F
3 changed files with 15 additions and 12 deletions

9
kitcom/common/parser.go Normal file
View File

@ -0,0 +1,9 @@
package common
type Parser struct {
Files []string
}
func (p *Parser) AddFile(path string) {
p.Files = append(p.Files, path)
}

View File

@ -8,23 +8,20 @@ import (
"regexp"
"efprojects.com/kitten-ipc/kitcom/api"
"efprojects.com/kitten-ipc/kitcom/common"
)
var decorComment = regexp.MustCompile(`^//\s?kittenipc:api$`)
type GoApiParser struct {
files []string
}
func (g *GoApiParser) AddFile(path string) {
g.files = append(g.files, path)
*common.Parser
}
func (g *GoApiParser) Parse() (*api.Api, error) {
var apis api.Api
for _, f := range g.files {
for _, f := range g.Files {
endpoints, err := g.parseFile(f)
if err != nil {
return nil, fmt.Errorf("parse file: %w", err)

View File

@ -7,6 +7,7 @@ import (
"strings"
"efprojects.com/kitten-ipc/kitcom/api"
"efprojects.com/kitten-ipc/kitcom/common"
"efprojects.com/kitten-ipc/kitcom/internal/tsgo/ast"
"efprojects.com/kitten-ipc/kitcom/internal/tsgo/core"
"efprojects.com/kitten-ipc/kitcom/internal/tsgo/parser"
@ -17,18 +18,14 @@ const TagName = "kittenipc"
const TagComment = "api"
type TypescriptApiParser struct {
files []string
}
func (t *TypescriptApiParser) AddFile(path string) {
t.files = append(t.files, path)
*common.Parser
}
func (t *TypescriptApiParser) Parse() (*api.Api, error) {
var apis api.Api
for _, f := range t.files {
for _, f := range t.Files {
endpoints, err := t.parseFile(f)
if err != nil {
return nil, fmt.Errorf("parse file: %w", err)