OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file |
| 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. |
| 4 |
| 5 import 'dart:async'; |
| 6 |
| 7 import 'package:analysis_server/protocol/protocol_generated.dart'; |
| 8 import 'package:analysis_server/src/computer/imported_elements_computer.dart'; |
| 9 import 'package:analyzer/dart/analysis/results.dart'; |
| 10 import 'package:test/test.dart'; |
| 11 import 'package:test_reflective_loader/test_reflective_loader.dart'; |
| 12 |
| 13 import '../../abstract_context.dart'; |
| 14 |
| 15 main() { |
| 16 defineReflectiveSuite(() { |
| 17 defineReflectiveTests(ImportElementsComputerTest); |
| 18 }); |
| 19 } |
| 20 |
| 21 @reflectiveTest |
| 22 class ImportElementsComputerTest extends AbstractContextTest { |
| 23 String sourcePath; |
| 24 |
| 25 setUp() { |
| 26 super.setUp(); |
| 27 sourcePath = provider.convertPath('/p/lib/source.dart'); |
| 28 } |
| 29 |
| 30 test_none() async { |
| 31 String selection = 'x + y + 1'; |
| 32 String content = """ |
| 33 plusThree(int x) { |
| 34 int y = 2; |
| 35 print($selection); |
| 36 } |
| 37 """; |
| 38 List<ImportedElements> elements = await _computeElements( |
| 39 content, content.indexOf(selection), selection.length); |
| 40 expect(elements, hasLength(0)); |
| 41 } |
| 42 |
| 43 Future<List<ImportedElements>> _computeElements( |
| 44 String sourceContent, int offset, int length) async { |
| 45 provider.newFile(sourcePath, sourceContent); |
| 46 ResolveResult result = await driver.getResult(sourcePath); |
| 47 ImportedElementsComputer computer = |
| 48 new ImportedElementsComputer(result.unit, offset, length); |
| 49 return computer.compute(); |
| 50 } |
| 51 } |
OLD | NEW |