Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Language server results not updated after changes to installed libraries #670

Closed
per1234 opened this issue Dec 7, 2021 · 3 comments · Fixed by #1808
Closed

Language server results not updated after changes to installed libraries #670

per1234 opened this issue Dec 7, 2021 · 3 comments · Fixed by #1808
Assignees
Labels
conclusion: resolved Issue was resolved topic: code Related to content of the project itself topic: language server Related to the Arduino Language Server type: imperfection Perceived defect in any part of project

Comments

@per1234
Copy link
Contributor

per1234 commented Dec 7, 2021

Describe the bug

The information provided by the Arduino language server is affected by the dependencies used by the sketch.

🐛 The lack of an update of the language server results after a change is made to the installed libraries or platforms (i.e., install, update, or uninstall) may cause them to be incorrect.

To Reproduce

  1. Open the following sketch in the Arduino IDE:
    #include <Arduino_APA102.h>
    Arduino_APA102 leds(1, 2, 3);
    void setup() {}
    void loop() {}
    If the library is not installed, problems will be indicated as expected.
  2. Install the "Arduino_APA102" library via Library Manager.

🐛 The problems are still indicated even though the sketch is now valid:

image

If you trigger an update by reopening the sketch, changing the code, etc., the language server results update and reflect the current state of the sketch's dependencies.

Expected behavior

Language server results are updated after making any change to installed libraries via the IDE interface:

  • Boards Manager
  • Library Manager
  • Sketch > Include Library > Add .ZIP Library...
  • File > Preferences > Sketchbook location

Desktop

  • OS: Windows 10
  • IDE Version: 2.0.0-rc1-snapshot.be55a0a
    Date: 2021-12-03T11:09:57.266Z
    CLI Version: 0.20.1 [abb21449]
  • Arduino Language Server version: 0.5.0-rc6
@per1234 per1234 added topic: code Related to content of the project itself type: imperfection Perceived defect in any part of project topic: language server Related to the Arduino Language Server labels Dec 7, 2021
@cmaglie
Copy link
Member

cmaglie commented Dec 9, 2021

With version 0.5.0-rc6 of the LS, the error disappears as soon as the user touch (makes a change) in the source code. This means that the LS needs a signal from the IDE that something changed in the global installation, so to fix this issue we need changes in the IDE.

I see only two possible solutions to this problem:

a) the IDE must restart the language server after each install/uninstall operation (this may be forced by running the command "Arduino: restart language server" from the command palette)

b) the IDE must send a "rebuild" command in some way to the language server

I personally prefer the solution "b" because restarting the language server is an expensive operation. The problem is that there is nothing like a "rebuild" command in the LSP (language server protocol). A workaround could be to produce a bougs "textDocument/didSave" event (that do not actually save anything) that in turns triggers a rebuild on the LS.

@kittaakos
Copy link
Contributor

I personally prefer the solution "b" because restarting the language server is an expensive operation.

👍 This seems to be the proper way.

The problem is that there is nothing like a "rebuild" command in the LSP (language server protocol)

FYI, it's possible to extend it, if you decide to do so in the future. Here is the Java example from VS Code to the JDT-LS:

"textDocument/didSave"

Or with textDocument/didChange with an empty contentChanges but with an increased version number.

@fstasi fstasi added this to the arduino-ide rc6 milestone Mar 24, 2022
@kittaakos kittaakos self-assigned this Jun 15, 2022
@fstasi fstasi removed this from the arduino-ide rc6 milestone Jun 21, 2022
@ubidefeo
Copy link

ubidefeo commented Sep 2, 2022

@kittaakos @cmaglie
what's the status of this issue?

kittaakos pushed a commit that referenced this issue Jan 9, 2023
Closes #670

Signed-off-by: Akos Kitta <a.kitta@arduino.cc>
kittaakos pushed a commit that referenced this issue Jan 16, 2023
Closes #670

Signed-off-by: Akos Kitta <a.kitta@arduino.cc>
@per1234 per1234 added the conclusion: resolved Issue was resolved label Jan 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
conclusion: resolved Issue was resolved topic: code Related to content of the project itself topic: language server Related to the Arduino Language Server type: imperfection Perceived defect in any part of project
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants