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

Side by Side Diff: utils/pub/validator/name.dart

Issue 12042053: Get rid of unneeded Future.immediate() calls. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 11 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) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 name_validator; 5 library name_validator;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 import 'dart:io'; 8 import 'dart:io';
9 9
10 import '../../../pkg/path/lib/path.dart' as path; 10 import '../../../pkg/path/lib/path.dart' as path;
(...skipping 30 matching lines...) Expand all
41 'This helps users know what library to import.'); 41 'This helps users know what library to import.');
42 } 42 }
43 }); 43 });
44 } 44 }
45 45
46 /// Returns a list of all libraries in the current package as paths relative 46 /// Returns a list of all libraries in the current package as paths relative
47 /// to the package's root directory. 47 /// to the package's root directory.
48 Future<List<String>> get _libraries { 48 Future<List<String>> get _libraries {
49 var libDir = join(entrypoint.root.dir, "lib"); 49 var libDir = join(entrypoint.root.dir, "lib");
50 return dirExists(libDir).then((libDirExists) { 50 return dirExists(libDir).then((libDirExists) {
51 if (!libDirExists) return new Future.immediate([]); 51 if (!libDirExists) return [];
52 return listDir(libDir, recursive: true); 52 return listDir(libDir, recursive: true);
53 }).then((files) { 53 }).then((files) {
54 return files 54 return files
55 .mappedBy((file) => relativeTo(file, dirname(libDir))) 55 .mappedBy((file) => relativeTo(file, dirname(libDir)))
56 .where((file) => !splitPath(file).contains("src") && 56 .where((file) => !splitPath(file).contains("src") &&
57 path.extension(file) == '.dart') 57 path.extension(file) == '.dart')
58 .toList(); 58 .toList();
59 }); 59 });
60 } 60 }
61 61
(...skipping 23 matching lines...) Expand all
85 builder 85 builder
86 ..add(source.substring(lastMatchEnd, match.start + 1)) 86 ..add(source.substring(lastMatchEnd, match.start + 1))
87 ..add("_") 87 ..add("_")
88 ..add(match.group(1).toLowerCase()); 88 ..add(match.group(1).toLowerCase());
89 lastMatchEnd = match.end; 89 lastMatchEnd = match.end;
90 } 90 }
91 builder.add(source.substring(lastMatchEnd)); 91 builder.add(source.substring(lastMatchEnd));
92 return builder.toString().toLowerCase(); 92 return builder.toString().toLowerCase();
93 } 93 }
94 } 94 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698