Class: Solargraph::Source::Chain::Or

Inherits:
Link
  • Object
show all
Defined in:
lib/solargraph/source/chain/or.rb

Constant Summary

Constants included from Logging

Logging::DEFAULT_LOG_LEVEL, Logging::LOG_LEVELS

Instance Attribute Summary collapse

Attributes inherited from Link

#last_context, #word

Instance Method Summary collapse

Methods inherited from Link

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

Methods included from Logging

log_level, logger

Methods included from Equality

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

Constructor Details

#initialize(links) ⇒ Or

Returns a new instance of Or.

Parameters:



10
11
12
13
14
# File 'lib/solargraph/source/chain/or.rb', line 10

def initialize links
  super('<or>')

  @links = links
end

Instance Attribute Details

Returns the value of attribute links.



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

def links
  @links
end

Instance Method Details

#resolve(api_map, name_pin, locals) ⇒ Object



16
17
18
19
20
21
22
23
24
25
# File 'lib/solargraph/source/chain/or.rb', line 16

def resolve api_map, name_pin, locals
  types = @links.map { |link| link.infer(api_map, name_pin, locals) }
  combined_type = Solargraph::ComplexType.new(types)
  unless types.all?(&:nullable?)
    # @sg-ignore flow sensitive typing should be able to handle redefinition
    combined_type = combined_type.without_nil
  end

  [Solargraph::Pin::ProxyType.anonymous(combined_type, source: :chain)]
end