class Rsense::Server::Listeners::FindDefinitionEventListener
Constants
- EventType
- SourceLocation
Attributes
context[RW]
locations[RW]
prefix[RW]
Public Class Methods
counter()
click to toggle source
# File lib/rsense/server/listeners/find_definition_event_listener.rb, line 30 def self.counter old = @@counter @@counter += 1 return old end
new(context)
click to toggle source
# File lib/rsense/server/listeners/find_definition_event_listener.rb, line 19 def initialize(context) @context = context @@counter = 0 @locations = Set.new end
Public Instance Methods
check_vertex(vertex)
click to toggle source
# File lib/rsense/server/listeners/find_definition_event_listener.rb, line 83 def check_vertex(vertex) if @context.main && event.type == EventType::METHOD_MISSING if vertex && vertex.getName().startsWith(@prefix) && vertex.getReceiverVertex() return true end end end
getLocations()
click to toggle source
# File lib/rsense/server/listeners/find_definition_event_listener.rb, line 36 def getLocations @locations end
setup()
click to toggle source
# File lib/rsense/server/listeners/find_definition_event_listener.rb, line 25 def setup @locations.clear @prefix = Rsense::Server::Command::FIND_DEFINITION_METHOD_NAME_PREFIX + @@counter end
update(event)
click to toggle source
# File lib/rsense/server/listeners/find_definition_event_listener.rb, line 40 def update(event) vertex = event.vertex if check_vertex(vertex) realName = vertex.getName().substring(@prefix.length) receivers = vertex.getReceiverVertex().getTypeSet() receivers.each do |receiver| receiver_type = receiver.getMetaClass() if receiver_type location = nil method = receiver_type.search_method(realName) if method @locations.add(method.getLocation) if method.getLocation else klass = nil if receiver_type instance_of? Rsense::Ruby::MetaClass metaClass = receiver_type if metaClass.getAttached instance_of? Rsense::Ruby::RubyModule klass = metaClass.getAttached end else klass = @context.project.graph().getRuntime().getContext().getCurrentScope().getModule() end if klass constant = klass.getConstant(realName) if constant instance_of? Rsense::Typing::Runtime::VertexHolder location = SourceLocation.of(constant.getVertex().getNode()) elsif constant instance_of? Rsense::Ruby::RubyModule location = constant.getLocation() end end end if location @locations.add(location) end end end vertex.cutout() end end