Skip to content

Language Server (autocomplete) not using menu settings #1029

Closed
@PaulStoffregen

Description

@PaulStoffregen

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

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions