Skip to content

Instantly share code, notes, and snippets.

@aki017
Created November 12, 2016 01:02
Show Gist options
  • Save aki017/67599d8b04da67904470b3c143674325 to your computer and use it in GitHub Desktop.
Save aki017/67599d8b04da67904470b3c143674325 to your computer and use it in GitHub Desktop.
arg name
def search_method_add_arg(sexp, indent = 0)
results = []
if sexp[0] == :method_add_arg
results << sexp
end
sexp.each do |s|
if s.is_a? Array
results += search_method_add_arg(s, indent+2)
end
end
results
end
def norm_arg(sexp)
results = []
results += norm_arg(sexp[1]) if sexp[1][0]==:args_add
results << sexp[2]
results
end
sexp = Ripper::SexpBuilder.new(f).parse
sexp = search_method_add_arg(sexp)
t = sexp.select{|s|
next false if s[1][0] != :fcall
s[1][1][2][0] == loc.lineno
}.last
args = norm_arg(t[2][1][1])
arg_names = args[0..1].map{|k| Sorcerer.source([:stmts_add, [:stmts_new], k]) }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment