Skip to content

Add support for children in Diagnostic object for complex errors #10271

Closed

Description

@trixnz

While working with languages like Rust with rich information in its errors, it's become apparent that not all of this information can be conveyed cleanly with the current Problems window. Take, for example, this error:

warning: this `if` has the same condition as a previous if, #[warn(ifs_same_cond)] on by default
 --> src\main.rs:6:15
  |
6 |     } else if a == b {
  |               ^^^^^^
  |
note: same as this
 --> src\main.rs:4:8
  |
4 |     if a == b {
  |        ^^^^^^
  = help: for further information visit https://github.com/Manishearth/rust-clippy/wiki#ifs_same_cond

The note referencing where the first condition was used would be helpful to the user, but we must omit it because the error list is sorted on the Range of the error, resulting in the note being sorted before the actual error:
2016-08-07_15-09-58
While the above example doesn't look too ambiguous, when there are several errors spread out through the window, it quickly becomes extremely difficult to figure out what relates to each other.

If Diagnostic had a children: Diagnostic[] field where we could add additional context around the error, we would be able to convey more information to the user about the events that led to the error/warning.

Activity

  1. dbaeumer commented on Aug 8, 2016

    @dbaeumer
    Member

    The same as this is IMO not a separate error / problem. The solution to this should be a more complex message instead of a diagnostic tree. Sandeep Somavarapu (@sandy081) what happens with multi line messages today in the problems view.

  2. sophiajt commented on Aug 8, 2016

    @sophiajt

    When Niko Matsakis (@nikomatsakis) and I were working on the new errors, one of the ways we envisioned them possibly working may be close to what Dirk Bäumer (@dbaeumer) (also, hi Dirk! long time no see!) is suggesting.

    As a first step, I think a diagnostic tree is an okay fix. But I think ideally (and apologies I don't have a mockup so you'll have to visualize), is something like this:

    • Errors/Warnings are squiggled, but notes aren't shown
    • When you click on an Error/Warn squiggle, you get a popup that is like peek. It shows you the rest of the notes that are important, but otherwise these are hidden

    Dirk Bäumer (@dbaeumer) - does vscode support lightbulbs or additional info notifications? Maybe this is something where the lightbulb could pop up if there are additional notes.

  3. dbaeumer commented on Aug 9, 2016

    @dbaeumer
    Member

    jonathandturner (Hi Jonathon, indeed long time no see. See you have fun with rust now) Yes, there is support for a lightbulb in VS Code. Have a look at the code action API. This allows you to provide code actions for every position in the document. We then show the light bulb with the corresponding actions to run.

    The peak UI for errors is already there. You can pressed F8 in the editor to activate this.

    capture

  4. sandy081 commented on Aug 15, 2016

    @sandy081
    Member

    Long messages are not shown completely in the problems view. A partial message with a ... is shown at the end. Complete message is shown as title (on hover). For more information refer to this feature request - #1927

    I would make this a dup of #1927 if this is only about showing multi line messages in the problems view.

  5. trixnz commented on Aug 15, 2016

    @trixnz
    Author

    Sandeep Somavarapu (@sandy081) I don't think this issue is necessarily about multi line messages. Consider the following error:

    error[E0502]: cannot borrow `x` as immutable because it is also borrowed as mutable
      --> src\main.rs:29:20
       |
    27 |     let y = &mut x;
       |                  - mutable borrow occurs here
    28 |     *y += 1;
    29 |     println!("{}", x);
       |                    ^ immutable borrow occurs here
    30 | }
       | - mutable borrow ends here
    

    Presently there doesn't appear (unless I am mistaken) to be a way to add squiggles to lines 27 and 29 without adding a new diagnostic entry for each, which would be ambiguous when there are other errors to look through. As a result, we can only add the cannot borrowxas immutable because it is also borrowed as mutable line to the diagnostic list.

    Allowing for children in the tree (or an alternative means) would allow us to highlight the two borrows which would lead back to the original error. As I understand, the lightbulbs are for code actions and wouldn't really fit the context here as there is no action to be taken.

  6. sandy081 commented on Aug 16, 2016

    @sandy081
    Member

    Cam (@trixnz) In the above example, is not it enough to add a single diagnostic entry to line 29 providing a detailed message and mentioning where mutable borrow occurred. I do not think we need to add a squiggle or a child entry for line 27. IMO line 27 is a reference that has to be made in diagnostic entry of line 29.

  7. added
    feature-request
    error-list
    on Aug 22, 2016
  8. kumarharsh commented on Oct 6, 2017

    @kumarharsh
    Contributor

    +1 - the Flow parser also returns errors in two places - one in the React component which was used, and one in the place where it was used. Right now, the flow plugin shows the error in the first place, but not the second, which is rather pointless. It'd be very helpful if VSCode did have this functionality.

  9. 22 remaining items

  10. sandy081 commented on Mar 20, 2018

    @sandy081
    Member

    Another version closer to what Johannes Rieken (@jrieken) has for F8

    image

    Johannes Rieken (@jrieken) Opinions?

  11. added a commit that references this issue on Mar 20, 2018
  12. sandy081 commented on Mar 21, 2018

    @sandy081
    Member

    Johannes Rieken (@jrieken) Kai Maetzel (@kieferrm)

    I set up a rust example

    Problems generated by the Rust (rls) extension

    screen shot 2018-03-21 at 14 05 31

    Problems with related information generated by my test extension

    screen shot 2018-03-21 at 14 05 16

  13. nrc commented on Mar 22, 2018

    @nrc

    Sandeep Somavarapu (@sandy081) that looks great! It would be really nice if we could squiggle under let x = 5 while this message was shown and/or display a snippet of line 2 in the panel (this might be useful if the message refers to code that is not currently visible, which does often happen).

  14. agauniyal commented on Mar 23, 2018

    @agauniyal

    The squiggle on related line might not be visible if the lines are too far apart to be visible in the same viewport, so if only related line is visible then it might look as if let x = 5 has the error instead.

  15. sophiajt commented on Mar 23, 2018

    @sophiajt

    Abhinav Gauniyal (@agauniyal) Sandeep Somavarapu (@sandy081) - can we show the squiggle in the peek window, rather than the (2, 9)?

  16. agauniyal commented on Mar 23, 2018

    @agauniyal

    Maybe peek window can contain a link to the related line(I've seen this behavior with codelens)?

  17. nrc commented on Mar 26, 2018

    @nrc

    The squiggle on related line might not be visible if the lines are too far apart to be visible in the same viewport, so if only related line is visible then it might look as if let x = 5 has the error instead.

    Is it possible to see the f8 panel without starting on the main error? If the user has to scroll to only see the related squiggle, then it doesn't seem too bad. Perhaps we could also use different colour squiggles to clarify?

    Maybe peek window can contain a link to the related line(I've seen this behavior with codelens)?

    This would be great!

  18. jrieken commented on Mar 26, 2018

    @jrieken
    Contributor

    I'd like encourage to continue the discussion about F8 and related diagnostics in #46562 because this issue has become quite large already. I am also going ahead and I am closing this one so that we can test and ship the first versions of the various pieces involved (API, LSP, problem panel, hover, and F8)

  19. locked and limited conversation to collaborators on May 10, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

apierror-listfeature-requestlanguages-diagnosticson-testplan

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions