class Rsense::Server::Listeners::WhereEventListener
Constants
- EventType
- SourceLocation
Attributes
closest[RW]
context[RW]
line[RW]
name[RW]
Public Class Methods
new(context)
click to toggle source
# File lib/rsense/server/listeners/where_event_listener.rb, line 17 def initialize(context) @context = context end
Public Instance Methods
prepare(line)
click to toggle source
# File lib/rsense/server/listeners/where_event_listener.rb, line 21 def prepare(line) @line = line end
update(event)
click to toggle source
# File lib/rsense/server/listeners/where_event_listener.rb, line 25 def update(event) eligible = [ EventType::DEFINE, EventType::CLASS, EventType::MODULE ] if context.main && eligible.any? {|e| event.type == e} if event.name && event.node loc = SourceLocation.of(event.node) loc_line = loc.getLine() if loc && @line >= loc_line && @line - @closest > @line - loc_line @closest = loc_line @name = event.name end end end end