PistonDevelopers / VisualRust

Visual Studio extension for Rust
MIT License
703 stars 72 forks source link

Get error markers working again #240

Open Boddlnagg opened 8 years ago

Boddlnagg commented 8 years ago

Error markers (squiggly lines) no longer appear with #234. The build errors will be shown in the error list, and clicking on them navigates to the error location, but the markers are missing. However, it's not clear to me whether adding the error markers from the MSBuild errors is a good idea, because they won't be updated when the file is changed (until you build again). Integrating with the Rust Language Server would be much better.

quixoticaxis commented 8 years ago

I don't know how it was before, but I'd like to ask if the notes are shown (or will be shown) somewhere. For example,

  --> src\main.rs:24:21
   |
24 |     match guess.cmp(&secret_number)
   |                     ^^^^^^^^^^^^^^ expected struct `std::string::String`, found integral variable
   |
   = note: expected type `&std::string::String`
   = note:    found type `&{integer}`

I understand that ^^^^^^^^ will be shown as error markers but where do notes and explanation go?

Boddlnagg commented 8 years ago

No, the notes are currently not shown. We take JSON formatted errors (cargo build --message-format=json) and extract the main message and span. The concept of multiline notes and explanations (and multiple spans) in error messages is somewhat incompatible to the whay VS usually presents errors. Do you have a good idea how to present them?

quixoticaxis commented 8 years ago

Well, I have an idea of how to present them: the same way as other "built-in" languages do - they show error description in a bubble that pops up when you hover the marker with a pointer. I've never created VS extensions so I'm not sure if it's hard to implement though.

quixoticaxis commented 8 years ago

At least it would be good to iterate over children in json and add them to the description section of an error. It doesn't looks perfectly but at least that way there is more information (like in good ol' c++ error messages).

Boddlnagg commented 8 years ago

You're welcome to improve that situation 👍 The build errors are created here: https://github.com/PistonDevelopers/VisualRust/blob/master/VisualRust.Build/Rustc.cs#L370 (LogRustcMessage)

quixoticaxis commented 8 years ago

@Boddlnagg hello again, I'm totally new to GitHub and can't check what I've done in full build (missing components to build solution and Java) but I've added a few lines to aggregate notes, hope they do their job. How can I make a pull request for review (request from GitHub Desktop fails)? Also are there any instructions on how to actually build the whole solution? github client

Vbif commented 8 years ago

@quixoticaxis Do you install all software components from https://github.com/PistonDevelopers/VisualRust#prerequisites ?

Boddlnagg commented 8 years ago

@quixoticaxis I don't know the GitHub Desktop Software ... but you can create a PR from the web interface from any branch in your fork. How to create a branch is explained in many tutorials in the web.

https://github.com/PistonDevelopers/VisualRust#contributing has all the information about how to get a full build working. It's especially important that you copy all the files from the VisualRust.Build debug output directory to %ProgramFiles(x86)%\MSBuild\VisualRust to make the MSBuild integration work. Or, if you're hacking on VisualRust.Build and don't want to copy all the files after each change, you can create a "redirection" by creating C:\Program Files (x86)\MSBuild\VisualRust\VisualRust.Rust.targets with the following content (all the other files are referenced relatively) and setting the correct path to your Git clone in there:

<?xml version="1.0" encoding="utf-8" ?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <!-- Copy this file to C:\Program Files (x86)\MSBuild\VisualRust\ to load build rules directly from build output -->
  <Import Project="<your>\<path>\<to>\VisualRust\VisualRust.Build\bin\Debug\VisualRust.Rust.targets" />
</Project>
quixoticaxis commented 8 years ago

@Boddlnagg thank you, I'll create a PR a bit later then. Unfortunately I can't install Java where I am now.