Skip to content

Commit 6eb6d4f

Browse files
pqCommit Queue
authored and
Commit Queue
committed
[macros] quick fix for DUPLICATE_AUGMENTATION_IMPORT
(This was stashed locally and just remembering it.) If this feels risky to land, happy to hold off. Change-Id: I5349414bf7eb609ea151866436df4df7bb46bcec Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/366884 Reviewed-by: Konstantin Shcheglov <[email protected]> Commit-Queue: Phil Quitslund <[email protected]>
1 parent 2837647 commit 6eb6d4f

File tree

4 files changed

+28
-4
lines changed

4 files changed

+28
-4
lines changed

pkg/analysis_server/lib/src/services/correction/dart/remove_unused_import.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class RemoveUnusedImport extends ResolvedCorrectionProducer {
2626
@override
2727
Future<void> compute(ChangeBuilder builder) async {
2828
// prepare ImportDirective
29-
var importDirective = node.thisOrAncestorOfType<ImportDirective>();
29+
var importDirective = node.thisOrAncestorOfType<UriBasedDirective>();
3030
if (importDirective == null) {
3131
return;
3232
}

pkg/analysis_server/lib/src/services/correction/error_fix_status.yaml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -519,9 +519,7 @@ CompileTimeErrorCode.DISALLOWED_TYPE_INSTANTIATION_EXPRESSION:
519519
status: needsFix
520520
since: 2.15
521521
CompileTimeErrorCode.DUPLICATE_AUGMENTATION_IMPORT:
522-
status: needsFix
523-
notes: |-
524-
Remove the duplicated import.
522+
status: hasFix
525523
CompileTimeErrorCode.DUPLICATE_CONSTRUCTOR_DEFAULT:
526524
status: noFix
527525
notes: |-

pkg/analysis_server/lib/src/services/correction/fix_internal.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -906,6 +906,9 @@ final _builtInNonLintProducers = <ErrorCode, List<ProducerGenerator>>{
906906
RemoveDefaultValue.new,
907907
RemoveRequired.new,
908908
],
909+
CompileTimeErrorCode.DUPLICATE_AUGMENTATION_IMPORT: [
910+
RemoveUnusedImport.new,
911+
],
909912
CompileTimeErrorCode.EMPTY_MAP_PATTERN: [
910913
ReplaceEmptyMapPattern.any,
911914
ReplaceEmptyMapPattern.empty,

pkg/analysis_server/test/src/services/correction/fix/remove_unused_import_test.dart

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,29 @@ void f(Completer f) {
178178
''');
179179
}
180180

181+
Future<void> test_duplicateAugmentation() async {
182+
newFile('$testPackageLibPath/a.dart', '''
183+
augment library 'test.dart';
184+
class A {}
185+
''');
186+
187+
newFile('$testPackageLibPath/b.dart', '''
188+
augment library 'test.dart';
189+
class B {}
190+
''');
191+
192+
await resolveTestCode('''
193+
import augment 'a.dart';
194+
import augment 'b.dart';
195+
import augment 'a.dart';
196+
''');
197+
198+
await assertHasFix('''
199+
import augment 'a.dart';
200+
import augment 'b.dart';
201+
''');
202+
}
203+
181204
Future<void> test_duplicateImport() async {
182205
await resolveTestCode('''
183206
import 'dart:math';

0 commit comments

Comments
 (0)