-
-
Notifications
You must be signed in to change notification settings - Fork 336
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Struct init fields completion. #1075
Conversation
9598bc3
to
41482af
Compare
This works well for the simple case but there are some very common cases that it does not support:
fn NonGenericGeneric() type {
return struct {
a: bool,
b: bool,
};
}
fn nonGenericGeneric() void {
var r = NonGenericGeneric(){}; // no completion
}
const MyStruct = struct {
a: bool,
b: bool,
fn inside() void {
var s = MyStruct{}; // no completion
}
};
fn outside() void {
var s = MyStruct{}; // completion
}
// inside "MyStruct.zig"
a: bool,
b: bool,
// inside "main.zig"
const MyStruct = @import("MyStruct.zig");
fn topLevelStruct() void {
var s = MyStruct{}; // no completion
}
const MyStruct = struct {
a: bool,
b: bool,
};
const Alias = MyStruct;
fn alias() void {
var s = Alias{}; // no completion
} |
I'm okay merging this as is, as it does increases ZLS capabilities. @nullptrdevs any chance you can rebase? |
41482af
to
3ab1c44
Compare
Thank you for taking the time to review, I will look into all of these, but some initial thoughts: Case 1: No idea where to start. Something something ComptimeInterpreter. const MyStruct = struct {
a: bool,
b: bool,
fn inside() void {
var s = MyStruct{.}; // no completion
}
};
fn outside() void {
var s = MyStruct{}; // completion
MyStruct. // no completion here either
} (Custom parser when?) Custom parse tokens looking for same .identifier, |
I am curious to know why this happens. |
Up for logic review and a fuzz (suggestions still welcome).
Caveat:Note:
Nested structs completion, ie
MyStruct{.fld = a, SomeOther{.dlf = 1}, .<complete here>}
, is out of scope, use locals.