lib/node_mutation/adapter/parser.rb in node_mutation-1.17.1 vs lib/node_mutation/adapter/parser.rb in node_mutation-1.18.0

- old
+ new

@@ -6,11 +6,11 @@ class NodeMutation::ParserAdapter < NodeMutation::Adapter def get_source(node) if node.is_a?(Array) return "" if node.empty? - source = file_content(node.first) + source = file_source(node.first) source[node.first.loc.expression.begin_pos...node.last.loc.expression.end_pos] else node.loc.expression.source end end @@ -26,11 +26,11 @@ else evaluated.loc.expression.source end when Array if evaluated.size > 0 - file_source = file_content(evaluated.first) + file_source = file_source(evaluated.first) source = file_source[evaluated.first.loc.expression.begin_pos...evaluated.last.loc.expression.end_pos] lines = source.split "\n" lines_count = lines.length if lines_count > 1 && lines_count == evaluated.size new_code = [] @@ -50,11 +50,11 @@ raise "can not parse \"#{code}\"" end end end - def file_content(node) + def file_source(node) node.loc.expression.source_buffer.source end def child_node_range(node, child_name) direct_child_name, nested_child_name = child_name.to_s.split('.', 2) @@ -160,10 +160,10 @@ end_loc = node.loc.expression.end NodeMutation::Struct::Location.new(end_loc.line, end_loc.column) end def get_indent(node) - file_content(node).split("\n")[get_start_loc(node).line - 1][/\A */].size + file_source(node).split("\n")[get_start_loc(node).line - 1][/\A */].size end private def child_node_by_name(node, child_name)