arduino-ide icon indicating copy to clipboard operation
arduino-ide copied to clipboard

#118, #1154 Link compiler errors to editor.

Open kittaakos opened this issue 3 years ago • 4 comments

Motivation

Can reveal the error location in the editor from the Output view.

Change description

In-action:

https://user-images.githubusercontent.com/1405703/182376367-d2f5c299-9370-49bb-a67d-342d887115ec.mp4

Noteworthy changes:

  • The error decoration is automatically removed from the editor when a TextDocumentChangeEvent affects the line where the decorator is.

https://user-images.githubusercontent.com/1405703/182377221-75662cf7-54bc-44b7-a485-4595cc61d05b.mp4

Other information

Closes #118 Closes #1154

Reviewer checklist

  • [ ] PR addresses a single concern.
  • [ ] The PR has no duplicates (please search among the Pull Requests before creating one)
  • [ ] PR title and description are properly filled.
  • [ ] Docs have been added / updated (for bug fixes / features)

kittaakos avatar Aug 02 '22 10:08 kittaakos

Scrolling the output view up at the end of the compilation can cause the link to be placed on the wrong line.

For the record, it's unrelated to scrolling. The output content is not the same as the content parsed for errors.

Parsed content:

Using board 'uno' from platform in folder: /Users/a.kitta/Library/Arduino15/packages/arduino/hardware/avr/1.8.5
Using core 'arduino' from platform in folder: /Users/a.kitta/Library/Arduino15/packages/arduino/hardware/avr/1.8.5
Detecting libraries used...
/Users/a.kitta/Library/Arduino15/packages/arduino/tools/avr-gcc/7.3.0-atmel3.6.1-arduino7/bin/avr-g++ -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10607 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR -I/Users/a.kitta/Library/Arduino15/packages/arduino/hardware/avr/1.8.5/cores/arduino -I/Users/a.kitta/Library/Arduino15/packages/arduino/hardware/avr/1.8.5/variants/standard /private/var/folders/z1/xkw1yh5n7rz4n8djprp1mdn80000gn/T/arduino-sketch-9AC154E96781B8A1BB81760239BC5D99/sketch/min.ino.cpp -o /dev/null
Generating function prototypes...
/Users/a.kitta/Library/Arduino15/packages/arduino/tools/avr-gcc/7.3.0-atmel3.6.1-arduino7/bin/avr-g++ -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10607 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR -I/Users/a.kitta/Library/Arduino15/packages/arduino/hardware/avr/1.8.5/cores/arduino -I/Users/a.kitta/Library/Arduino15/packages/arduino/hardware/avr/1.8.5/variants/standard /private/var/folders/z1/xkw1yh5n7rz4n8djprp1mdn80000gn/T/arduino-sketch-9AC154E96781B8A1BB81760239BC5D99/sketch/min.ino.cpp -o /private/var/folders/z1/xkw1yh5n7rz4n8djprp1mdn80000gn/T/arduino-sketch-9AC154E96781B8A1BB81760239BC5D99/preproc/ctags_target_for_gcc_minus_e.cpp
/Users/a.kitta/Library/Arduino15/packages/builtin/tools/ctags/5.8-arduino11/ctags -u --language-force=c++ -f - --c++-kinds=svpf --fields=KSTtzns --line-directives /private/var/folders/z1/xkw1yh5n7rz4n8djprp1mdn80000gn/T/arduino-sketch-9AC154E96781B8A1BB81760239BC5D99/preproc/ctags_target_for_gcc_minus_e.cpp
Compiling sketch...
/Users/a.kitta/Library/Arduino15/packages/arduino/tools/avr-gcc/7.3.0-atmel3.6.1-arduino7/bin/avr-g++ -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -MMD -flto -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10607 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR -I/Users/a.kitta/Library/Arduino15/packages/arduino/hardware/avr/1.8.5/cores/arduino -I/Users/a.kitta/Library/Arduino15/packages/arduino/hardware/avr/1.8.5/variants/standard /private/var/folders/z1/xkw1yh5n7rz4n8djprp1mdn80000gn/T/arduino-sketch-9AC154E96781B8A1BB81760239BC5D99/sketch/min.ino.cpp -o /private/var/folders/z1/xkw1yh5n7rz4n8djprp1mdn80000gn/T/arduino-sketch-9AC154E96781B8A1BB81760239BC5D99/sketch/min.ino.cpp.o
/Users/a.kitta/Documents/Arduino/min/min.ino: In function 'void setup()':
/Users/a.kitta/Documents/Arduino/min/min.ino:2:3: error: 'someerror' was not declared in this scope
   someerror
   ^~~~~~~~~
