Skip to content

goto-definition for interface implementations #698

Closed

Description

@kermorgant

When working with interfaces, you might be tempted to use goto-definition to look into an implementation of the interface but this currently just gets you to the interface.

It would be nice to have the ability to choose which implementation of the method you want to take a peek at

As a bonus, having only one shortcut handling this smartly (ie open directly when no alternatives) would be nice.

Activity

  1. einenlum commented on Jul 4, 2019

    @einenlum
    Collaborator

    I also need to find the different implementations of an interface in a project. Could be a really nice feature. 👍

  2. camilledejoye commented on Jul 8, 2019

    @camilledejoye
    Contributor

    +1 to find all implementations of an interface, so useful when working on a project you are not familiar with.

    The only problem I see here is the time it take to scan a project.
    It may only be because we still got the legacy code inside our project but it's always more than 30s to find references in my work project.
    So it can be pretty annoying to wait that long when we want to jump to a definition.
    Should the feature work only for interface and abstract class ?
    Can it be faster to scan only for classes instead of references in all files ?

  3. einenlum commented on Jul 8, 2019

    @einenlum
    Collaborator

    I guess making a list of all classes that exclude every class not extending or implementing an interface (even with a regex maxbe?) could first improve the performance of the search?

  4. kermorgant commented on Jul 8, 2019

    @kermorgant
    ContributorAuthor

    @elythyr Have you considered adding a composer.json using classmap strategy to your legacy project, just for the sake of improving phpactor's performance ?

  5. dantleech commented on Jul 8, 2019

    @dantleech
    Collaborator

    Should the feature work only for interface and abstract class ?

    I don't see why it should, we need to scan all classes in the project anyway.

    Can it be faster to scan only for classes instead of references in all files ?

    We still need to load and parse all files in the project - but we don't have to analyse them, we only need to check if the implemented interfaces / extended class is a descendant of the requested interface/class (this could be done with WorseReflection, which is lazy and so shouldn't add more overhead than required).

    So it should be faster than find all references, which has to basically interpret each file.

    (as a note, it would be possible add a cache / database to index these things in the future, which brings it's own problems, but might be a nice option).

  6. dantleech commented on Mar 29, 2020

    @dantleech
    Collaborator

    This is "working" with the https://github.com/phpactor/indexer extension, and will be bundled with the next release. #918

    Caveat that automatically indexing code will only work with the LSP integration (although you can index (and watch) the code with a dedicated command)

  7. dantleech commented on May 3, 2020

    @dantleech
    Collaborator

    This is implemented with the indexer. Support for methods will be added in next release.

  8. einenlum commented on Jun 18, 2020

    @einenlum
    Collaborator

    I missed that! Thank you so much @dantleech It works so great :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions