|
| 1 | +// Copyright (c) 2020, the Dart project authors. Please see the AUTHORS file |
| 2 | +// for details. All rights reserved. Use of this source code is governed by a |
| 3 | +// BSD-style license that can be found in the LICENSE file. |
| 4 | + |
| 5 | +import 'package:analysis_server/src/services/linter/lint_names.dart'; |
| 6 | +import 'package:test_reflective_loader/test_reflective_loader.dart'; |
| 7 | + |
| 8 | +import 'bulk_fix_processor.dart'; |
| 9 | + |
| 10 | +void main() { |
| 11 | + defineReflectiveSuite(() { |
| 12 | + defineReflectiveTests(AddDiagnosticPropertyReferenceTest); |
| 13 | + }); |
| 14 | +} |
| 15 | + |
| 16 | +@reflectiveTest |
| 17 | +class AddDiagnosticPropertyReferenceTest extends BulkFixProcessorTest { |
| 18 | + @override |
| 19 | + String get lintCode => LintNames.diagnostic_describe_all_properties; |
| 20 | + |
| 21 | + Future<void> test_singleFile() async { |
| 22 | + addFlutterPackage(); |
| 23 | + await resolveTestUnit(''' |
| 24 | +import 'package:flutter/foundation.dart'; |
| 25 | +import 'package:flutter/widgets.dart'; |
| 26 | +
|
| 27 | +class C extends Widget with Diagnosticable { |
| 28 | + bool get absorbing => _absorbing; |
| 29 | + bool _absorbing; |
| 30 | + bool ignoringSemantics; |
| 31 | + @override |
| 32 | + void debugFillProperties(DiagnosticPropertiesBuilder properties) { |
| 33 | + super.debugFillProperties(properties); |
| 34 | + properties.add(DiagnosticsProperty<bool>('absorbing', absorbing)); |
| 35 | + } |
| 36 | +} |
| 37 | +
|
| 38 | +class D extends Widget with Diagnosticable { |
| 39 | + bool ignoringSemantics; |
| 40 | + @override |
| 41 | + void debugFillProperties(DiagnosticPropertiesBuilder properties) { |
| 42 | + } |
| 43 | +} |
| 44 | +'''); |
| 45 | + await assertHasFix(''' |
| 46 | +import 'package:flutter/foundation.dart'; |
| 47 | +import 'package:flutter/widgets.dart'; |
| 48 | +
|
| 49 | +class C extends Widget with Diagnosticable { |
| 50 | + bool get absorbing => _absorbing; |
| 51 | + bool _absorbing; |
| 52 | + bool ignoringSemantics; |
| 53 | + @override |
| 54 | + void debugFillProperties(DiagnosticPropertiesBuilder properties) { |
| 55 | + super.debugFillProperties(properties); |
| 56 | + properties.add(DiagnosticsProperty<bool>('absorbing', absorbing)); |
| 57 | + properties.add(DiagnosticsProperty<bool>('ignoringSemantics', ignoringSemantics)); |
| 58 | + } |
| 59 | +} |
| 60 | +
|
| 61 | +class D extends Widget with Diagnosticable { |
| 62 | + bool ignoringSemantics; |
| 63 | + @override |
| 64 | + void debugFillProperties(DiagnosticPropertiesBuilder properties) { |
| 65 | + properties.add(DiagnosticsProperty<bool>('ignoringSemantics', ignoringSemantics)); |
| 66 | + } |
| 67 | +} |
| 68 | +'''); |
| 69 | + } |
| 70 | +} |
0 commit comments