-
Notifications
You must be signed in to change notification settings - Fork 71
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
Completion inside static initialization #603
Comments
I think the reason this doesn't work (except not being implemented) is that this syntax is ambigious with delegates. IMO without context this reads much more like a delegate and you want to complete some function or variable which is in the scope, starting with But well I think I only do this because of not a lot of support in the language for these struct initializers and not a lot of support in DCD. It would be cool if this syntax was supported more and for delegates rather using |
I don't know what DCD is capable of but if it can look up |
It's not implemented. Try a gotto definition or a DDOC request on a valid complete StructInitializer and you'll get nothing either. |
How can I do a go to definition on a struct initializer? What would that resolve to? |
struct Foo
{
/// bar DDOC
int bar;
int foo;
}
void main()
{
Foo foo = {bar: 0, foo: 0};
} now in the struct init, place the cursor over |
Probably this has to be done in dsymbol because we are in a struct init and it's just a matter of scope because this works for example: int outerScope1;
int outerScope2;
struct Foo
{
/// bar DDOC
int bar;
int foo;
}
void main()
{
Foo foo = {bar: 0, foo: 0, outerSco|};
} So for now you got completion for what's in the parent scope... not super useful. |
Ah, you mean like that. |
Hence this request 😉. |
I've managed to do it but it's an awful hack : a hidden Not sure if it's worth: https://github.com/dlang-community/dsymbol/pull/141/files |
Also |
Isn’t there a better w to do this? Like checking if the type has a constructor or not. |
In dsymbol not really, to get completions you need a scope with the right things as children and there's nothing provided to do it for this special case. In DCD maybe a bit of manual parsing. At some point the expression preceding the caret pos is parsed. |
In the above example completion works fine after the dot. But will not work inside a static initialization like below:
Static initialization [1] applies both to structs and unions.
[1] https://dlang.org/spec/struct.html#static_struct_init
The text was updated successfully, but these errors were encountered: