You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
decls=Ruby::Signature::Parser.parse_signature(sig_base_path.read)decl_map={}decls.eachdo |decl|
ifd=decl_map[decl.name]# TODO: Is it right for decl is not a class / module?c=Ruby::Signature::AST::Declarations::Classm=Ruby::Signature::AST::Declarations::Modulenextunlessd.is_a?(c) || d.is_a?(m)nextunlessdecl.is_a?(c) || decl.is_a?(m)d.members.concatdecl.membersifd.is_a?(c) && decl.is_a?(c)decl_map[decl.name]=c.new(name: d.name,type_params: d.type_params,super_class: d.super_class || decl.super_class,members: d.members,annotations: d.annotations,location: d.location,comment: d.comment)endelsedecl_map[decl.name]=declendend
But I think rbs command should provide a solution(s) for the problem.
So, I think it is better if rbs prototype rb command displays deduped declarations.
And we can implement rbs dedupe sub-command as an alternative. The sub-command may be useful for RBS files that are generated by other programs. But I'm not sure the sub-command is actually necessary.
By the way, I guess rbs prototype rbi also has the same issue.
How about the ideas? I'd like to implement them if they are acceptable.
The text was updated successfully, but these errors were encountered:
It's a good point. However, I don't think deduping declarations makes much sense. The tool is for prototyping and none of these fixes will completely solve the problem.
My suggestion is the simplest workaround: to stop generating declarations for empty classes/modules.
Problem
rbs prototype rb
command may generate duplicated declarations.For example:
a.rb
In this case,
class A
is duplicated.And it easily causes in the real applications.
Solution
Now I avoid the problem with the following code.
full version: https://gist.github.com/pocke/a3faa4b87416c3d899e626f9197f2174#file-steep-rake-L13-L33
But I think rbs command should provide a solution(s) for the problem.
So, I think it is better if
rbs prototype rb
command displays deduped declarations.And we can implement
rbs dedupe
sub-command as an alternative. The sub-command may be useful for RBS files that are generated by other programs. But I'm not sure the sub-command is actually necessary.By the way, I guess
rbs prototype rbi
also has the same issue.How about the ideas? I'd like to implement them if they are acceptable.
The text was updated successfully, but these errors were encountered: