serve-d
serve-d copied to clipboard
Templated struct/function autocompletion support
Currently autocompletion doesn't work with https://dlang.org/spec/class.html#alias-this .
Example:
struct Scoped(T)
{
T payload;
alias payload this;
@disable this();
@disable this(this);
~this()
{
.destroy(payload);
}
}
class DisplayArea: DrawingArea {
Chip8Display display;
this(Chip8Display d) {
display = d;
super();
addOnDraw(&draw);
}
bool draw(Scoped!Context ctx, Widget w) {
Pattern pattern = Pattern.createForSurface(display.surface);
pattern.setFilter(cairo_filter_t.NEAREST);
ctx.scale(4, 4);
ctx.setSource(pattern);
ctx.paint();
return true;
}
}
In this case an attempt to auto-complete ctx.
within the draw
function doesn't show any Context functions/members.
see https://github.com/dlang-community/DCD/issues/12
alias this works, if you replace T by Context, you'll get proper completion
The problem is with the template, DCD doesn't resolve it
I began work on this, currently i managed to get templated functions to work
PR here: https://github.com/dlang-community/dsymbol/pull/178
I will see if i can make this one to work too!