Module: Kettle::Dev::PrismUtils

Defined in:
sig/kettle/dev.rbs

Overview

Shared utilities for working with Prism AST nodes

Constant Summary collapse

Prism =

Class Method Summary collapse

Class Method Details

.block_call_to?Boolean

Check if a node is a block call to a specific method



362
# File 'sig/kettle/dev.rbs', line 362

def self.block_call_to?: (Prism::Node node, Symbol method_name) -> bool

.call_to?Boolean

Check if a node is a specific method call



359
# File 'sig/kettle/dev.rbs', line 359

def self.call_to?: (Prism::Node node, Symbol method_name) -> bool

.extract_const_nameString?

Extract qualified constant name from a constant node



333
# File 'sig/kettle/dev.rbs', line 333

def self.extract_const_name: (Prism::Node? node) -> String?

.extract_literal_valueString, ...

Extract literal value from string or symbol nodes



330
# File 'sig/kettle/dev.rbs', line 330

def self.extract_literal_value: (Prism::Node? node) -> (String | Symbol)?

.extract_statementsArray[Prism::Node]

Extract statements from a Prism body node



321
# File 'sig/kettle/dev.rbs', line 321

def self.extract_statements: (Prism::Node? body_node) -> Array[Prism::Node]

.find_leading_commentsObject

Find leading comments for a statement node



336
# File 'sig/kettle/dev.rbs', line 336

def self.find_leading_comments: (

.inline_comments_for_nodeObject

Find inline comments for a statement node



344
# File 'sig/kettle/dev.rbs', line 344

def self.inline_comments_for_node: (

.node_to_sourceString

Convert a Prism AST node to Ruby source code



350
# File 'sig/kettle/dev.rbs', line 350

def self.node_to_source: (Prism::Node? node) -> String

.normalize_argumentString

Normalize an argument node to canonical format



356
# File 'sig/kettle/dev.rbs', line 356

def self.normalize_argument: (Prism::Node arg) -> String

.normalize_call_nodeString

Normalize a call node to use parentheses format



353
# File 'sig/kettle/dev.rbs', line 353

def self.normalize_call_node: (Prism::Node node) -> String

.parse_with_commentsPrism::ParseResult

Parse Ruby source code and return Prism parse result with comments



318
# File 'sig/kettle/dev.rbs', line 318

def self.parse_with_comments: (String source) -> Prism::ParseResult

.statement_keyObject

Generate a unique key for a statement node to identify equivalent statements



324
# File 'sig/kettle/dev.rbs', line 324

def self.statement_key: (