hind 0.1.7 → 0.1.9
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 +20 -3
- data/lib/hind/lsif/generator.rb +50 -5
- data/lib/hind/lsif/global_state.rb +0 -1
- data/lib/hind/lsif/visitors/declaration_visitor.rb +0 -1
- data/lib/hind/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 046343c3a41a8a05497b40d7bdcb9f6d2b36fb86552939100ddc11f0315ad7c2
|
4
|
+
data.tar.gz: c02124f19d952e174f6b4c37481c940f552c1a2847601ba58905526e12d78acc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 26451ad30df53aa0ebcf4eb301dff7864473cef23b292165bc4c2d6e4eefad41a3a8d4bc8c00c628f29997e0d7e9301abbe5f72c5e4b240a193373d2b68c9d23
|
7
|
+
data.tar.gz: 7d4017a84074b81466a37141b8a8ed91b7f8bc11f3fd104b4637a73b6a47e4c69b87b1bac501196f73d7cb5180d3e315d81f88f72b135d2eb47dd33aceb1ce63
|
data/lib/hind/cli.rb
CHANGED
@@ -68,10 +68,23 @@ module Hind
|
|
68
68
|
File.open(options[:output], 'w') do |output_file|
|
69
69
|
say 'First pass: Collecting declarations...', :cyan if options[:verbose]
|
70
70
|
|
71
|
+
# Write initial LSIF data (metadata and project vertices)
|
72
|
+
initial_data = generator.get_initial_data
|
73
|
+
if initial_data&.any?
|
74
|
+
say 'Writing initial LSIF data...', :cyan if options[:verbose]
|
75
|
+
output_file.puts(initial_data.map(&:to_json).join("\n"))
|
76
|
+
end
|
77
|
+
|
71
78
|
# First pass: Process all files to collect declarations
|
72
79
|
declaration_data = generator.collect_declarations(file_contents)
|
73
80
|
|
74
81
|
say "Found #{declaration_data[:declarations].size} declarations (classes, modules, constants)", :cyan if options[:verbose]
|
82
|
+
|
83
|
+
# Write declaration LSIF data next
|
84
|
+
if declaration_data[:lsif_data]&.any?
|
85
|
+
output_file.puts(declaration_data[:lsif_data].map(&:to_json).join("\n"))
|
86
|
+
end
|
87
|
+
|
75
88
|
say 'Processing files for references...', :cyan if options[:verbose]
|
76
89
|
|
77
90
|
# Second pass: Process each file for references
|
@@ -80,13 +93,17 @@ module Hind
|
|
80
93
|
say "Processing file: #{relative_path}", :cyan
|
81
94
|
end
|
82
95
|
|
83
|
-
|
96
|
+
reference_lsif_data = generator.process_file(
|
84
97
|
content: content,
|
85
98
|
uri: relative_path
|
86
99
|
)
|
87
|
-
|
88
|
-
output_file.puts(lsif_data.map(&:to_json).join("\n"))
|
100
|
+
output_file.puts(reference_lsif_data.map(&:to_json).join("\n"))
|
89
101
|
end
|
102
|
+
|
103
|
+
# Finalize and write cross-file references
|
104
|
+
say 'Processing cross-file references...', :cyan if options[:verbose]
|
105
|
+
final_references = generator.finalize_references
|
106
|
+
output_file.puts(final_references.map(&:to_json).join("\n"))
|
90
107
|
end
|
91
108
|
end
|
92
109
|
|
data/lib/hind/lsif/generator.rb
CHANGED
@@ -27,6 +27,7 @@ module Hind
|
|
27
27
|
@current_document_id = nil
|
28
28
|
@lsif_data = []
|
29
29
|
@current_uri = nil
|
30
|
+
@last_vertex_id = @vertex_id
|
30
31
|
|
31
32
|
initialize_project if metadata[:initial]
|
32
33
|
end
|
@@ -48,13 +49,23 @@ module Hind
|
|
48
49
|
end
|
49
50
|
end
|
50
51
|
|
51
|
-
|
52
|
+
# Store the last used vertex ID and reset reference index
|
53
|
+
@last_vertex_id = @vertex_id
|
54
|
+
@last_reference_index = @lsif_data.length
|
55
|
+
|
56
|
+
{
|
57
|
+
declarations: @global_state.declarations,
|
58
|
+
lsif_data: @lsif_data
|
59
|
+
}
|
52
60
|
end
|
53
61
|
|
54
62
|
def process_file(params)
|
55
63
|
@current_uri = params[:uri]
|
56
64
|
content = params[:content]
|
57
65
|
|
66
|
+
# Restore vertex ID from last declaration pass
|
67
|
+
@vertex_id = @last_vertex_id
|
68
|
+
|
58
69
|
@document_id = nil
|
59
70
|
@current_document_id = nil
|
60
71
|
|
@@ -64,11 +75,45 @@ module Hind
|
|
64
75
|
visitor = ReferenceVisitor.new(self, @current_uri)
|
65
76
|
visitor.visit(ast)
|
66
77
|
|
67
|
-
result = @lsif_data
|
68
78
|
finalize_document_state
|
79
|
+
|
80
|
+
# Update last vertex ID
|
81
|
+
@last_vertex_id = @vertex_id
|
82
|
+
|
83
|
+
# Return only the new LSIF data since last call
|
84
|
+
result = @lsif_data[@last_reference_index..]
|
85
|
+
@last_reference_index = @lsif_data.length
|
69
86
|
result
|
70
87
|
end
|
71
88
|
|
89
|
+
def get_initial_data
|
90
|
+
@initial_data
|
91
|
+
end
|
92
|
+
|
93
|
+
def finalize_references
|
94
|
+
# Restore vertex ID
|
95
|
+
@vertex_id = @last_vertex_id
|
96
|
+
# Process all references to create definition results
|
97
|
+
@global_state.references.each do |qualified_name, references|
|
98
|
+
declaration = @global_state.declarations[qualified_name]
|
99
|
+
next unless declaration && declaration[:result_set_id]
|
100
|
+
|
101
|
+
# Create reference result for this symbol
|
102
|
+
ref_result_id = emit_vertex('referenceResult')
|
103
|
+
emit_edge('textDocument/references', declaration[:result_set_id], ref_result_id)
|
104
|
+
|
105
|
+
# Group references by document
|
106
|
+
references_by_doc = references.group_by { |ref| ref[:document_id] }
|
107
|
+
|
108
|
+
# Create item edges for each document's references
|
109
|
+
references_by_doc.each do |doc_id, refs|
|
110
|
+
emit_edge('item', ref_result_id, refs.map { |r| r[:range_id] }, 'references', doc_id)
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
@lsif_data
|
115
|
+
end
|
116
|
+
|
72
117
|
def register_declaration(declaration)
|
73
118
|
return unless @current_uri && declaration[:node]
|
74
119
|
|
@@ -173,11 +218,11 @@ module Hind
|
|
173
218
|
|
174
219
|
range_id = emit_vertex('range', {
|
175
220
|
start: {
|
176
|
-
line: start_location.start_line
|
221
|
+
line: start_location.start_line,
|
177
222
|
character: start_location.start_column
|
178
223
|
},
|
179
224
|
end: {
|
180
|
-
line: end_location.end_line
|
225
|
+
line: end_location.end_line,
|
181
226
|
character: end_location.end_column
|
182
227
|
}
|
183
228
|
})
|
@@ -241,7 +286,7 @@ module Hind
|
|
241
286
|
when :module
|
242
287
|
"module #{declaration[:name]}"
|
243
288
|
when :constant
|
244
|
-
value_info = declaration[:node].value ? " = #{declaration[:node].value.
|
289
|
+
value_info = declaration[:node].value.content ? " = #{declaration[:node].value.content}" : ''
|
245
290
|
"#{declaration[:name]}#{value_info}"
|
246
291
|
else
|
247
292
|
declaration[:name].to_s
|
data/lib/hind/version.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hind
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Aboobacker MK
|
8
8
|
bindir: exe
|
9
9
|
cert_chain: []
|
10
|
-
date: 2025-02-
|
10
|
+
date: 2025-02-15 00:00:00.000000000 Z
|
11
11
|
dependencies:
|
12
12
|
- !ruby/object:Gem::Dependency
|
13
13
|
name: prism
|