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 speedup vol. 2 #599

Closed
wants to merge 42 commits into from

Conversation

Declspeck
Copy link
Contributor

@Declspeck Declspeck commented Feb 14, 2018

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

@Declspeck
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.

@Declspeck
Copy link
Contributor Author

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

@felixfbecker
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.

@felixfbecker
Copy link
Owner

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

@Declspeck
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.

@Declspeck
Copy link
Contributor Author

...And thanks for reviewing the other PRs!

@Declspeck
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

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.

@@ -216,10 +280,164 @@ public function unserialize($serialized)
public function serialize()
{
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.

@Declspeck
Copy link
Contributor Author

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

@jens1o
Copy link
Contributor

jens1o commented Mar 10, 2018

Thank you!

@@ -341,7 +341,7 @@ public function provideCompletion(
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

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) === '()') {

@pkirkinezis
Copy link

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

@felixfbecker
Copy link
Owner

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

@felixfbecker
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?

@jens1o
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?

@felixfbecker
Copy link
Owner

Awesome. Here is roughly what you need to do:

Add the fork as a git remote:

git remote add Declspeck [email protected]: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
Copy link
Contributor

jens1o commented Oct 24, 2018

Awesome, thanks for the heads up!

@felixfbecker
Copy link
Owner

🎉 This issue has been resolved in version 5.4.3 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

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

Successfully merging this pull request may close these issues.

5 participants