Module: Kettle::Dev::PrismUtils
- Defined in:
- sig/kettle/dev/prism_utils.rbs
Overview
Shared utilities for working with Prism AST nodes
Constant Summary collapse
- Prism =
Class Method Summary collapse
-
.block_call_to? ⇒ Boolean
Check if a node is a block call to a specific method.
-
.call_to? ⇒ Boolean
Check if a node is a specific method call.
-
.extract_const_name ⇒ String?
Extract qualified constant name from a constant node.
-
.extract_literal_value ⇒ String, ...
Extract literal value from string or symbol nodes.
-
.extract_statements ⇒ Array[Prism::Node]
Extract statements from a Prism body node.
-
.find_leading_comments ⇒ Object
Find leading comments for a statement node.
-
.inline_comments_for_node ⇒ Object
Find inline comments for a statement node.
-
.node_to_source ⇒ String
Convert a Prism AST node to Ruby source code.
-
.normalize_argument ⇒ String
Normalize an argument node to canonical format.
-
.normalize_call_node ⇒ String
Normalize a call node to use parentheses format.
-
.parse_with_comments ⇒ Prism::ParseResult
Parse Ruby source code and return Prism parse result with comments.
-
.statement_key ⇒ Object
Generate a unique key for a statement node to identify equivalent statements.
Class Method Details
.block_call_to? ⇒ Boolean
Check if a node is a block call to a specific method
52 |
# File 'sig/kettle/dev/prism_utils.rbs', line 52
def self.block_call_to?: (Prism::Node node, Symbol method_name) -> bool
|
.call_to? ⇒ Boolean
Check if a node is a specific method call
49 |
# File 'sig/kettle/dev/prism_utils.rbs', line 49
def self.call_to?: (Prism::Node node, Symbol method_name) -> bool
|
.extract_const_name ⇒ String?
Extract qualified constant name from a constant node
23 |
# File 'sig/kettle/dev/prism_utils.rbs', line 23
def self.extract_const_name: (Prism::Node? node) -> String?
|
.extract_literal_value ⇒ String, ...
Extract literal value from string or symbol nodes
20 |
# File 'sig/kettle/dev/prism_utils.rbs', line 20
def self.extract_literal_value: (Prism::Node? node) -> (String | Symbol)?
|
.extract_statements ⇒ Array[Prism::Node]
Extract statements from a Prism body node
11 |
# File 'sig/kettle/dev/prism_utils.rbs', line 11
def self.extract_statements: (Prism::Node? body_node) -> Array[Prism::Node]
|
.find_leading_comments ⇒ Object
Find leading comments for a statement node
26 |
# File 'sig/kettle/dev/prism_utils.rbs', line 26
def self.find_leading_comments: (
|
.inline_comments_for_node ⇒ Object
Find inline comments for a statement node
34 |
# File 'sig/kettle/dev/prism_utils.rbs', line 34
def self.inline_comments_for_node: (
|
.node_to_source ⇒ String
Convert a Prism AST node to Ruby source code
40 |
# File 'sig/kettle/dev/prism_utils.rbs', line 40
def self.node_to_source: (Prism::Node? node) -> String
|
.normalize_argument ⇒ String
Normalize an argument node to canonical format
46 |
# File 'sig/kettle/dev/prism_utils.rbs', line 46
def self.normalize_argument: (Prism::Node arg) -> String
|
.normalize_call_node ⇒ String
Normalize a call node to use parentheses format
43 |
# File 'sig/kettle/dev/prism_utils.rbs', line 43
def self.normalize_call_node: (Prism::Node node) -> String
|
.parse_with_comments ⇒ Prism::ParseResult
Parse Ruby source code and return Prism parse result with comments
8 |
# File 'sig/kettle/dev/prism_utils.rbs', line 8
def self.parse_with_comments: (String source) -> Prism::ParseResult
|
.statement_key ⇒ Object
Generate a unique key for a statement node to identify equivalent statements
14 |
# File 'sig/kettle/dev/prism_utils.rbs', line 14
def self.statement_key: (
|