hashicorp/hcl

Introduce `Code` to `Diagnostic`

radeksimko opened this issue · 0 comments

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

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