Yes, spot on: add all namespaces that needs to be imported. :)
Manual namespace import
alright, I get it. Something like "apply all recommended fixes", or "import all namespaces"
Hi,
I realized what isn't so good about ctrl
+.
Even though there is only 1 class with the name, I have to activate the quick actions, read the options, and select the one that I want.
In contrast, PHP Namespace Resolver
just adds it without asking. It only asks when there are multiple classes with the same name.
Thank you.
Sadly that's how VSCode deals with Code Actions.
Although PHP Tools adds the namespace automatically already during the code completion - it's called Auto Import (https://docs.devsense.com/en/vscode/editor/auto-import). So it's even quicker.
I hope it helps,
Best,
Jakub
Yea, but the automatic adding doesn't always work, especially when there are typing mistakes or editing of the names etc.
- Edited
is it possible to expose a command that I can call to resolve the namespace of the class that the cursor is on?
Today, I'm using the shortcut key ctrl + alt + i
to "force" it.
The issue is that there are frequently classes of the same name, I need to select the correct one.
This plugin does it quite well https://open-vsx.org/extension/MehediDracula/php-namespace-resolver
I suspect this feature requires a language server, so I prefer to just rely on yours. Thank you.
Ctrl+.
should do the trick (https://docs.devsense.com/en/vscode/editor/code-actions#import-name), if I understand correctly
I did and tried for quite a whlie already. For instance in my project, Router
class has 3 possibilities:
use Illuminate\Routing\Router;
use Google\Service\Compute\Router;
use Symfony\Component\Routing\Router;
But Quick Fix...
showed No code actions available
See the difference in the 2 videos: https://imgur.com/a/Ggh0yqs
phptools I see, there is no Quick Fix, because there is nothing to fix. The Router
is a perfectly valid name in this context.
So you'd like to use a different Router
. We don't have a "quick fix" like that, but I'll note it in our to-do to add some refactorings for this. It's a good idea!
Thanks! If you could, perhaps make selection the same style like finding files/workspaces instead of a pop up :)
JakubMisek I'm "patiently" waiting for this feature. Thank you! :)
phptools getting there :)
bump :)
phptools implemented 😄
will be available in the next pre-release.
thanks can share which version so I can test? Thank you.
phptools it will be version 1.31.12887
and newer
I'm on 1.33, how do I test this? Don't see any new commands with "namespace" in them.
phptools There should be quick actions, i.e.:
- Edited
Pressing ctrl + .
while my cusor was on Request
had no effect for me, nothing pops up.
Can we define our own keyboard shortcut?
(And I can't seem to attach images here... ctrl+v doesn't convert into a URL like normal and it brings me back to the previous conversation on this forum)