Introduce `Code` to `Diagnostic`
- Dominant language
- Go
- Stars
- 5.8k
- Forks
- 657
- Avg merge
- 20h 36m
- Merged PRs (30d)
- 6
Description
## 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:
```go
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 the `hcl.Diagnostic` struct
- [ ] Fill out the `Code` field for existing diagnostics which are "fixable"
- [ ] TODO
- [ ] Document naming conventions for the `Code`/`DiagCode`
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by locating the hcl.Diagnostic definition and the existing diagnostic declarations in this repository. Review the proposal and the linked code-action and LSP specifications, then determine the field shape, naming conventions, and which existing diagnostics are fixable. Done means the new code field is introduced, applicable diagnostics are populated, and the convention is documented.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- devtools
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100