class HamlLint::RubyExtraction::PlaceholderMarkerChunk
This chunk just adds a marker (with a custom name) to the generated Ruby and only attempts to transfer the corrections it receives to the indentation of the associated lines.
Also used so that Rubocop doesn’t think that there is nothing in ‘if` and other such structures, so that it does corrections that make sense for the HAML.
Public Class Methods
new(node, marker_name, indent:, nb_lines: 1, **kwargs)
click to toggle source
Calls superclass method
HamlLint::RubyExtraction::BaseChunk::new
# File lib/haml_lint/ruby_extraction/placeholder_marker_chunk.rb, line 10 def initialize(node, marker_name, indent:, nb_lines: 1, **kwargs) @marker_name = marker_name @indent = indent @nb_lines = nb_lines super(node, nil, **kwargs.merge(end_marker_indent: @indent)) end
Public Instance Methods
end_marker_indent()
click to toggle source
# File lib/haml_lint/ruby_extraction/placeholder_marker_chunk.rb, line 36 def end_marker_indent @indent end
full_assemble(coordinator)
click to toggle source
# File lib/haml_lint/ruby_extraction/placeholder_marker_chunk.rb, line 17 def full_assemble(coordinator) @start_marker_line_number = coordinator.add_marker(@indent, name: @marker_name, haml_line_index: haml_line_index) end
haml_end_line_index()
click to toggle source
# File lib/haml_lint/ruby_extraction/placeholder_marker_chunk.rb, line 32 def haml_end_line_index haml_line_index + @nb_lines - 1 end
transfer_correction(coordinator, all_corrected_ruby_lines, haml_lines)
click to toggle source
# File lib/haml_lint/ruby_extraction/placeholder_marker_chunk.rb, line 22 def transfer_correction(coordinator, all_corrected_ruby_lines, haml_lines) marker_index = coordinator.find_line_index_of_marker_in_corrections(@start_marker_line_number, name: @marker_name) new_indent = all_corrected_ruby_lines[marker_index].index(/\S/) return if new_indent == @indent (haml_line_index..haml_end_line_index).each do |i| haml_lines[i] = HamlLint::Utils.indent(haml_lines[i], new_indent - @indent) end end