| 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.integration.analysis.outline; | 5 library test.integration.analysis.outline; |
| 6 | 6 |
| 7 import 'package:analysis_server/src/protocol.dart'; | 7 import 'package:analysis_server/src/protocol.dart'; |
| 8 import 'package:unittest/unittest.dart'; | 8 import 'package:unittest/unittest.dart'; |
| 9 | 9 |
| 10 import '../../reflective_tests.dart'; | 10 import '../../reflective_tests.dart'; |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 } | 34 } |
| 35 | 35 |
| 36 class Class2 { | 36 class Class2 { |
| 37 } | 37 } |
| 38 '''; | 38 '''; |
| 39 writeFile(pathname, text); | 39 writeFile(pathname, text); |
| 40 standardAnalysisSetup(); | 40 standardAnalysisSetup(); |
| 41 sendAnalysisSetSubscriptions({ | 41 sendAnalysisSetSubscriptions({ |
| 42 AnalysisService.OUTLINE: [pathname] | 42 AnalysisService.OUTLINE: [pathname] |
| 43 }); | 43 }); |
| 44 Map outline; | 44 Outline outline; |
| 45 onAnalysisOutline.listen((params) { | 45 onAnalysisOutline.listen((AnalysisOutlineParams params) { |
| 46 expect(params['file'], equals(pathname)); | 46 expect(params.file, equals(pathname)); |
| 47 outline = params['outline']; | 47 outline = params.outline; |
| 48 }); | 48 }); |
| 49 return analysisFinished.then((_) { | 49 return analysisFinished.then((_) { |
| 50 expect(outline['element']['kind'], equals('COMPILATION_UNIT')); | 50 expect(outline.element.kind, equals(ElementKind.COMPILATION_UNIT)); |
| 51 expect(outline['offset'], equals(0)); | 51 expect(outline.offset, equals(0)); |
| 52 expect(outline['length'], equals(text.length)); | 52 expect(outline.length, equals(text.length)); |
| 53 List classes = outline['children']; | 53 List<Outline> classes = outline.children; |
| 54 expect(classes, hasLength(2)); | 54 expect(classes, hasLength(2)); |
| 55 expect(classes[0]['element']['name'], equals('Class1')); | 55 expect(classes[0].element.name, equals('Class1')); |
| 56 expect(classes[1]['element']['name'], equals('Class2')); | 56 expect(classes[1].element.name, equals('Class2')); |
| 57 checkConnected(classes); | 57 checkConnected(classes); |
| 58 List members = classes[0]['children']; | 58 List<Outline> members = classes[0].children; |
| 59 expect(members, hasLength(5)); | 59 expect(members, hasLength(5)); |
| 60 expect(members[0]['element']['name'], equals('field')); | 60 expect(members[0].element.name, equals('field')); |
| 61 expect(members[1]['element']['name'], equals('method')); | 61 expect(members[1].element.name, equals('method')); |
| 62 expect(members[2]['element']['name'], equals('staticMethod')); | 62 expect(members[2].element.name, equals('staticMethod')); |
| 63 expect(members[3]['element']['name'], equals('getter')); | 63 expect(members[3].element.name, equals('getter')); |
| 64 expect(members[4]['element']['name'], equals('setter')); | 64 expect(members[4].element.name, equals('setter')); |
| 65 checkConnected(members); | 65 checkConnected(members); |
| 66 }); | 66 }); |
| 67 } | 67 } |
| 68 | 68 |
| 69 /** | 69 /** |
| 70 * Verify that the range of source text covered by the given outline objects | 70 * Verify that the range of source text covered by the given outline objects |
| 71 * is connected (the end of each object in the list corresponds to the start | 71 * is connected (the end of each object in the list corresponds to the start |
| 72 * of the next). | 72 * of the next). |
| 73 */ | 73 */ |
| 74 void checkConnected(List outlineObjects) { | 74 void checkConnected(List<Outline> outlineObjects) { |
| 75 for (int i = 0; i < outlineObjects.length - 1; i++) { | 75 for (int i = 0; i < outlineObjects.length - 1; i++) { |
| 76 expect(outlineObjects[i + 1]['offset'], equals(outlineObjects[i]['offset'] | 76 expect(outlineObjects[i + 1].offset, equals(outlineObjects[i].offset |
| 77 + outlineObjects[i]['length'])); | 77 + outlineObjects[i].length)); |
| 78 } | 78 } |
| 79 } | 79 } |
| 80 } | 80 } |
| 81 | 81 |
| 82 main() { | 82 main() { |
| 83 runReflectiveTests(Test); | 83 runReflectiveTests(Test); |
| 84 } | 84 } |
| OLD | NEW |