Class: RubyLsp::ParameterScope

Inherits:
Object
  • Object
show all
Extended by:
T::Sig
Defined in:
lib/ruby_lsp/parameter_scope.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#parentObject (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

Returns:

  • (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