Class: Holistic::Ruby::Reference::Repository
- Inherits:
-
Object
- Object
- Holistic::Ruby::Reference::Repository
- Defined in:
- lib/holistic/ruby/reference/repository.rb
Constant Summary collapse
- INDICES =
[ :file_path, :type_inference_status, :referenced_scope_fully_qualified_name ].freeze
Instance Attribute Summary collapse
-
#table ⇒ Object
readonly
Returns the value of attribute table.
Instance Method Summary collapse
- #delete(identifier) ⇒ Object
- #find_by_cursor(cursor) ⇒ Object
-
#initialize ⇒ Repository
constructor
A new instance of Repository.
- #list_references_in_file(file_path) ⇒ Object
- #list_references_pending_type_inference_conclusion ⇒ Object
- #list_references_to(fully_qualified_scope_name) ⇒ Object
- #list_references_to_scopes_in_file(scopes:, file_path:) ⇒ Object
- #register_reference(reference) ⇒ Object
Constructor Details
#initialize ⇒ Repository
Returns a new instance of Repository.
13 14 15 |
# File 'lib/holistic/ruby/reference/repository.rb', line 13 def initialize @table = ::Holistic::Database::Table.new(primary_attribute: :identifier, indices: INDICES) end |
Instance Attribute Details
#table ⇒ Object (readonly)
Returns the value of attribute table.
5 6 7 |
# File 'lib/holistic/ruby/reference/repository.rb', line 5 def table @table end |
Instance Method Details
#delete(identifier) ⇒ Object
53 54 55 |
# File 'lib/holistic/ruby/reference/repository.rb', line 53 def delete(identifier) table.delete(identifier) end |
#find_by_cursor(cursor) ⇒ Object
27 28 29 30 31 32 33 |
# File 'lib/holistic/ruby/reference/repository.rb', line 27 def find_by_cursor(cursor) table.filter(:file_path, cursor.file_path).map { _1[:reference] }.each do |reference| return reference if reference.location.contains?(cursor) end nil end |
#list_references_in_file(file_path) ⇒ Object
39 40 41 |
# File 'lib/holistic/ruby/reference/repository.rb', line 39 def list_references_in_file(file_path) table.filter(:file_path, file_path).map { _1[:reference] } end |
#list_references_pending_type_inference_conclusion ⇒ Object
49 50 51 |
# File 'lib/holistic/ruby/reference/repository.rb', line 49 def list_references_pending_type_inference_conclusion table.filter(:type_inference_status, ::Holistic::Ruby::TypeInference::STATUS_PENDING).map { _1[:reference] } end |
#list_references_to(fully_qualified_scope_name) ⇒ Object
35 36 37 |
# File 'lib/holistic/ruby/reference/repository.rb', line 35 def list_references_to(fully_qualified_scope_name) table.filter(:referenced_scope_fully_qualified_name, fully_qualified_scope_name).map { _1[:reference] } end |
#list_references_to_scopes_in_file(scopes:, file_path:) ⇒ Object
43 44 45 46 47 |
# File 'lib/holistic/ruby/reference/repository.rb', line 43 def list_references_to_scopes_in_file(scopes:, file_path:) scopes.list_scopes_in_file(file_path).flat_map do |scope| table.filter(:referenced_scope_fully_qualified_name, scope.fully_qualified_name).map { _1[:reference] } end end |
#register_reference(reference) ⇒ Object
17 18 19 20 21 22 23 24 25 |
# File 'lib/holistic/ruby/reference/repository.rb', line 17 def register_reference(reference) table.update({ reference:, identifier: reference.identifier, file_path: reference.location.file_path, type_inference_status: reference.conclusion.status, referenced_scope_fully_qualified_name: reference.conclusion.dependency_identifier }) end |