Open
Description
If, e.g. write:
int main() {
std::cout << "Hello world\n";
}
I think it would be nice for the compiler to suggest importing <iostream>
. If I later write
#include <iostream>
int main() {
std::cout << "Hello world\n";
int a = 0, b = 0;
std::memcpy(&a, &b, 4);
}
it would be nice if it suggested importing <cstring>
. I think a simple internal list of popular functions would be enough, we don't need to get fancy here.
I don't know if this collides with functionality that clangd or similar tools already provide though.
Popular D compilers have similar functionality:
~ » cat test.d
void main() {
writeln("hello world");
}
~ » ldc2 test.d
test.d(7): Error: `writeln` is not defined, perhaps `import std.stdio;` is needed?