simplify tagStoreCompletionItems
This commit is contained in:
parent
0cfc792849
commit
9f688cf4ed
@ -856,34 +856,21 @@ fn tagStoreCompletionItems(self: DocumentStore, arena: std.mem.Allocator, handle
|
|||||||
const tracy_zone = tracy.trace(@src());
|
const tracy_zone = tracy.trace(@src());
|
||||||
defer tracy_zone.end();
|
defer tracy_zone.end();
|
||||||
|
|
||||||
const completion_set: analysis.CompletionSet = @field(handle.document_scope, name);
|
var dependencies = std.ArrayListUnmanaged(Uri){};
|
||||||
|
try dependencies.append(self.allocator, handle);
|
||||||
|
try collectDependencies(self.allocator, self, handle, dependencies);
|
||||||
|
|
||||||
// TODO Better solution for deciding what tags to include
|
// TODO Better solution for deciding what tags to include
|
||||||
var result_set = analysis.CompletionSet{};
|
var result_set = analysis.CompletionSet{};
|
||||||
try result_set.ensureTotalCapacity(arena, completion_set.entries.items(.key).len);
|
|
||||||
|
|
||||||
for (completion_set.entries.items(.key)) |completion| {
|
for (dependencies) |uri| {
|
||||||
result_set.putAssumeCapacityNoClobber(completion, {});
|
// not every dependency is loaded which results in incomplete completion
|
||||||
}
|
const hdl = self.handles.get(uri) orelse continue;
|
||||||
|
const curr_set = @field(hdl.document_scope, name);
|
||||||
for (handle.import_uris.items) |uri| {
|
|
||||||
const curr_set = @field(self.handles.get(uri).?.document_scope, name);
|
|
||||||
for (curr_set.entries.items(.key)) |completion| {
|
for (curr_set.entries.items(.key)) |completion| {
|
||||||
try result_set.put(arena, completion, {});
|
try result_set.put(arena, completion, {});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (handle.cimports.items(.hash)) |hash| {
|
|
||||||
const result = self.cimports.get(hash) orelse continue;
|
|
||||||
switch (result) {
|
|
||||||
.success => |uri| {
|
|
||||||
const curr_set = @field(self.handles.get(uri).?.document_scope, name);
|
|
||||||
for (curr_set.entries.items(.key)) |completion| {
|
|
||||||
try result_set.put(arena, completion, {});
|
|
||||||
}
|
|
||||||
},
|
|
||||||
.failure => {},
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return result_set.entries.items(.key);
|
return result_set.entries.items(.key);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user