Class: AppMap::Inspect::InstanceMethodParseNode
- Inherits:
-
MethodParseNode
- Object
- Struct
- ParseNodeStruct
- ParseNode
- MethodParseNode
- AppMap::Inspect::InstanceMethodParseNode
- Defined in:
- lib/appmap/inspect/parse_node.rb
Overview
A method defines as a :def AST node.
Instance Attribute Summary
Attributes inherited from ParseNodeStruct
Instance Method Summary collapse
-
#class_name ⇒ Object
class_name should be inferred from the enclosing type.
- #name ⇒ Object
-
#static? ⇒ Boolean
An instance method defined in an sclass is a static method.
Methods inherited from MethodParseNode
Methods inherited from ParseNode
#enclosing_type_node, from_node, #parent_node, #preceding_sibling_nodes, #public?
Instance Method Details
#class_name ⇒ Object
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 |
#name ⇒ Object
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.
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 |