| 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/computer/element.dart'; | |
| 10 import 'package:analysis_server/src/computer/error.dart'; | |
| 11 import 'package:analysis_server/src/constants.dart'; | 9 import 'package:analysis_server/src/constants.dart'; |
| 12 import 'package:analysis_server/src/edit/edit_domain.dart'; | 10 import 'package:analysis_server/src/edit/edit_domain.dart'; |
| 13 import 'package:analysis_server/src/edit/fix.dart'; | |
| 14 import 'package:analysis_server/src/protocol.dart'; | 11 import 'package:analysis_server/src/protocol.dart'; |
| 15 import 'package:analysis_services/constants.dart'; | 12 import 'package:analysis_services/constants.dart'; |
| 16 import 'package:analysis_services/correction/change.dart'; | |
| 17 import 'package:analysis_testing/reflective_tests.dart'; | 13 import 'package:analysis_testing/reflective_tests.dart'; |
| 18 import 'package:unittest/unittest.dart'; | 14 import 'package:unittest/unittest.dart' hide ERROR; |
| 19 | 15 |
| 20 import '../analysis_abstract.dart'; | 16 import '../analysis_abstract.dart'; |
| 21 | 17 |
| 22 | 18 |
| 23 main() { | 19 main() { |
| 24 groupSep = ' | '; | 20 groupSep = ' | '; |
| 25 runReflectiveTests(FixesTest); | 21 runReflectiveTests(FixesTest); |
| 26 } | 22 } |
| 27 | 23 |
| 28 | 24 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 40 main() { | 36 main() { |
| 41 print(42) | 37 print(42) |
| 42 } | 38 } |
| 43 '''); | 39 '''); |
| 44 return waitForTasksFinished().then((_) { | 40 return waitForTasksFinished().then((_) { |
| 45 Request request = new Request('0', EDIT_GET_FIXES); | 41 Request request = new Request('0', EDIT_GET_FIXES); |
| 46 request.setParameter(FILE, testFile); | 42 request.setParameter(FILE, testFile); |
| 47 request.setParameter(OFFSET, findOffset('print')); | 43 request.setParameter(OFFSET, findOffset('print')); |
| 48 Response response = handleSuccessfulRequest(request); | 44 Response response = handleSuccessfulRequest(request); |
| 49 List<Map<String, Object>> errorFixesJsonList = response.getResult(FIXES); | 45 List<Map<String, Object>> errorFixesJsonList = response.getResult(FIXES); |
| 50 List<ErrorFixes> errorFixesList = errorFixesJsonList.map(ErrorFixes.fromJs
on).toList(); | 46 expect(errorFixesJsonList, hasLength(1)); |
| 51 expect(errorFixesList, hasLength(1)); | |
| 52 { | 47 { |
| 53 ErrorFixes errorFixes = errorFixesList[0]; | 48 Map<String, Object> fixes = errorFixesJsonList[0]; |
| 54 { | 49 Map<String, Object> error = fixes[ERROR]; |
| 55 AnalysisError error = errorFixes.error; | 50 expect(error[SEVERITY], 'ERROR'); |
| 56 expect(error.severity, 'ERROR'); | 51 expect(error[TYPE], 'SYNTACTIC_ERROR'); |
| 57 expect(error.type, 'SYNTACTIC_ERROR'); | 52 expect(fixes[FIXES], hasLength(1)); |
| 58 expect(error.message, "Expected to find ';'"); | |
| 59 { | |
| 60 Location location = error.location; | |
| 61 expect(location.file, testFile); | |
| 62 expect(location.offset, 19); | |
| 63 expect(location.length, 1); | |
| 64 expect(location.startLine, 2); | |
| 65 expect(location.startColumn, 11); | |
| 66 } | |
| 67 } | |
| 68 expect(errorFixes.fixes, hasLength(1)); | |
| 69 { | |
| 70 Change change = errorFixes.fixes[0]; | |
| 71 expect(change.message, "Insert ';'"); | |
| 72 expect(change.edits, hasLength(1)); | |
| 73 { | |
| 74 FileEdit fileEdit = change.edits[0]; | |
| 75 expect(fileEdit.file, testFile); | |
| 76 expect( | |
| 77 fileEdit.edits.toString(), | |
| 78 "[Edit(offset=20, length=0, replacement=:>;<:)]"); | |
| 79 } | |
| 80 } | |
| 81 } | 53 } |
| 82 }); | 54 }); |
| 83 } | 55 } |
| 84 } | 56 } |
| OLD | NEW |