Vscode-intelephense: "Add Use Declaration" does not work

Created on 26 Apr 2018  Â·  8Comments  Â·  Source: bmewburn/vscode-intelephense

I am finding that the "Add Use Declaration" does not work. If I have code like:

public function __construct(SomeClassName $some_class_instance) {}

I can't add a use statement for this class, should that work? Does the plugin require that the fully qualified path to the class be in place to make the "add use" work?

Also, does your plugin provide a link to the classes in the "use" statements, so I can command+click to open them, or is that the namespace resolution plugin?

Thanks.

Most helpful comment

The infamous "Add Use Declaration" has been removed in 1.0 and will be reimplemented as a code action in a future release. For now ctrl + space (or whatever your keybinding for completion suggestions are) will bring up the completion dialog an auto add a use decl.

All 8 comments

Ya I am also having problems with this. I can't figure out if I am doing something wrong of it is a bug.

Having the same issue, so I installed this and it's working really well for me.

Just installed this package today and tried to use this feature and it's not working for me either.

Same here. Neither if I write an alias. I can't even see a log or error in the Output.
As said by @ngocphamm, PHP Namespace Resolver works perfectly for this feature. I've been using that extension for long.

Same here, Intelephense 0.8.8, Visual Studio Code 1.25.1 – which is a shame, because otherwise the extension is perfect for me. The speed and precision of it is great!

It just opens a dialog for entering an optional alias, but no matter what I do (i.e. input an alias or not), no use statement is added.

Can we supply any data to help fix the issue, or help in any other way, @bmewburn?

I noticed something: when you're typing code this extension autocompletes classes, even if they're not in the namespace. If you press Enter or Tab, the Use Declaration for that class is added. So, this works while you're typing the class name, choose the class in the dialog, and press Enter or Tab.

+1

The infamous "Add Use Declaration" has been removed in 1.0 and will be reimplemented as a code action in a future release. For now ctrl + space (or whatever your keybinding for completion suggestions are) will bring up the completion dialog an auto add a use decl.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

swashata picture swashata  Â·  3Comments

mushmelty picture mushmelty  Â·  4Comments

muuvmuuv picture muuvmuuv  Â·  4Comments

aleksandervines picture aleksandervines  Â·  3Comments

ottopic picture ottopic  Â·  3Comments