Introduce `Code` to `Diagnostic`
radeksimko opened this issue · 0 comments
radeksimko commented
Background
In order to support upcoming work on code actions in the Terraform language server and possibly other future language servers and editor integrations, it is necessary to have some way for downstream HCL consumers to uniquely identify diagnostics such as these:
hcl.Diagnostic{
Severity: hcl.DiagError,
Summary: "Ambiguous attribute key",
Detail: "If this expression is intended to be a reference, wrap it ...",
Subject: e.Range().Ptr(),
}
See more details about code actions at
- https://code.visualstudio.com/docs/editor/refactoring#_code-actions-quick-fixes-and-refactorings
- https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#textDocument_codeAction
Proposal
- Introduce a new
Code DiagCode
field into thehcl.Diagnostic
struct - Fill out the
Code
field for existing diagnostics which are "fixable"- TODO
- Document naming conventions for the
Code
/DiagCode