hind 0.1.12 → 0.1.14
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/hind/cli.rb +35 -25
- data/lib/hind/lsif/generator.rb +21 -19
- data/lib/hind/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: edc5339a6fe71b30f48781500d996901bef7732b5d6ed6a54ce561d057edce19
|
4
|
+
data.tar.gz: 8dd64ea610eaf53314e918d91846d42839b522550e2b29a2a626228f7c459fbd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d85651252a56a48c32c3285205cea32d0aa99e8098b396168cb1bf3357b61a9deff6ef90ceecee3b891761205bcb1d420235d4859b780629555080c040d9b25e
|
7
|
+
data.tar.gz: e69fa976556441508e1f46f7bb2636989a3cb810922636b1e460e3fa68130c7dc60538e55609349365506bf3fe21807a379c4afd5f54f4272582f02071164eef
|
data/lib/hind/cli.rb
CHANGED
@@ -49,22 +49,6 @@ module Hind
|
|
49
49
|
}
|
50
50
|
)
|
51
51
|
|
52
|
-
# Create file content map with relative paths
|
53
|
-
file_contents = {}
|
54
|
-
files.each do |file|
|
55
|
-
absolute_path = File.expand_path(file)
|
56
|
-
relative_path = Pathname.new(absolute_path)
|
57
|
-
.relative_path_from(Pathname.new(generator.metadata[:projectRoot]))
|
58
|
-
.to_s
|
59
|
-
|
60
|
-
begin
|
61
|
-
file_contents[relative_path] = File.read(absolute_path)
|
62
|
-
rescue => e
|
63
|
-
warn "Warning: Failed to read file '#{file}': #{e.message}"
|
64
|
-
next
|
65
|
-
end
|
66
|
-
end
|
67
|
-
|
68
52
|
File.open(options[:output], 'w') do |output_file|
|
69
53
|
say 'First pass: Collecting declarations...', :cyan if options[:verbose]
|
70
54
|
|
@@ -76,28 +60,54 @@ module Hind
|
|
76
60
|
end
|
77
61
|
|
78
62
|
# First pass: Process all files to collect declarations
|
79
|
-
declaration_data =
|
63
|
+
declaration_data = {}
|
64
|
+
files.each do |file|
|
65
|
+
absolute_path = File.expand_path(file)
|
66
|
+
relative_path = Pathname.new(absolute_path)
|
67
|
+
.relative_path_from(Pathname.new(generator.metadata[:projectRoot]))
|
68
|
+
.to_s
|
69
|
+
|
70
|
+
begin
|
71
|
+
content = File.read(absolute_path)
|
72
|
+
file_declaration_data = generator.collect_file_declarations(content, relative_path)
|
73
|
+
declaration_data.merge!(file_declaration_data)
|
74
|
+
rescue => e
|
75
|
+
warn "Warning: Failed to read file '#{file}': #{e.message}"
|
76
|
+
next
|
77
|
+
end
|
78
|
+
end
|
80
79
|
|
81
|
-
say "Found #{declaration_data[:declarations]
|
80
|
+
say "Found #{declaration_data[:declarations]&.size} declarations (classes, modules, constants)", :cyan if options[:verbose]
|
82
81
|
|
83
82
|
# Write declaration LSIF data next
|
84
|
-
if declaration_data[:lsif_data]
|
83
|
+
if declaration_data[:lsif_data].any?
|
85
84
|
output_file.puts(declaration_data[:lsif_data].map(&:to_json).join("\n"))
|
86
85
|
end
|
87
86
|
|
88
87
|
say 'Processing files for references...', :cyan if options[:verbose]
|
89
88
|
|
90
89
|
# Second pass: Process each file for references
|
91
|
-
|
90
|
+
files.each do |file|
|
91
|
+
absolute_path = File.expand_path(file)
|
92
|
+
relative_path = Pathname.new(absolute_path)
|
93
|
+
.relative_path_from(Pathname.new(generator.metadata[:projectRoot]))
|
94
|
+
.to_s
|
95
|
+
|
92
96
|
if options[:verbose]
|
93
97
|
say "Processing file: #{relative_path}", :cyan
|
94
98
|
end
|
95
99
|
|
96
|
-
|
97
|
-
content
|
98
|
-
|
99
|
-
|
100
|
-
|
100
|
+
begin
|
101
|
+
content = File.read(absolute_path)
|
102
|
+
reference_lsif_data = generator.process_file(
|
103
|
+
content: content,
|
104
|
+
uri: relative_path
|
105
|
+
)
|
106
|
+
output_file.puts(reference_lsif_data.map(&:to_json).join("\n"))
|
107
|
+
rescue => e
|
108
|
+
warn "Warning: Failed to read file '#{file}': #{e.message}"
|
109
|
+
next
|
110
|
+
end
|
101
111
|
end
|
102
112
|
end
|
103
113
|
end
|
data/lib/hind/lsif/generator.rb
CHANGED
@@ -32,24 +32,22 @@ module Hind
|
|
32
32
|
initialize_project if metadata[:initial]
|
33
33
|
end
|
34
34
|
|
35
|
-
def
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
warn "Warning: Failed to collect declarations from '#{path}': #{e.message}"
|
49
|
-
end
|
35
|
+
def collect_file_declarations(content, path)
|
36
|
+
@current_uri = path
|
37
|
+
@document_id = nil
|
38
|
+
@current_document_id = nil
|
39
|
+
|
40
|
+
begin
|
41
|
+
ast = Parser.new(content).parse
|
42
|
+
setup_document
|
43
|
+
visitor = DeclarationVisitor.new(self, path)
|
44
|
+
visitor.visit(ast)
|
45
|
+
finalize_document_state
|
46
|
+
rescue => e
|
47
|
+
warn "Warning: Failed to collect declarations from '#{path}': #{e.message}"
|
50
48
|
end
|
51
49
|
|
52
|
-
# Store the last used vertex ID and
|
50
|
+
# Store the last used vertex ID and reference index
|
53
51
|
@last_vertex_id = @vertex_id
|
54
52
|
@last_reference_index = @lsif_data.length
|
55
53
|
|
@@ -98,12 +96,12 @@ module Hind
|
|
98
96
|
setup_document if @document_id.nil?
|
99
97
|
current_doc_id = @document_id
|
100
98
|
|
101
|
-
range_id = if declaration[:type] == :
|
99
|
+
range_id = if declaration[:type] == :constant
|
102
100
|
create_range(declaration[:node].name_loc)
|
103
101
|
elsif declaration[:type] == :module
|
104
|
-
create_range(declaration[:node].
|
102
|
+
create_range(declaration[:node].constant_path.location)
|
105
103
|
elsif declaration[:type] == :class
|
106
|
-
create_range(declaration[:node].constant_path)
|
104
|
+
create_range(declaration[:node].constant_path.location)
|
107
105
|
else
|
108
106
|
create_range(declaration[:node].location)
|
109
107
|
end
|
@@ -153,6 +151,10 @@ module Hind
|
|
153
151
|
|
154
152
|
@global_state.add_reference(reference[:name], @current_uri, range_id, current_doc_id)
|
155
153
|
emit_edge('next', range_id, declaration[:result_set_id])
|
154
|
+
|
155
|
+
reference_result = emit_vertex('referenceResult')
|
156
|
+
emit_edge('textDocument/references', declaration[:result_set_id], reference_result)
|
157
|
+
emit_edge('item', reference_result, [range_id], 'references', @document_id)
|
156
158
|
end
|
157
159
|
|
158
160
|
private
|
data/lib/hind/version.rb
CHANGED