Class: RubyLsp::ParameterScope
- Inherits:
-
Object
- Object
- RubyLsp::ParameterScope
- Extended by:
- T::Sig
- Defined in:
- lib/ruby_lsp/parameter_scope.rb
Instance Attribute Summary collapse
-
#parent ⇒ Object
readonly
Returns the value of attribute parent.
Instance Method Summary collapse
- #<<(name) ⇒ Object
-
#initialize(parent = nil) ⇒ ParameterScope
constructor
A new instance of ParameterScope.
- #parameter?(name) ⇒ Boolean
- #type_for(name) ⇒ Object
Constructor Details
#initialize(parent = nil) ⇒ ParameterScope
Returns a new instance of ParameterScope.
12 13 14 15 |
# File 'lib/ruby_lsp/parameter_scope.rb', line 12 def initialize(parent = nil) @parent = parent @parameters = T.let(Set.new, T::Set[Symbol]) end |
Instance Attribute Details
#parent ⇒ Object (readonly)
Returns the value of attribute parent.
9 10 11 |
# File 'lib/ruby_lsp/parameter_scope.rb', line 9 def parent @parent end |
Instance Method Details
#<<(name) ⇒ Object
18 19 20 |
# File 'lib/ruby_lsp/parameter_scope.rb', line 18 def <<(name) @parameters << name.to_sym end |
#parameter?(name) ⇒ Boolean
28 29 30 31 |
# File 'lib/ruby_lsp/parameter_scope.rb', line 28 def parameter?(name) sym = name.to_sym @parameters.include?(sym) || (!@parent.nil? && @parent.parameter?(sym)) end |
#type_for(name) ⇒ Object
23 24 25 |
# File 'lib/ruby_lsp/parameter_scope.rb', line 23 def type_for(name) parameter?(name) ? :parameter : :variable end |