lib/analyst/entities/module.rb in analyst-0.14.2 vs lib/analyst/entities/module.rb in analyst-0.15.0
- old
+ new
@@ -1,33 +1,30 @@
module Analyst
module Entities
class Module < Entity
+ handles_node :module
+
+ def kind
+ "Module"
+ end
+
def name
- const_node_array(name_node).join('::')
+ name_entity.name
end
def full_name
parent.full_name.empty? ? name : parent.full_name + '::' + name
end
private
- def name_node
- ast.children.first
+ def name_entity
+ @name_entity ||= process_node(name_node)
end
- # takes a (const) node and returns an array specifying the fully-qualified
- # constant name that it represents. ya know, so CoolModule::SubMod::SweetClass
- # would be parsed to:
- # (const
- # (const
- # (const nil :CoolModule) :SubMod) :SweetClass)
- # and passing that node here would return [:CoolModule, :SubMod, :SweetClass]
- def const_node_array(node)
- return [] if node.nil?
- raise "expected (const) node or nil, got (#{node.type})" unless node.type == :const
- const_node_array(node.children.first) << node.children[1]
+ def name_node
+ ast.children.first
end
end
end
end