| 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 library analyzer.file_system.memory_file_system; | 5 library analyzer.file_system.memory_file_system; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 import 'dart:collection'; | 8 import 'dart:collection'; |
| 9 import 'dart:convert'; | 9 import 'dart:convert'; |
| 10 import 'dart:core'; | 10 import 'dart:core'; |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 88 _pathToResource.remove(path); | 88 _pathToResource.remove(path); |
| 89 _pathToBytes.remove(path); | 89 _pathToBytes.remove(path); |
| 90 _pathToTimestamp.remove(path); | 90 _pathToTimestamp.remove(path); |
| 91 _notifyWatchers(path, ChangeType.REMOVE); | 91 _notifyWatchers(path, ChangeType.REMOVE); |
| 92 } | 92 } |
| 93 | 93 |
| 94 @override | 94 @override |
| 95 File getFile(String path) => new _MemoryFile(this, path); | 95 File getFile(String path) => new _MemoryFile(this, path); |
| 96 | 96 |
| 97 @override | 97 @override |
| 98 Folder getFolder(String path) => newFolder(path); | 98 Folder getFolder(String path) { |
| 99 path = pathContext.normalize(path); |
| 100 if (!pathContext.isAbsolute(path)) { |
| 101 throw new ArgumentError("Path must be absolute : $path"); |
| 102 } |
| 103 return new _MemoryFolder(this, path); |
| 104 } |
| 99 | 105 |
| 100 @override | 106 @override |
| 101 Future<List<int>> getModificationTimes(List<Source> sources) async { | 107 Future<List<int>> getModificationTimes(List<Source> sources) async { |
| 102 return sources.map((source) { | 108 return sources.map((source) { |
| 103 String path = source.fullName; | 109 String path = source.fullName; |
| 104 return _pathToTimestamp[path] ?? -1; | 110 return _pathToTimestamp[path] ?? -1; |
| 105 }).toList(); | 111 }).toList(); |
| 106 } | 112 } |
| 107 | 113 |
| 108 @override | 114 @override |
| (...skipping 426 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 535 | 541 |
| 536 @override | 542 @override |
| 537 get hashCode => path.hashCode; | 543 get hashCode => path.hashCode; |
| 538 | 544 |
| 539 @override | 545 @override |
| 540 Folder get parent { | 546 Folder get parent { |
| 541 String parentPath = _provider.pathContext.dirname(path); | 547 String parentPath = _provider.pathContext.dirname(path); |
| 542 if (parentPath == path) { | 548 if (parentPath == path) { |
| 543 return null; | 549 return null; |
| 544 } | 550 } |
| 545 return _provider.getResource(parentPath); | 551 return _provider.getFolder(parentPath); |
| 546 } | 552 } |
| 547 | 553 |
| 548 @override | 554 @override |
| 549 String get shortName => _provider.pathContext.basename(path); | 555 String get shortName => _provider.pathContext.basename(path); |
| 550 | 556 |
| 551 @override | 557 @override |
| 552 bool operator ==(other) { | 558 bool operator ==(other) { |
| 553 if (runtimeType != other.runtimeType) { | 559 if (runtimeType != other.runtimeType) { |
| 554 return false; | 560 return false; |
| 555 } | 561 } |
| 556 return path == other.path; | 562 return path == other.path; |
| 557 } | 563 } |
| 558 | 564 |
| 559 @override | 565 @override |
| 560 String toString() => path; | 566 String toString() => path; |
| 561 | 567 |
| 562 @override | 568 @override |
| 563 Uri toUri() => _provider.pathContext.toUri(path); | 569 Uri toUri() => _provider.pathContext.toUri(path); |
| 564 } | 570 } |
| OLD | NEW |