Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Autocomplete speedup vol. 2 #599

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

Closed
Declspeck wants to merge 42 commits into felixfbecker:master from Declspeck:autocomplet-speedup

Conversation

@Declspeck
Copy link
Contributor

@Declspeck Declspeck commented Feb 14, 2018
edited
Loading

This PR does everything that the original Autocomplete Speedup (#451) does, and what your branch of it did:

  • Refactors Index into a tree structure, rather than an array of Fqns to definitions.
  • Use the new Index to speed up ::, -> completions.

In addition to that, this PR

  • Also uses the new Index to speed up completion on names, e.g. array_mer| and adds benchmark for that.
  • Rewrites name completion in terms of generators
  • Makes the completion tests for name completion stricter (TestCla| should not complete OtherClass)
  • Completes aliased namespaces, e.g.use Microsof\PhpParser\Node; Node\Stat| correctly, adds tests for this
  • Only completes direct children, i.e. TestNamesp| no longer completes TestNamespace\SubNamespace\Foo\Bar.

Misc. unrelated changes:

  • Add documentation comments to CompletionTest
  • Shorten lines in CompletionProvider.php to make it pass composer lint

vinkla, phil-nelson, K0bin, cyberbit, Vaggal, foltra, pjio, ifeltsweet, nicolasmure, PHLAK, and 4 more reacted with thumbs up emoji jens1o, Nightbr, martinfojtik, vinkla, jacks0n, foltra, pjio, ifeltsweet, PHLAK, Ciantic, and 3 more reacted with hooray emoji
nicolasmure and others added 30 commits November 13, 2017 20:18
Copy link
Contributor Author

I got another (unrelated) question about the completion logic - for roamed symbols, do we want to complete the name as fully qualified? It seems to make sense for my_user_defined_fu| -> \my_user_defined_function, but not for array_mer| -> \array_merge.

If so, it should probably be expressed as a textEdit rather than insertText, since at least lsp-mode in Emacs does not know what to do in the case where the insert text does not match the text that has been written.

Copy link
Contributor Author

I added all the parts removed from this PR as separate PRs: #607 #606 #605 #604 #602

Copy link
Owner

Currently when in a namespace we complete to \array_merge afaik. If we had settings there probably should be a setting for it.

Copy link
Owner

Need some more time to review this.
Would you mind updating the description?

Copy link
Contributor Author

Sure, I'll update it after work today (or at the very latest tomorrow) - I already forgot what I'm wanting to merge here, so I have to take another look myself. It looks like I also have a conflict to resolve.

Copy link
Contributor Author

...And thanks for reviewing the other PRs!

Copy link
Contributor Author

I updated the description and merged master into this.

foreach ($list->items as $item) {
// Remove ()
if (is_string($item->insertText) && substr($item->insertText, strlen($item->insertText) - 2) === '()') {
$item->insertText = substr($item->insertText, 0, strlen($item->insertText) - 2);
Copy link
Contributor

@jens1o jens1o Mar 1, 2018
edited
Loading

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no need to use strlen here(this line and the line before).

Use substr($item->insertText, -2);(or substr($item->insertText, 0, -2);) instead.

{
return serialize([
'definitions' => $this->definitions,
'definitions' => iterator_to_array($this->getDefinitions(), true),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the second parameter is already the default one, no need for the true.

Copy link
Contributor Author

Thanks for the feedback @jens1o - I finally got around to addressing it.

jens1o reacted with thumbs up emoji

Copy link
Contributor

jens1o commented Mar 10, 2018

Thank you!

$list->items = array_values(iterator_to_array($items));
foreach ($list->items as $item) {
// Remove ()
if (is_string($item->insertText) && substr($item->insertText, strlen($item->insertText) - 2) === '()') {
Copy link
Contributor

@jens1o jens1o Mar 10, 2018
edited
Loading

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this line can be simplified too
if (is_string($item->insertText) && substr($item->insertText, -2) === '()') {

Copy link

Hello
Do we have an estimation date on when this will be merged if it will be merged ?

Copy link
Owner

Short answer, no, we don't have an estimate date.

Copy link
Owner

Hey @Declspeck, sorry I had forgotten about this PR. Just took a look and it looks good to me. Do you think this is in a mergeable state / are you still interested in getting it across the finish line?

Ciantic and tam5 reacted with thumbs up emoji nicolasmure, jens1o, vinkla, cyberbit, jacks0n, phh, Bertutchio, PHLAK, orthagh, evolbug, and 6 more reacted with hooray emoji cmatzenbach reacted with heart emoji

Copy link
Contributor

jens1o commented Oct 24, 2018

@felixfbecker I'd be interested in completing this PR. What do I need to do? Copy the clone?

vinkla, anovix, sunverwerth, and tam5 reacted with thumbs up emoji

Copy link
Owner

Awesome. Here is roughly what you need to do:

Add the fork as a git remote:

git remote add Declspeck git@github.com:Declspeck/php-language-server.git

Fetch it:

git fetch Declspeck

Check it out:

git checkout autocomplet-speedup

Merge in master (make sure master is up to date):

git merge master

Fix merge conflicts and commit
Push to your own fork:

git push -u jens1o autocomplet-speedup
jens1o, vinkla, sunverwerth, and ifeltsweet reacted with thumbs up emoji

Copy link
Contributor

jens1o commented Oct 24, 2018

Awesome, thanks for the heads up!

Ciantic reacted with thumbs up emoji

Copy link
Owner

🎉 This issue has been resolved in version 5.4.3 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

tam5 reacted with thumbs up emoji tam5 reacted with laugh emoji tam5, evolbug, chsjr1996, and cyberbit reacted with hooray emoji tam5 reacted with heart emoji

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

Reviewers

1 more reviewer

@jens1o jens1o jens1o left review comments

Reviewers whose approvals may not affect merge requirements

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

AltStyle によって変換されたページ (->オリジナル) /