Ameba::Source::Corrector - ameba 1.7.0

# class Ameba::Source::Corrector

- Ameba::Source::Corrector
- Reference
- Object

##
Overview

This class takes source code and rewrites it based on the different correction actions supplied.

##
Defined in:

ameba/source/corrector.cr

##
Constructors

- .new(code : String)

##
Instance Method Summary

- #insert_after(location, end_location, content)

  Shortcut for `#wrap(location, end_location, nil, content)`

- #insert_after(range : Range(Int32, Int32), content)

  Shortcut for `#wrap(range, nil, content)`

- #insert_after(pos : Int32, content)

  Shortcut for `#insert_after(...pos, content)`

- #insert_after(node : Crystal::ASTNode, content)

  Shortcut for `#wrap(node, nil, content)`

- #insert_after(location, content)

  Shortcut for `#insert_after(location, location, content)`

- #insert_before(location, end_location, content)

  Shortcut for `#wrap(location, end_location, content, nil)`

- #insert_before(range : Range(Int32, Int32), content)

  Shortcut for `#wrap(range, content, nil)`

- #insert_before(pos : Int32, content)

  Shortcut for `#insert_before(pos.., content)`

- #insert_before(node : Crystal::ASTNode, content)

  Shortcut for `#wrap(node, content, nil)`

- #insert_before(location, content)

  Shortcut for `#insert_before(location, location, content)`

- #process

  Applies all scheduled changes and returns modified source as a new string.

- #remove(location, end_location)

  Shortcut for `#replace(location, end_location, "")`

- #remove(range : Range(Int32, Int32))

  Shortcut for `#replace(range, "")`

- #remove(node : Crystal::ASTNode)

  Shortcut for `#replace(node, "")`

- #remove_leading(location, end_location, size)

  Removes size characters from the beginning of the given range.

- #remove_leading(range : Range(Int32, Int32), size)

  Removes size characters from the beginning of the given range.

- #remove_leading(node : Crystal::ASTNode, size)

  Removes size characters from the beginning of the given node.

- #remove_preceding(location, end_location, size)

  Removes size characters prior to the source range.

- #remove_preceding(range : Range(Int32, Int32), size)

  Removes size characters prior to the source range.

- #remove_preceding(node : Crystal::ASTNode, size)

  Removes size characters prior to the given node.

- #remove_trailing(location, end_location, size)

  Removes size characters from the end of the given range.

- #remove_trailing(range : Range(Int32, Int32), size)

  Removes size characters from the end of the given range.

- #remove_trailing(node : Crystal::ASTNode, size)

  Removes size characters from the end of the given node.

- #replace(location, end_location, content)

  Replaces the code of the given range with content.

- #replace(range : Range(Int32, Int32), content)

  Replaces the code of the given range with content.

- #replace(node : Crystal::ASTNode, content)

  Replaces the code of the given node with content.

- #wrap(location, end_location, insert_before, insert_after)

  Inserts the given strings before and after the given range.

- #wrap(range : Range(Int32, Int32), insert_before, insert_after)

  Inserts the given strings before and after the given range.

- #wrap(node : Crystal::ASTNode, insert_before, insert_after)

  Inserts the given strings before and after the given node.

##
Constructor Detail

def self.new(code : String) #

##
Instance Method Detail

def insert_after(location, end_location, content) #

Shortcut for `#wrap(location, end_location, nil, content)`

def insert_after(range : Range(Int32, Int32), content) #

Shortcut for `#wrap(range, nil, content)`

def insert_after(pos : Int32, content) #

Shortcut for `#insert_after(...pos, content)`

def insert_after(node : Crystal::ASTNode, content) #

Shortcut for `#wrap(node, nil, content)`

def insert_after(location, content) #

Shortcut for `#insert_after(location, location, content)`

def insert_before(location, end_location, content) #

Shortcut for `#wrap(location, end_location, content, nil)`

def insert_before(range : Range(Int32, Int32), content) #

Shortcut for `#wrap(range, content, nil)`

def insert_before(pos : Int32, content) #

Shortcut for `#insert_before(pos.., content)`

def insert_before(node : Crystal::ASTNode, content) #

Shortcut for `#wrap(node, content, nil)`

def insert_before(location, content) #

Shortcut for `#insert_before(location, location, content)`

def process #

Applies all scheduled changes and returns modified source as a new string.

def remove(location, end_location) #

Shortcut for `#replace(location, end_location, "")`

def remove(range : Range(Int32, Int32)) #

Shortcut for `#replace(range, "")`

def remove(node : Crystal::ASTNode) #

Shortcut for `#replace(node, "")`

def remove_leading(location, end_location, size) #

Removes size characters from the beginning of the given range. If size is greater than the size of the range, the removed region can overrun the end of the range.

def remove_leading(range : Range(Int32, Int32), size) #

Removes size characters from the beginning of the given range. If size is greater than the size of the range, the removed region can overrun the end of the range.

def remove_leading(node : Crystal::ASTNode, size) #

Removes size characters from the beginning of the given node. If size is greater than the size of the node, the removed region can overrun the end of the node.

def remove_preceding(location, end_location, size) #

Removes size characters prior to the source range.

def remove_preceding(range : Range(Int32, Int32), size) #

Removes size characters prior to the source range.

def remove_preceding(node : Crystal::ASTNode, size) #

Removes size characters prior to the given node.

def remove_trailing(location, end_location, size) #

Removes size characters from the end of the given range. If size is greater than the size of the range, the removed region can overrun the beginning of the range.

def remove_trailing(range : Range(Int32, Int32), size) #

Removes size characters from the end of the given range. If size is greater than the size of the range, the removed region can overrun the beginning of the range.

def remove_trailing(node : Crystal::ASTNode, size) #

Removes size characters from the end of the given node. If size is greater than the size of the node, the removed region can overrun the beginning of the node.

def replace(location, end_location, content) #

Replaces the code of the given range with content.

def replace(range : Range(Int32, Int32), content) #

Replaces the code of the given range with content.

def replace(node : Crystal::ASTNode, content) #

Replaces the code of the given node with content.

def wrap(location, end_location, insert_before, insert_after) #

Inserts the given strings before and after the given range.

def wrap(range : Range(Int32, Int32), insert_before, insert_after) #

Inserts the given strings before and after the given range.

def wrap(node : Crystal::ASTNode, insert_before, insert_after) #

Inserts the given strings before and after the given node.