Class: RDoc::Parser::PrismRuby::RDocVisitor::MethodSignatureVisitor

Inherits:
Prism::Visitor
  • Object
show all
Defined in:
lib/rdoc/parser/prism_ruby.rb

Overview

:nodoc:

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeMethodSignatureVisitor

Returns a new instance of MethodSignatureVisitor.



1002
1003
1004
1005
1006
# File 'lib/rdoc/parser/prism_ruby.rb', line 1002

def initialize
  @params = nil
  @calls_super = false
  @yields = []
end

Instance Attribute Details

#calls_superObject (readonly)

Returns the value of attribute calls_super.



1000
1001
1002
# File 'lib/rdoc/parser/prism_ruby.rb', line 1000

def calls_super
  @calls_super
end

#paramsObject (readonly)

Returns the value of attribute params.



1000
1001
1002
# File 'lib/rdoc/parser/prism_ruby.rb', line 1000

def params
  @params
end

#yieldsObject (readonly)

Returns the value of attribute yields.



1000
1001
1002
# File 'lib/rdoc/parser/prism_ruby.rb', line 1000

def yields
  @yields
end

Class Method Details

.scan_signature(def_node) ⇒ Object



991
992
993
994
995
996
997
# File 'lib/rdoc/parser/prism_ruby.rb', line 991

def scan_signature(def_node)
  visitor = new
  def_node.body&.accept(visitor)
  params = "(#{def_node.parameters&.slice})"
  block_params = visitor.yields.first
  [params, block_params, visitor.calls_super]
end

Instance Method Details

#visit_def_node(node) ⇒ Object



1008
1009
1010
# File 'lib/rdoc/parser/prism_ruby.rb', line 1008

def visit_def_node(node)
  # stop traverse inside nested def
end

#visit_forwarding_super_node(node) ⇒ Object



1021
1022
1023
# File 'lib/rdoc/parser/prism_ruby.rb', line 1021

def visit_forwarding_super_node(node)
  @calls_super = true
end

#visit_super_node(node) ⇒ Object



1016
1017
1018
1019
# File 'lib/rdoc/parser/prism_ruby.rb', line 1016

def visit_super_node(node)
  @calls_super = true
  super
end

#visit_yield_node(node) ⇒ Object



1012
1013
1014
# File 'lib/rdoc/parser/prism_ruby.rb', line 1012

def visit_yield_node(node)
  @yields << (node.arguments&.slice || '')
end