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

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

Issue 12079112: Make a bunch of stuff in pub synchronous. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fix after merge. Created 7 years, 10 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
« no previous file with comments | « utils/pub/validator/lib.dart ('k') | utils/tests/pub/io_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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;
11 import '../entrypoint.dart'; 11 import '../entrypoint.dart';
12 import '../io.dart'; 12 import '../io.dart';
13 import '../utils.dart';
13 import '../validator.dart'; 14 import '../validator.dart';
14 15
15 /// Dart reserved words, from the Dart spec. 16 /// Dart reserved words, from the Dart spec.
16 final _RESERVED_WORDS = [ 17 final _RESERVED_WORDS = [
17 "abstract", "as", "dynamic", "export", "external", "factory", "get", 18 "abstract", "as", "dynamic", "export", "external", "factory", "get",
18 "implements", "import", "library", "operator", "part", "set", "static", 19 "implements", "import", "library", "operator", "part", "set", "static",
19 "typedef" 20 "typedef"
20 ]; 21 ];
21 22
22 /// A validator that validates the name of the package and its libraries. 23 /// A validator that validates the name of the package and its libraries.
(...skipping 17 matching lines...) Expand all
40 'the name of the package, "${entrypoint.root.name}".\n' 41 'the name of the package, "${entrypoint.root.name}".\n'
41 'This helps users know what library to import.'); 42 'This helps users know what library to import.');
42 } 43 }
43 }); 44 });
44 } 45 }
45 46
46 /// Returns a list of all libraries in the current package as paths relative 47 /// Returns a list of all libraries in the current package as paths relative
47 /// to the package's root directory. 48 /// to the package's root directory.
48 Future<List<String>> get _libraries { 49 Future<List<String>> get _libraries {
49 var libDir = join(entrypoint.root.dir, "lib"); 50 var libDir = join(entrypoint.root.dir, "lib");
50 return dirExists(libDir).then((libDirExists) { 51 return defer(() {
51 if (!libDirExists) return []; 52 if (!dirExists(libDir)) return [];
52 return listDir(libDir, recursive: true); 53 return listDir(libDir, recursive: true);
53 }).then((files) { 54 }).then((files) {
54 return files 55 return files
55 .map((file) => relativeTo(file, dirname(libDir))) 56 .map((file) => relativeTo(file, dirname(libDir)))
56 .where((file) => !splitPath(file).contains("src") && 57 .where((file) => !splitPath(file).contains("src") &&
57 path.extension(file) == '.dart') 58 path.extension(file) == '.dart')
58 .toList(); 59 .toList();
59 }); 60 });
60 } 61 }
61 62
(...skipping 23 matching lines...) Expand all
85 builder 86 builder
86 ..add(source.substring(lastMatchEnd, match.start + 1)) 87 ..add(source.substring(lastMatchEnd, match.start + 1))
87 ..add("_") 88 ..add("_")
88 ..add(match.group(1).toLowerCase()); 89 ..add(match.group(1).toLowerCase());
89 lastMatchEnd = match.end; 90 lastMatchEnd = match.end;
90 } 91 }
91 builder.add(source.substring(lastMatchEnd)); 92 builder.add(source.substring(lastMatchEnd));
92 return builder.toString().toLowerCase(); 93 return builder.toString().toLowerCase();
93 } 94 }
94 } 95 }
OLDNEW
« no previous file with comments | « utils/pub/validator/lib.dart ('k') | utils/tests/pub/io_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698