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

auto import

Open yannick opened this issue 7 years ago • 11 comments

not sure if feasible, but one could possibly suggest imports for methods that are within current includes + stdlib.

yannick avatar Nov 28 '16 13:11 yannick

Can you explain this further or give an example? I already implemented a function to add imports in workspace-d now which will add many new features but I'm waiting for my PR on libdparse to get merged before I push it. Maybe the new planned release already has that feature. Also check https://github.com/Pure-D/workspace-d/issues for the features I had planned

WebFreak001 avatar Nov 28 '16 14:11 WebFreak001

I think he meant that when you use a symbol from currently not imported module, the import would automatically be added to the source file.

CZDanol avatar Jan 19 '17 20:01 CZDanol

Hm I have that already if you explicitly go to the error and press the code lens. I could also add a command doing that for all issues in the file too though

WebFreak001 avatar Jan 19 '17 20:01 WebFreak001

Would it be possible to add non-imported symbols to the intellisense and import them when a programmer would use them?

CZDanol avatar Jan 19 '17 20:01 CZDanol

That should be possible, I need to see how to optimize it though to avoid lag

WebFreak001 avatar Jan 19 '17 20:01 WebFreak001

👍

CZDanol avatar Jan 19 '17 20:01 CZDanol

@WebFreak001 can you elaborate how to use "code lens" if iam writing writefln somewhere where i do not import std.stdio i cannot seem to automatically import?

extrawurst avatar Jan 21 '17 19:01 extrawurst

You need to save and there needs to be a red squiggly line under it. If it marks it as error it will trigger a search when you go to the error with the code cursor

WebFreak001 avatar Jan 21 '17 23:01 WebFreak001

i see the squiggly line yes. nothing happens though when i put the cursor there... :(

extrawurst avatar Jan 22 '17 20:01 extrawurst

you've got code-d 2.16.0 right? Only released it yesterday

WebFreak001 avatar Jan 22 '17 20:01 WebFreak001

This would be very nice! I know it's done tremendously well for Java. I would suggest combining this with squiggly lines for unused imports & a 'remove unused imports' command (or automatically removing unused imports upon using the sort imports command).

(Assuming Intellisense finds what you're looking for, I'm having some issues but I may have broken my project)

HuskyNator avatar Apr 14 '22 17:04 HuskyNator

fixed in serve-d nightly/beta, will get release for all in next code-d + stable serve-d release

WebFreak001 avatar Jan 23 '23 09:01 WebFreak001