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

Introduce column number in AST nodes #1724

Merged
merged 2 commits into from
Nov 26, 2024
Merged

Conversation

andreabergia
Copy link
Contributor

@andreabergia andreabergia commented Nov 11, 2024

This PR introduces column numbers in all AST nodes.
It also modifies the existing tests for the parser, and adds a lot more cases in a different class. I have gone through Parser measuring code coverage to ensure that the tests cover (almost) all the cases - the things I didn't really test are the non-standard things like xml, array comprehension, or let expression.

There is a breaking change: in case of a function call such as:

a.
 b()

rhino will now assign line 1 to the expression, not line 2 (i.e. we assign the start of the expression, not the position of the parenthesis for the function call). This is for coherency with other parsers - I've checked what happen via https://astexplorer.net/ and it seems like the consensus is what I have implemented.

@rbri
Copy link
Collaborator

rbri commented Nov 11, 2024

:-D Execution failed for task ':tests:spotlessJavaCheck'. :-D

@andreabergia andreabergia force-pushed the column-number branch 2 times, most recently from 83cb30a to d9fc589 Compare November 19, 2024 17:29
@andreabergia andreabergia changed the title WIP: Introduce column number in AST nodes Introduce column number in AST nodes Nov 19, 2024
@andreabergia andreabergia marked this pull request as ready for review November 19, 2024 17:45
@gbrail
Copy link
Collaborator

gbrail commented Nov 25, 2024

Looks good to me, and I lost track -- this is the first of a few things, right? Are we going to get to the point where we output the column number in the actual stack traces? That will be very nice indeed.

@gbrail
Copy link
Collaborator

gbrail commented Nov 26, 2024

This is great progress and will help people in the future. Thanks for all the hard work here! I hope that we can next progress to getting column numbers in stack traces!

@gbrail gbrail merged commit f6c86fc into mozilla:master Nov 26, 2024
3 checks passed
@andreabergia andreabergia deleted the column-number branch November 26, 2024 07:42
@p-bakker
Copy link
Collaborator

@andreabergia just FMI: was this change driver by the desire to properly support sourcemaps? See #1308

@andreabergia
Copy link
Contributor Author

It's a step towards many things:

  • having column numbers in stack traces
  • supporting source maps properly
  • implementing the DAP protocol

@p-bakker
Copy link
Collaborator

Also see #973

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.

4 participants