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

Restructure internal state #71

Open
jackbsteinberg opened this issue Sep 6, 2019 · 5 comments
Open

Restructure internal state #71

jackbsteinberg opened this issue Sep 6, 2019 · 5 comments
Milestone

Comments

@jackbsteinberg
Copy link
Owner

Currently the rewriter holds onto internal state in the form of a list of imports, which are accumulated and added to each file at the end of its rewrite. With the introduction of JSDoc comments in #70, there is new information to be accumulated during the rewrite and operated on at the conclusion.

Currently, the JSDoc removal happens with another pass through the descendants of the sourceFile, but it would be more efficient to track the additions and remove them as part of the internal state at the end. This refactor, coupled with a refactor of the imports into a more organized Import class, would straighten out the state mechanism the rewriter uses, organize the individual components of that mechanism, and remove an inefficient additional traversal.

@domenic
Copy link
Collaborator

domenic commented Sep 6, 2019

Most importantly in my mind, it would also avoid removing jsdoc comments that were not added by the rewriter, which the current #70 does.

@fergald
Copy link
Collaborator

fergald commented Sep 9, 2019

Does the rewriter drop all comments? I just checked and we have no tests that check for preseving comments.

@jackbsteinberg
Copy link
Owner Author

Currently the rewriter drops JSDoc comments which prefix variable statements. This is a pattern I don't believe we use often in LAPIs, but if we choose to these should be preserved. Tests and implementation need to be added to ensure normal comments and non-rewritten JSDoc comments are preserved.

@fergald
Copy link
Collaborator

fergald commented Sep 10, 2019

What does it do to non-JSDoc comments?

@fergald
Copy link
Collaborator

fergald commented Sep 10, 2019

Nevermind, I played with the tests, I can see it preserves normal comments.

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

No branches or pull requests

3 participants