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

Add initial methods draft for js parser visitor #113

Merged
merged 2 commits into from
Sep 24, 2024
Merged

Conversation

OlegDokuka
Copy link
Member

No description provided.

@@ -1,2 +1,3 @@
export * from './markers';
export * from './visitor';
export * from './tree';
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we should instead require client code to separately import the tree module. I am still uncertain about this, but we can discuss this on our weekly sync. I also don't really like how the WebStorm IDE adds imports, which has probably also influenced how I feel about this.

Copy link
Member Author

Choose a reason for hiding this comment

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

Usually index ts imports all required bits for external users. in JS world in is unconvinient to import from internal subdiricotires

return new J.Unknown(randomId(), Space.EMPTY, Markers.EMPTY, new Source(randomId(), Space.EMPTY, Markers.EMPTY, node.getText()));
}

visitEndOfFileToken(node: ts.Node) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Am I correct in assuming that this class is generated? If so, we should also add the generator to the Git repo somewhere, so that we can rerun it when necessary. To that end I propose a few changes:

  • Create an interface in a separate file, so that we can actually regenerate it
  • Onlt generate a visit method for Node subtypes. Specifically, I would probably only generate a visit method for those Node subtypes which have a corresponding create method in the NodeFactory interface
  • Change the parameter type to use the corresponding interface type. E.g. visitIdentifier(node: ts.Identifier)
  • I think it would probably also be good to make the Visitor interface generic and then have an additional parameter of that generic T type, which we can pass around.
  • Possibly we should also have a generic type parameter for the return type, which in our case would probably be J then. But unsure about that part.

Copy link
Member Author

Choose a reason for hiding this comment

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

it is not. I manually imported all possible methods

Copy link
Member Author

Choose a reason for hiding this comment

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

we can remove method that are not used after we start working on lst. all those methods are created based on all possible kinds of nodes (see ts.SyntaxKind for more info)

@OlegDokuka OlegDokuka marked this pull request as ready for review September 24, 2024 10:36
@OlegDokuka OlegDokuka merged commit b01563c into main Sep 24, 2024
1 check passed
@OlegDokuka OlegDokuka deleted the main-parser-visitor branch September 24, 2024 10:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

2 participants