a lil bit refactoring
This commit is contained in:
parent
2759bec46c
commit
10ac5dfae8
9
kitcom/common/parser.go
Normal file
9
kitcom/common/parser.go
Normal file
@ -0,0 +1,9 @@
|
||||
package common
|
||||
|
||||
type Parser struct {
|
||||
Files []string
|
||||
}
|
||||
|
||||
func (p *Parser) AddFile(path string) {
|
||||
p.Files = append(p.Files, path)
|
||||
}
|
||||
@ -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)
|
||||
|
||||
@ -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)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user