Chromium Code Reviews| 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 resource; | 5 library resource; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 import 'dart:collection'; | |
| 8 import 'dart:io' as io; | 9 import 'dart:io' as io; |
| 9 | 10 |
| 10 import 'package:analyzer/src/generated/engine.dart' show TimestampedData; | 11 import 'package:analyzer/src/generated/engine.dart' show TimestampedData; |
| 11 import 'package:analyzer/src/generated/java_io.dart'; | 12 import 'package:analyzer/src/generated/java_io.dart'; |
| 12 import 'package:analyzer/src/generated/source_io.dart'; | 13 import 'package:analyzer/src/generated/source_io.dart'; |
| 13 import 'package:path/path.dart'; | 14 import 'package:path/path.dart'; |
| 14 import 'package:watcher/watcher.dart'; | 15 import 'package:watcher/watcher.dart'; |
| 15 | 16 |
| 16 | 17 |
| 17 /** | 18 /** |
| (...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 258 return streamController.stream; | 259 return streamController.stream; |
| 259 } | 260 } |
| 260 } | 261 } |
| 261 | 262 |
| 262 | 263 |
| 263 /** | 264 /** |
| 264 * An in-memory implementation of [ResourceProvider]. | 265 * An in-memory implementation of [ResourceProvider]. |
| 265 * Use `/` as a path separator. | 266 * Use `/` as a path separator. |
| 266 */ | 267 */ |
| 267 class MemoryResourceProvider implements ResourceProvider { | 268 class MemoryResourceProvider implements ResourceProvider { |
| 268 final Map<String, _MemoryResource> _pathToResource = <String, _MemoryResource> {}; | 269 final Map<String, _MemoryResource> _pathToResource = new HashMap<String, _Memo ryResource>(); |
|
scheglov
2014/06/06 19:26:46
More than 80 characters.
| |
| 269 final Map<String, String> _pathToContent = <String, String>{}; | 270 final Map<String, String> _pathToContent = new HashMap<String, String>(); |
| 270 final Map<String, int> _pathToTimestamp = <String, int>{}; | 271 final Map<String, int> _pathToTimestamp = new HashMap<String, int>(); |
| 271 final Map<String, StreamController<WatchEvent>> _pathToWatcher = | 272 final Map<String, StreamController<WatchEvent>> _pathToWatcher = |
| 272 <String, StreamController<WatchEvent>>{}; | 273 new HashMap<String, StreamController<WatchEvent>>(); |
| 273 int nextStamp = 0; | 274 int nextStamp = 0; |
| 274 | 275 |
| 275 @override | 276 @override |
| 276 Resource getResource(String path) { | 277 Resource getResource(String path) { |
| 277 path = posix.normalize(path); | 278 path = posix.normalize(path); |
| 278 Resource resource = _pathToResource[path]; | 279 Resource resource = _pathToResource[path]; |
| 279 if (resource == null) { | 280 if (resource == null) { |
| 280 resource = new _MemoryFile(this, path); | 281 resource = new _MemoryFile(this, path); |
| 281 } | 282 } |
| 282 return resource; | 283 return resource; |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 447 return new _PhysicalFolder(directory); | 448 return new _PhysicalFolder(directory); |
| 448 } else { | 449 } else { |
| 449 io.File file = new io.File(path); | 450 io.File file = new io.File(path); |
| 450 return new _PhysicalFile(file); | 451 return new _PhysicalFile(file); |
| 451 } | 452 } |
| 452 } | 453 } |
| 453 | 454 |
| 454 @override | 455 @override |
| 455 Context get pathContext => io.Platform.isWindows ? windows : posix; | 456 Context get pathContext => io.Platform.isWindows ? windows : posix; |
| 456 } | 457 } |
| OLD | NEW |