Skip to content

Conversation

@rmagatti
Copy link
Contributor

@rmagatti rmagatti commented Jun 22, 2021

Really new at this.

Initially this looks like more files than I'd want to commit, maybe missing a .gitignore or something.

Checklist:

  • All tests pass in CI.
  • There are sufficient tests for the new fix/feature.
  • Grammar rules have not been renamed unless absolutely necessary.
  • The conflicts section hasn't grown too much.
  • The parser size hasn't grown too much (check the value of STATE_COUNT in src/parser.c).

@mjambon
Copy link
Contributor

mjambon commented Jun 22, 2021

I don't know what those new files are. @maxbrunsfeld would know. My guess is either you ran a command from the wrong folder or there's been a recent change in tree-sitter and it's normal that these new files should be added.

@rmagatti
Copy link
Contributor Author

rmagatti commented Jul 8, 2021

@mjambon is this even the right way of adding the override modifier at least?

@mjambon
Copy link
Contributor

mjambon commented Jul 8, 2021

It looks reasonable based on what we already have but I wonder about the order of all these modifiers. Do they have to come in this particular order e.g. static override readonly async? I'd look into the official typescript implementation and/or check the behavior in the typescript playground since I don't think there's an up-to-date spec. Maybe the old one from 2016 is still useful (https://javascript.xgqfrms.xyz/pdfs/TypeScript%20Language%20Specification.pdf).

@mjambon
Copy link
Contributor

mjambon commented Jul 8, 2021

If you find out that the order of the modifiers is well defined, then we can merge the current implementation. Otherwise if it's not clear or the order doesn't matter, we can instead parse them as:

repeat(choice($.static, $.override, $.readonly, ...))

This tolerates duplicates but I think it would be fine.

@maxbrunsfeld
Copy link
Contributor

I think that if @mjambon's suggestion works, we should prefer it, because that format generally results in significantly fewer parse states, which makes the parser faster and smaller to download.

There are likely to be restrictions on the allowed order, but it's reasonable to regard violations of those restrictions as semantic errors, not syntax errors.

@rmagatti
Copy link
Contributor Author

So I did go through and fix the ordering at least in the public_field_definition piece.
I'll try and do a few more tests soon.

@rmagatti
Copy link
Contributor Author

If you find out that the order of the modifiers is well defined, then we can merge the current implementation. Otherwise if it's not clear or the order doesn't matter, we can instead parse them as:

repeat(choice($.static, $.override, $.readonly, ...))

This tolerates duplicates but I think it would be fine.

The order seems to be important indeed.
Screen Shot 2021-07-12 at 12 34 11 AM

@rmagatti rmagatti marked this pull request as ready for review July 12, 2021 06:48
@rmagatti rmagatti changed the title WIP - Add override modifier Add override modifier Jul 19, 2021
@mjambon
Copy link
Contributor

mjambon commented Aug 2, 2021

@maxbrunsfeld this PR adds several new generated files, presumably due to recent versions of tree-sitter generating more files. Should they be added or git-ignored?

  • tsx/Cargo.toml
  • tsx/binding.gyp
  • tsx/bindings/node/binding.cc
  • tsx/bindings/node/index.js
  • tsx/bindings/rust/build.rs
  • tsx/bindings/rust/lib.rs
  • [same for typescript/]

@mjambon
Copy link
Contributor

mjambon commented Aug 2, 2021

@rmagatti sorry for not responding earlier. To expedite this, could please check the checkbox items?

I see that the tests don't pass because of string_fragment that was introduced in the main branch. You need to merge master or rebase.

@mjambon mjambon mentioned this pull request Aug 2, 2021
@rmagatti
Copy link
Contributor Author

rmagatti commented Aug 2, 2021

Thanks for the review @mjambon I'll try and get back to this as soon as I can.

@rmagatti
Copy link
Contributor Author

rmagatti commented Aug 10, 2021

@mjambon would you mind kicking off the workflows? I'd like to see if things look good now.
Tests seem to run fine for me locally now.

@rmagatti rmagatti requested a review from mjambon August 12, 2021 15:40
@mjambon
Copy link
Contributor

mjambon commented Aug 12, 2021

@rmagatti what about my two earlier comments?

@mjambon
Copy link
Contributor

mjambon commented Aug 12, 2021

@maxbrunsfeld what about these new generated files mentioned in my earlier comment?

@rmagatti
Copy link
Contributor Author

@rmagatti what about my two earlier comments?

Oh wow, idk how I missed those, I'll check them out!

@rmagatti
Copy link
Contributor Author

@mjambon One of the comments is addressed. The one about the conflict I'm not sure how to improve on, at least from a quick look. 😅
I'll try and give this a deeper look later though.

@rmagatti
Copy link
Contributor Author

rmagatti commented Sep 7, 2021

Yeah I don't know enough about how this works to know how to not have to add the conflict. 😞

@mjambon
Copy link
Contributor

mjambon commented Sep 7, 2021

@rmagatti we need an answer from @maxbrunsfeld about all those new generated files. Do they need to be git-ignored?

As an aside:

Personally, I think generated files should not be placed in a source repo because:

  1. They mess up diffs.
  2. They let malicious contributors add code to the generated files that will escape review due to their large size.

Problem (2) can be avoided by requiring an admin or a bot to generate the files.

The solution we're using for semgrep is to treat generated code as build artifacts, and put them into their own git(hub) repo.

@rmagatti
Copy link
Contributor Author

rmagatti commented Sep 7, 2021

Yeah, despite having very little context on this particular project overall I agree with your side point as a general principle @mjambon.

@dcreager
Copy link
Contributor

These newly generated files should be removed from this PR, because they're redundant with similarly named files in the repo root. See #135 (comment) for more details, and tree-sitter/tree-sitter#1243 for a top-level tree-sitter-wide discussion about generated files.

version "0.19.0"
resolved "https://codeload.github.com/tree-sitter/tree-sitter-javascript/tar.gz/2c5b138ea488259dbf11a34595042eb261965259"
dependencies:
nan "^2.12.1"
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need this yarn.lock?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is usually a committed file to keep actual package versions consistent. I can remove it , but I'd recommend having it in the repo.

@mjambon
Copy link
Contributor

mjambon commented Sep 16, 2021

Could you add a test for override and remove the yarn.lock unless it's important for some reason (I don't know much about yarn), then I think we can merge this!

@rmagatti
Copy link
Contributor Author

Could you add a test for override and remove the yarn.lock unless it's important for some reason (I don't know much about yarn), then I think we can merge this!

I'll give it a try, haven't looked at how tests work for this yet. Good thing the weekend is right around the corner 😄

@rmagatti
Copy link
Contributor Author

Added a simple query test @mjambon

@mjambon
Copy link
Contributor

mjambon commented Sep 21, 2021

great. Merging!

@mjambon mjambon merged commit 85389c3 into tree-sitter:master Sep 21, 2021
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.

5 participants