diff --git a/rules/terraform_deprecated_index.go b/rules/terraform_deprecated_index.go index dc028a3..0cfd438 100644 --- a/rules/terraform_deprecated_index.go +++ b/rules/terraform_deprecated_index.go @@ -48,20 +48,16 @@ func (r *TerraformDeprecatedIndexRule) Check(runner tflint.Runner) error { return nil } - diags := runner.WalkExpressions(tflint.ExprWalkFunc(func(expr hcl.Expression) hcl.Diagnostics { - filename := expr.Range().Filename - file, err := runner.GetFile(filename) - if err != nil { - return hcl.Diagnostics{ - { - Severity: hcl.DiagError, - Summary: "failed to call GetFile()", - Detail: err.Error(), - }, - } - } + files, err := runner.GetFiles() + if err != nil { + return err + } + diags := runner.WalkExpressions(tflint.ExprWalkFunc(func(expr hcl.Expression) hcl.Diagnostics { for _, variable := range expr.Variables() { + filename := expr.Range().Filename + file := files[filename] + bytes := expr.Range().SliceBytes(file.Bytes) tokens, diags := hclsyntax.LexExpression(bytes, filename, variable.SourceRange().Start)