Class: MetaCommit::Extension::MarkdownSupport::Diffs::TextChange
- Inherits:
-
Diff
- Object
- Contracts::Diff
- Diff
- MetaCommit::Extension::MarkdownSupport::Diffs::TextChange
- Defined in:
- lib/meta_commit_markdown_support/diffs/text_change.rb
Constant Summary
Constants inherited from Diff
Constants included from ContextualAstAccessor
ContextualAstAccessor::ELEMENT_TYPE_ANCHOR, ContextualAstAccessor::ELEMENT_TYPE_CODE, ContextualAstAccessor::ELEMENT_TYPE_HEADER, ContextualAstAccessor::ELEMENT_TYPE_IMAGE, ContextualAstAccessor::ELEMENT_TYPE_LISTS, ContextualAstAccessor::ELEMENT_TYPE_LIST_ITEM, ContextualAstAccessor::ELEMENT_TYPE_PARAGRAPH, ContextualAstAccessor::ELEMENT_TYPE_TEXT
Instance Method Summary collapse
Methods inherited from Diff
#inspect, #supports_parser?, #to_s, #type_addition?, #type_deletion?, #type_replace?
Methods included from ContextualAstAccessor
#anchor?, #anchor_context?, #anchor_target, #anchor_title, #closest_header_of_list, #code?, #code_context?, #code_first_line, #context_node_neighbours, #context_nodes_on_line, #contextual_ast_has_target_node, #element_closest_to, #elements_of_type_on_line, #header?, #header_content, #image?, #list?, #list_context?, #list_item?, #nested_list_context?, #paragraph?, #paragraph_context?, #parent_list_item_title, #starts_on_line?, #string_content, #text?, #text_context?
Instance Method Details
#string_representation ⇒ String
14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/meta_commit_markdown_support/diffs/text_change.rb', line 14 def string_representation # because target_node is [text] # and [parent element] - has -> [paragraph] - has -> [text] # and we need to get access to [parent_element] neighbours parent_element_depth = change_context.new_contextual_ast.context_nodes.count - 2 parent_element_neighbours = context_node_neighbours(change_context.new_contextual_ast, parent_element_depth) if !parent_element_neighbours.last.nil? && header?(parent_element_neighbours.last) header = header_content(parent_element_neighbours.last) return "change content of #{header} section" end "change #{change_context.new_file_path}" end |
#supports_change(context) ⇒ Boolean
5 6 7 8 9 10 11 |
# File 'lib/meta_commit_markdown_support/diffs/text_change.rb', line 5 def supports_change(context) context.type == TYPE_REPLACE && contextual_ast_has_target_node(context.old_contextual_ast) && contextual_ast_has_target_node(context.new_contextual_ast) && text?(context.old_contextual_ast.target_node) && text?(context.new_contextual_ast.target_node) end |