languageserver

package module
v0.24.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 8, 2022 License: Apache-2.0 Imports: 5 Imported by: 0

README

Cadence Language Server

The Cadence Language Server implements the Language Server Protocol (LSP). It provides editors and IDEs that support LSP language features like auto complete, go to definition, documentation and type information on hover, etc.

Traditionally providing such features had to repeatedly implemented for each tool, as each tool provides different APIs for implementing the same feature. By implementing the LSP, the Cadence Language Server can be re-used in multiple development tools. For example, it is used by the Visual Studio Code extension (through the Flow CLI, which embeds the language server), and also in the Flow Playground (by compiling the language server to WebAssembly).

Development

Main functionality

The main functionality of the language server, such as providing reporting diagnostics (e.g. errors), auto completion, etc. is implemented in the server package.

Integration with the Flow network

The Cadence language server optionally provides integration with the Flow network, such as signing and submitting transactions.

This code can be found in the integration package.

Language Server Protocol Types

The Go code for the LSP types can be found in the protocol package. The code is generated from the specification's TypeScript declarations using scripts.

Building for WebAssembly

The Cadence language server can be compiled to WebAssembly. It currently assumes to be used in a JavaScript environment.

make wasm
Tests

The integration tests for the Cadence Language Server are written in TypeScript and can be found in the test directory.

Debugging
GoLang and VSCode

You can setup debugging of Language Server in VSCode by first going in VSCode Cadence > Extension Settings and under Cadence: Flow Command putting absolute location of run.sh script found in this directory (example: /Users/dapper/Dev/cadence/languageserver/run.sh).

After you set the run script you should follow "Attach to a process on a local machine" tutorial to debug the language server in GoLand.

M1 Problems Currently running gops on OSX ARM architecture won't work. A workaround for debugging is to use functionality in tests/util.go. You can use utility functions to log to a file like so:

test.Log("test log")

And at the same time run the command in your terminal:

tail -f ./debug.log

Doing so you should see the output of all Log calls you make.

Note: this method works on all architectures

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RunWithStdio

func RunWithStdio(enableFlowClient bool)

Types

This section is empty.

Directories

Path Synopsis
cmd
languageserver command
Package protocol contains data types and code for LSP jsonrpcs generated automatically from vscode-languageserver-node commit: db16b7f53b318e8ff44aa95ac8faa5e2486b63aa last fetched Thu Aug 01 2019 14:02:39 GMT-0700 (Pacific Daylight Time)
Package protocol contains data types and code for LSP jsonrpcs generated automatically from vscode-languageserver-node commit: db16b7f53b318e8ff44aa95ac8faa5e2486b63aa last fetched Thu Aug 01 2019 14:02:39 GMT-0700 (Pacific Daylight Time)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL