Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(20)

Side by Side Diff: pkg/analysis_server/test/services/correction/fix_test.dart

Issue 3004293002: Add fixes for two more lint rules (Closed)
Patch Set: Created 3 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « pkg/analysis_server/lib/src/services/correction/fix_internal.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 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. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 import 'dart:async'; 5 import 'dart:async';
6 6
7 import 'package:analysis_server/plugin/edit/fix/fix_core.dart'; 7 import 'package:analysis_server/plugin/edit/fix/fix_core.dart';
8 import 'package:analysis_server/plugin/edit/fix/fix_dart.dart'; 8 import 'package:analysis_server/plugin/edit/fix/fix_dart.dart';
9 import 'package:analysis_server/src/services/correction/fix.dart'; 9 import 'package:analysis_server/src/services/correction/fix.dart';
10 import 'package:analysis_server/src/services/correction/fix_internal.dart'; 10 import 'package:analysis_server/src/services/correction/fix_internal.dart';
(...skipping 5792 matching lines...) Expand 10 before | Expand all | Expand 10 after
5803 5803
5804 await applyFix(DartFixKind.REMOVE_AWAIT); 5804 await applyFix(DartFixKind.REMOVE_AWAIT);
5805 5805
5806 verifyResult(''' 5806 verifyResult('''
5807 bad() async { 5807 bad() async {
5808 print('hola'); 5808 print('hola');
5809 } 5809 }
5810 '''); 5810 ''');
5811 } 5811 }
5812 5812
5813 test_removeEmptyCatch_newLine() async {
5814 String src = '''
5815 void foo() {
5816 try {}
5817 catch (e) {/*LINT*/}
5818 finally {}
5819 }
5820 ''';
5821 await findLint(src, LintNames.empty_catches);
5822
5823 await applyFix(DartFixKind.REMOVE_EMPTY_CATCH);
5824
5825 verifyResult('''
5826 void foo() {
5827 try {}
5828 finally {}
5829 }
5830 ''');
5831 }
5832
5833 test_removeEmptyCatch_sameLine() async {
5834 String src = '''
5835 void foo() {
5836 try {} catch (e) {/*LINT*/} finally {}
5837 }
5838 ''';
5839 await findLint(src, LintNames.empty_catches);
5840
5841 await applyFix(DartFixKind.REMOVE_EMPTY_CATCH);
5842
5843 verifyResult('''
5844 void foo() {
5845 try {} finally {}
5846 }
5847 ''');
5848 }
5849
5850 test_removeEmptyConstructorBody() async {
5851 String src = '''
5852 class C {
5853 C() {/*LINT*/}
5854 }
5855 ''';
5856 await findLint(src, LintNames.empty_constructor_bodies);
5857
5858 await applyFix(DartFixKind.REMOVE_EMPTY_CONSTRUCTOR_BODY);
5859
5860 verifyResult('''
5861 class C {
5862 C();
5863 }
5864 ''');
5865 }
5866
5813 test_removeEmptyElse_newLine() async { 5867 test_removeEmptyElse_newLine() async {
5814 String src = ''' 5868 String src = '''
5815 void foo(bool cond) { 5869 void foo(bool cond) {
5816 if (cond) { 5870 if (cond) {
5817 // 5871 //
5818 } 5872 }
5819 else /*LINT*/; 5873 else /*LINT*/;
5820 } 5874 }
5821 '''; 5875 ''';
5822 await findLint(src, LintNames.avoid_empty_else); 5876 await findLint(src, LintNames.avoid_empty_else);
(...skipping 766 matching lines...) Expand 10 before | Expand all | Expand 10 after
6589 @override 6643 @override
6590 final AnalysisError error; 6644 final AnalysisError error;
6591 6645
6592 _DartFixContextImpl(this.resourceProvider, this.analysisDriver, 6646 _DartFixContextImpl(this.resourceProvider, this.analysisDriver,
6593 this.astProvider, this.unit, this.error); 6647 this.astProvider, this.unit, this.error);
6594 6648
6595 @override 6649 @override
6596 GetTopLevelDeclarations get getTopLevelDeclarations => 6650 GetTopLevelDeclarations get getTopLevelDeclarations =>
6597 analysisDriver.getTopLevelNameDeclarations; 6651 analysisDriver.getTopLevelNameDeclarations;
6598 } 6652 }
OLDNEW
« no previous file with comments | « pkg/analysis_server/lib/src/services/correction/fix_internal.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698