Skip to content

Commit

Permalink
refactor: pull language id check into var
Browse files Browse the repository at this point in the history
  • Loading branch information
ansgarm committed Jul 5, 2024
1 parent c1d7dba commit a8cf88f
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion internal/features/stacks/jobs/parse_stack.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,12 @@ func ParseStackConfiguration(ctx context.Context, fs ReadOnlyFS, stackStore *sta
var diags ast.Diagnostics
rpcContext := lsctx.DocumentContext(ctx)

isMatchingLanguageId := (rpcContext.LanguageID == lsp.Stacks.String() || rpcContext.LanguageID == lsp.Deploy.String())

// Only parse the file that's being changed/opened, unless this is 1st-time parsing
if record.DiagnosticsState[globalAst.HCLParsingSource] == operation.OpStateLoaded &&
rpcContext.IsDidChangeRequest() &&
(rpcContext.LanguageID == lsp.Stacks.String() || rpcContext.LanguageID == lsp.Deploy.String()) {
isMatchingLanguageId {
// the file has already been parsed, so only examine this file and not the whole module
err = stackStore.SetDiagnosticsState(stackPath, globalAst.HCLParsingSource, operation.OpStateLoading)
if err != nil {
Expand Down

0 comments on commit a8cf88f

Please sign in to comment.