diff --git a/.github/codecov.yml b/.github/codecov.yml new file mode 100644 index 0000000..6e1dfdf --- /dev/null +++ b/.github/codecov.yml @@ -0,0 +1,3 @@ +coverage: + ignore: + - "modfetch" diff --git a/README.md b/README.md index 6f660ad..e6e41d2 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,6 @@ mod - Module support for Go/XGo ===== [![Build Status](https://github.com/goplus/mod/actions/workflows/go.yml/badge.svg)](https://github.com/goplus/mod/actions/workflows/go.yml) -[![Go Report Card](https://goreportcard.com/badge/github.com/goplus/mod)](https://goreportcard.com/report/github.com/goplus/mod) [![GitHub release](https://img.shields.io/github/v/tag/goplus/mod.svg?label=release)](https://github.com/goplus/mod/releases) [![Coverage Status](https://codecov.io/gh/goplus/mod/branch/main/graph/badge.svg)](https://codecov.io/gh/goplus/mod) [![GoDoc](https://pkg.go.dev/badge/github.com/goplus/mod.svg)](https://pkg.go.dev/github.com/goplus/mod) diff --git a/modfile/rule.go b/modfile/rule.go index ff3694f..9cc6897 100644 --- a/modfile/rule.go +++ b/modfile/rule.go @@ -91,8 +91,15 @@ type Project struct { PkgPaths []string // package paths of classfile and optional inline-imported packages. Import []*Import // auto-imported packages Pack *Pack // pack directive (at most one per project) - Flat bool // if true, all matching files are fragments of the project class (no work classfiles) - Syntax *Line + + // AutoLambdas maps command => number of parameters before auto lambda. + // See https://github.com/goplus/xgo/issues/2828. + AutoLambdas map[string]int + + // if Flat is true, all matching files are fragments of the project class (no work classfiles). + Flat bool + + Syntax *Line } // IsProj checks if a (ext, fname) pair is a project file or not. diff --git a/xgomod/classfile.go b/xgomod/classfile.go index 438d6f2..4d6f0f0 100644 --- a/xgomod/classfile.go +++ b/xgomod/classfile.go @@ -59,10 +59,20 @@ func IsNotFound(err error) bool { // ClassKind checks a fname is a known classfile or not. // If it is, then it checks the fname is a project file or not. +// +// Deprecated: use ClassInfo instead. func (p *Module) ClassKind(fname string) (isProj, ok bool) { + _, isProj, ok = p.ClassInfo(fname) + return +} + +// ClassInfo checks a fname is a known classfile or not. +// If it is, it returns the auto-lambda map, whether it is a project file, and true. +// See https://github.com/goplus/xgo/issues/2828 to learn about auto lambda. +func (p *Module) ClassInfo(fname string) (autoLambdas map[string]int, isProj, ok bool) { ext := modfile.ClassExt(fname) if c, ok := p.projs[ext]; ok { - return c.IsProj(ext, fname), true + return c.AutoLambdas, c.IsProj(ext, fname), true } return } diff --git a/xgomod/xgomod_test.go b/xgomod/xgomod_test.go index 897cea6..d6e20e5 100644 --- a/xgomod/xgomod_test.go +++ b/xgomod/xgomod_test.go @@ -150,8 +150,8 @@ func TestClassfile2(t *testing.T) { if err := mod.ImportClasses(func(c *Project) {}); err != nil { t.Fatal("mod.ImportClasses:", err) } - if isProj, ok := mod.ClassKind("foo_yap.gox"); !ok || !isProj { - t.Fatal("mod.ClassKind foo_yap.gox:", isProj, ok) + if _, isProj, ok := mod.ClassInfo("foo_yap.gox"); !ok || !isProj { + t.Fatal("mod.ClassInfo foo_yap.gox:", isProj, ok) } if _, ok := mod.ClassKind("foo.gox"); ok { t.Fatal("mod.ClassKind foo.gox: ok?")