diff --git a/gopmod/classfile.go b/gopmod/classfile.go index af0e821..502d461 100644 --- a/gopmod/classfile.go +++ b/gopmod/classfile.go @@ -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 } diff --git a/modfile/rule.go b/modfile/rule.go index 17fdebe..2f34997 100644 --- a/modfile/rule.go +++ b/modfile/rule.go @@ -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 } diff --git a/modfile/rule_test.go b/modfile/rule_test.go index 4a48037..20c3bad 100644 --- a/modfile/rule_test.go +++ b/modfile/rule_test.go @@ -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) } }