Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(280)

Side by Side Diff: pkg/analysis_server/lib/src/resource.dart

Issue 300853006: Tests for exceptional situations in MemoryResourceProvider. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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:io' as io; 7 import 'dart:io' as io;
8 8
9 import 'package:analyzer/src/generated/engine.dart' show TimestampedData; 9 import 'package:analyzer/src/generated/engine.dart' show TimestampedData;
10 import 'package:analyzer/src/generated/java_io.dart'; 10 import 'package:analyzer/src/generated/java_io.dart';
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 path = posix.normalize(path); 240 path = posix.normalize(path);
241 Resource resource = _pathToResource[path]; 241 Resource resource = _pathToResource[path];
242 if (resource == null) { 242 if (resource == null) {
243 resource = new _MemoryFile(this, path); 243 resource = new _MemoryFile(this, path);
244 } 244 }
245 return resource; 245 return resource;
246 } 246 }
247 247
248 Folder newFolder(String path) { 248 Folder newFolder(String path) {
249 path = posix.normalize(path); 249 path = posix.normalize(path);
250 if (path.isEmpty) {
251 throw new ArgumentError('Empty paths are not supported');
252 }
253 if (!path.startsWith('/')) { 250 if (!path.startsWith('/')) {
254 throw new ArgumentError("Path must start with '/'"); 251 throw new ArgumentError("Path must start with '/'");
255 } 252 }
256 _MemoryFolder folder = null; 253 _MemoryFolder folder = null;
257 String partialPath = ""; 254 String partialPath = "";
258 for (String pathPart in path.split('/')) { 255 for (String pathPart in path.split('/')) {
259 if (pathPart.isEmpty) { 256 if (pathPart.isEmpty) {
260 continue; 257 continue;
261 } 258 }
262 partialPath += '/' + pathPart; 259 partialPath += '/' + pathPart;
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
372 Resource getResource(String path) { 369 Resource getResource(String path) {
373 if (io.FileSystemEntity.isDirectorySync(path)) { 370 if (io.FileSystemEntity.isDirectorySync(path)) {
374 io.Directory directory = new io.Directory(path); 371 io.Directory directory = new io.Directory(path);
375 return new _PhysicalFolder(directory); 372 return new _PhysicalFolder(directory);
376 } else { 373 } else {
377 io.File file = new io.File(path); 374 io.File file = new io.File(path);
378 return new _PhysicalFile(file); 375 return new _PhysicalFile(file);
379 } 376 }
380 } 377 }
381 } 378 }
OLDNEW
« no previous file with comments | « no previous file | pkg/analysis_server/test/resource_test.dart » ('j') | pkg/analysis_server/test/resource_test.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698