-
Notifications
You must be signed in to change notification settings - Fork 130
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Rootmodule diagnostics #288
Conversation
internal/lsp/diagnostics.go
Outdated
diags = append(diags, lsp.Diagnostic{ | ||
Range: HCLRangeToLSP(*hclDiag.Subject), | ||
Severity: HCLSeverityToLSP(hclDiag.Severity), | ||
Source: "Terraform", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Previously I had this set to HCL
, however now I think since the diagnostics are coming from the new decoder, they could be interpreted as not just syntax, but also provider schema specific? Therefore I thought saying the source was Terraform
was most appropriate, let me know if that is an incorrect interpretation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The spec doesn't seem to go into much detail in describing this field, but it seems to suggest that each linter should be reported with its own Source
- in our case I reckon that would apply to tflint
and I would think potentially to terraform validate
too?
The key question is how does the field affect the UX or anything in practice - I have no idea 🤷♂️
Re HCL
/Terraform
- our current diags in particular actually come just from hclsyntax.ParseConfig
, so HCL might be more appropriate here. The schema is not involved in the validation at all.
terraform-ls/internal/terraform/rootmodule/root_module.go
Lines 464 to 468 in 8bfea75
f, pDiags := hclsyntax.ParseConfig(src, name, hcl.InitialPos) | |
diags = append(diags, pDiags...) | |
if f != nil { | |
files[name] = f | |
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll switch it back then.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, just one question about the subject-less diags.
@radeksimko I moved |
internal/lsp/range.go
Outdated
} | ||
if r.End.Line < 0 { | ||
r.End.Line = 0 | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was this added as a reaction to any particular edge case you ran into?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
HCL range start with index 1, in the event there is no subject, I passed a zero'd HCL range to the converter, this would result in negative values in the LSP conversion (since LSP range is index 0), this just ensures we don't send an invalid range
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. |
This refactor based on the new decoder architecture brings the language server as close as possible to having project wide diagnostics #270 . Diagnostics are calculated for the entire rootmodule on file open and change. It does mean that a user that has several rootmodules open won't see diagnostics far a particular rootmodule (effectively folder) until a file is opened within a that rootmodule.
Closes #270