Class: AppMap::Inspect::InstanceMethodParseNode

Inherits:
MethodParseNode show all
Defined in:
lib/appmap/inspect/parse_node.rb

Overview

A method defines as a :def AST node.

Instance Attribute Summary

Attributes inherited from ParseNodeStruct

#ancestors, #file_path, #node

Instance Method Summary collapse

Methods inherited from MethodParseNode

#enclosing_names, #to_feature

Methods inherited from ParseNode

#enclosing_type_node, from_node, #parent_node, #preceding_sibling_nodes, #public?

Instance Method Details

#class_nameObject

class_name should be inferred from the enclosing type.



99
100
101
# File 'lib/appmap/inspect/parse_node.rb', line 99

def class_name
  enclosing_names.join('::')
end

#nameObject



94
95
96
# File 'lib/appmap/inspect/parse_node.rb', line 94

def name
  node.children[0].to_s
end

#static?Boolean

An instance method defined in an sclass is a static method.

TODO: Well, not strictly true. A singleton class can be defined on a class or on an instance. In fact, to Ruby a class method is really just an instance method on a class. So, this needs fixing to try and determine if the singleton class is defined on an instance or on a class. This may actually be hard (impossible?) to do from static parsing.

Returns:



110
111
112
113
114
# File 'lib/appmap/inspect/parse_node.rb', line 110

def static?
  result = ancestors[-1].type == :sclass ||
    (ancestors[-1].type == :begin && ancestors[-2] && ancestors[-2].type == :sclass)
  !!result
end