-
Ensure that a
replace
statement exists inlanguageserver/go.mod
, so that the language server compiles with the local changes to Cadence. -
Find the Visual Studio Code preference named "Cadence: Flow Command" and change it to:
1/path/to/cadence/languageserver/run.sh -
Restart Visual Studio Code
This will automatically recompile the language server every time it is started.
-
Follow the instructions above (see "Running the latest version of the Language Server in the Visual Studio Code Extension")
-
Attach to the process of the language server started by Visual Studio Code.
For example, in Goland, choose Run -> Attach to Process.
This requires gops to be installed, which can be done using
go get github.com/google/gops
.
The runtime/cmd
directory
contains command-line tools that are useful when working on the implementation for Cadence, or with Cadence code:
-
The
parse
tool can be used to parse (syntactically analyze) Cadence code. By default, it reports syntactical errors in the given Cadence program, if any, in a human-readable format. By providing the-json
it returns the AST of the program in JSON format if the given program is syntactically valid, or syntactical errors in JSON format (including position information).1$ echo "X" | go run ./runtime/cmd/parse2error: unexpected token: identifier3--> :1:04|51 | X6| ^1$ echo "let x = 1" | go run ./runtime/cmd/parse -json2[3{4"program": {5"Type": "Program",6"Declarations": [7{8"Type": "VariableDeclaration",9"StartPos": {10"Offset": 0,11"Line": 1,12"Column": 013},14"EndPos": {15"Offset": 8,16"Line": 1,17"Column": 818},19[...] -
The
check
tool can be used to check (semantically analyze) Cadence code. By default, it reports semantic errors in the given Cadence program, if any, in a human-readable format. By providing the-json
it returns the AST in JSON format, or semantic errors in JSON format (including position information).1$ echo "let x = 1" | go run ./runtime/cmd/check 1 ↵2error: error: missing access modifier for constant3--> :1:04|51 | let x = 16| ^ -
The
main
tools can be used to execute Cadence programs. If a no argument is provided, the REPL (Read-Eval-Print-Loop) is started. If an argument is provided, the Cadence program at the given path is executed. The program must have a function namedmain
which has no parameters and no return type.1$ go run ./runtime/cmd/main 130 ↵2Welcome to Cadence v0.12.3!3Type '.help' for assistance.451> let x = 262> x + 3751$ echo 'pub fun main () { log("Hello, world!") }' > hello.cdc2$ go run ./runtime/cmd/main hello.cdc3"Hello, world!"
Run the checker tests with the cadence.checkConcurrently
flag, e.g.
1go test -race -v ./runtime/tests/checker -cadence.checkConcurrently=10
This runs each check of a checker test 10 times, concurrently, and asserts that the checker errors of all checks are equal.