Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
coverage:
ignore:
- "modfetch"
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
11 changes: 9 additions & 2 deletions modfile/rule.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Comment thread
xushiwei marked this conversation as resolved.

// 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.
Expand Down
12 changes: 11 additions & 1 deletion xgomod/classfile.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Comment thread
xushiwei marked this conversation as resolved.
}
return
}
Expand Down
4 changes: 2 additions & 2 deletions xgomod/xgomod_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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?")
Expand Down