Skip to content

Commit

Permalink
Add model plugin (#163)
Browse files Browse the repository at this point in the history
* Add 'model' plugin.

* Fix misc issues
  • Loading branch information
raphael authored Jun 29, 2024
1 parent 1d31762 commit cc763ed
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 7 deletions.
2 changes: 1 addition & 1 deletion model/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@
GOPATH=$(shell go env GOPATH)
include ../plugins.mk

gen:
gen:
2 changes: 1 addition & 1 deletion model/expr/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@ type (

// Register design root with eval engine.
func init() {
InitRoot()
if err := eval.Register(Root); err != nil {
panic(err)
}
InitRoot()
}

// InitRoot initializes the root expression.
Expand Down
9 changes: 4 additions & 5 deletions model/validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,12 @@ func Validate(_ string, roots []eval.Root, files []*codegen.File) ([]*codegen.Fi
var r *modelexpr.RootExpr
var ok bool
for _, root := range roots {
if r, ok := root.(*expr.RootExpr); ok {
if re, ok := root.(*expr.RootExpr); ok {
// Note: this root is guaranteed to be appear before the model root
services = r.Services
services = re.Services
continue
}
r, ok = root.(*modelexpr.RootExpr)
if ok {
if r, ok = root.(*modelexpr.RootExpr); ok {
break
}
}
Expand Down Expand Up @@ -152,7 +151,7 @@ func Validate(_ string, roots []eval.Root, files []*codegen.File) ([]*codegen.Fi
pluralize(len(noService)), strings.Join(noService, ", "), pluralVerb(len(noService)))
}

return nil, nil
return files, nil
}

// Helper functions to handle singular/plural
Expand Down

0 comments on commit cc763ed

Please sign in to comment.