/Users/a.kitta/Documents/Arduino/min/min.ino:2:3: note: suggested alternative: 'strerror'
   someerror
   ^~~~~~~~~
   strerror


Content printed to Output:

Using board 'uno' from platform in folder: /Users/a.kitta/Library/Arduino15/packages/arduino/hardware/avr/1.8.5
Using core 'arduino' from platform in folder: /Users/a.kitta/Library/Arduino15/packages/arduino/hardware/avr/1.8.5
Detecting libraries used...
/Users/a.kitta/Library/Arduino15/packages/arduino/tools/avr-gcc/7.3.0-atmel3.6.1-arduino7/bin/avr-g++ -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10607 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR -I/Users/a.kitta/Library/Arduino15/packages/arduino/hardware/avr/1.8.5/cores/arduino -I/Users/a.kitta/Library/Arduino15/packages/arduino/hardware/avr/1.8.5/variants/standard /private/var/folders/z1/xkw1yh5n7rz4n8djprp1mdn80000gn/T/arduino-sketch-9AC154E96781B8A1BB81760239BC5D99/sketch/min.ino.cpp -o /dev/null
Generating function prototypes...
/Users/a.kitta/Library/Arduino15/packages/arduino/tools/avr-gcc/7.3.0-atmel3.6.1-arduino7/bin/avr-g++ -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10607 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR -I/Users/a.kitta/Library/Arduino15/packages/arduino/hardware/avr/1.8.5/cores/arduino -I/Users/a.kitta/Library/Arduino15/packages/arduino/hardware/avr/1.8.5/variants/standard /private/var/folders/z1/xkw1yh5n7rz4n8djprp1mdn80000gn/T/arduino-sketch-9AC154E96781B8A1BB81760239BC5D99/sketch/min.ino.cpp -o /private/var/folders/z1/xkw1yh5n7rz4n8djprp1mdn80000gn/T/arduino-sketch-9AC154E96781B8A1BB81760239BC5D99/preproc/ctags_target_for_gcc_minus_e.cpp
/Users/a.kitta/Library/Arduino15/packages/builtin/tools/ctags/5.8-arduino11/ctags -u --language-force=c++ -f - --c++-kinds=svpf --fields=KSTtzns --line-directives /private/var/folders/z1/xkw1yh5n7rz4n8djprp1mdn80000gn/T/arduino-sketch-9AC154E96781B8A1BB81760239BC5D99/preproc/ctags_target_for_gcc_minus_e.cpp
/Users/a.kitta/Documents/Arduino/min/min.ino: In function 'void setup()':
/Users/a.kitta/Documents/Arduino/min/min.ino:2:3: error: 'someerror' was not declared in this scope
   someerror
   ^~~~~~~~~
