Skip to content
This repository has been archived by the owner on Jan 31, 2025. It is now read-only.

fix: transpile step #12

Merged
merged 2 commits into from
Dec 18, 2024
Merged

Conversation

tbruyelle
Copy link
Contributor

@tbruyelle tbruyelle commented Dec 17, 2024

The gno transpile -gobuild command did not work because there was no go.mod file in the directory. Adding the GO111MODULE=off env discards this error and makes the command work properly.

Other changes:

  • Removed the GnoFile argument from Transpile because the command should be run on the workspace folder instead of just the directory of where the GnoFile is located. Adding a new field workspaceFolder in the server struct for that purpose, this field is set at the initialize LSP step.
  • Merge the Transpile() and TranspileAndBuild() functions, because the errors format between transpile and gobuild is the same since fix: unify the precompile output to make it easier to parse and read.  gno#1670.
  • Update ParseErrors so it stops trying the guess the column end of the error (remove call to findErrors). I consider this step unecessary because it is not reliable. This also makes the function faster because it stops iterating over the file's tokens.
  • Improve error handling so the absence of gno binary is reported.
  • Update getTranspileDiagnostics() so it filters the errors according to the file in parameter. Also removes looking at the errors in the typecheck cache, because all the errors are returned by gno transpile -gobuild. I'm not sure about the future of typecheck cache with this change, maybe it should be completely removed.

As a result of these changes, the test document_open.txtar is updated:

  • the error code is now transpile instead of typecheck (because the errors come now from the transpile command instead of the typecheck cache)
  • the column end is set to column start (because the transpile command only returns the start column and findErrors is no longer invoked)

I know these changes are a bit opinionated, I am of course open to discussion.

@tbruyelle tbruyelle requested a review from x1unix as a code owner December 17, 2024 10:47
internal/lsp/build.go Outdated Show resolved Hide resolved
- remove the unecessary tools.Build step
- add GO111MODULE=off to remove the error related to the absence of
  go.mod
- filter error correctly according to file notification
- see NOTEs for more contextualized infos
@tbruyelle tbruyelle force-pushed the tbruyelle/fix/transpile branch from 5f8770f to 344ca17 Compare December 18, 2024 16:02
@x1unix x1unix merged commit 336b382 into gnolang:master Dec 18, 2024
1 check passed
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants