PLC-lang/rusty

Improve reporting multiple issues for the exact same location

Offen

#962 geöffnet am 06.09.2023

 (1 Kommentar) (0 Reaktionen) (0 zugewiesene Personen)Rust (71 Forks)auto 404
enhancementgood first issuelow-priority

Repository-Metriken

Stars
 (351 Sterne)
PR-Merge-Metriken
 (PR-Metriken ausstehend)

Beschreibung

Some situations report multiple issues for the exact same location. They get reported as independant issues and it is hard to see that th e last three are probably just follow up errors of the first one:

error: Unexpected token: expected DataTypeDefinition but found KeywordAbstract
  ┌─ test.st:1:30
  │
1 │ CLASS TestClass METHOD foo : ABSTRACT END_METHOD END_CLASS
  │                              ^^^^^^^^ Unexpected token: expected DataTypeDefinition but found KeywordAbstract

error: Unexpected token: expected Datatype but found ABSTRACT
  ┌─ test.st:1:30
  │
1 │ CLASS TestClass METHOD foo : ABSTRACT END_METHOD END_CLASS
  │                              ^^^^^^^^ Unexpected token: expected Datatype but found ABSTRACT

error: Unexpected token: expected Literal but found ABSTRACT
  ┌─ test.st:1:30
  │
1 │ CLASS TestClass METHOD foo : ABSTRACT END_METHOD END_CLASS
  │                              ^^^^^^^^ Unexpected token: expected Literal but found ABSTRACT

error: Unexpected token: expected KeywordSemicolon but found 'ABSTRACT'
  ┌─ test.st:1:30
  │
1 │ CLASS TestClass METHOD foo : ABSTRACT END_METHOD END_CLASS
  │                              ^^^^^^^^ Unexpected token: expected KeywordSemicolon but found 'ABSTRACT'

We should try to group diagnostics by their location before we report them. Something like this:

error: Unexpected token: expected DataTypeDefinition but found KeywordAbstract (+ 3 additional)
  ┌─ test.st:1:30
  │
1 │ CLASS TestClass METHOD foo : ABSTRACT END_METHOD END_CLASS
  │                              ^^^^^^^^ 1. Unexpected token: expected DataTypeDefinition but found KeywordAbstract
  │                                       2. Unexpected token: expected Datatype but found ABSTRACT
  │                                       3. Unexpected token: expected Literal but found ABSTRACT
  │                                       4. Unexpected token: expected KeywordSemicolon but found ABSTRACT

Contributor Guide