Compiling sketch...
/Users/a.kitta/Library/Arduino15/packages/arduino/tools/avr-gcc/7.3.0-atmel3.6.1-arduino7/bin/avr-g++ -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -MMD -flto -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10607 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR -I/Users/a.kitta/Library/Arduino15/packages/arduino/hardware/avr/1.8.5/cores/arduino -I/Users/a.kitta/Library/Arduino15/packages/arduino/hardware/avr/1.8.5/variants/standard /private/var/folders/z1/xkw1yh5n7rz4n8djprp1mdn80000gn/T/arduino-sketch-9AC154E96781B8A1BB81760239BC5D99/sketch/min.ino.cpp -o /private/var/folders/z1/xkw1yh5n7rz4n8djprp1mdn80000gn/T/arduino-sketch-9AC154E96781B8A1BB81760239BC5D99/sketch/min.ino.cpp.o
/Users/a.kitta/Documents/Arduino/min/min.ino:2:3: note: suggested alternative: 'strerror'
   someerror
   ^~~~~~~~~
   strerror

exit status 1

Compilation error: 'someerror' was not declared in this scope

The important part is the location of the Compiling sketch....

Note, the Output contains more information than the parsed output. It's normal and expected:

exit status 1

Compilation error: 'someerror' was not declared in this scope

Here is the list of sent (by Theia backend) and received (by Theia frontend, Output view) messages:

root INFO compile-response, SEND 2022-08-10T14:40:48.177Z 2 Using board 'uno' from platform in folder: /Users/a.kitta/Library/Arduino15/packages/arduino/hardware/avr/1.8.5
Using core 'arduino' from platform in folder: /Users/a.kitta/Library/Arduino15/packages/arduino/hardware/avr/1.8.5
root INFO compile-response, RECEIVED 2022-08-10T14:40:48.178Z 2 Using board 'uno' from platform in folder: /Users/a.kitta/Library/Arduino15/packages/arduino/hardware/avr/1.8.5
Using core 'arduino' from platform in folder: /Users/a.kitta/Library/Arduino15/packages/arduino/hardware/avr/1.8.5
root INFO compile-response, SEND 2022-08-10T14:40:48.343Z 2 Detecting libraries used...
root INFO compile-response, RECEIVED 2022-08-10T14:40:48.346Z 2 Detecting libraries used...
root INFO compile-response, SEND 2022-08-10T14:40:48.410Z 2 /Users/a.kitta/Library/Arduino15/packages/arduino/tools/avr-gcc/7.3.0-atmel3.6.1-arduino7/bin/avr-g++ -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10607 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR -I/Users/a.kitta/Library/Arduino15/packages/arduino/hardware/avr/1.8.5/cores/arduino -I/Users/a.kitta/Library/Arduino15/packages/arduino/hardware/avr/1.8.5/variants/standard /private/var/folders/z1/xkw1yh5n7rz4n8djprp1mdn80000gn/T/arduino-sketch-9AC154E96781B8A1BB81760239BC5D99/sketch/min.ino.cpp -o /dev/null
Generating function prototypes...
/Users/a.kitta/Library/Arduino15/packages/arduino/tools/avr-gcc/7.3.0-atmel3.6.1-arduino7/bin/avr-g++ -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10607 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR -I/Users/a.kitta/Library/Arduino15/packages/arduino/hardware/avr/1.8.5/cores/arduino -I/Users/a.kitta/Library/Arduino15/packages/arduino/hardware/avr/1.8.5/variants/standard /private/var/folders/z1/xkw1yh5n7rz4n8djprp1mdn80000gn/T/arduino-sketch-9AC154E96781B8A1BB81760239BC5D99/sketch/min.ino.cpp -o /private/var/folders/z1/xkw1yh5n7rz4n8djprp1mdn80000gn/T/arduino-sketch-9AC154E96781B8A1BB81760239BC5D99/preproc/ctags_target_for_gcc_minus_e.cpp
root INFO compile-response, RECEIVED 2022-08-10T14:40:48.410Z 2 /Users/a.kitta/Library/Arduino15/packages/arduino/tools/avr-gcc/7.3.0-atmel3.6.1-arduino7/bin/avr-g++ -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10607 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR -I/Users/a.kitta/Library/Arduino15/packages/arduino/hardware/avr/1.8.5/cores/arduino -I/Users/a.kitta/Library/Arduino15/packages/arduino/hardware/avr/1.8.5/variants/standard /private/var/folders/z1/xkw1yh5n7rz4n8djprp1mdn80000gn/T/arduino-sketch-9AC154E96781B8A1BB81760239BC5D99/sketch/min.ino.cpp -o /dev/null
Generating function prototypes...
/Users/a.kitta/Library/Arduino15/packages/arduino/tools/avr-gcc/7.3.0-atmel3.6.1-arduino7/bin/avr-g++ -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10607 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR -I/Users/a.kitta/Library/Arduino15/packages/arduino/hardware/avr/1.8.5/cores/arduino -I/Users/a.kitta/Library/Arduino15/packages/arduino/hardware/avr/1.8.5/variants/standard /private/var/folders/z1/xkw1yh5n7rz4n8djprp1mdn80000gn/T/arduino-sketch-9AC154E96781B8A1BB81760239BC5D99/sketch/min.ino.cpp -o /private/var/folders/z1/xkw1yh5n7rz4n8djprp1mdn80000gn/T/arduino-sketch-9AC154E96781B8A1BB81760239BC5D99/preproc/ctags_target_for_gcc_minus_e.cpp
root INFO compile-response, SEND 2022-08-10T14:40:48.442Z 2 /Users/a.kitta/Library/Arduino15/packages/builtin/tools/ctags/5.8-arduino11/ctags -u --language-force=c++ -f - --c++-kinds=svpf --fields=KSTtzns --line-directives /private/var/folders/z1/xkw1yh5n7rz4n8djprp1mdn80000gn/T/arduino-sketch-9AC154E96781B8A1BB81760239BC5D99/preproc/ctags_target_for_gcc_minus_e.cpp
root INFO compile-response, RECEIVED 2022-08-10T14:40:48.444Z 2 /Users/a.kitta/Library/Arduino15/packages/builtin/tools/ctags/5.8-arduino11/ctags -u --language-force=c++ -f - --c++-kinds=svpf --fields=KSTtzns --line-directives /private/var/folders/z1/xkw1yh5n7rz4n8djprp1mdn80000gn/T/arduino-sketch-9AC154E96781B8A1BB81760239BC5D99/preproc/ctags_target_for_gcc_minus_e.cpp
root INFO compile-response, SEND 2022-08-10T14:40:48.510Z 0 /Users/a.kitta/Documents/Arduino/min/min.ino: In function 'void setup()':
/Users/a.kitta/Documents/Arduino/min/min.ino:2:3: error: 'someerror' was not declared in this scope
   someerror
   ^~~~~~~~~
