Class: AppMap::Inspect::StaticMethodParseNode

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

Overview

A method defines as a :defs AST node. For example:

class Main

def Main.main_func; end
def explain
  some_func.tap do |s|
    def s.inspect; self; end
  end
end

end

Instance Attribute Summary

Attributes inherited from ParseNodeStruct

#ancestors, #file_path, #node

Class Method Summary collapse

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?

Class Method Details

.static?(node) ⇒ Boolean

Returns:

  • (Boolean)


130
131
132
# File 'lib/appmap/inspect/parse_node.rb', line 130

def static?(node)
  %i[self const].member?(node.children[0].type)
end

Instance Method Details

#class_nameObject

class_name is specified as nil if it should be inferred from the enclosing type.



141
142
143
144
145
146
147
148
149
150
# File 'lib/appmap/inspect/parse_node.rb', line 141

def class_name
  case (defs_type = node.children[0].type)
  when :self
    class_name_from_enclosing_type
  when :const
    class_name_from_declaration
  else
    raise "Unrecognized 'defs' method type : #{defs_type.inspect}"
  end
end

#nameObject



135
136
137
# File 'lib/appmap/inspect/parse_node.rb', line 135

def name
  node.children[1].to_s
end

#static?Boolean

Returns:

  • (Boolean)


152
153
154
# File 'lib/appmap/inspect/parse_node.rb', line 152

def static?
  true
end