Skip to content

feat: add Ranges to GoComment parser nodes#1225

Merged
a-h merged 2 commits intoa-h:mainfrom
dgrundel:more-ranges
Jul 26, 2025
Merged

feat: add Ranges to GoComment parser nodes#1225
a-h merged 2 commits intoa-h:mainfrom
dgrundel:more-ranges

Conversation

@dgrundel
Copy link
Copy Markdown
Contributor

Hi there, I'm working on a Templ Linting tool for my project. In order to (a) display useful results to users and (b) enable linter config via comments (similar to eslint's eslint-disable), the tool needs to be able to understand the original source location of parsed nodes.

I came across a discussion thread on this topic and @joerdav seemed to agree that Templ's own parser should be able to support this: #586

So, here I am with what I hope to be the first of a handful of pull requests to add Ranges to various parser nodes. I kept this one small to ensure that I'm following the right conventions, etc. Happy to receive feedback on the PR. I would like to make future PRs a bit longer so I'm not bombarding you with them, but if you prefer many smaller changes that'd fine with me.

Thanks for taking a look!

Copy link
Copy Markdown
Owner

@a-h a-h left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, just a minor nit if you don't mind, then happy to merge.

A number of small PRs would be preferable to a big one.

Contents: " single line comment",
Multiline: false,
Range: Range{
To: Position{Index: 22, Line: 0, Col: 22},
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know that the From value is a zero value, but I think it would be clearer if From: Position{Index: 0, Line: 0, Col: 0}, was visible.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed! Thank you for updating and merging. I will be sure to do this for future PRs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants