| OLD | NEW |
| 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.edit.fixes; | 5 library test.edit.fixes; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 | 8 |
| 9 import 'package:analysis_server/src/edit/edit_domain.dart'; | 9 import 'package:analysis_server/src/edit/edit_domain.dart'; |
| 10 import 'package:analysis_server/src/protocol.dart'; | 10 import 'package:analysis_server/src/protocol.dart'; |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 foo() { | 34 foo() { |
| 35 print(1) | 35 print(1) |
| 36 } | 36 } |
| 37 bar() { | 37 bar() { |
| 38 print(10) print(20) | 38 print(10) print(20) |
| 39 } | 39 } |
| 40 '''); | 40 '''); |
| 41 return waitForTasksFinished().then((_) { | 41 return waitForTasksFinished().then((_) { |
| 42 // print(1) | 42 // print(1) |
| 43 { | 43 { |
| 44 List<ErrorFixes> errorFixes = _getFixesAt('print(1)'); | 44 List<AnalysisErrorFixes> errorFixes = _getFixesAt('print(1)'); |
| 45 expect(errorFixes, hasLength(1)); | 45 expect(errorFixes, hasLength(1)); |
| 46 _isSyntacticErrorWithSingleFix(errorFixes[0]); | 46 _isSyntacticErrorWithSingleFix(errorFixes[0]); |
| 47 } | 47 } |
| 48 // print(10) | 48 // print(10) |
| 49 { | 49 { |
| 50 List<ErrorFixes> errorFixes = _getFixesAt('print(10)'); | 50 List<AnalysisErrorFixes> errorFixes = _getFixesAt('print(10)'); |
| 51 expect(errorFixes, hasLength(2)); | 51 expect(errorFixes, hasLength(2)); |
| 52 _isSyntacticErrorWithSingleFix(errorFixes[0]); | 52 _isSyntacticErrorWithSingleFix(errorFixes[0]); |
| 53 _isSyntacticErrorWithSingleFix(errorFixes[1]); | 53 _isSyntacticErrorWithSingleFix(errorFixes[1]); |
| 54 } | 54 } |
| 55 }); | 55 }); |
| 56 } | 56 } |
| 57 | 57 |
| 58 void _isSyntacticErrorWithSingleFix(ErrorFixes fixes) { | 58 void _isSyntacticErrorWithSingleFix(AnalysisErrorFixes fixes) { |
| 59 AnalysisError error = fixes.error; | 59 AnalysisError error = fixes.error; |
| 60 expect(error.severity, ErrorSeverity.ERROR); | 60 expect(error.severity, AnalysisErrorSeverity.ERROR); |
| 61 expect(error.type, ErrorType.SYNTACTIC_ERROR); | 61 expect(error.type, AnalysisErrorType.SYNTACTIC_ERROR); |
| 62 expect(fixes.fixes, hasLength(1)); | 62 expect(fixes.fixes, hasLength(1)); |
| 63 } | 63 } |
| 64 | 64 |
| 65 List<ErrorFixes> _getFixesAt(String search) { | 65 List<AnalysisErrorFixes> _getFixesAt(String search) { |
| 66 int offset = findOffset(search); | 66 int offset = findOffset(search); |
| 67 return _getFixes(offset); | 67 return _getFixes(offset); |
| 68 } | 68 } |
| 69 | 69 |
| 70 | 70 |
| 71 List<ErrorFixes> _getFixes(int offset) { | 71 List<AnalysisErrorFixes> _getFixes(int offset) { |
| 72 Request request = new EditGetFixesParams(testFile, offset).toRequest('0'); | 72 Request request = new EditGetFixesParams(testFile, offset).toRequest('0'); |
| 73 Response response = handleSuccessfulRequest(request); | 73 Response response = handleSuccessfulRequest(request); |
| 74 var result = new EditGetFixesResult.fromResponse(response); | 74 var result = new EditGetFixesResult.fromResponse(response); |
| 75 return result.fixes; | 75 return result.fixes; |
| 76 } | 76 } |
| 77 } | 77 } |
| OLD | NEW |