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) #

Instance Method Detail

def insert_after(location, end_location, content) #

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

def insert_after(pos : Int32, content) #

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

def insert_after(location, content) #

def insert_before(location, end_location, content) #

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

def insert_before(pos : Int32, content) #

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

def insert_before(location, content) #

def process #

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


def remove(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.