Code completion includes extension methods from other types

Raised by @BendixMa at Dart-Code/Dart-Code#2208. I can repro this on v2.8.0-dev, it seems like a server issue.


Hey,

when I declare a dart extension like so:

extension StringExtensions on String {
  bool get definitelyNotAnInt => false;

  void dontShowThisFunctionOnAnInt() {}
}

and use it subsequently in code like so:

main(List<String> args) {
  int integer = 0;
  integer. // and let vs-code show autocompletions here
}

then the suggestion list will include the extensions declared on the String class as shown below.

dart-code-issue

Especially when you have multiple extensions declared on multiple types than this will quickly make autocompletion almost useless as there are so many unrelated suggestions and you cannot find the functions/fields in the list that the class actually defines.

Author: Fantashit

1 thought on “Code completion includes extension methods from other types

Comments are closed.