class Ameba::AST::ImplicitReturnVisitor

Overview

AST visitor that finds nodes that are not used by their surrounding scope.

A stack is used to keep track of when a node is used, incrementing every time something will capture its implicit (or explicit) return value, such as the path in a class name or the value in an assign.

This also allows for passing through whether a node is captured from a nodes parent to its children, such as from an if statements parent to it's body, as the body is not used by the if itself, but by its parent scope.

Defined in:

ameba/ast/visitors/implicit_return_visitor.cr

Instance Method Summary

Instance methods inherited from class Ameba::AST::BaseVisitor

visit(node : Crystal::ASTNode) visit

Constructor methods inherited from class Ameba::AST::BaseVisitor

new(rule : Ameba::Rule::Base, source : Ameba::Source) new

Instance Method Detail

def visit(node : Crystal::Expressions) : Bool #

The stack is swapped out here as Crystal::Expressions are isolated from their parents scope. Only the last line in an expressions node can be captured by their parent node.


[View source]
def visit(node : Crystal::BinaryOp) : Bool #

[View source]
def visit(node : Crystal::Call) : Bool #

[View source]
def visit(node : Crystal::Arg) : Bool #

[View source]
def visit(node : Crystal::EnumDef) : Bool #

[View source]
def visit(node : Crystal::Assign | Crystal::OpAssign) : Bool #

[View source]
def visit(node : Crystal::MultiAssign) : Bool #

[View source]
def visit(node : Crystal::If | Crystal::Unless) : Bool #

[View source]
def visit(node : Crystal::While | Crystal::Until) : Bool #

[View source]
def visit(node : Crystal::Def) : Bool #

[View source]
def visit(node : Crystal::ClassDef | Crystal::ModuleDef) : Bool #

[View source]
def visit(node : Crystal::FunDef) : Bool #

[View source]
def visit(node : Crystal::Cast | Crystal::NilableCast) : Bool #

[View source]
def visit(node : Crystal::Annotation) : Bool #

[View source]
def visit(node : Crystal::TypeDeclaration) : Bool #

[View source]
def visit(node : Crystal::ArrayLiteral | Crystal::TupleLiteral) : Bool #

[View source]
def visit(node : Crystal::StringInterpolation) : Bool #

[View source]
def visit(node : Crystal::HashLiteral | Crystal::NamedTupleLiteral) : Bool #

[View source]
def visit(node : Crystal::Case) : Bool #

[View source]
def visit(node : Crystal::Select) : Bool #

[View source]
def visit(node : Crystal::When) : Bool #

[View source]
def visit(node : Crystal::Rescue) : Bool #

[View source]
def visit(node : Crystal::ExceptionHandler) : Bool #

[View source]
def visit(node : Crystal::ControlExpression) : Bool #

[View source]
def visit(node : Crystal::RangeLiteral) : Bool #

[View source]
def visit(node : Crystal::RegexLiteral) : Bool #

[View source]
def visit(node : Crystal::BoolLiteral | Crystal::CharLiteral | Crystal::NumberLiteral | Crystal::StringLiteral | Crystal::SymbolLiteral | Crystal::ProcLiteral) : Bool #

[View source]
def visit(node : Crystal::Yield) : Bool #

[View source]
def visit(node : Crystal::Generic | Crystal::Path | Crystal::Union) : Bool #

[View source]
def visit(node : Crystal::Macro | Crystal::MacroIf | Crystal::MacroFor) : Bool #

[View source]
def visit(node : Crystal::UninitializedVar) : Bool #

[View source]
def visit(node : Crystal::LibDef) : Bool #

[View source]
def visit(node : Crystal::Include | Crystal::Extend) : Bool #

[View source]
def visit(node : Crystal::Alias) #

[View source]
def visit(node : Crystal::TypeDef) #

[View source]
def visit(node) #

[View source]