swiftlang / vscode-swift

Visual Studio Code Extension for Swift
https://marketplace.visualstudio.com/items?itemName=sswg.swift-lang
Apache License 2.0
708 stars 47 forks source link

Deduplicate swift diagnostics #821

Closed award999 closed 4 weeks ago

award999 commented 1 month ago

Fixes #653

This does not include serialized diagnostics which will involve changes in swift itself

award999 commented 1 month ago

@swift-server-bot test this please

award999 commented 1 month ago

@swift-server-bot test this please

adam-fowler commented 1 month ago

One issue that might come up as well, the compiler sometimes generates info diagnostics (related to an error) you don't get from SKLSP. Will be a bit weird if we remove an error because SKLSP says it is fixed, but the related info diagnostic is not removed because it came from the build.

An easy way to replicate this is have a protocol and a struct that conforms to this protocol. Add a new requirement to the protocol and compile your project. You get an info diagnostic Protocol requires .... When you add the requirement to your struct this info diagnostic is not removed.

The info diagnostics are already problematic as they are not associated with the error that created them. Ideally we would be able to create a hierarchy of diagnostics where the info diagnostic was a child of the actual error diagnostic instead of a flat list. Don't think that is possible in VSCode though

EDIT: Just noticed Diagnostic has a relatedInformation field. Is this something we could use for informational diagnostics, if we can associate them with an error.

award999 commented 1 month ago

One issue that might come up as well, the compiler sometimes generates info diagnostics (related to an error) you don't get from SKLSP. Will be a bit weird if we remove an error because SKLSP says it is fixed, but the related info diagnostic is not removed because it came from the build.

An easy way to replicate this is have a protocol and a struct that conforms to this protocol. Add a new requirement to the protocol and compile your project. You get an info diagnostic Protocol requires .... When you add the requirement to your struct this info diagnostic is not removed.

The info diagnostics are already problematic as they are not associated with the error that created them. Ideally we would be able to create a hierarchy of diagnostics where the info diagnostic was a child of the actual error diagnostic instead of a flat list. Don't think that is possible in VSCode though

EDIT: Just noticed Diagnostic has a relatedInformation field. Is this something we could use for informational diagnostics, if we can associate them with an error.

Ya I stumbled across yesterday that a "note" always is attached to the preceding warning or error. Will put that patch up soon, and ya will be adding it into the relatedInformation :)

award999 commented 1 month ago

@swift-server-bot test this please

award999 commented 1 month ago

@swift-server-bot test this please