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 574 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
585 */ | 585 */ |
586 FileState getFileForPath(String path) { | 586 FileState getFileForPath(String path) { |
587 FileState file = _pathToCanonicalFile[path]; | 587 FileState file = _pathToCanonicalFile[path]; |
588 if (file == null) { | 588 if (file == null) { |
589 File resource = _resourceProvider.getFile(path); | 589 File resource = _resourceProvider.getFile(path); |
590 Source fileSource = resource.createSource(); | 590 Source fileSource = resource.createSource(); |
591 Uri uri = _sourceFactory.restoreUri(fileSource); | 591 Uri uri = _sourceFactory.restoreUri(fileSource); |
592 // Try to get the existing instance. | 592 // Try to get the existing instance. |
593 file = _uriToFile[uri]; | 593 file = _uriToFile[uri]; |
594 // If we have a file, call it the canonical one and return it. | 594 // If we have a file, call it the canonical one and return it. |
595 if (file != null) { | 595 if (file != null && file.path == path) { |
596 _pathToCanonicalFile[path] = file; | 596 _pathToCanonicalFile[path] = file; |
597 return file; | 597 return file; |
598 } | 598 } |
599 // Create a new file. | 599 // Create a new file. |
600 FileSource uriSource = new FileSource(resource, uri); | 600 FileSource uriSource = new FileSource(resource, uri); |
601 file = new FileState._(this, path, uri, uriSource); | 601 file = new FileState._(this, path, uri, uriSource); |
602 _uriToFile[uri] = file; | 602 _uriToFile[uri] = file; |
603 _addFileWithPath(path, file); | 603 _addFileWithPath(path, file); |
604 _pathToCanonicalFile[path] = file; | 604 _pathToCanonicalFile[path] = file; |
605 file.refresh(); | 605 file.refresh(); |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
680 .where((f) => f._transitiveFiles == null) | 680 .where((f) => f._transitiveFiles == null) |
681 .toSet(); | 681 .toSet(); |
682 } | 682 } |
683 | 683 |
684 Set<FileState> get filesWithoutTransitiveSignature { | 684 Set<FileState> get filesWithoutTransitiveSignature { |
685 return state._uriToFile.values | 685 return state._uriToFile.values |
686 .where((f) => f._transitiveSignature == null) | 686 .where((f) => f._transitiveSignature == null) |
687 .toSet(); | 687 .toSet(); |
688 } | 688 } |
689 } | 689 } |
OLD | NEW |