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

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

Issue 1764853002: Quick fix to ignore a specific error (#25915). (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: fixes Created 4 years, 9 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 library test.services.correction.fix; 5 library test.services.correction.fix;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 8
9 import 'package:analysis_server/plugin/edit/fix/fix_core.dart'; 9 import 'package:analysis_server/plugin/edit/fix/fix_core.dart';
10 import 'package:analysis_server/plugin/edit/fix/fix_dart.dart'; 10 import 'package:analysis_server/plugin/edit/fix/fix_dart.dart';
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after
245 ''' 245 '''
246 class Test { 246 class Test {
247 final int a; 247 final int a;
248 final int b; 248 final int b;
249 final int c; 249 final int c;
250 Test(this.a, this.b, [this.c]); 250 Test(this.a, this.b, [this.c]);
251 } 251 }
252 '''); 252 ''');
253 } 253 }
254 254
255 test_addIgnoreWarning() async {
256 resolveTestUnit('''
257 main() {
258 int x = ''; //invalid_assignment
259 }
260 ''');
261 await assertHasFix(
262 DartFixKind.IGNORE_ERROR,
263 '''
264 main() {
265 //ignore: invalid_assignment
266 int x = ''; //invalid_assignment
267 }
268 ''');
269 }
270
255 test_addMissingParameter_function_positional_hasNamed() async { 271 test_addMissingParameter_function_positional_hasNamed() async {
256 resolveTestUnit(''' 272 resolveTestUnit('''
257 test({int a}) {} 273 test({int a}) {}
258 main() { 274 main() {
259 test(1); 275 test(1);
260 } 276 }
261 '''); 277 ''');
262 await assertNoFix(DartFixKind.ADD_MISSING_PARAMETER_POSITIONAL); 278 await assertNoFix(DartFixKind.ADD_MISSING_PARAMETER_POSITIONAL);
263 } 279 }
264 280
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
466 String message1 = "Expected to find ';'"; 482 String message1 = "Expected to find ';'";
467 String message2 = "Undefined name 'await'"; 483 String message2 = "Undefined name 'await'";
468 expect(errors.map((e) => e.message), unorderedEquals([message1, message2])); 484 expect(errors.map((e) => e.message), unorderedEquals([message1, message2]));
469 for (AnalysisError error in errors) { 485 for (AnalysisError error in errors) {
470 if (error.message == message1) { 486 if (error.message == message1) {
471 List<Fix> fixes = await _computeFixes(error); 487 List<Fix> fixes = await _computeFixes(error);
472 expect(fixes, isEmpty); 488 expect(fixes, isEmpty);
473 } 489 }
474 if (error.message == message2) { 490 if (error.message == message2) {
475 List<Fix> fixes = await _computeFixes(error); 491 List<Fix> fixes = await _computeFixes(error);
492 // remove ignore fix
493 fixes.removeWhere((Fix fix) => fix.kind == DartFixKind.IGNORE_ERROR);
476 // has exactly one fix 494 // has exactly one fix
477 expect(fixes, hasLength(1)); 495 expect(fixes, hasLength(1));
478 Fix fix = fixes[0]; 496 Fix fix = fixes[0];
479 expect(fix.kind, DartFixKind.ADD_ASYNC); 497 expect(fix.kind, DartFixKind.ADD_ASYNC);
480 // apply to "file" 498 // apply to "file"
481 List<SourceFileEdit> fileEdits = fix.change.edits; 499 List<SourceFileEdit> fileEdits = fix.change.edits;
482 expect(fileEdits, hasLength(1)); 500 expect(fileEdits, hasLength(1));
483 resultCode = SourceEdit.applySequence(testCode, fileEdits[0].edits); 501 resultCode = SourceEdit.applySequence(testCode, fileEdits[0].edits);
484 // verify 502 // verify
485 expect( 503 expect(
(...skipping 4748 matching lines...) Expand 10 before | Expand all | Expand 10 after
5234 @override 5252 @override
5235 void t() { } 5253 void t() { }
5236 } 5254 }
5237 '''); 5255 ''');
5238 } 5256 }
5239 5257
5240 void verifyResult(String expectedResult) { 5258 void verifyResult(String expectedResult) {
5241 expect(resultCode, expectedResult); 5259 expect(resultCode, expectedResult);
5242 } 5260 }
5243 } 5261 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698