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 import 'dart:async'; | 5 import 'dart:async'; |
6 | 6 |
7 import 'package:analysis_server/src/provisional/completion/dart/completion_dart.
dart'; | 7 import 'package:analysis_server/src/provisional/completion/dart/completion_dart.
dart'; |
8 import 'package:analysis_server/src/services/completion/completion_core.dart'; | 8 import 'package:analysis_server/src/services/completion/completion_core.dart'; |
9 import 'package:analysis_server/src/services/completion/completion_performance.d
art'; | 9 import 'package:analysis_server/src/services/completion/completion_performance.d
art'; |
10 import 'package:analysis_server/src/services/completion/dart/completion_manager.
dart'; | 10 import 'package:analysis_server/src/services/completion/dart/completion_manager.
dart'; |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 requestCompleter.complete(request); | 60 requestCompleter.complete(request); |
61 }); | 61 }); |
62 request = await performAnalysis(200, requestCompleter); | 62 request = await performAnalysis(200, requestCompleter); |
63 | 63 |
64 var directives = request.target.unit.directives; | 64 var directives = request.target.unit.directives; |
65 | 65 |
66 List<ImportElement> imports = request.libraryElement.imports; | 66 List<ImportElement> imports = request.libraryElement.imports; |
67 expect(imports, hasLength(directives.length + 1)); | 67 expect(imports, hasLength(directives.length + 1)); |
68 | 68 |
69 ImportElement importNamed(String expectedUri) { | 69 ImportElement importNamed(String expectedUri) { |
70 return imports.firstWhere((elem) => elem.uri == expectedUri, orElse: () { | 70 List<String> uriList = <String>[]; |
71 var importedNames = imports.map((elem) => elem.uri); | 71 for (ImportElement importElement in imports) { |
72 fail('Failed to find $expectedUri in $importedNames'); | 72 String uri = importElement.importedLibrary.source.uri.toString(); |
73 }); | 73 uriList.add(uri); |
| 74 if (uri.endsWith(expectedUri)) { |
| 75 return importElement; |
| 76 } |
| 77 } |
| 78 fail('Failed to find $expectedUri in $uriList'); |
| 79 return null; |
74 } | 80 } |
75 | 81 |
76 void assertImportedLib(String expectedUri) { | 82 void assertImportedLib(String expectedUri) { |
77 ImportElement importElem = importNamed(expectedUri); | 83 ImportElement importElem = importNamed(expectedUri); |
78 expect(importElem.importedLibrary.exportNamespace, isNotNull); | 84 expect(importElem.importedLibrary.exportNamespace, isNotNull); |
79 } | 85 } |
80 | 86 |
81 // Assert that the new imports each have an export namespace | 87 // Assert that the new imports each have an export namespace |
82 assertImportedLib(null /* dart:core */); | 88 assertImportedLib('dart:core'); |
83 assertImportedLib('/libA.dart'); | 89 assertImportedLib('libA.dart'); |
84 } | 90 } |
85 } | 91 } |
OLD | NEW |