Module: Holistic::Ruby::Scope::Store

Extended by:
Store
Included in:
Store
Defined in:
lib/holistic/ruby/scope/store.rb

Instance Method Summary collapse

Instance Method Details

#call(database:, lexical_parent:, kind:, name:, location:) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/holistic/ruby/scope/store.rb', line 7

def call(database:, lexical_parent:, kind:, name:, location:)
  fully_qualified_name = build_fully_qualified_name(lexical_parent:, kind:, name:)

  scope = database.find(fully_qualified_name)

  if scope.nil?
    record = Record.new(fully_qualified_name, { fully_qualified_name:, name:, kind:, locations: Location::Collection.new(name) })

    scope = database.store(fully_qualified_name, record)
  end

  scope.locations << location

  scope.relation(:lexical_parent).add!(lexical_parent)
  scope.relation(:scope_defined_in_file).add!(location.declaration.file)

  scope
end