Class: Audition::Static::Checks::RactorIsolation::CaptureScanner
- Inherits:
-
Prism::Visitor
- Object
- Prism::Visitor
- Audition::Static::Checks::RactorIsolation::CaptureScanner
- Defined in:
- lib/audition/static/checks/ractor_isolation.rb
Overview
Walks the Ractor block's body tracking how many block scopes deep we are; a local reference with depth greater than that resolves outside the Ractor block.
Instance Attribute Summary collapse
-
#names ⇒ Object
readonly
Returns the value of attribute names.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize ⇒ CaptureScanner
constructor
A new instance of CaptureScanner.
- #visit_block_node(node) ⇒ Object
-
#visit_def_node(node) ⇒ Object
Method definitions open fresh scopes; nothing inside them can capture the surrounding locals.
- #visit_lambda_node(node) ⇒ Object
Constructor Details
#initialize ⇒ CaptureScanner
Returns a new instance of CaptureScanner.
63 64 65 66 67 |
# File 'lib/audition/static/checks/ractor_isolation.rb', line 63 def initialize @names = [] @level = 0 super end |
Instance Attribute Details
#names ⇒ Object (readonly)
Returns the value of attribute names.
61 62 63 |
# File 'lib/audition/static/checks/ractor_isolation.rb', line 61 def names @names end |
Class Method Details
.scan(body) ⇒ Object
55 56 57 58 59 |
# File 'lib/audition/static/checks/ractor_isolation.rb', line 55 def self.scan(body) scanner = new scanner.visit(body) scanner.names.uniq end |
Instance Method Details
#visit_block_node(node) ⇒ Object
69 70 71 72 73 74 |
# File 'lib/audition/static/checks/ractor_isolation.rb', line 69 def visit_block_node(node) @level += 1 super ensure @level -= 1 end |
#visit_def_node(node) ⇒ Object
Method definitions open fresh scopes; nothing inside them can capture the surrounding locals.
85 86 |
# File 'lib/audition/static/checks/ractor_isolation.rb', line 85 def visit_def_node(node) end |
#visit_lambda_node(node) ⇒ Object
76 77 78 79 80 81 |
# File 'lib/audition/static/checks/ractor_isolation.rb', line 76 def visit_lambda_node(node) @level += 1 super ensure @level -= 1 end |