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/dart/ast/ast.dart'; | 8 import 'package:analyzer/dart/ast/ast.dart'; |
9 import 'package:analyzer/dart/ast/token.dart'; | 9 import 'package:analyzer/dart/ast/token.dart'; |
10 import 'package:analyzer/error/listener.dart'; | 10 import 'package:analyzer/error/listener.dart'; |
(...skipping 643 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
654 FileState canonicalFile = getFileForPath(path); | 654 FileState canonicalFile = getFileForPath(path); |
655 List<FileState> allFiles = _pathToFiles[path].toList(); | 655 List<FileState> allFiles = _pathToFiles[path].toList(); |
656 if (allFiles.length == 1) { | 656 if (allFiles.length == 1) { |
657 return allFiles; | 657 return allFiles; |
658 } | 658 } |
659 return allFiles | 659 return allFiles |
660 ..remove(canonicalFile) | 660 ..remove(canonicalFile) |
661 ..insert(0, canonicalFile); | 661 ..insert(0, canonicalFile); |
662 } | 662 } |
663 | 663 |
| 664 /** |
| 665 * Remove the file with the given [path]. |
| 666 */ |
| 667 void removeFile(String path) { |
| 668 _uriToFile.clear(); |
| 669 knownFilePaths.clear(); |
| 670 _pathToFiles.clear(); |
| 671 _pathToCanonicalFile.clear(); |
| 672 _partToLibraries.clear(); |
| 673 } |
| 674 |
664 void _addFileWithPath(String path, FileState file) { | 675 void _addFileWithPath(String path, FileState file) { |
665 var files = _pathToFiles[path]; | 676 var files = _pathToFiles[path]; |
666 if (files == null) { | 677 if (files == null) { |
667 knownFilePaths.add(path); | 678 knownFilePaths.add(path); |
668 files = <FileState>[]; | 679 files = <FileState>[]; |
669 _pathToFiles[path] = files; | 680 _pathToFiles[path] = files; |
670 } | 681 } |
671 files.add(file); | 682 files.add(file); |
672 } | 683 } |
673 } | 684 } |
674 | 685 |
675 @visibleForTesting | 686 @visibleForTesting |
676 class FileSystemStateTestView { | 687 class FileSystemStateTestView { |
677 final FileSystemState state; | 688 final FileSystemState state; |
678 | 689 |
679 FileSystemStateTestView(this.state); | 690 FileSystemStateTestView(this.state); |
680 | 691 |
681 Set<FileState> get filesWithoutTransitiveFiles { | 692 Set<FileState> get filesWithoutTransitiveFiles { |
682 return state._uriToFile.values | 693 return state._uriToFile.values |
683 .where((f) => f._transitiveFiles == null) | 694 .where((f) => f._transitiveFiles == null) |
684 .toSet(); | 695 .toSet(); |
685 } | 696 } |
686 | 697 |
687 Set<FileState> get filesWithoutTransitiveSignature { | 698 Set<FileState> get filesWithoutTransitiveSignature { |
688 return state._uriToFile.values | 699 return state._uriToFile.values |
689 .where((f) => f._transitiveSignature == null) | 700 .where((f) => f._transitiveSignature == null) |
690 .toSet(); | 701 .toSet(); |
691 } | 702 } |
692 } | 703 } |
OLD | NEW |