See the VSCode extension README for more information on how to install and setup the FIDL LSP extension in VSCode.
To launch a local test instance of VSCode running the extension:
fx genand then
fx build build/fidl:validate_fidl_project_jsonto make sure fidl_project.json exists.
fx build host_x64/fidl-lint.
fidl-misc/vscode-language-fidl/directory in VSCode, and run the
To run tests:
go test -p 1 ./...
-p flag specifies that we don't want tests run in parallel, as some of them write to and read from the filesystem and can collide. If you want to force your tests to be re-run (as test results are cached and not re-run until code in that package has changed), you can run with the flag
The general flow of control in the language server goes like this:
FileSystemto make the change
LangHandlertriggers a re-analysis by the
LangHandlerdispatches the request to the
Analyzerextracts the needed information and returns it
LangHandlersends the response to the client
This package includes the core logic of the language server. It deals with LSP specific boilerplate, JSON-RPC messages, etc. It includes the
LangHandler type, which handles LSP requests, sends reponses and notifications to the client, and dispatches changes to the state manager or requests for analyses to the
The language server's state management is in the
state package. Currently this is just an in memory file system (mapping of editor file names to file text). This could be wrapped in e.g. an
RWLock to enable concurrent handling of LSP requests and notifications.
The “backend” of the server, which doesn't know about LSP but knows how to compile FIDL and analyze the JSON IR.
Analyzer type, which maintains a set of compiled FIDL
Librarys and their constituent files, dependencies, and build artifacts. Main entry point is
Analyzer.Analyze(), which is called every time a file is changed on the client.
Analyze recompiles the relevant FIDL library for that file and imports the JSON IR.
Analyzer compiles FIDL libraries by invoking
fidlc in a separate process, gets diagnostics from
fidl-lint, and uses
fidl-format for formatting. It locates dependencies using a
fidl_project.json file, the path to which will be configurable in the LSP client extension.
fidl_project.json declares all FIDL libraries the language server should be aware of, the paths to their constituent files, the path to their JSON IR, and their dependencies (by library name).
This list documents LSP features supported by fidl-lsp.