Closed cmaglie closed 2 years ago
We should look into Language Server Index Format Specification (LSIF):
The purpose of the Language Server Index Format (LSIF) is it to define a standard format for language servers or other programming tools to dump their knowledge about a workspace. This dump can later be used to answer language server LSP requests for the same workspace without running the language server itself.
It looks promising.
In inols.log
:
{"jsonrpc":"2.0","method":"arduino/buildCompleted","params":{"build_path":"/private/var/folders/z1/xkw1yh5n7rz4n8djprp1mdn80000gn/T/arduino-sketch-2A25CBEDDFEB3508AE8DDDA45D126AAA"}}Content-Length: 58
In inols-err.log
: (I do not know if it's promising but it's there)
15:15:04.433519 [92mIDE --> LS NOTIF arduino/buildCompleted[0m
15:15:04.433562 [92m arduino/buildCompleted: [93mwrite-locked[0m[0m
15:15:04.475205 [92m arduino/buildCompleted: [93mwrite-unlocked[0m[0m
I've included most of your changes here. We should probably document better the ino/didCompleteBuild
custom command.
Please check if the PR fulfills these requirements
What kind of change does this PR introduce? With this patch, we should gain some speed improvements in sketch rebuilds by caching libraries detection results from previous builds.
What is the current behavior? When the sketch is rebuilt the libraries detection phase could take a very long time, especially if the sketch uses a lot of libraries or even a single library that contains a lot of files.
What is the new behavior? The sketch is now rebuilt skipping the libraries detection and using the libraries detected on the latest "full" build. A single "full" build is done when the language server is started, all subsequent builds will be without libraries detection. This means that
#include <...>
added after the language server startup may not be indexed/recognized until the next full build.To trigger a new "full" build there are now two ways:
arduino/buildCompleted
LSP notification from the IDEThe
arduino/buildCompleted
notification is an Arduino custom notification (it's not part of the LSP specification), it should be sent by the IDE to the language server after a full compile is triggered by the user of the IDE. Inside the notification, there is abuildPath
field that should point to the path of the build directory so the language server can pick the result of libraries detection from there.Other information This PR uses a patched
arduino-cli
that support theSkipLibrariesDiscovery
flag: https://github.com/arduino/arduino-cli/pull/1777