sorbet_view 0.12.0 → 0.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/sorbet_view/cli/runner.rb +11 -0
- data/lib/sorbet_view/file_system/output_manager.rb +7 -0
- data/lib/sorbet_view/lsp/server.rb +14 -0
- data/lib/sorbet_view/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 0ddd4cdea781d69ee2a7201e5a1790b2d301e7b4594676062694e21b70ad0ccb
|
|
4
|
+
data.tar.gz: 7e5896931aba1f74b73f536fac8d17008e969c4867aa331334606e56cc26575c
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: '058e840d95cb4860d469f116e316f97d7ee624c8c7b5160bd77d36ce8f34b686d519187652a508d177853030d625ac120fc4e6c09d4805a64ac56818757e9030'
|
|
7
|
+
data.tar.gz: c08fcd9435a1529a84ef8a7c1be7ca020bc4678aefe109fbe1772a50a4caf988043383ff8092533fa7aa3ee1418fb3d29b96381cbbd7f3d3d887c2a640a6bff0
|
|
@@ -100,6 +100,8 @@ module SorbetView
|
|
|
100
100
|
templates = FileSystem::ProjectScanner.scan(config)
|
|
101
101
|
puts "Compiling #{templates.length} template(s)..."
|
|
102
102
|
|
|
103
|
+
compiled_ruby_paths = T.let(Set.new, T::Set[String])
|
|
104
|
+
|
|
103
105
|
templates.each do |path|
|
|
104
106
|
result = compiler.compile_file(path)
|
|
105
107
|
|
|
@@ -108,6 +110,7 @@ module SorbetView
|
|
|
108
110
|
end
|
|
109
111
|
|
|
110
112
|
output_manager.write(result)
|
|
113
|
+
compiled_ruby_paths << result.source_map.ruby_path
|
|
111
114
|
puts " #{path} -> #{result.source_map.ruby_path}"
|
|
112
115
|
end
|
|
113
116
|
|
|
@@ -119,11 +122,19 @@ module SorbetView
|
|
|
119
122
|
results = component_compiler.compile_file(path)
|
|
120
123
|
results.each do |result|
|
|
121
124
|
output_manager.write(result)
|
|
125
|
+
compiled_ruby_paths << result.source_map.ruby_path
|
|
122
126
|
puts " #{path} -> #{result.source_map.ruby_path}"
|
|
123
127
|
end
|
|
124
128
|
end
|
|
125
129
|
end
|
|
126
130
|
|
|
131
|
+
# Clean stale compiled files
|
|
132
|
+
stale = Dir.glob(File.join(config.output_dir, '**', '*.rb')).reject { |f| compiled_ruby_paths.include?(f) }
|
|
133
|
+
stale.each do |f|
|
|
134
|
+
File.delete(f)
|
|
135
|
+
puts " Removed stale: #{f}"
|
|
136
|
+
end
|
|
137
|
+
|
|
127
138
|
total_ms = (Process.clock_gettime(Process::CLOCK_MONOTONIC) - total_start) * 1000.0
|
|
128
139
|
puts "Done. (total: #{total_ms.round(1)}ms)"
|
|
129
140
|
Perf.report
|
|
@@ -31,6 +31,13 @@ module SorbetView
|
|
|
31
31
|
end
|
|
32
32
|
end
|
|
33
33
|
|
|
34
|
+
# Delete the compiled output for a given template path
|
|
35
|
+
sig { params(template_path: String).void }
|
|
36
|
+
def delete(template_path)
|
|
37
|
+
ruby_path = File.join(@output_dir, "#{template_path}.rb")
|
|
38
|
+
File.delete(ruby_path) if File.exist?(ruby_path)
|
|
39
|
+
end
|
|
40
|
+
|
|
34
41
|
sig { void }
|
|
35
42
|
def clean
|
|
36
43
|
FileUtils.rm_rf(@output_dir)
|
|
@@ -636,6 +636,8 @@ module SorbetView
|
|
|
636
636
|
removed.each do |path|
|
|
637
637
|
@logger.debug("File removed: #{path}")
|
|
638
638
|
@position_translator.unregister(path)
|
|
639
|
+
@output_manager.delete(path)
|
|
640
|
+
notify_sorbet_file_removed(path)
|
|
639
641
|
end
|
|
640
642
|
rescue => e
|
|
641
643
|
@logger.error("FileWatcher callback error: #{e.message}")
|
|
@@ -697,6 +699,18 @@ module SorbetView
|
|
|
697
699
|
end
|
|
698
700
|
end
|
|
699
701
|
|
|
702
|
+
sig { params(template_path: String).void }
|
|
703
|
+
def notify_sorbet_file_removed(template_path)
|
|
704
|
+
ruby_path = File.join(@config.output_dir, "#{template_path}.rb")
|
|
705
|
+
ruby_uri = @uri_mapper.path_to_uri(ruby_path)
|
|
706
|
+
return unless @sorbet_open_uris.include?(ruby_uri)
|
|
707
|
+
|
|
708
|
+
@sorbet.send_notification('textDocument/didClose', {
|
|
709
|
+
'textDocument' => { 'uri' => ruby_uri }
|
|
710
|
+
})
|
|
711
|
+
@sorbet_open_uris.delete(ruby_uri)
|
|
712
|
+
end
|
|
713
|
+
|
|
700
714
|
sig { params(message: T::Hash[String, T.untyped]).void }
|
|
701
715
|
def forward_to_sorbet(message)
|
|
702
716
|
@sorbet.forward(message)
|
data/lib/sorbet_view/version.rb
CHANGED