hh_server needn't sort autocomplete results when IDE will do it instead
commitf2456ddd7d72324238e115493fd8ba312b430e89
authorLucian Wischik <ljw@fb.com>
Fri, 14 Jul 2017 17:04:33 +0000 (14 10:04 -0700)
committerHhvm Bot <hhvm-bot@users.noreply.github.com>
Fri, 14 Jul 2017 17:12:19 +0000 (14 10:12 -0700)
tree0cef2e1c1806d693a524fd4b2aa620429ac5191c
parentf9c00398935f4dc33abf58cb3119283ab5899894
hh_server needn't sort autocomplete results when IDE will do it instead

Summary:
Long story short, (1) there's no need for hh_server to sort its autocomplete suggestions when connected to an IDE since the IDE will use its own sort, (2) if hh_server isn't sorting, then it needn't bother computing its `expected_ty` field.

Previously, autocompleteService.ml was sorting its results -- if doing autocomplete inside a function argument position then it prioritized completions whose return type matched the parameter type, and apart from that it sorted alphabetically.

The previous Nuclide persistent connection ignored that sort order. It instead used a sort order primarily geared towards getting a good result for partial matches, e.g. when you type `$this->con|` then it preferred the autocomplete options that matched the letters `c` and `o` and `n` -- preferring them together, preferring them in that capitalization, and so on. This is implemented in autocomplete.js::compareHackCompletions. Although implemented in the Hack package, there's nothing Hack specific about it - it's just a general purpose algorithm to prefer certain kinds of typeahead matches.

Flow actually uses a different typeahead filter sorting algorithm. It just uses the off-the-shelf package fuzzaldrin-plus.

(AutocompletePlus itself also uses fuzzaldrin-plus, but as far as I can tell that's only used for the default SymbolProvider; when you write your own provider you're expected to sort yourself).

Anyway, I'm removing sorting from hh_server in these cases where it's not needed. (Partly because we'll have to implement LSP-specific sorting algorithms and it's confusing things when Hack does its own sort; partly because autocomplete is taking 400ms for a 1000+ member class which is rather too long and I wonder if this is a culprit.)

Reviewed By: dabek

Differential Revision: D5376780

fbshipit-source-id: 32ec344afb03295584b8565119b098fdc8b99646
hphp/hack/src/server/autocompleteService.ml
hphp/hack/test/autocomplete/namespace_global_fallback.php
hphp/hack/test/autocomplete/namespace_global_fallback.php.exp
hphp/hack/test/autocomplete/static_get.php
hphp/hack/test/autocomplete/static_get.php.exp
hphp/hack/test/integration_ml/integration_test_base.ml