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
-
.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
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_name ⇒ String?
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_value ⇒ String, ...
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_statements ⇒ Array[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_comments ⇒ Object
Find leading comments for a statement node
336 |
# File 'sig/kettle/dev.rbs', line 336
def self.find_leading_comments: (
|
.inline_comments_for_node ⇒ Object
Find inline comments for a statement node
344 |
# File 'sig/kettle/dev.rbs', line 344
def self.inline_comments_for_node: (
|
.node_to_source ⇒ String
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_argument ⇒ String
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_node ⇒ String
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_comments ⇒ Prism::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_key ⇒ Object
Generate a unique key for a statement node to identify equivalent statements
324 |
# File 'sig/kettle/dev.rbs', line 324
def self.statement_key: (
|