Sha256: 3d2b08cf2fee31218e87c9b2f963217b9bcbd50424ac42b21150e8012fb869bf
Contents?: true
Size: 690 Bytes
Versions: 8
Compression:
Stored size: 690 Bytes
Contents
# frozen_string_literal: true module Synvert::Core # AppendAction to append code to the bottom of node body. class Rewriter::AppendAction < Rewriter::Action END_LENGTH = "\nend".length def calculate_position @begin_pos = :begin == @node.type ? @node.loc.expression.end_pos : @node.loc.expression.end_pos - @node.column - END_LENGTH @end_pos = @begin_pos end private # Indent of the node. # # @param node [Parser::AST::Node] # @return [String] n times whitesphace def indent(node) if %i[block class].include? node.type ' ' * (node.column + DEFAULT_INDENT) else ' ' * node.column end end end end
Version data entries
8 entries across 8 versions & 1 rubygems