Class: Solargraph::Source::Chain::Constant
- Defined in:
- lib/solargraph/source/chain/constant.rb
Instance Attribute Summary
Attributes inherited from Link
Instance Method Summary collapse
-
#initialize(word) ⇒ Constant
constructor
A new instance of Constant.
- #resolve(api_map, name_pin, locals) ⇒ Object
Methods inherited from Link
Constructor Details
#initialize(word) ⇒ Constant
Returns a new instance of Constant.
5 6 7 |
# File 'lib/solargraph/source/chain/constant.rb', line 5 def initialize word @word = word end |
Instance Method Details
#resolve(api_map, name_pin, locals) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/solargraph/source/chain/constant.rb', line 9 def resolve api_map, name_pin, locals return [Pin::ROOT_PIN] if word.empty? if word.start_with?('::') context = '' bottom = word[2..-1] else context = name_pin.context.namespace bottom = word end if bottom.include?('::') ns = bottom.split('::')[0..-2].join('::') else ns = '' end result = api_map.get_constants(ns, context) last_name = bottom.split('::').last result.select{ |p| p.name == last_name } end |