Class: RuboCop::AST::NodePattern::Compiler::Debug::Trace

Inherits:
Object
  • Object
show all
Defined in:
lib/rubocop/ast/node_pattern/compiler/debug.rb

Overview

Compiled node pattern requires a named parameter ‘trace`, which should be an instance of this class

Instance Method Summary collapse

Constructor Details

#initializeTrace



14
15
16
# File 'lib/rubocop/ast/node_pattern/compiler/debug.rb', line 14

def initialize
  @visit = {}
end

Instance Method Details

#enter(node_id) ⇒ Object

rubocop:disable Naming/PredicateMethod



19
20
21
22
# File 'lib/rubocop/ast/node_pattern/compiler/debug.rb', line 19

def enter(node_id)
  @visit[node_id] = false
  true
end

#matched?(node_id) ⇒ Boolean

return nil (not visited), false (not matched) or true (matched)



30
31
32
# File 'lib/rubocop/ast/node_pattern/compiler/debug.rb', line 30

def matched?(node_id)
  @visit[node_id]
end

#success(node_id) ⇒ Object

rubocop:enable Naming/PredicateMethod



25
26
27
# File 'lib/rubocop/ast/node_pattern/compiler/debug.rb', line 25

def success(node_id)
  @visit[node_id] = true
end