serve-d icon indicating copy to clipboard operation
serve-d copied to clipboard

Templated struct/function autocompletion support

Open UARTman opened this issue 2 years ago • 2 comments

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.

UARTman avatar Jun 08 '22 08:06 UARTman

see https://github.com/dlang-community/DCD/issues/12

WebFreak001 avatar Jun 08 '22 09:06 WebFreak001

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!

ryuukk avatar Jun 19 '22 18:06 ryuukk