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

Automatically include necessary imports if missing from a model file #4

Open
object88 opened this issue Oct 28, 2016 · 3 comments
Open
Labels

Comments

@object88
Copy link
Collaborator

The current code requires that ImmutableModel must exist in a model file for it to be functional. It would be nice to include that import in the generated portion of the file if it is missing.

@pbomb
Copy link
Owner

pbomb commented Oct 29, 2016

Agreed. The same is true for the immutable import. I feel like a pull request might be coming. Yeah? 😉

@object88
Copy link
Collaborator Author

Feel free to assign it to me, and I'll poke at it.

@pbomb pbomb added the ready label Oct 29, 2016
@object88
Copy link
Collaborator Author

object88 commented Nov 4, 2016

Working through this. When I first looked at this, I had assumed that the comment block was free-floating, but I now see that comment blocks pretty much have to be associated with a code block (as per issues in the ast-types project). (Which also means that because it is possible to have more than one ModelType in a file, there will be more than one comment block.)

I have a very rudimentary pass at this which pops an import at the end of a file.

Before proceeding further, I'd like to do another refactor which will prepend the comment block only to the first added code block. This will have the side benefit of making it easier to handle pre-existing added code blocks -- look through all top-level code blocks in sequential order and remove anything at or after the block which has out delimiting comment. This is Good(tm) because if we add the ImmutableModel import, I'd rather not see that leak into the original code.

Thoughts or feedback?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants