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

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

Issue 2662483003: Better error message for missing async with await (Closed)
Patch Set: Created 3 years, 10 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 454 matching lines...) Expand 10 before | Expand all | Expand 10 after
465 // No fix for ";". 465 // No fix for ";".
466 { 466 {
467 AnalysisError error = errors[0]; 467 AnalysisError error = errors[0];
468 expect(error.message, "Expected to find ';'."); 468 expect(error.message, "Expected to find ';'.");
469 List<Fix> fixes = await _computeFixes(error); 469 List<Fix> fixes = await _computeFixes(error);
470 expect(fixes, isEmpty); 470 expect(fixes, isEmpty);
471 } 471 }
472 // Has fix for "await". 472 // Has fix for "await".
473 { 473 {
474 AnalysisError error = errors[1]; 474 AnalysisError error = errors[1];
475 expect(error.message, startsWith("Undefined name 'await'.")); 475 expect(error.message, startsWith("Undefined name 'await' in function"));
476 List<Fix> fixes = await _computeFixes(error); 476 List<Fix> fixes = await _computeFixes(error);
477 // has exactly one fix 477 // has exactly one fix
478 expect(fixes, hasLength(1)); 478 expect(fixes, hasLength(1));
479 Fix fix = fixes[0]; 479 Fix fix = fixes[0];
480 expect(fix.kind, DartFixKind.ADD_ASYNC); 480 expect(fix.kind, DartFixKind.ADD_ASYNC);
481 // apply to "file" 481 // apply to "file"
482 List<SourceFileEdit> fileEdits = fix.change.edits; 482 List<SourceFileEdit> fileEdits = fix.change.edits;
483 expect(fileEdits, hasLength(1)); 483 expect(fileEdits, hasLength(1));
484 resultCode = SourceEdit.applySequence(testCode, fileEdits[0].edits); 484 resultCode = SourceEdit.applySequence(testCode, fileEdits[0].edits);
485 // verify 485 // verify
(...skipping 5162 matching lines...) Expand 10 before | Expand all | Expand 10 after
5648 5648
5649 @override 5649 @override
5650 final CompilationUnit unit; 5650 final CompilationUnit unit;
5651 5651
5652 @override 5652 @override
5653 final AnalysisError error; 5653 final AnalysisError error;
5654 5654
5655 _DartFixContextImpl(this.resourceProvider, this.getTopLevelDeclarations, 5655 _DartFixContextImpl(this.resourceProvider, this.getTopLevelDeclarations,
5656 this.analysisContext, this.unit, this.error); 5656 this.analysisContext, this.unit, this.error);
5657 } 5657 }
OLDNEW
« no previous file with comments | « no previous file | pkg/analyzer/lib/src/error/codes.dart » ('j') | pkg/analyzer/lib/src/error/codes.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698