-
Notifications
You must be signed in to change notification settings - Fork 340
Closed
Labels
in editorRelates to code editing or language featuresRelates to code editing or language featuresin lsp/analysis serverSomething to be fixed in the Dart analysis serverSomething to be fixed in the Dart analysis serveris bug
Milestone
Description
Quick fixes for imports are inserting the code at the wrong place.
Consider this example:
@TestOn('windows')
import 'package:test/test.dart';
import 'package:win32/win32.dart';
void main() {
test('Allocate Bluetooth PIN', () {
final pin = calloc<BLUETOOTH_PIN_INFO>();
pin.ref.pin = Uint8List.fromList([1, 2, 5, 0]);
pin.ref.pinLength = 4;
expect(pin.ref.pin.sublist(0, 4), equals(Uint8List.fromList([1, 2, 5, 0])));
expect(pin.ref.pinLength, equals(4));
});
}Note that Uint8List has a squiggly under it, representing that it is not understood. If I hit Ctrl+. DartCode offers me the library import I need:

If I accept that recommendation, it inserts the new import at the top of the file:
import 'dart:typed_data';
@TestOn('windows')
import 'package:test/test.dart';
import 'package:win32/win32.dart';However, the @TestOn platform selector only works if it is the first thing in the file:
Just put it at the top of your file, before any library or import declarations
Unfortunately, this issue is quite insidious, because you only notice it if you happen to run the test on a platform that doesn't support it. Not sure where the fix is, but figured DartCode was a good place to start!
Dart Version
Dart SDK version: 2.12.0-262.0.dev (dev) (Tue Jan 26 06:57:59 2021 -0800) on "windows_x64"
Dart Code extension is 3.18.1.
Metadata
Metadata
Assignees
Labels
in editorRelates to code editing or language featuresRelates to code editing or language featuresin lsp/analysis serverSomething to be fixed in the Dart analysis serverSomething to be fixed in the Dart analysis serveris bug