-
Notifications
You must be signed in to change notification settings - Fork 6
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
Conversation
@@ -1,2 +1,3 @@ | |||
export * from './markers'; | |||
export * from './visitor'; | |||
export * from './tree'; |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
openrewrite/src/javascript/parser.ts
Outdated
return new J.Unknown(randomId(), Space.EMPTY, Markers.EMPTY, new Source(randomId(), Space.EMPTY, Markers.EMPTY, node.getText())); | ||
} | ||
|
||
visitEndOfFileToken(node: ts.Node) { |
There was a problem hiding this comment.
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 correspondingcreate
method in theNodeFactory
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.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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)
No description provided.