JakubMisek

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.

    JakubMisek

    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!

      JakubMisek

      Thanks! If you could, perhaps make selection the same style like finding files/workspaces instead of a pop up :)

        11 days later

        JakubMisek I'm "patiently" waiting for this feature. Thank you! :)

          a month later
          24 days later

          phptools implemented 😄

          will be available in the next pre-release.

            thanks can share which version so I can test? Thank you.

              2 months later

              I'm on 1.33, how do I test this? Don't see any new commands with "namespace" in them.

                5 days later

                JakubMisek

                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)

                  phptools

                  I think it's a different shortcut on Mac/Linux. Do you see a lightbulb if you place a cursor on Request?

                  Keyboard mapping can be changed in VSCode, the command is called "Quick Fix".

                  9 days later

                  Yes, I see a light bulb.

                  I'm on code server actually, I suppose that is Linux? I checked and found multiple definitions for ctrl + . by default.


                    JakubMisek I don't think "Quick Fix" is suitable. My monitor is 1440 px in height at 100%, the list is too long to fit and there is no scrolling capability. I think switching to the ctrl + p style is more suitable 🙏

                      phptools I see!

                      I agree. A command would make more sense in this case, and in case of anyone having so many classes.