Sha256: ace3043bb722ced71f38e02be6a39cd5f235a3560bc1cc518bdd37b0737537cd
Contents?: true
Size: 1.21 KB
Versions: 1
Compression:
Stored size: 1.21 KB
Contents
require 'reek/code_context' module Reek class ModuleContext < CodeContext def ModuleContext.create(outer, exp) res = Name.resolve(exp[1], outer) ModuleContext.new(res[0], res[1]) end def ModuleContext.from_s(src) source = src.to_reek_source sniffer = Sniffer.new(source) CodeParser.new(sniffer).process_module(source.syntax_tree) end attr_reader :class_variables, :attributes def initialize(outer, name) super(outer, nil) @name = name @attributes = Set.new @class_variables = Set.new end def check_for_attribute_declaration(exp) if [:attr, :attr_reader, :attr_writer, :attr_accessor].include? exp[2] exp[3][1..-1].each {|arg| record_attribute(arg[1])} end end def myself @myself ||= @outer.find_module(@name) end def find_module(modname) return nil unless myself @myself.const_or_nil(modname.to_s) end def outer_name "#{@outer.outer_name}#{@name}::" end def record_attribute(attr) @attributes << Name.new(attr) end def record_class_variable(cvar) @class_variables << Name.new(cvar) end def variable_names [] end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
reek-1.2.2 | lib/reek/module_context.rb |