OLD | NEW |
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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 []; | 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 .map((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 |
62 void _checkName(String name, String description) { | 62 void _checkName(String name, String description) { |
63 if (name == "") { | 63 if (name == "") { |
64 errors.add("$description may not be empty."); | 64 errors.add("$description may not be empty."); |
65 } else if (!new RegExp(r"^[a-zA-Z0-9_]*$").hasMatch(name)) { | 65 } else if (!new RegExp(r"^[a-zA-Z0-9_]*$").hasMatch(name)) { |
(...skipping 19 matching lines...) Expand all Loading... |
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 } |
OLD | NEW |