root INFO compile-response, SEND 2022-08-10T14:40:48.510Z 2 Compiling sketch...
/Users/a.kitta/Library/Arduino15/packages/arduino/tools/avr-gcc/7.3.0-atmel3.6.1-arduino7/bin/avr-g++ -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -MMD -flto -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10607 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR -I/Users/a.kitta/Library/Arduino15/packages/arduino/hardware/avr/1.8.5/cores/arduino -I/Users/a.kitta/Library/Arduino15/packages/arduino/hardware/avr/1.8.5/variants/standard /private/var/folders/z1/xkw1yh5n7rz4n8djprp1mdn80000gn/T/arduino-sketch-9AC154E96781B8A1BB81760239BC5D99/sketch/min.ino.cpp -o /private/var/folders/z1/xkw1yh5n7rz4n8djprp1mdn80000gn/T/arduino-sketch-9AC154E96781B8A1BB81760239BC5D99/sketch/min.ino.cpp.o
root INFO compile-response, RECEIVED 2022-08-10T14:40:48.511Z 0 /Users/a.kitta/Documents/Arduino/min/min.ino: In function 'void setup()':
/Users/a.kitta/Documents/Arduino/min/min.ino:2:3: error: 'someerror' was not declared in this scope
   someerror
   ^~~~~~~~~
