vburenin / ifacemaker

Generate interfaces from structure methods.
Apache License 2.0
320 stars 43 forks source link

Comments, Tests and a little refactoring #23

Closed DenLilleMand closed 5 years ago

DenLilleMand commented 5 years ago

Fixed #22 which was kind of a bug converting all named return values to unnamed return values in the interface.

GetParameters was used for both return values and parameters which was a little confusing i thouth, so i changed the name of it. The parameters use of it also threw away the merged boolean, which i didnt like too much, so decided to get rid of the merged boolean, because it was only used to wrap the return values in paranthesis or not. Now we just always wrap return values in paranthesis because the FormatCode just removes them anyway.

Impl a new method GetReceiverType which checks if the receiver is nil to decide whether the FuncDecl is a method or a function. The other impl by calling GetFields was also ok, because it was guarded against getting called on a nil FuncDecl.Recv object, but i think it is cleaner just to check it yourself.

New implementation of the private function check to make the logic of the check explicit.

Also adding some unit tests for some of the old and new methods.