Class: Rsense::Server::Listeners::WhereEventListener
- Inherits:
-
Object
- Object
- Rsense::Server::Listeners::WhereEventListener
- Includes:
- Java::org.cx4a.rsense::Project::EventListener
- Defined in:
- lib/rsense/server/listeners/where_event_listener.rb
Constant Summary collapse
- EventType =
Rsense::Typing::Graph::EventListener::EventType
- SourceLocation =
Rsense::Util::SourceLocation
Instance Attribute Summary collapse
-
#closest ⇒ Object
Returns the value of attribute closest.
-
#context ⇒ Object
Returns the value of attribute context.
-
#line ⇒ Object
Returns the value of attribute line.
-
#name ⇒ Object
Returns the value of attribute name.
Instance Method Summary collapse
-
#initialize(context) ⇒ WhereEventListener
constructor
A new instance of WhereEventListener.
- #prepare(line) ⇒ Object
- #update(event) ⇒ Object
Constructor Details
#initialize(context) ⇒ WhereEventListener
Returns a new instance of WhereEventListener.
17 18 19 |
# File 'lib/rsense/server/listeners/where_event_listener.rb', line 17 def initialize(context) @context = context end |
Instance Attribute Details
#closest ⇒ Object
Returns the value of attribute closest.
15 16 17 |
# File 'lib/rsense/server/listeners/where_event_listener.rb', line 15 def closest @closest end |
#context ⇒ Object
Returns the value of attribute context.
15 16 17 |
# File 'lib/rsense/server/listeners/where_event_listener.rb', line 15 def context @context end |
#line ⇒ Object
Returns the value of attribute line.
15 16 17 |
# File 'lib/rsense/server/listeners/where_event_listener.rb', line 15 def line @line end |
#name ⇒ Object
Returns the value of attribute name.
15 16 17 |
# File 'lib/rsense/server/listeners/where_event_listener.rb', line 15 def name @name end |
Instance Method Details
#prepare(line) ⇒ Object
21 22 23 |
# File 'lib/rsense/server/listeners/where_event_listener.rb', line 21 def prepare(line) @line = line end |
#update(event) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 |
# 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 |