Class: FiberAudit::Static::CallSiteExtractor::ASTVisitor
- Inherits:
-
Object
- Object
- FiberAudit::Static::CallSiteExtractor::ASTVisitor
- Defined in:
- lib/fiber_audit/static/call_site_extractor.rb
Overview
Internal visitor that walks the AST and extracts call sites. Keeping the traversal state together makes scope propagation explicit. rubocop:disable Metrics/ClassLength
Instance Attribute Summary collapse
-
#call_sites ⇒ Object
readonly
Returns the value of attribute call_sites.
Instance Method Summary collapse
-
#initialize(file_path:, source:, semantic_index:) ⇒ ASTVisitor
constructor
A new instance of ASTVisitor.
- #visit(node) ⇒ Object
Constructor Details
#initialize(file_path:, source:, semantic_index:) ⇒ ASTVisitor
Returns a new instance of ASTVisitor.
117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 |
# File 'lib/fiber_audit/static/call_site_extractor.rb', line 117 def initialize(file_path:, source:, semantic_index:) @file_path = file_path @source = source @semantic_index = semantic_index @call_sites = [] # Scope tracking stacks @nesting_stack = [] # Array of constant names (class/module nesting) @scope_stack = [] # Array of [class_or_module, method_name, method_kind] @in_singleton_class = false # Track if inside `class << self` # Assignment tracking: local variable -> {constant:, confidence:} # Scoped per method; no ivars attached to Prism nodes. @assignment_scope = {} end |
Instance Attribute Details
#call_sites ⇒ Object (readonly)
Returns the value of attribute call_sites.
115 116 117 |
# File 'lib/fiber_audit/static/call_site_extractor.rb', line 115 def call_sites @call_sites end |
Instance Method Details
#visit(node) ⇒ Object
133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 |
# File 'lib/fiber_audit/static/call_site_extractor.rb', line 133 def visit(node) return unless node case node when Prism::ClassNode visit_class(node) when Prism::ModuleNode visit_module(node) when Prism::SingletonClassNode visit_singleton_class(node) when Prism::DefNode visit_def(node) when Prism::IfNode, Prism::UnlessNode, Prism::CaseNode visit_branching(node) when Prism::CallNode visit_call(node) when Prism::LocalVariableWriteNode, Prism::InstanceVariableWriteNode visit_assignment(node) else visit_children(node) end end |