Class: Solargraph::Source::Chain::Array

Inherits:
Literal show all
Defined in:
lib/solargraph/source/chain/array.rb

Instance Attribute Summary

Attributes inherited from Link

#last_context

Instance Method Summary collapse

Methods inherited from Link

#clone_body, #clone_head, #constant?, #desc, #head?, #inspect, #nullable?, #to_s, #undefined?

Methods included from Equality

#==, #eql?, #equality_fields, #freeze, #hash

Constructor Details

#initialize(children) ⇒ Array

Returns a new instance of Array.

Parameters:

  • children (::Array<Chain>)


6
7
8
9
# File 'lib/solargraph/source/chain/array.rb', line 6

def initialize children
  super('::Array')
  @children = children
end

Instance Method Details

#resolve(api_map, name_pin, locals) ⇒ Object

Parameters:



18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/solargraph/source/chain/array.rb', line 18

def resolve api_map, name_pin, locals
  child_types = @children.map do |child|
    child.infer(api_map, name_pin, locals)
  end

  type = if child_types.uniq.length == 1 && child_types.first.defined?
           ComplexType::UniqueType.new('Array', [], child_types.uniq, rooted: true, parameters_type: :list)
         else
           ComplexType::UniqueType.new('Array', rooted: true)
         end
  [Pin::ProxyType.anonymous(type)]
end

#wordObject



11
12
13
# File 'lib/solargraph/source/chain/array.rb', line 11

def word
  @word ||= "<#{@type}>"
end