natanfudge / Auto-Using

Visual Studio Code extension that auto imports and provides auto complete for available imports in C#
https://marketplace.visualstudio.com/items?itemName=Fudge.auto-using
GNU Lesser General Public License v3.0
37 stars 7 forks source link

Optimize completionItemProvider references #3

Closed natanfudge closed 5 years ago

natanfudge commented 5 years ago

Currently all logic is done every time provideCompletionItems is called. When the word to complete is empty it can take around 200ms to compute. This could grow much worse with additional references and a server involved. Therefore we initialize a data structure at activation that needs to be able to do the following things at lg(n) or faster time (where n is the total number of references):

A sorted array of vscode.completionItem should do.

pushqrdx commented 5 years ago

@natanfudge So here is how i imagine completions should be prioritized

  1. This Package (Highest)
  2. Frequently Used (Medium) - Completions from lowest priority make their way to here based on usage.
  3. Non-imported Packages (Lowest)
natanfudge commented 5 years ago

I don't have control over the c# ext's completions. Instead I manipulate this extension's labels to overall sort in this order:

  1. Imported in this file(omnisharp) + Imported before but not in this file(AU)
  2. Never imported before(AU)

And the goal for the sort order would probably be:

  1. Imported in file(omnisharp) + not imported but in the same project(AU) + not imported but imported elsewhere recently (AU)
  2. Imported before but not recently(AU)
  3. Never imported before(AU)

A serious hack is in order to be able to change other extensions' completions.

natanfudge commented 5 years ago

Regarding speed: it seems that it actually doesn't take that long? Not sure why I'm getting different results now.

natanfudge commented 5 years ago

It appears that the calculations actually don't take barely any time, it's just vscode takes some time to load the completions.