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

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

Issue 2975253002: Format analyzer, analysis_server, analyzer_plugin, front_end and kernel with the latest dartfmt. (Closed)
Patch Set: Created 3 years, 5 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
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/src/services/correction/organize_directives.dart '; 7 import 'package:analysis_server/src/services/correction/organize_directives.dart ';
8 import 'package:analyzer/error/error.dart'; 8 import 'package:analyzer/error/error.dart';
9 import 'package:analyzer/src/dart/analysis/driver.dart'; 9 import 'package:analyzer/src/dart/analysis/driver.dart';
10 import 'package:analyzer_plugin/protocol/protocol_common.dart' 10 import 'package:analyzer_plugin/protocol/protocol_common.dart'
(...skipping 16 matching lines...) Expand all
27 test_keep_duplicateImports_withDifferentPrefix() async { 27 test_keep_duplicateImports_withDifferentPrefix() async {
28 await _computeUnitAndErrors(r''' 28 await _computeUnitAndErrors(r'''
29 import 'dart:async' as async1; 29 import 'dart:async' as async1;
30 import 'dart:async' as async2; 30 import 'dart:async' as async2;
31 31
32 main() { 32 main() {
33 async1.Future f; 33 async1.Future f;
34 async2.Stream s; 34 async2.Stream s;
35 }'''); 35 }''');
36 // validate change 36 // validate change
37 _assertOrganize( 37 _assertOrganize(r'''
38 r'''
39 import 'dart:async' as async1; 38 import 'dart:async' as async1;
40 import 'dart:async' as async2; 39 import 'dart:async' as async2;
41 40
42 main() { 41 main() {
43 async1.Future f; 42 async1.Future f;
44 async2.Stream s; 43 async2.Stream s;
45 }''', 44 }''', removeUnresolved: true, removeUnused: true);
46 removeUnresolved: true,
47 removeUnused: true);
48 } 45 }
49 46
50 test_remove_duplicateImports() async { 47 test_remove_duplicateImports() async {
51 await _computeUnitAndErrors(r''' 48 await _computeUnitAndErrors(r'''
52 import 'dart:async'; 49 import 'dart:async';
53 import 'dart:async'; 50 import 'dart:async';
54 51
55 main() { 52 main() {
56 Future f; 53 Future f;
57 }'''); 54 }''');
58 // validate change 55 // validate change
59 _assertOrganize( 56 _assertOrganize(r'''
60 r'''
61 import 'dart:async'; 57 import 'dart:async';
62 58
63 main() { 59 main() {
64 Future f; 60 Future f;
65 }''', 61 }''', removeUnresolved: true, removeUnused: true);
66 removeUnresolved: true,
67 removeUnused: true);
68 } 62 }
69 63
70 test_remove_duplicateImports_differentText_uri() async { 64 test_remove_duplicateImports_differentText_uri() async {
71 await _computeUnitAndErrors(r''' 65 await _computeUnitAndErrors(r'''
72 import 'dart:async' as async; 66 import 'dart:async' as async;
73 import "dart:async" as async; 67 import "dart:async" as async;
74 68
75 main() { 69 main() {
76 async.Future f; 70 async.Future f;
77 }'''); 71 }''');
78 // validate change 72 // validate change
79 _assertOrganize( 73 _assertOrganize(r'''
80 r'''
81 import 'dart:async' as async; 74 import 'dart:async' as async;
82 75
83 main() { 76 main() {
84 async.Future f; 77 async.Future f;
85 }''', 78 }''', removeUnresolved: true, removeUnused: true);
86 removeUnresolved: true,
87 removeUnused: true);
88 } 79 }
89 80
90 test_remove_duplicateImports_withSamePrefix() async { 81 test_remove_duplicateImports_withSamePrefix() async {
91 await _computeUnitAndErrors(r''' 82 await _computeUnitAndErrors(r'''
92 import 'dart:async' as async; 83 import 'dart:async' as async;
93 import 'dart:async' as async; 84 import 'dart:async' as async;
94 85
95 main() { 86 main() {
96 async.Future f; 87 async.Future f;
97 }'''); 88 }''');
98 // validate change 89 // validate change
99 _assertOrganize( 90 _assertOrganize(r'''
100 r'''
101 import 'dart:async' as async; 91 import 'dart:async' as async;
102 92
103 main() { 93 main() {
104 async.Future f; 94 async.Future f;
105 }''', 95 }''', removeUnresolved: true, removeUnused: true);
106 removeUnresolved: true,
107 removeUnused: true);
108 } 96 }
109 97
110 test_remove_unresolvedDirectives() async { 98 test_remove_unresolvedDirectives() async {
111 addSource('/existing_part1.dart', 'part of lib;'); 99 addSource('/existing_part1.dart', 'part of lib;');
112 addSource('/existing_part2.dart', 'part of lib;'); 100 addSource('/existing_part2.dart', 'part of lib;');
113 await _computeUnitAndErrors(r''' 101 await _computeUnitAndErrors(r'''
114 library lib; 102 library lib;
115 103
116 import 'dart:async'; 104 import 'dart:async';
117 import 'dart:noSuchImportSdkLibrary'; 105 import 'dart:noSuchImportSdkLibrary';
118 import 'dart:math'; 106 import 'dart:math';
119 import 'package:noSuchImportPackage/andLib.dart'; 107 import 'package:noSuchImportPackage/andLib.dart';
120 108
121 export 'dart:noSuchExportSdkLibrary'; 109 export 'dart:noSuchExportSdkLibrary';
122 export 'dart:async'; 110 export 'dart:async';
123 export 'package:noSuchExportPackage/andLib.dart'; 111 export 'package:noSuchExportPackage/andLib.dart';
124 export 'dart:math'; 112 export 'dart:math';
125 113
126 part 'existing_part1.dart'; 114 part 'existing_part1.dart';
127 part 'no_such_part.dart'; 115 part 'no_such_part.dart';
128 part 'existing_part2.dart'; 116 part 'existing_part2.dart';
129 117
130 main() { 118 main() {
131 } 119 }
132 '''); 120 ''');
133 // validate change 121 // validate change
134 _assertOrganize( 122 _assertOrganize(r'''
135 r'''
136 library lib; 123 library lib;
137 124
138 import 'dart:async'; 125 import 'dart:async';
139 import 'dart:math'; 126 import 'dart:math';
140 127
141 export 'dart:async'; 128 export 'dart:async';
142 export 'dart:math'; 129 export 'dart:math';
143 130
144 part 'existing_part1.dart'; 131 part 'existing_part1.dart';
145 part 'existing_part2.dart'; 132 part 'existing_part2.dart';
146 133
147 main() { 134 main() {
148 } 135 }
149 ''', 136 ''', removeUnresolved: true);
150 removeUnresolved: true);
151 } 137 }
152 138
153 test_remove_unusedImports() async { 139 test_remove_unusedImports() async {
154 await _computeUnitAndErrors(r''' 140 await _computeUnitAndErrors(r'''
155 library lib; 141 library lib;
156 142
157 import 'dart:async'; 143 import 'dart:async';
158 import 'dart:math'; 144 import 'dart:math';
159 import 'dart:convert'; 145 import 'dart:convert';
160 import 'dart:collection'; 146 import 'dart:collection';
161 147
162 main() { 148 main() {
163 print(PI); 149 print(PI);
164 new HashMap(); 150 new HashMap();
165 } 151 }
166 '''); 152 ''');
167 // validate change 153 // validate change
168 _assertOrganize( 154 _assertOrganize(r'''
169 r'''
170 library lib; 155 library lib;
171 156
172 import 'dart:collection'; 157 import 'dart:collection';
173 import 'dart:math'; 158 import 'dart:math';
174 159
175 main() { 160 main() {
176 print(PI); 161 print(PI);
177 new HashMap(); 162 new HashMap();
178 } 163 }
179 ''', 164 ''', removeUnused: true);
180 removeUnused: true);
181 } 165 }
182 166
183 test_remove_unusedImports2() async { 167 test_remove_unusedImports2() async {
184 await _computeUnitAndErrors(r''' 168 await _computeUnitAndErrors(r'''
185 import 'dart:async'; 169 import 'dart:async';
186 import 'dart:math'; 170 import 'dart:math';
187 171
188 class A {} 172 class A {}
189 173
190 main() { 174 main() {
191 Future f; 175 Future f;
192 }'''); 176 }''');
193 // validate change 177 // validate change
194 _assertOrganize( 178 _assertOrganize(r'''
195 r'''
196 import 'dart:async'; 179 import 'dart:async';
197 180
198 class A {} 181 class A {}
199 182
200 main() { 183 main() {
201 Future f; 184 Future f;
202 }''', 185 }''', removeUnresolved: true, removeUnused: true);
203 removeUnresolved: true,
204 removeUnused: true);
205 } 186 }
206 187
207 test_sort() async { 188 test_sort() async {
208 await _computeUnitAndErrors(r''' 189 await _computeUnitAndErrors(r'''
209 library lib; 190 library lib;
210 191
211 export 'dart:bbb'; 192 export 'dart:bbb';
212 import 'dart:bbb'; 193 import 'dart:bbb';
213 export 'package:bbb/bbb.dart'; 194 export 'package:bbb/bbb.dart';
214 export 'http://bbb.com'; 195 export 'http://bbb.com';
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
331 expect(result, expectedCode); 312 expect(result, expectedCode);
332 } 313 }
333 314
334 Future<Null> _computeUnitAndErrors(String code) async { 315 Future<Null> _computeUnitAndErrors(String code) async {
335 addTestSource(code); 316 addTestSource(code);
336 AnalysisResult result = await driver.getResult(testSource.fullName); 317 AnalysisResult result = await driver.getResult(testSource.fullName);
337 testUnit = result.unit; 318 testUnit = result.unit;
338 testErrors = result.errors; 319 testErrors = result.errors;
339 } 320 }
340 } 321 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698