root INFO compile-response, RECEIVED 2022-08-10T14:40:48.514Z 2 Compiling sketch...
/Users/a.kitta/Library/Arduino15/packages/arduino/tools/avr-gcc/7.3.0-atmel3.6.1-arduino7/bin/avr-g++ -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -MMD -flto -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10607 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR -I/Users/a.kitta/Library/Arduino15/packages/arduino/hardware/avr/1.8.5/cores/arduino -I/Users/a.kitta/Library/Arduino15/packages/arduino/hardware/avr/1.8.5/variants/standard /private/var/folders/z1/xkw1yh5n7rz4n8djprp1mdn80000gn/T/arduino-sketch-9AC154E96781B8A1BB81760239BC5D99/sketch/min.ino.cpp -o /private/var/folders/z1/xkw1yh5n7rz4n8djprp1mdn80000gn/T/arduino-sketch-9AC154E96781B8A1BB81760239BC5D99/sketch/min.ino.cpp.o
root INFO compile-response, SEND 2022-08-10T14:40:48.544Z 0 /Users/a.kitta/Documents/Arduino/min/min.ino:2:3: note: suggested alternative: 'strerror'
   someerror
   ^~~~~~~~~
   strerror
root INFO compile-response, RECEIVED 2022-08-10T14:40:48.546Z 0 /Users/a.kitta/Documents/Arduino/min/min.ino:2:3: note: suggested alternative: 'strerror'
   someerror
   ^~~~~~~~~
   strerror

kittaakos avatar Aug 10 '22 14:08 kittaakos

On my Windows machine, clicking the "Reveal Error" link or using the Ctrl+click shortcut does not result in the cursor moving to the file and line specified in the error message.

It should be fixed now.

Scrolling the output view up at the end of the compilation can cause the link to be placed on the wrong line.

It was unrelated to the scrolling, but it should work correctly now.

I notice that multiple error lines are now highlighted, whereas with previous versions of the Arduino IDE (going all the way back to the introduction of the feature at 4611381), only a single line was highlighted unless the arduino.compile.experimental advanced setting was enabled.

This change is required to support all error links from the output, not only one 😬 . I can add the technical explanation on why if required. @per1234, do you prefer to show only one error (highlighted with the "red" line) even if there are multiple errors? It's not a trivial task but probably doable. Thank you!

When a sketch file contains multiple error highlights, the selection is lost at each highlighted line while selecting in an upward direction.

I could not reproduce it on both macOS and Windows so far.

kittaakos avatar Aug 11 '22 10:08 kittaakos

When a sketch file contains multiple error highlights, the selection is lost at each highlighted line while selecting in an upward direction.

I could not reproduce it on both macOS and Windows so far.

I still could not reproduce it.

Per, if you have some time, please give the updated version a try. I still see some issues when deleting content from the editor, the markers are not removed correctly. I try to find a solution and/or document the known issues. Upstream: https://github.com/microsoft/monaco-editor/issues/2138

kittaakos avatar Aug 11 '22 15:08 kittaakos

I still could not reproduce it.

I can reproduce it consistently on both Windows and Linux when using 2.0.0-rc9-snapshot-0c9e1ab (the build from https://github.com/arduino/arduino-ide/commit/fef76f2349d341478b3e528aa9f2ed57f77ca0bf). I can not reproduce it when using the build from https://github.com/arduino/arduino-ide/pull/1275/commits/5b6580c6a4c6949ca66db109e285feeb7ae989b9, so it must have been fixed inadvertently by some of the changes you made between those revisions.

do you prefer to show only one error (highlighted with the "red" line) even if there are multiple errors?

I don't have a strong preference either way. I only mentioned the change because it seemed possibly related to the lost selection bug.

per1234 avatar Aug 11 '22 17:08 per1234