Class: Solargraph::Pin::Parameter

Inherits:
LocalVariable show all
Defined in:
lib/solargraph/pin/parameter.rb

Instance Attribute Summary

Attributes included from Localized

#presence

Attributes inherited from BaseVariable

#assignment

Attributes inherited from Base

#code_object, #kind, #location, #name, #path

Attributes included from Common

#closure, #location

Instance Method Summary collapse

Methods inherited from LocalVariable

#initialize, #kind

Methods included from Localized

#visible_at?, #visible_from?

Methods inherited from BaseVariable

#==, #completion_item_kind, #initialize, #nil_assignment?, #probe, #signature, #symbol_kind, #variable?

Methods included from Source::NodeMethods

const_from, drill_signature, get_node_end_position, get_node_start_position, infer_literal_node_type, pack_name, resolve_node_signature, returns_from, unpack_name

Methods inherited from Base

#==, #comments, #completion_item_kind, #deprecated?, #directives, #docstring, #filename, #infer, #initialize, #inspect, #macros, #maybe_directives?, #nearly?, #probe, #probed?, #proxied?, #proxy, #realize, #symbol_kind, #to_s, #variable?

Methods included from Conversions

#completion_item, #detail, #link_documentation, #reset_conversions, #resolve_completion_item, #signature_help

Methods included from Common

#binder, #comments, #context, #kind, #name, #namespace, #path

Constructor Details

This class inherits a constructor from Solargraph::Pin::LocalVariable

Instance Method Details

#documentationObject


34
35
36
37
38
# File 'lib/solargraph/pin/parameter.rb', line 34

def documentation
  tag = param_tag
  return '' if tag.nil? || tag.text.nil?
  tag.text
end

#indexInteger

The parameter's zero-based location in the block's signature.


17
18
19
# File 'lib/solargraph/pin/parameter.rb', line 17

def index
  closure.parameter_names.index(name)
end

#return_typeObject


4
5
6
7
8
9
10
11
12
# File 'lib/solargraph/pin/parameter.rb', line 4

def return_type
  if @return_type.nil?
    @return_type = ComplexType.new
    found = param_tag
    @return_type = ComplexType.try_parse(*found.types) unless found.nil? or found.types.nil?
  end
  super
  @return_type
end

#try_merge!(pin) ⇒ Object


27
28
29
30
31
32
# File 'lib/solargraph/pin/parameter.rb', line 27

def try_merge! pin
  return false unless super && closure.nearly?(pin.closure)
  @return_type = pin.return_type
  reset_conversions
  true
end

#typify(api_map) ⇒ Object


22
23
24
25
# File 'lib/solargraph/pin/parameter.rb', line 22

def typify api_map
  return return_type.qualify(api_map, closure.context.namespace) unless return_type.undefined?
  closure.is_a?(Pin::Block) ? typify_block_param(api_map) : typify_method_param(api_map)
end