class Xumlidot::Parsers::MethodSignature
Parser for the arguments to a method
e.g. formats def method(a, b = nil)
to a string 'a, b = nil'
Attributes
definition[R]
Container for values assigned to a variable
class Assignments < Hash end
Public Class Methods
new(exp, superclass_method = false)
click to toggle source
Calls superclass method
# File lib/xumlidot/parsers/method_signature.rb, line 21 def initialize(exp, superclass_method = false) super() @definition = ::Xumlidot::Types::MethodSignature.new @definition.visibility = Scope.get_visibility @definition.args = Args.new(exp.dup[0..2]).definition # only pass the method definition into args @definition.superclass_method = superclass_method #@assignments = Assignments.new process(exp) end
Public Instance Methods
process_call(exp)
click to toggle source
CALLS TODO: We need a seperate assignment class to parse these especially assignments so that we can attempt to work out types
# File lib/xumlidot/parsers/method_signature.rb, line 66 def process_call(exp) exp.shift # remove the :call recv = process(exp.shift) # recv name = exp.shift args = process(exp.shift) # args exp rescue Exception => e if ENV["XUMLIDOT_DEBUG"] STDERR.puts "ERROR (MethodSignature#process_call) #{e.message}" STDERR.puts e.backtrace.reverse end exp end
process_defn(exp)
click to toggle source
# File lib/xumlidot/parsers/method_signature.rb, line 38 def process_defn(exp) exp.shift unless auto_shift_type # node type exp.shift if exp.first.is_a?(Sexp) && exp.first.value == :self # remove :self @definition.name = exp.shift @definition.file = exp.file @definition.line_number = exp.line @definition.line_max = exp.line_max more = exp.shift process(more) if more.is_a?(Sexp) && !more.empty? s() rescue Exception => e STDERR.puts " ** bug: unable to proces defn #{exp}" if ENV["XUMLIDOT_DEBUG"] STDERR.puts "ERROR (MethodSignature#process_defn) #{e.message}" STDERR.puts e.backtrace.reverse end s() end
process_defs(exp)
click to toggle source
# File lib/xumlidot/parsers/method_signature.rb, line 59 def process_defs(exp) process_defn(exp) end
process_lasgn(exp)
click to toggle source
# File lib/xumlidot/parsers/method_signature.rb, line 82 def process_lasgn(exp) exp.shift # remove :lasgn name = exp.shift.to_s value = exp.shift #@assignments[name] = value process(value) s() end
to_s()
click to toggle source
# File lib/xumlidot/parsers/method_signature.rb, line 34 def to_s @definition.to_s end