hind 0.1.7 → 0.1.8
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 +47 -2
- 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: debf085e96a2d5683f8aac3870ab5c06ce0b28adc8dfa960227fb0a763defcee
|
4
|
+
data.tar.gz: 475b21bdbc4502c445a24be086e131c511f53972f113e7dda6e2b52eb03b16b1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: da48ed207a58c99a9a544c2f5f2d0b3c88aecd7fa36ef7fc348064f925033ae33b7702c04d1147970a583b27a2031c5de7ca89b4b9d0aefb731ae0b3ffa93ce7
|
7
|
+
data.tar.gz: 88f86b97957a68ab50d153311d6d07a0ab0d99f39dfabe2409039ef86fc22af6f162419ddb926de58c938ebc9de165291c30e33556ac25db0d467ec1c450e610
|
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
|
|
data/lib/hind/version.rb
CHANGED