Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Autocomplete class name #539

Closed
zored opened this issue Nov 29, 2018 · 9 comments
Closed

Autocomplete class name #539

zored opened this issue Nov 29, 2018 · 9 comments

Comments

@zored
Copy link

zored commented Nov 29, 2018

Thank you for amazing tool! 👍

I would be awesome to autocomplete namespaces:

>>> namespace A\B\C {class Foo{}}
>>> use Fo<tab>
>>> use \A\B\C\Foo

Is it possible right now? I can try to create PR if needed 😄

@bobthecow
Copy link
Owner

it is possible to autocomplete class names if (1) you’re using a readline implementation which supports autocomplete and (2) you’ve already autoloaded the file that defines that class.

@zored
Copy link
Author

zored commented Nov 30, 2018

Thank you for response!

Does fuzzy search work?

# Actual:
>>> new \A\B\C\F<tab>
>>> new \A\B\C\Foo;

# Expected:
>>> new Fo<tab>
>>> new \A\B\C\Foo;

I came from PhpStorm and I don't remember namespace name of each class 😄

@theofidry
Copy link
Contributor

@bobthecow so what is the missing part for the auto-completion? Loading all the code we potentially want to auto-complete?

@bobthecow
Copy link
Owner

@theofidry i've been kicking around the idea of "autoload warmers" for a while. wanna make one? 😄

i imagine it would be an interface, and maybe a couple of implementations. one based on composer, that reads either configs or generated autoloaders, uses them to enumerate all possible classes. another could be symfony finder based, and walk the filesystem according to the finder rules.

in all cases, we probably just want them to emit a list of files which possibly / probably contain classes, then use php parser to parse the file and make sure (1) it's valid PHP and won't error, (2) it contains only class and function definitions at the top level, not things that probably have side effects.

@simensen
Copy link

I suspect that #571 could be closed in favor of this, if I'm reading this correctly. :)

I've done some experimenting on my own and have been able to make a lot of my classes available but it seems to not bring interfaces in. It finds them, it calls

I may be interested in trying to get the autoload warmers implemented if I had some vague high-level direction to go in... unless @theofidry is already on it? :)

@theofidry
Copy link
Contributor

Unfortunately, I've been a bit too busy this last year so I'm more focusing on trying to keep a few of my OSS projects alive and not start something new :)

@bobthecow
Copy link
Owner

@simensen Yes, do it!

I don't have strong opinions on what it looks like. Probably something similar to how we do autocomplete matchers, where you can use config to register your own, or projects like Laravel Tinker can provide more specific implementations, but we ship with some reasonable defaults that will work for most cases.

I'd guess: one implementation that takes Symfony Finder-style paths (or a Finder instance itself), one implementation that uses the project's composer autoload config, and one implementation that handles composer dump-autoload?

@bobthecow
Copy link
Owner

Does fuzzy search work?

Unfortunately, no, due to limitations in readline. It strips out completions that don't match the current input, so even if we provided A\B\C\Foo as a completion for Fo, readline would refuse to show it :(

@bobthecow
Copy link
Owner

Moving the "autoload warmers" bit to a proper issue (#650) and closing this one as "wontfix", because the remainder of the ticket isn't possible. Thanks readline!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants