Skip to content

Commit

Permalink
modload.Module: Project
Browse files Browse the repository at this point in the history
  • Loading branch information
xushiwei committed Jan 7, 2024
1 parent a2b92f6 commit e1e27d0
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
2 changes: 1 addition & 1 deletion gopmod/classfile.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ func (p *Module) importClassFrom(modVer module.Version, impcls func(c *Project))
if err != nil {
return
}
c := mod.Opt.Project
c := mod.Project()
if c == nil {
return ErrNotClassFileMod
}
Expand Down
14 changes: 9 additions & 5 deletions modload/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,14 @@ func LoadFrom(gomod, gopmod string) (p Module, err error) {

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

func (p Module) Project() *modfile.Project {
return p.Opt.Project
}

func hasGopExtended(opt *modfile.File) bool {
return opt.Project != nil || len(opt.Import) > 0
}

// Save saves all changes of this module.
func (p Module) Save() (err error) {
if p.IsDefault() {
Expand All @@ -209,7 +217,7 @@ func (p Module) Save() (err error) {
return
}

if opt := p.Opt; gopExtended(opt) {
if opt := p.Opt; hasGopExtended(opt) {
data, err = opt.Format()
if err != nil {
return
Expand All @@ -219,10 +227,6 @@ func (p Module) Save() (err error) {
return
}

func gopExtended(opt *modfile.File) bool {
return opt.Project != nil || len(opt.Import) > 0
}

/*
const (
gopMod = "github.com/goplus/gop"
Expand Down

0 comments on commit e1e27d0

Please sign in to comment.