diff --git a/internal/lsp/build.go b/internal/lsp/build.go index 6d07cc0..8448421 100644 --- a/internal/lsp/build.go +++ b/internal/lsp/build.go @@ -20,7 +20,7 @@ type ErrorInfo struct { Tool string } -func (s *server) PrecompileAndBuild(file *GnoFile) ([]ErrorInfo, error) { +func (s *server) TranspileAndBuild(file *GnoFile) ([]ErrorInfo, error) { pkgDir := filepath.Dir(file.URI.Filename()) pkgName := filepath.Base(pkgDir) tmpDir := filepath.Join(s.env.GNOHOME, "gnopls", "tmp", pkgName) @@ -30,10 +30,10 @@ func (s *server) PrecompileAndBuild(file *GnoFile) ([]ErrorInfo, error) { return nil, err } - preOut, _ := tools.Precompile(tmpDir) + preOut, _ := tools.Transpile(tmpDir) slog.Info(string(preOut)) if len(preOut) > 0 { - return parseErrors(file, string(preOut), "precompile") + return parseErrors(file, string(preOut), "transpile") } buildOut, _ := tools.Build(tmpDir) @@ -91,9 +91,11 @@ func parseErrors(file *GnoFile, output, cmd string) ([]ErrorInfo, error) { // numbers to account for the header information in the generated Go file. func findError(file *GnoFile, fname string, line, col int, msg string, tool string) ErrorInfo { msg = strings.TrimSpace(msg) - if tool == "precompile" { - // fname parsed from precompile result can be incorrect - // e.g filename = `filename.gno: precompile: parse: tmp.gno` + // TODO: can be removed? + // see: https://github.com/gnolang/gno/pull/1670 + if tool == "transpile" { + // fname parsed from transpile result can be incorrect + // e.g filename = `filename.gno: transpile: parse: tmp.gno` parts := strings.Split(fname, ":") fname = parts[0] } diff --git a/internal/lsp/diagnostics.go b/internal/lsp/diagnostics.go index c8cfa15..737cd07 100644 --- a/internal/lsp/diagnostics.go +++ b/internal/lsp/diagnostics.go @@ -13,7 +13,7 @@ import ( func (s *server) publishDiagnostics(ctx context.Context, conn jsonrpc2.Conn, file *GnoFile) error { slog.Info("Lint", "path", file.URI.Filename()) - errors, err := s.PrecompileAndBuild(file) + errors, err := s.TranspileAndBuild(file) if err != nil { return err } diff --git a/internal/tools/build.go b/internal/tools/build.go index 97b03f0..d48ff6f 100644 --- a/internal/tools/build.go +++ b/internal/tools/build.go @@ -5,8 +5,8 @@ import ( "path/filepath" ) -// Build a Gno package: gno precompile -gobuild . -// TODO: Remove this in the favour of directly using tools/precompile.go +// Build a Gno package: gno transpile -gobuild . +// TODO: Remove this in the favour of directly using tools/transpile.go func Build(rootDir string) ([]byte, error) { - return exec.Command("gno", "precompile", "-skip-imports", "-gobuild", filepath.Join(rootDir)).CombinedOutput() + return exec.Command("gno", "transpile", "-skip-imports", "-gobuild", filepath.Join(rootDir)).CombinedOutput() } diff --git a/internal/tools/precompile.go b/internal/tools/precompile.go deleted file mode 100644 index 28c8052..0000000 --- a/internal/tools/precompile.go +++ /dev/null @@ -1,11 +0,0 @@ -package tools - -import ( - "os/exec" - "path/filepath" -) - -// Precompile a Gno package: gno precompile . -func Precompile(rootDir string) ([]byte, error) { - return exec.Command("gno", "precompile", "-skip-imports", filepath.Join(rootDir)).CombinedOutput() -} diff --git a/internal/tools/transpile.go b/internal/tools/transpile.go new file mode 100644 index 0000000..4ff66de --- /dev/null +++ b/internal/tools/transpile.go @@ -0,0 +1,11 @@ +package tools + +import ( + "os/exec" + "path/filepath" +) + +// Transpile a Gno package: gno transpile . +func Transpile(rootDir string) ([]byte, error) { + return exec.Command("gno", "transpile", "-skip-imports", filepath.Join(rootDir)).CombinedOutput() +}