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



15
16
17
18
19
20
21
22
23
24
# File 'lib/ruby_language_server/scope_data/variable.rb', line 15

def self.build(scope, name, line = 1, column = 1, type = TYPE_VARIABLE)
  path = [scope.full_name, name].join(JoinHash[TYPE_VARIABLE])
  create!(
    line:,
    column:,
    name:,
    path:,
    variable_type: type
  )
end

Instance Method Details

#constant?Boolean

Returns:

  • (Boolean)


26
27
28
# File 'lib/ruby_language_server/scope_data/variable.rb', line 26

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

#top_lineObject

Convenience for tags



31
32
33
# File 'lib/ruby_language_server/scope_data/variable.rb', line 31

def top_line
  line
end