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 (autocomplete) not using menu settings #1029

Closed
3 tasks done
PaulStoffregen opened this issue Jun 9, 2022 · 1 comment · Fixed by #1812
Closed
3 tasks done

Language Server (autocomplete) not using menu settings #1029

PaulStoffregen opened this issue Jun 9, 2022 · 1 comment · Fixed by #1812
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

@PaulStoffregen
Copy link

PaulStoffregen commented Jun 9, 2022

Describe the problem

The autocomplete and variable info popups find info corresponding to the Tools menu configuration options at their defaults, even when the user has changed them to a different configuration. The tools menu config can cause the build process to use a different set of defines, changing which code is actually compiled. The IDE should cause the language server to always operate with settings from the currently selected menu config, but today it appears to be always using the menu defaults regardless of what has actually been selected in those menus.

To reproduce

Using Arduino IDE 2.0.0-rc7.

1: add https://www.pjrc.com/teensy/td_156/package_teensy_index.json to additional board manager URLs in File > Preferences

2: in boards manager, search for "teensy" and install Teensy package 1.56.1

3: set the current board to Tools > Board > Teensy > Teensy 4.1

4: open or type any program with Serial, such as

void setup() {
  Serial.begin();
}

void loop() {
}

5: hover your mouse over "Serial". A popup will appear telling you the type is "class usb_serial_class".
image

6: click Tools > USB Type and change the configuration to "RawHID"
image

7: again hover your mouse over "Serial". The popup will reappear, incorrectly telling you the type is still "class usb_serial_class".
image

8: right click Serial and select "Go To Definition". A new tab will open, showing the wrong definition which is not compiled cause CDC_DATA_INTERFACE and CDC_STATUS_INTERFACE are not defined when USB Type RawHID is selected.
image

Expected behavior

When USB Type is set to RawHID, the Serial object is defined as "usb_seremu_class Serial" at line 75 in usb_inst.cpp.

image

Changing the menu configuration alters the compiler build flags, causing completely different code to be compiled. The IDE should always configure the Language Server with the defines or other build flags from the menu configuration.

Arduino IDE version

2.0.0-rc7

Operating system

Linux

Operating system version

Ubuntu 20.04

Additional context

No response

Issue checklist

  • I searched for previous reports in the issue tracker
  • I verified the problem still occurs when using the latest nightly build
  • My report contains all necessary details
@PaulStoffregen PaulStoffregen added the type: imperfection Perceived defect in any part of project label Jun 9, 2022
@per1234 per1234 added the topic: language server Related to the Arduino Language Server label Jun 9, 2022
@kittaakos kittaakos self-assigned this Jun 9, 2022
@kittaakos kittaakos added the topic: code Related to content of the project itself label Jun 9, 2022
@per1234
Copy link
Contributor

per1234 commented Jul 10, 2022

I can see the problem here in the language server logs:

2022/07/10 16:26:52 Language server launched with arguments:
2022/07/10 16:26:52   arg[0] = c:\ide 2\tip\68-7d96153\resources\app\node_modules\arduino-ide-extension\build\arduino-language-server.exe
2022/07/10 16:26:52   arg[1] = -clangd
2022/07/10 16:26:52   arg[2] = c:\ide 2\tip\68-7d96153\resources\app\node_modules\arduino-ide-extension\build\clangd.exe
2022/07/10 16:26:52   arg[3] = -cli-daemon-addr
2022/07/10 16:26:52   arg[4] = localhost:1048
2022/07/10 16:26:52   arg[5] = -cli-daemon-instance
2022/07/10 16:26:52   arg[6] = 1
2022/07/10 16:26:52   arg[7] = -fqbn
2022/07/10 16:26:52   arg[8] = teensy:avr:teensy41
2022/07/10 16:26:52   arg[9] = -board-name
2022/07/10 16:26:52   arg[10] = "Teensy 4.1"
2022/07/10 16:26:52   arg[11] = -log
2022/07/10 16:26:52   arg[12] = -logpath
2022/07/10 16:26:52   arg[13] = c:\Users\per\Documents\Arduino\lstest

The IDE is not passing the full FQBN via the -fqbn flag when starting the language server. This causes the default values to be used for the custom board options rather than the values the user has selected from the custom board option menus. The IDE must pass the full FQBN (in this case teensy:avr:teensy41:usb=rawhid,speed=600,opt=o2std,keys=en-us) to the language server.

kittaakos pushed a commit that referenced this issue Jan 10, 2023
restart the LS when board settings of the running LS has changed

Closes #1029

Signed-off-by: Akos Kitta <[email protected]>
kittaakos pushed a commit that referenced this issue Jan 11, 2023
restart the LS when board settings of the running LS has changed

Closes #1029

Signed-off-by: Akos Kitta <[email protected]>
kittaakos pushed a commit that referenced this issue Jan 16, 2023
restart the LS when board settings of the running LS has changed

Closes #1029

Signed-off-by: Akos Kitta <[email protected]>
kittaakos pushed a commit that referenced this issue Jan 16, 2023
restart the LS when board settings of the running LS has changed

Closes #1029

Signed-off-by: Akos Kitta <[email protected]>
@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.

3 participants