| 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: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 Loading... |
| 28 | 28 |
| 29 return _libraries.transform((libraries) { | 29 return _libraries.transform((libraries) { |
| 30 for (var library in libraries) { | 30 for (var library in libraries) { |
| 31 var libName = path.basenameWithoutExtension(library); | 31 var libName = path.basenameWithoutExtension(library); |
| 32 _checkName(libName, 'The name of "$library", "$libName",'); | 32 _checkName(libName, 'The name of "$library", "$libName",'); |
| 33 } | 33 } |
| 34 | 34 |
| 35 if (libraries.length == 1) { | 35 if (libraries.length == 1) { |
| 36 var libName = path.basenameWithoutExtension(libraries[0]); | 36 var libName = path.basenameWithoutExtension(libraries[0]); |
| 37 if (libName == entrypoint.root.name) return; | 37 if (libName == entrypoint.root.name) return; |
| 38 warnings.add('The name of "$libraries[0]", "$libName", should match ' | 38 warnings.add('The name of "${libraries[0]}", "$libName", should match ' |
| 39 'the name of the package, "${entrypoint.root.name}".\n' | 39 'the name of the package, "${entrypoint.root.name}".\n' |
| 40 'This helps users know what library to import.'); | 40 'This helps users know what library to import.'); |
| 41 } | 41 } |
| 42 }); | 42 }); |
| 43 } | 43 } |
| 44 | 44 |
| 45 /// Returns a list of all libraries in the current package as paths relative | 45 /// Returns a list of all libraries in the current package as paths relative |
| 46 /// to the package's root directory. | 46 /// to the package's root directory. |
| 47 Future<List<String>> get _libraries { | 47 Future<List<String>> get _libraries { |
| 48 var libDir = join(entrypoint.root.dir, "lib"); | 48 var libDir = join(entrypoint.root.dir, "lib"); |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 builder | 84 builder |
| 85 ..add(source.substring(lastMatchEnd, match.start + 1)) | 85 ..add(source.substring(lastMatchEnd, match.start + 1)) |
| 86 ..add("_") | 86 ..add("_") |
| 87 ..add(match.group(1).toLowerCase()); | 87 ..add(match.group(1).toLowerCase()); |
| 88 lastMatchEnd = match.end; | 88 lastMatchEnd = match.end; |
| 89 } | 89 } |
| 90 builder.add(source.substring(lastMatchEnd)); | 90 builder.add(source.substring(lastMatchEnd)); |
| 91 return builder.toString().toLowerCase(); | 91 return builder.toString().toLowerCase(); |
| 92 } | 92 } |
| 93 } | 93 } |
| OLD | NEW |