Sha256: f12473638d7bfe600f748190d8ce2eab1fbfcffc435729620fa72135716b421a
Contents?: true
Size: 1.13 KB
Versions: 1
Compression:
Stored size: 1.13 KB
Contents
module Simplabs module Excellent module Parsing class ResbodyContext < SexpContext #:nodoc: STATEMENT_NODES = [:fcall, :return, :attrasgn, :vcall, :call, :str, :lit, :hash, :false, :true, :nil] def initialize(exp, parent) super @contains_statements = contains_statements? end def has_statements? @contains_statements end def assigns_exception_to_local_variable? @exp[1][2].node_type == :lasgn && @exp[1][2][2].to_a == [:gvar, :$!] rescue false end private def contains_statements?(exp = @exp) return true if STATEMENT_NODES.include?(exp.node_type) return true if assigning_other_than_exception_to_local_variable?(exp) return true if (exp[1][0] == :array && exp[2][0] == :array rescue false) return true if exp.children.any? { |child| contains_statements?(child) } end def assigning_other_than_exception_to_local_variable?(exp) exp.node_type == :lasgn && exp[2].to_a != [:gvar, :$!] end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
excellent-1.7.2 | lib/simplabs/excellent/parsing/resbody_context.rb |