Merge pull request #1232 from Techatrix/usingnamespace-invalid-usingtrail
clear using_trail when calling resolveUse
This commit is contained in:
commit
e1e75a1e63
@ -2390,6 +2390,7 @@ pub fn innermostContainer(handle: *const DocumentStore.Handle, source_index: usi
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn resolveUse(analyser: *Analyser, uses: []const Ast.Node.Index, symbol: []const u8, handle: *const DocumentStore.Handle) error{OutOfMemory}!?DeclWithHandle {
|
fn resolveUse(analyser: *Analyser, uses: []const Ast.Node.Index, symbol: []const u8, handle: *const DocumentStore.Handle) error{OutOfMemory}!?DeclWithHandle {
|
||||||
|
analyser.using_trail.clearRetainingCapacity();
|
||||||
for (uses) |index| {
|
for (uses) |index| {
|
||||||
const gop = try analyser.using_trail.getOrPut(analyser.gpa, index);
|
const gop = try analyser.using_trail.getOrPut(analyser.gpa, index);
|
||||||
if (gop.found_existing) continue;
|
if (gop.found_existing) continue;
|
||||||
|
@ -483,6 +483,22 @@ test "completion - usingnamespace" {
|
|||||||
, &.{
|
, &.{
|
||||||
.{ .label = "inner", .kind = .Function, .detail = "fn inner() void" },
|
.{ .label = "inner", .kind = .Function, .detail = "fn inner() void" },
|
||||||
});
|
});
|
||||||
|
try testCompletion(
|
||||||
|
\\fn Bar(comptime Self: type) type {
|
||||||
|
\\ return struct {
|
||||||
|
\\ fn inner(self: Self) void { _ = self; }
|
||||||
|
\\ };
|
||||||
|
\\}
|
||||||
|
\\const Foo = struct {
|
||||||
|
\\ pub usingnamespace Bar(Foo);
|
||||||
|
\\ fn deinit(self: Foo) void { _ = self; }
|
||||||
|
\\};
|
||||||
|
\\const foo: Foo = undefined;
|
||||||
|
\\const bar = foo.<cursor>
|
||||||
|
, &.{
|
||||||
|
.{ .label = "inner", .kind = .Function, .detail = "fn inner(self: Self) void" },
|
||||||
|
.{ .label = "deinit", .kind = .Function, .detail = "fn deinit(self: Foo) void" },
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
test "completion - block" {
|
test "completion - block" {
|
||||||
|
Loading…
Reference in New Issue
Block a user