class Ameba::Source::Corrector

Overview

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

Defined in:

ameba/source/corrector.cr

Constructors

Instance Method Summary

Constructor Detail

def self.new(code : String) #

[View source]

Instance Method Detail

def insert_after(location, end_location, content) #

[View source]
def insert_after(node : Crystal::ASTNode, content) #

[View source]
def insert_after(location, content) #

[View source]
def insert_before(location, end_location, content) #

[View source]
def insert_before(node : Crystal::ASTNode, content) #

[View source]
def insert_before(location, content) #

[View source]
def process #

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


[View source]
def remove(location, end_location) #

[View source]
def remove(node : Crystal::ASTNode) #

Shortcut for #replace(node, "")


[View source]
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.


[View source]
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.


[View source]
def remove_preceding(location, end_location, size) #

Removes size characters prior to the source range.


[View source]
def remove_preceding(node : Crystal::ASTNode, size) #

Removes size characters prior to the given node.


[View source]
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.


[View source]
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.


[View source]
def replace(location, end_location, content) #

Replaces the code of the given range with content.


[View source]
def replace(node : Crystal::ASTNode, content) #

Replaces the code of the given node with content.


[View source]
def wrap(location, end_location, insert_before, insert_after) #

Inserts the given strings before and after the given range.


[View source]
def wrap(node : Crystal::ASTNode, insert_before, insert_after) #

Inserts the given strings before and after the given node.


[View source]