class

Ameba::Source::Corrector

Inherits Reference < Object

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

Constructors

new(code : String)
Source

Instance methods

insert_after(location, end_location, content)

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

Source
insert_after(range : Range(Int32, Int32), content)

Shortcut for wrap(range, nil, content)

Source
insert_after(pos : Int32, content)

Shortcut for insert_after(...pos, content)

Source
insert_after(node : Crystal::ASTNode, content)

Shortcut for wrap(node, nil, content)

Source
insert_after(location, content)

Shortcut for insert_after(location, location, content)

Source
insert_before(location, end_location, content)

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

Source
insert_before(range : Range(Int32, Int32), content)

Shortcut for wrap(range, content, nil)

Source
insert_before(pos : Int32, content)

Shortcut for insert_before(pos.., content)

Source
insert_before(node : Crystal::ASTNode, content)

Shortcut for wrap(node, content, nil)

Source
insert_before(location, content)

Shortcut for insert_before(location, location, content)

Source
process

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

Source
remove(location, end_location)

Shortcut for replace(location, end_location, "")

Source
remove(range : Range(Int32, Int32))

Shortcut for replace(range, "")

Source
remove(node : Crystal::ASTNode)

Shortcut for replace(node, "")

Source
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.

Source
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.

Source
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.

Source
remove_preceding(location, end_location, size)

Removes size characters prior to the source range.

Source
remove_preceding(range : Range(Int32, Int32), size)

Removes size characters prior to the source range.

Source
remove_preceding(node : Crystal::ASTNode, size)

Removes size characters prior to the given node.

Source
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.

Source
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.

Source
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.

Source
replace(location, end_location, content)

Replaces the code of the given range with content.

Source
replace(range : Range(Int32, Int32), content)

Replaces the code of the given range with content.

Source
replace(node : Crystal::ASTNode, content)

Replaces the code of the given node with content.

Source
wrap(location, end_location, insert_before, insert_after)

Inserts the given strings before and after the given range.

Source
wrap(range : Range(Int32, Int32), insert_before, insert_after)

Inserts the given strings before and after the given range.

Source
wrap(node : Crystal::ASTNode, insert_before, insert_after)

Inserts the given strings before and after the given node.

Source