Skip to content

Commit

Permalink
Merge pull request #20 from xushiwei/q
Browse files Browse the repository at this point in the history
remove Kind type (use isWork, isProj bool)
  • Loading branch information
xushiwei committed Aug 26, 2023
2 parents b9ac1f4 + fdea208 commit c9d34fd
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 19 deletions.
6 changes: 2 additions & 4 deletions gopmod/classfile.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,9 @@ var (

// -----------------------------------------------------------------------------

type Kind = modfile.Kind

func (p *Module) ClassKind(ext string) (kind Kind) {
func (p *Module) ClassKind(ext string) (isWork, isProj bool) {
if c, ok := p.projects[ext]; ok {
kind = c.Kind(ext)
isWork, isProj = c.Kind(ext)
}
return
}
Expand Down
15 changes: 3 additions & 12 deletions modfile/rule.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,23 +80,14 @@ type Class struct {
Syntax *Line
}

type Kind int

const (
KindNone Kind = 0
KindWork = 1
KindProject = 2
KindBoth = KindProject | KindWork
)

func (p *Project) Kind(ext string) (kind Kind) {
func (p *Project) Kind(ext string) (isWork, isProj bool) {
for _, w := range p.Works {
if w.Ext == ext {
kind |= KindWork
isWork = true
}
}
if p.Ext == ext {
kind |= KindProject
isProj = true
}
return
}
Expand Down
6 changes: 3 additions & 3 deletions modfile/rule_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,9 @@ func TestMustQuote(t *testing.T) {

func TestKind(t *testing.T) {
proj := &Project{Works: []*Class{{Ext: ".spx"}}, Ext: ".spx"}
kind := proj.Kind(".spx")
if kind != KindBoth {
t.Fatal("proj.Kind:", kind)
isWork, isProj := proj.Kind(".spx")
if !isWork || !isProj {
t.Fatal("proj.Kind:", isWork, isProj)
}
}

Expand Down

0 comments on commit c9d34fd

Please sign in to comment.