Skip to content

Commit 92ebe0d

Browse files
committed
refactor(classfile): remove built-in .spx and .gmx handling
Remove the remaining default `.spx` and `.gmx` classfile detection from the parser, build helpers, formatter, watcher, and related tests. This also drops legacy `.yap`-specific test cases and chore script filters, keeping `_yap.gox` as the supported yap classfile form in this repository. Updates goplus/mod#139 Signed-off-by: Aofei Sheng <aofei@aofeisheng.com>
1 parent 8cf5e51 commit 92ebe0d

File tree

14 files changed

+17
-101
lines changed

14 files changed

+17
-101
lines changed

cl/builtin_test.go

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -290,8 +290,8 @@ func TestClassNameAndExt(t *testing.T) {
290290
if name != "bar_abc" || clsfile != "bar.abc" || ext != "_yap.gox" {
291291
t.Fatal("classNameAndExt:", name, ext)
292292
}
293-
name, clsfile, ext = ClassNameAndExt("/foo/get-bar_:id.yap")
294-
if name != "get_bar_id" || clsfile != "get-bar_:id" || ext != ".yap" {
293+
name, clsfile, ext = ClassNameAndExt("/foo/get-bar_:id_app.gox")
294+
if name != "get_bar_id" || clsfile != "get-bar_:id" || ext != "_app.gox" {
295295
t.Fatal("classNameAndExt:", name, ext)
296296
}
297297
}
@@ -326,10 +326,6 @@ func TestFileClassType(t *testing.T) {
326326
{true, true, false, "Abc_test.gox", "caseAbc", true, true},
327327
{true, true, false, "main_test.gox", "case_main", true, true},
328328

329-
{true, false, false, "get.yap", "get", false, true},
330-
{true, false, false, "get_p_#id.yap", "get_p_id", false, true},
331-
{true, false, true, "main.yap", "AppV2", false, true},
332-
333329
{true, false, false, "abc_yap.gox", "abc", false, true},
334330
{true, false, false, "Abc_yap.gox", "Abc", false, true},
335331
{true, false, true, "main_yap.gox", "App", false, true},
@@ -344,11 +340,6 @@ func TestFileClassType(t *testing.T) {
344340
}
345341
lookupClass := func(ext string) (c *Project, ok bool) {
346342
switch ext {
347-
case ".yap":
348-
return &modfile.Project{
349-
Ext: ".yap", Class: "AppV2",
350-
Works: []*modfile.Class{{Ext: ".yap", Class: "Handler"}},
351-
PkgPaths: []string{"github.com/goplus/yap"}}, true
352343
case "_yap.gox":
353344
return &modfile.Project{
354345
Ext: "_yap.gox", Class: "App",
@@ -643,7 +634,7 @@ func testPanic(t *testing.T, panicMsg string, doPanic func()) {
643634

644635
func TestClassFileEnd(t *testing.T) {
645636
fset := token.NewFileSet()
646-
f, err := parser.ParseFile(fset, "get.yap", `json {"id": ${id} }`, parser.ParseXGoClass)
637+
f, err := parser.ParseFile(fset, "get_app.gox", `json {"id": ${id} }`, parser.ParseXGoClass)
647638
if err != nil {
648639
t.Fatal(err)
649640
}

cmd/chore/xgofullspec/fullspec.xgo

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ func dump(f any) {
3131
func isGopFile(file string) bool {
3232
if len(file) > 4 {
3333
switch file[len(file)-4:] {
34-
case ".xgo", ".gop", ".gox", ".gsh", ".spx", ".yap":
34+
case ".xgo", ".gop", ".gox", ".gsh":
3535
return true
3636
}
3737
}

cmd/chore/xgominispec/minispec.xgo

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import (
2727
func isGopFile(file string) bool {
2828
if len(file) > 4 {
2929
switch file[len(file)-4:] {
30-
case ".xgo", ".gop", ".gox", ".gsh", ".spx", ".yap":
30+
case ".xgo", ".gop", ".gox", ".gsh":
3131
return true
3232
}
3333
}

cmd/internal/gopfmt/fmt.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ func (w *walker) walk(path string, d fs.DirEntry, err error) error {
151151
switch ext {
152152
case ".go", ".xgo", ".gop":
153153
ok = true
154-
case ".gox", ".spx", ".gmx":
154+
case ".gox":
155155
ok, class = true, true
156156
default:
157157
class = mod.IsClass(ext)
@@ -164,7 +164,7 @@ func (w *walker) walk(path string, d fs.DirEntry, err error) error {
164164
switch ext {
165165
case ".go", ".xgo", ".gop":
166166
ok = true
167-
case ".gox", ".spx", ".gmx":
167+
case ".gox":
168168
ok, class = true, true
169169
}
170170
return

go.sum

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ github.com/fsnotify/fsnotify v1.9.0 h1:2Ml+OJNzbYCTzsxtv8vKSFD9PbJjmhYF14k/jKC7S
22
github.com/fsnotify/fsnotify v1.9.0/go.mod h1:8jBTzvmWwFyi3Pb8djgCCO5IBqzKJ/Jwo8TRcHyHii0=
33
github.com/goccy/go-yaml v1.19.2 h1:PmFC1S6h8ljIz6gMRBopkjP1TVT7xuwrButHID66PoM=
44
github.com/goccy/go-yaml v1.19.2/go.mod h1:XBurs7gK8ATbW4ZPGKgcbrY1Br56PdM69F7LkFRi1kA=
5-
github.com/goplus/cobra v1.9.13 h1:onu/65rXILVMc7RBvdY1mGdOIZ/F4C/6o7DWgglwFaw=
5+
github.com/goplus/cobra v1.9.13 h1:doLBppK2LJ4Giy3qv3WdJrZKXMLVpYOJ/hmYBcCzpQ4=
66
github.com/goplus/cobra v1.9.13/go.mod h1:p4LhfNJDKEpiGjGiNn0crUXL5dUPA5DX2ztYpEJR34E=
77
github.com/goplus/gogen v1.21.2 h1:xbXPgZOZiQx/WBM0nZxVSxFbtdCMZCRB+lguDnh8pfs=
88
github.com/goplus/gogen v1.21.2/go.mod h1:Y7ulYW3wonQ3d9er00b0uGFEV/IUZa6okWJZh892ACQ=

parser/_testdata/gmxtest/foo.gmx

Lines changed: 0 additions & 1 deletion
This file was deleted.

parser/_testdata/gmxtest/parser.expect

Lines changed: 0 additions & 24 deletions
This file was deleted.

parser/_testdata/spxtest/foo.spx

Lines changed: 0 additions & 1 deletion
This file was deleted.

parser/_testdata/spxtest/parser.expect

Lines changed: 0 additions & 24 deletions
This file was deleted.

parser/parser_xgo.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -244,9 +244,7 @@ func reqPkg(pkgs map[string]*ast.Package, name string) *ast.Package {
244244
func defaultClassKind(fname string) (isProj bool, ok bool) {
245245
ext := path.Ext(fname)
246246
switch ext {
247-
case ".spx":
248-
return fname == "main.spx", true
249-
case ".gsh", ".gmx":
247+
case ".gsh":
250248
return true, true
251249
}
252250
return

0 commit comments

Comments
 (0)