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

Refactor #14

Closed
wants to merge 1 commit into from
Closed

Refactor #14

wants to merge 1 commit into from

Conversation

nkovacs
Copy link
Collaborator

@nkovacs nkovacs commented Jun 29, 2017

Move all the business logic of parsing and generating code
into maker subpackage.

Instead of functions, the maker package exports a Maker struct,
which has two exported methods: ParseSource to add a file,
and MakeInterface to create the interface.

The struct now handles the data that was previously handled
by the main package between the invocation of the two functions.

Don't use token.Pos to access source file byte slice,
this doesn't work when there are multiple files in the fileset.
Use go/printer or directly get the parsed strings from the ast nodes.

Ignore dot imports, assume they will not be needed by the
generated struct.

Throw errors when aliases conflict or a package is imported
with different aliases (#9).

Add a "Code generated by" comment per
https://golang.org/s/generatedcode

Add tests + travis.


This is a pretty big change. I've only tested this on a single project (with a few automatically generated interfaces), so I may have missed something.

Move all the business logic of parsing and generating code
into maker subpackage.

Instead of functions, the maker package exports a Maker struct,
which has two exported methods: ParseSource to add a file,
and MakeInterface to create the interface.

The struct now handles the data that was previously handled
by the main package between the invocation of the two functions.

Don't use token.Pos to access source file byte slice,
this doesn't work when there are multiple files in the fileset.
Use go/printer or directly get the parsed strings from the ast nodes.

Ignore dot imports, assume they will not be needed by the
generated struct.

Throw errors when aliases conflict or a package is imported
with different aliases (vburenin#9).

Add a "Code generated by" comment per
https://golang.org/s/generatedcode

Add tests + travis.
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.

2 participants