| OLD | NEW |
| 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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:convert'; | 5 import 'dart:convert'; |
| 6 import 'dart:typed_data'; | 6 import 'dart:typed_data'; |
| 7 | 7 |
| 8 import 'package:analyzer/file_system/file_system.dart'; | 8 import 'package:analyzer/file_system/file_system.dart'; |
| 9 import 'package:analyzer/file_system/memory_file_system.dart'; | 9 import 'package:analyzer/file_system/memory_file_system.dart'; |
| 10 import 'package:analyzer/source/package_map_resolver.dart'; | 10 import 'package:analyzer/source/package_map_resolver.dart'; |
| (...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 317 | 317 |
| 318 expect(file.partedFiles, hasLength(1)); | 318 expect(file.partedFiles, hasLength(1)); |
| 319 expect(file.partedFiles[0].path, a4); | 319 expect(file.partedFiles[0].path, a4); |
| 320 expect(file.partedFiles[0].uri, FastUri.parse('package:aaa/a4.dart')); | 320 expect(file.partedFiles[0].uri, FastUri.parse('package:aaa/a4.dart')); |
| 321 | 321 |
| 322 expect(file.directReferencedFiles, hasLength(5)); | 322 expect(file.directReferencedFiles, hasLength(5)); |
| 323 | 323 |
| 324 expect(fileSystemState.getFilesForPath(a1), [file]); | 324 expect(fileSystemState.getFilesForPath(a1), [file]); |
| 325 } | 325 } |
| 326 | 326 |
| 327 test_getFileForPath_onlyDartFiles() { |
| 328 String a = _p('/test/lib/a.dart'); |
| 329 String b = _p('/test/lib/b.dart'); |
| 330 String c = _p('/test/lib/c.dart'); |
| 331 String d = _p('/test/lib/d.dart'); |
| 332 provider.newFile( |
| 333 a, |
| 334 r''' |
| 335 library lib; |
| 336 import 'dart:math'; |
| 337 import 'b.dart'; |
| 338 import 'not_dart.txt'; |
| 339 export 'c.dart'; |
| 340 export 'not_dart.txt'; |
| 341 part 'd.dart'; |
| 342 part 'not_dart.txt'; |
| 343 '''); |
| 344 FileState file = fileSystemState.getFileForPath(a); |
| 345 expect(file.importedFiles.map((f) => f.path), [b]); |
| 346 expect(file.exportedFiles.map((f) => f.path), [c]); |
| 347 expect(file.partedFiles.map((f) => f.path), [d]); |
| 348 expect(fileSystemState.knownFilePaths, unorderedEquals([a, b, c, d])); |
| 349 } |
| 350 |
| 327 test_getFileForPath_part() { | 351 test_getFileForPath_part() { |
| 328 String a1 = _p('/aaa/lib/a1.dart'); | 352 String a1 = _p('/aaa/lib/a1.dart'); |
| 329 String a2 = _p('/aaa/lib/a2.dart'); | 353 String a2 = _p('/aaa/lib/a2.dart'); |
| 330 provider.newFile( | 354 provider.newFile( |
| 331 a1, | 355 a1, |
| 332 r''' | 356 r''' |
| 333 library a1; | 357 library a1; |
| 334 part 'a2.dart'; | 358 part 'a2.dart'; |
| 335 '''); | 359 '''); |
| 336 provider.newFile( | 360 provider.newFile( |
| (...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 653 void _assertTransitiveFiles(FileState file, List<FileState> expected) { | 677 void _assertTransitiveFiles(FileState file, List<FileState> expected) { |
| 654 expect(file.transitiveFiles, unorderedEquals(expected)); | 678 expect(file.transitiveFiles, unorderedEquals(expected)); |
| 655 } | 679 } |
| 656 | 680 |
| 657 String _p(String path) => provider.convertPath(path); | 681 String _p(String path) => provider.convertPath(path); |
| 658 | 682 |
| 659 static String _md5(String content) { | 683 static String _md5(String content) { |
| 660 return hex.encode(md5.convert(UTF8.encode(content)).bytes); | 684 return hex.encode(md5.convert(UTF8.encode(content)).bytes); |
| 661 } | 685 } |
| 662 } | 686 } |
| OLD | NEW |