Class: RubyLanguageServer::ScopeData::Variable

Inherits:
Base
  • Object
show all
Defined in:
lib/ruby_language_server/scope_data/variable.rb

Constant Summary

Constants inherited from Base

Base::BLOCK_NAME, Base::JoinHash, Base::TYPE_BLOCK, Base::TYPE_CLASS, Base::TYPE_METHOD, Base::TYPE_MODULE, Base::TYPE_ROOT, Base::TYPE_VARIABLE

Instance Attribute Summary

Attributes inherited from Base

#type

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#method?

Class Method Details

.build(scope, name, line = 1, column = 1, type = TYPE_VARIABLE) ⇒ Object

attr_accessor :line # line attr_accessor :column # column attr_accessor :name # name attr_accessor :path # Module::Class name



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/ruby_language_server/scope_data/variable.rb', line 18

def self.build(scope, name, line = 1, column = 1, type = TYPE_VARIABLE)
  path = [scope.full_name, name].join(JoinHash[TYPE_VARIABLE])
  create!(
    line: line,
    column: column,
    name: name,
    path: path,
    variable_type: type
  )
  # @name = name
  # @line = line
  # @column = column
  # @full_name =
  # @type = type
  # raise "bogus variable #{inspect}" unless @name.instance_of? String
end

Instance Method Details

#constant?Boolean

Returns:

  • (Boolean)


35
36
37
# File 'lib/ruby_language_server/scope_data/variable.rb', line 35

def constant?
  !name&.match(/^[A-Z]/).nil?
end

#top_lineObject

Convenience for tags



40
41
42
# File 'lib/ruby_language_server/scope_data/variable.rb', line 40

def top_line
  line
end