lib/reek/source/source_code.rb in reek-3.1 vs lib/reek/source/source_code.rb in reek-3.2

- old
+ new

@@ -18,11 +18,11 @@ attr_reader :description # Initializer. # - # code - ruby code as String + # code - Ruby code as String # description - 'STDIN', 'string' or a filepath as String # parser - the parser to use for generating AST's out of the given source def initialize(code, description, parser = Parser::Ruby22) @source = code @description = description @@ -80,18 +80,22 @@ # for the given source def syntax_tree @syntax_tree ||= begin begin - ast, comments = @parser.parse_with_comments(@source, @description) + ast, comments = parser.parse_with_comments(source, description) rescue Racc::ParseError, Parser::SyntaxError => error $stderr.puts "#{description}: #{error.class.name}: #{error}" end # See https://whitequark.github.io/parser/Parser/Source/Comment/Associator.html comment_map = Parser::Source::Comment.associate(ast, comments) if ast TreeDresser.new.dress(ast, comment_map) end end + + private + + private_attr_reader :parser, :source end end end