feat: add extra diagnostic block for coder metadata#122
Conversation
Only `code` is present right now.
| } | ||
|
|
||
| func SetDiagnosticExtra(diag *hcl.Diagnostic, extra DiagnosticExtra) { | ||
| existing, ok := hcl.DiagnosticExtra[DiagnosticExtra](diag) |
There was a problem hiding this comment.
Is this code necessary?
if ok { // If an existing extra is present, we will keep the underlying // wrapped. This is not perfect, as any parents are lost. // So try to avoid calling 'SetDiagnosticExtra' more than once. extra.wrapped = existing.wrapped diag.Extra = extra return }
It feels like this code is already chaining the diag.extra so that each extra.wrapped points to the parent extra.
if diag.Extra != nil {
extra.wrapped = diag.Extra
}
diag.Extra = extra
There was a problem hiding this comment.
I'll write a test for this to illustrate 👍
There was a problem hiding this comment.
preview/types/diagnostics_test.go
Line 44 in 57148ba
parent -> extra -> child, we lose the parent.
If we did that you mentioned, it would be
parent -> extra -> new(extra) -> child. And the first extra would take priority on the Extract
Only
codeis present right now.