holistic-ruby 0.1.4 → 0.1.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +5 -5
- data/exe/holistic-ruby +0 -1
- data/lib/holistic/application.rb +12 -4
- data/lib/holistic/database/migrations.rb +23 -0
- data/lib/holistic/database/node.rb +37 -0
- data/lib/holistic/database/relation.rb +21 -0
- data/lib/holistic/database.rb +57 -0
- data/lib/holistic/document/file/record.rb +10 -0
- data/lib/holistic/document/file/repository.rb +24 -0
- data/lib/holistic/document/file/store.rb +13 -0
- data/lib/holistic/document/location.rb +4 -6
- data/lib/holistic/document/unsaved/record.rb +12 -3
- data/lib/holistic/extensions/ruby/stdlib.rb +8 -8
- data/lib/holistic/language_server/requests/lifecycle/initialize.rb +5 -10
- data/lib/holistic/language_server/requests/text_document/completion.rb +16 -5
- data/lib/holistic/language_server/requests/text_document/did_close.rb +5 -9
- data/lib/holistic/language_server/requests/text_document/did_open.rb +1 -0
- data/lib/holistic/language_server/requests/text_document/did_save.rb +5 -9
- data/lib/holistic/language_server/requests/text_document/find_references.rb +7 -4
- data/lib/holistic/language_server/requests/text_document/go_to_definition.rb +3 -2
- data/lib/holistic/language_server/stdio/parser.rb +2 -2
- data/lib/holistic/language_server/stdio/start.rb +1 -1
- data/lib/holistic/ruby/autocompletion/suggest.rb +45 -25
- data/lib/holistic/ruby/parser/constant_resolution.rb +11 -11
- data/lib/holistic/ruby/parser/live_editing/process_file_changed.rb +23 -23
- data/lib/holistic/ruby/parser/program_visitor.rb +62 -29
- data/lib/holistic/ruby/parser.rb +51 -11
- data/lib/holistic/ruby/reference/delete.rb +18 -0
- data/lib/holistic/ruby/reference/find_referenced_scope.rb +2 -2
- data/lib/holistic/ruby/reference/record.rb +15 -8
- data/lib/holistic/ruby/reference/repository.rb +19 -41
- data/lib/holistic/ruby/reference/store.rb +29 -0
- data/lib/holistic/ruby/scope/delete.rb +29 -0
- data/lib/holistic/ruby/scope/lexical.rb +11 -0
- data/lib/holistic/ruby/scope/list_class_methods.rb +19 -0
- data/lib/holistic/ruby/scope/list_instance_methods.rb +19 -0
- data/lib/holistic/ruby/scope/list_references.rb +3 -3
- data/lib/holistic/ruby/scope/location.rb +9 -9
- data/lib/holistic/ruby/scope/outline.rb +10 -10
- data/lib/holistic/ruby/scope/record.rb +20 -50
- data/lib/holistic/ruby/scope/repository.rb +29 -26
- data/lib/holistic/ruby/scope/store.rb +45 -0
- data/lib/holistic/ruby/type_inference/clue/method_call.rb +1 -0
- data/lib/holistic/ruby/type_inference/clue/reference_to_superclass.rb +9 -0
- data/lib/holistic/ruby/type_inference/clue/scope_reference.rb +1 -0
- data/lib/holistic/ruby/type_inference/processing_queue.rb +28 -0
- data/lib/holistic/ruby/type_inference/resolver/class_method.rb +9 -0
- data/lib/holistic/ruby/type_inference/resolver/instance_method.rb +9 -0
- data/lib/holistic/ruby/type_inference/resolver/scope.rb +24 -0
- data/lib/holistic/ruby/type_inference/solve.rb +25 -69
- data/lib/holistic/ruby/type_inference/solve_pending_references.rb +3 -1
- data/lib/holistic/version.rb +1 -1
- metadata +21 -10
- data/lib/holistic/database/table.rb +0 -78
- data/lib/holistic/document/file.rb +0 -36
- data/lib/holistic/ruby/parser/table_of_contents.rb +0 -17
- data/lib/holistic/ruby/reference/register.rb +0 -15
- data/lib/holistic/ruby/reference/unregister.rb +0 -11
- data/lib/holistic/ruby/scope/register.rb +0 -31
- data/lib/holistic/ruby/scope/unregister.rb +0 -27
- data/lib/holistic/ruby/type_inference/conclusion.rb +0 -20
@@ -5,7 +5,9 @@ module Holistic::Ruby::TypeInference
|
|
5
5
|
extend self
|
6
6
|
|
7
7
|
def call(application:)
|
8
|
-
application.
|
8
|
+
until application.type_inference_processing_queue.empty?
|
9
|
+
reference = application.type_inference_processing_queue.pop
|
10
|
+
|
9
11
|
Solve.call(application:, reference:)
|
10
12
|
end
|
11
13
|
end
|
data/lib/holistic/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: holistic-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Luiz Vasconcellos
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-09-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: syntax_tree
|
@@ -73,9 +73,14 @@ files:
|
|
73
73
|
- lib/holistic.rb
|
74
74
|
- lib/holistic/application.rb
|
75
75
|
- lib/holistic/background_process.rb
|
76
|
-
- lib/holistic/database
|
76
|
+
- lib/holistic/database.rb
|
77
|
+
- lib/holistic/database/migrations.rb
|
78
|
+
- lib/holistic/database/node.rb
|
79
|
+
- lib/holistic/database/relation.rb
|
77
80
|
- lib/holistic/document/cursor.rb
|
78
|
-
- lib/holistic/document/file.rb
|
81
|
+
- lib/holistic/document/file/record.rb
|
82
|
+
- lib/holistic/document/file/repository.rb
|
83
|
+
- lib/holistic/document/file/store.rb
|
79
84
|
- lib/holistic/document/location.rb
|
80
85
|
- lib/holistic/document/unsaved/change.rb
|
81
86
|
- lib/holistic/document/unsaved/collection.rb
|
@@ -110,23 +115,29 @@ files:
|
|
110
115
|
- lib/holistic/ruby/parser/live_editing/process_file_changed.rb
|
111
116
|
- lib/holistic/ruby/parser/nesting_syntax.rb
|
112
117
|
- lib/holistic/ruby/parser/program_visitor.rb
|
113
|
-
- lib/holistic/ruby/
|
118
|
+
- lib/holistic/ruby/reference/delete.rb
|
114
119
|
- lib/holistic/ruby/reference/find_referenced_scope.rb
|
115
120
|
- lib/holistic/ruby/reference/record.rb
|
116
|
-
- lib/holistic/ruby/reference/register.rb
|
117
121
|
- lib/holistic/ruby/reference/repository.rb
|
118
|
-
- lib/holistic/ruby/reference/
|
122
|
+
- lib/holistic/ruby/reference/store.rb
|
123
|
+
- lib/holistic/ruby/scope/delete.rb
|
119
124
|
- lib/holistic/ruby/scope/kind.rb
|
125
|
+
- lib/holistic/ruby/scope/lexical.rb
|
126
|
+
- lib/holistic/ruby/scope/list_class_methods.rb
|
127
|
+
- lib/holistic/ruby/scope/list_instance_methods.rb
|
120
128
|
- lib/holistic/ruby/scope/list_references.rb
|
121
129
|
- lib/holistic/ruby/scope/location.rb
|
122
130
|
- lib/holistic/ruby/scope/outline.rb
|
123
131
|
- lib/holistic/ruby/scope/record.rb
|
124
|
-
- lib/holistic/ruby/scope/register.rb
|
125
132
|
- lib/holistic/ruby/scope/repository.rb
|
126
|
-
- lib/holistic/ruby/scope/
|
133
|
+
- lib/holistic/ruby/scope/store.rb
|
127
134
|
- lib/holistic/ruby/type_inference/clue/method_call.rb
|
135
|
+
- lib/holistic/ruby/type_inference/clue/reference_to_superclass.rb
|
128
136
|
- lib/holistic/ruby/type_inference/clue/scope_reference.rb
|
129
|
-
- lib/holistic/ruby/type_inference/
|
137
|
+
- lib/holistic/ruby/type_inference/processing_queue.rb
|
138
|
+
- lib/holistic/ruby/type_inference/resolver/class_method.rb
|
139
|
+
- lib/holistic/ruby/type_inference/resolver/instance_method.rb
|
140
|
+
- lib/holistic/ruby/type_inference/resolver/scope.rb
|
130
141
|
- lib/holistic/ruby/type_inference/solve.rb
|
131
142
|
- lib/holistic/ruby/type_inference/solve_pending_references.rb
|
132
143
|
- lib/holistic/version.rb
|
@@ -1,78 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
class Holistic::Database::Table
|
4
|
-
attr_reader :primary_attribute, :primary_index, :secondary_indices
|
5
|
-
|
6
|
-
def initialize(primary_attribute:, indices: [])
|
7
|
-
@primary_attribute = primary_attribute
|
8
|
-
|
9
|
-
@primary_index = ::Hash.new
|
10
|
-
|
11
|
-
@secondary_indices = indices.map do |attribute_name|
|
12
|
-
[attribute_name, ::Hash.new { |hash, key| hash[key] = ::Set.new }]
|
13
|
-
end.to_h
|
14
|
-
end
|
15
|
-
|
16
|
-
RecordNotUniqueError = ::Class.new(::StandardError)
|
17
|
-
|
18
|
-
def insert(record)
|
19
|
-
primary_key = record.fetch(primary_attribute)
|
20
|
-
|
21
|
-
if primary_index.key?(primary_key)
|
22
|
-
raise RecordNotUniqueError, "record already inserted: #{record.inspect}"
|
23
|
-
end
|
24
|
-
|
25
|
-
primary_index[primary_key] = record
|
26
|
-
|
27
|
-
secondary_indices.each do |attribute_name, secondary_index|
|
28
|
-
Array(record[attribute_name]).each do |value|
|
29
|
-
secondary_index[value].add(primary_key)
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
def find(identifier)
|
35
|
-
primary_index[identifier]
|
36
|
-
end
|
37
|
-
|
38
|
-
def filter(name, value)
|
39
|
-
return [] unless secondary_indices[name].key?(value)
|
40
|
-
|
41
|
-
secondary_indices.dig(name, value).to_a.map { find(_1) }
|
42
|
-
end
|
43
|
-
|
44
|
-
def update(record)
|
45
|
-
primary_key = record.fetch(primary_attribute)
|
46
|
-
|
47
|
-
delete(primary_key)
|
48
|
-
|
49
|
-
insert(record)
|
50
|
-
end
|
51
|
-
|
52
|
-
def delete(primary_key)
|
53
|
-
record = find(primary_key)
|
54
|
-
|
55
|
-
return if record.nil?
|
56
|
-
|
57
|
-
primary_index.delete(primary_key)
|
58
|
-
|
59
|
-
secondary_indices.each do |attribute_name, index_data|
|
60
|
-
Array(record[attribute_name]).each do |value|
|
61
|
-
index_data[value].delete(primary_key)
|
62
|
-
index_data.delete(value) if index_data[value].empty?
|
63
|
-
end
|
64
|
-
end
|
65
|
-
|
66
|
-
record
|
67
|
-
end
|
68
|
-
|
69
|
-
concerning :TestHelpers do
|
70
|
-
def all
|
71
|
-
primary_index.values
|
72
|
-
end
|
73
|
-
|
74
|
-
def size
|
75
|
-
primary_index.size
|
76
|
-
end
|
77
|
-
end
|
78
|
-
end
|
@@ -1,36 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Holistic::Document
|
4
|
-
class File
|
5
|
-
attr_reader :path
|
6
|
-
|
7
|
-
def initialize(path:)
|
8
|
-
@path = path
|
9
|
-
end
|
10
|
-
|
11
|
-
def read
|
12
|
-
::File.read(path)
|
13
|
-
end
|
14
|
-
|
15
|
-
def write(content)
|
16
|
-
::File.write(path, content)
|
17
|
-
end
|
18
|
-
|
19
|
-
class Fake
|
20
|
-
attr_reader :path
|
21
|
-
|
22
|
-
def initialize(path:, content:)
|
23
|
-
@path = path
|
24
|
-
@content = content
|
25
|
-
end
|
26
|
-
|
27
|
-
def read
|
28
|
-
@content
|
29
|
-
end
|
30
|
-
|
31
|
-
def write(content)
|
32
|
-
@content = content
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
@@ -1,17 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Holistic::Ruby::Parser
|
4
|
-
# TODO: move to an attibute of the scope
|
5
|
-
class TableOfContents
|
6
|
-
attr_reader :records
|
7
|
-
|
8
|
-
def initialize
|
9
|
-
@records = Hash.new { |hash, key| hash[key] = {} }
|
10
|
-
end
|
11
|
-
|
12
|
-
def register(scope:, name:, clue:)
|
13
|
-
@records[scope.fully_qualified_name][name] ||= []
|
14
|
-
@records[scope.fully_qualified_name][name] << clue
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
@@ -1,15 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Holistic::Ruby::Reference
|
4
|
-
module Register
|
5
|
-
extend self
|
6
|
-
|
7
|
-
def call(repository:, scope:, clues:, location:)
|
8
|
-
conclusion = ::Holistic::Ruby::TypeInference::Conclusion.pending
|
9
|
-
|
10
|
-
reference = ::Holistic::Ruby::Reference::Record.new(scope:, clues:, location:, conclusion:)
|
11
|
-
|
12
|
-
repository.register_reference(reference)
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
@@ -1,31 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Holistic::Ruby::Scope
|
4
|
-
module Register
|
5
|
-
extend self
|
6
|
-
|
7
|
-
def call(repository:, parent:, kind:, name:, location:)
|
8
|
-
child_scope = append_location_to_existing_scope(scope: parent, name:, location:) || add_new_scope(parent:, kind:, name:, location:)
|
9
|
-
|
10
|
-
repository.register_scope(child_scope)
|
11
|
-
|
12
|
-
child_scope
|
13
|
-
end
|
14
|
-
|
15
|
-
private
|
16
|
-
|
17
|
-
def append_location_to_existing_scope(scope:, name:, location:)
|
18
|
-
child_scope = scope.children.find { _1.name == name }
|
19
|
-
|
20
|
-
return if child_scope.nil?
|
21
|
-
|
22
|
-
child_scope.tap { _1.locations << location }
|
23
|
-
end
|
24
|
-
|
25
|
-
def add_new_scope(parent:, kind:, name:, location:)
|
26
|
-
child_scope = Record.new(kind:, name:, parent:, location:)
|
27
|
-
|
28
|
-
child_scope.tap { parent.children << _1 }
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
@@ -1,27 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Holistic::Ruby::Scope
|
4
|
-
module Unregister
|
5
|
-
extend self
|
6
|
-
|
7
|
-
def call(repository:, fully_qualified_name:, file_path:)
|
8
|
-
scope = repository.find_by_fully_qualified_name(fully_qualified_name)
|
9
|
-
|
10
|
-
return :scope_not_found if scope.nil?
|
11
|
-
|
12
|
-
updated_locations = scope.locations.reject! { |scope_location| scope_location.declaration.file_path == file_path }
|
13
|
-
|
14
|
-
return :scope_not_defined_in_speciefied_file if updated_locations.nil?
|
15
|
-
|
16
|
-
if updated_locations.empty?
|
17
|
-
scope.parent.children.delete(scope)
|
18
|
-
|
19
|
-
repository.delete_by_fully_qualified_name(fully_qualified_name)
|
20
|
-
else
|
21
|
-
repository.register_scope(scope)
|
22
|
-
end
|
23
|
-
|
24
|
-
:definition_unregistered
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
@@ -1,20 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Holistic::Ruby::TypeInference
|
4
|
-
STATUS_PENDING = :pending
|
5
|
-
STATUS_DONE = :done
|
6
|
-
|
7
|
-
Conclusion = ::Data.define(:status, :dependency_identifier) do
|
8
|
-
def self.pending
|
9
|
-
new(status: STATUS_PENDING, dependency_identifier: nil)
|
10
|
-
end
|
11
|
-
|
12
|
-
def self.unresolved
|
13
|
-
new(status: STATUS_DONE, dependency_identifier: nil)
|
14
|
-
end
|
15
|
-
|
16
|
-
def self.done(dependency_identifier)
|
17
|
-
new(status: STATUS_DONE, dependency_identifier:)
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|