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

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

Issue 11471048: Revise path library. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years 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/path.dart ('k') | utils/tests/pub/path/path_posix_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:io'; 7 import 'dart:io';
8 8
9 import '../entrypoint.dart'; 9 import '../entrypoint.dart';
10 import '../io.dart'; 10 import '../io.dart';
(...skipping 17 matching lines...) Expand all
28 28
29 var libDir = join(entrypoint.root.dir, "lib"); 29 var libDir = join(entrypoint.root.dir, "lib");
30 return dirExists(libDir).chain((libDirExists) { 30 return dirExists(libDir).chain((libDirExists) {
31 if (!libDirExists) return new Future.immediate([]); 31 if (!libDirExists) return new Future.immediate([]);
32 return listDir(libDir, recursive: true); 32 return listDir(libDir, recursive: true);
33 }).transform((files) { 33 }).transform((files) {
34 for (var file in files) { 34 for (var file in files) {
35 file = relativeTo(file, libDir); 35 file = relativeTo(file, libDir);
36 if (splitPath(file).contains("src")) continue; 36 if (splitPath(file).contains("src")) continue;
37 if (path.extension(file) != '.dart') continue; 37 if (path.extension(file) != '.dart') continue;
38 var libName = path.filenameWithoutExtension(file); 38 var libName = path.basenameWithoutExtension(file);
39 _checkName(libName, 'The name of "$file", "$libName",'); 39 _checkName(libName, 'The name of "$file", "$libName",');
40 } 40 }
41 }); 41 });
42 } 42 }
43 43
44 void _checkName(String name, String description) { 44 void _checkName(String name, String description) {
45 if (name == "") { 45 if (name == "") {
46 errors.add("$description may not be empty."); 46 errors.add("$description may not be empty.");
47 } else if (!new RegExp(r"^[a-zA-Z0-9_]*$").hasMatch(name)) { 47 } else if (!new RegExp(r"^[a-zA-Z0-9_]*$").hasMatch(name)) {
48 errors.add("$description must be a valid Dart identifier: it may only " 48 errors.add("$description must be a valid Dart identifier: it may only "
(...skipping 17 matching lines...) Expand all
66 builder 66 builder
67 ..add(source.substring(lastMatchEnd, match.start + 1)) 67 ..add(source.substring(lastMatchEnd, match.start + 1))
68 ..add("_") 68 ..add("_")
69 ..add(match.group(1).toLowerCase()); 69 ..add(match.group(1).toLowerCase());
70 lastMatchEnd = match.end; 70 lastMatchEnd = match.end;
71 } 71 }
72 builder.add(source.substring(lastMatchEnd)); 72 builder.add(source.substring(lastMatchEnd));
73 return builder.toString().toLowerCase(); 73 return builder.toString().toLowerCase();
74 } 74 }
75 } 75 }
OLDNEW
« no previous file with comments | « utils/pub/path.dart ('k') | utils/tests/pub/path/path_posix_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698