Dart-Code icon indicating copy to clipboard operation
Dart-Code copied to clipboard

Autocomplete doesn't work properly with enums when using named imports

Open osaxma opened this issue 2 years ago • 3 comments

Describe the bug

When using named imports, auto completing enum doesn't show the value but prompt to insert a switch condition as shown below:

To Reproduce

Screen Shot 2023-10-16 at 7 11 11 PM
import 'dart:ui' as ui;

void main() {
  final x = ui.BlendMod  // <~~ auto complete here
}

Expected behavior

I expect the enum values to be shown

Please complete the following information: Extension version: v3.74.0 VS Code version: 1.83.1 Flutter 3.13.6 • channel stable • Dart 3.1.3 • DevTools 2.25.0

osaxma avatar Oct 16 '23 16:10 osaxma

Seems like there are two unrelated issues here:

  1. switch expression showing up in the wrong place
  2. Enum member not showing up

A single-file repro that doesn't require Flutter:

import '' as e; // import self as e

enum MyEnum {
  one,
  two,
}


void main() {
  final x = e.MyEnum.^
}

DanTup avatar Oct 16 '23 16:10 DanTup

One of these is easier to fix than the other, so splitting the switch expression part out to https://github.com/Dart-Code/Dart-Code/issues/4795.

DanTup avatar Oct 16 '23 16:10 DanTup

Also see https://stackoverflow.com/q/77873381/ which describes a similar problem for static methods when using named imports.

jamesderlin avatar Jan 24 '24 18:01 jamesderlin

It appears that this has been resolved now:

image

image

DanTup avatar Nov 26 '24 14:11 DanTup