Class: Solargraph::Source::Chain::Literal
- Defined in:
- lib/solargraph/source/chain/literal.rb
Constant Summary
Constants included from Logging
Logging::DEFAULT_LOG_LEVEL, Logging::LOG_LEVELS
Instance Attribute Summary collapse
-
#value ⇒ Object
readonly
Returns the value of attribute value.
-
#word ⇒ Object
readonly
Returns the value of attribute word.
Attributes inherited from Link
Instance Method Summary collapse
-
#initialize(type, node) ⇒ Literal
constructor
A new instance of Literal.
- #resolve(api_map, name_pin, locals) ⇒ Object
Methods inherited from Link
#clone_body, #clone_head, #constant?, #desc, #head?, #inspect, #nullable?, #to_s, #undefined?
Methods included from Logging
Methods included from Equality
Constructor Details
#initialize(type, node) ⇒ Literal
Returns a new instance of Literal.
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/solargraph/source/chain/literal.rb', line 13 def initialize type, node super("<#{type}>") # @todo We might be able to do some light inference from literals and # tuples as long as literal values are intransitive. # if node.is_a?(::Parser::AST::Node) # # @sg-ignore flow sensitive typing needs to narrow down type with an if is_a? check # if node.type == :true # @value = true # # @sg-ignore flow sensitive typing needs to narrow down type with an if is_a? check # elsif node.type == :false # @value = false # # @sg-ignore flow sensitive typing needs to narrow down type with an if is_a? check # elsif %i[int sym].include?(node.type) # # @sg-ignore flow sensitive typing needs to narrow down type with an if is_a? check # @value = node.children.first # end # end @type = type # @literal_type = ComplexType.try_parse(@value.inspect) @literal_type = ComplexType::UNDEFINED @complex_type = ComplexType.try_parse(type) end |
Instance Attribute Details
#value ⇒ Object (readonly)
Returns the value of attribute value.
9 10 11 |
# File 'lib/solargraph/source/chain/literal.rb', line 9 def value @value end |
#word ⇒ Object (readonly)
Returns the value of attribute word.
9 10 11 |
# File 'lib/solargraph/source/chain/literal.rb', line 9 def word @word end |
Instance Method Details
#resolve(api_map, name_pin, locals) ⇒ Object
44 45 46 47 48 49 50 51 |
# File 'lib/solargraph/source/chain/literal.rb', line 44 def resolve api_map, name_pin, locals if api_map.super_and_sub?(@complex_type.name, @literal_type.name) [Pin::ProxyType.anonymous(@literal_type, source: :chain)] else # we don't support this value as a literal type [Pin::ProxyType.anonymous(@complex_type, source: :chain)] end end |