Compiler-assisted code reflection for IDEs

SealabJaster sealabjaster at gmail.com
Fri Jul 16 10:02:06 UTC 2021


A common flaw with things like code-d and (in my limited 
experience) Visual-D, these plugins are unable to resolve even 
simple things like:

```d
struct S(T)
{
     T a;
}

...

S!int.init.// No autocompletion from this point.
```

I was wondering if functionality can be added onto the compiler 
(DMD at least, due to its speed) which allows for external 
tooling to gain accurate information about the code?

Take the above struct for example, maybe when the plugin detects 
the following:

```d
S!int myS;
```

It could make a call to the compiler like: `dmd myapp.d -reflect 
"myapp.S!(int)"`, where the compiler would return all the info it 
can (It's a struct, it has a member of int called a, etc.)

It's just a rough idea, but I hope you can see what I'm trying to 
suggest, and why I feel it's at least worth asking about.

In other words, build some much needed language service 
functionality into the compiler, to allow the actual language 
servers to provide a much higher quality experience. Naively 
assuming it's as simple as that :3


More information about the Digitalmars-d mailing list