Skip to content
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

Incorrect srcRange for files starting with a multiline comment #551

Open
dbanck opened this issue Aug 29, 2022 · 1 comment
Open

Incorrect srcRange for files starting with a multiline comment #551

dbanck opened this issue Aug 29, 2022 · 1 comment
Labels

Comments

@dbanck
Copy link
Member

dbanck commented Aug 29, 2022

When a HCL file starts with a multiline comment, the SrcRange of the hclsyntax.Body starts after the multiline comment.

Test data

Example file starting with a multiline comment:

/********************************
 Some comment
********************************/

data "google_project" "project" {
  project_id = var.project_id
}

Example code for parsing the file:

f, _ := hclsyntax.ParseConfig(src, filename, pos)
body, _ := f.Body.(*hclsyntax.Body)
fmt.Println(body.Range())

Full example here: https://gist.github.com/dbanck/83e0e7936556eab2184d5d89e9d1feac

Expected behavior

SrcRange for the example file should be main.tf:1,1-8,1

Actual behavior

SrcRange for the example file is reported as main.tf:3,34-8,1

@rickygodoy
Copy link

Any updates on this? I'll still facing this as of today.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants