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

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

Issue 11476030: Properly parse library names on Windows in pub. (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 | « no previous file | no next file » | 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 15 matching lines...) Expand all
26 _checkName(entrypoint.root.name, 'Package name "${entrypoint.root.name}"'); 26 _checkName(entrypoint.root.name, 'Package name "${entrypoint.root.name}"');
27 27
28 var libDir = join(entrypoint.root.dir, "lib"); 28 var libDir = join(entrypoint.root.dir, "lib");
29 return dirExists(libDir).chain((libDirExists) { 29 return dirExists(libDir).chain((libDirExists) {
30 if (!libDirExists) return new Future.immediate([]); 30 if (!libDirExists) return new Future.immediate([]);
31 return listDir(libDir, recursive: true); 31 return listDir(libDir, recursive: true);
32 }).transform((files) { 32 }).transform((files) {
33 for (var file in files) { 33 for (var file in files) {
34 if (file.contains("/src/")) continue; 34 if (file.contains("/src/")) continue;
35 if (new Path(file).extension != 'dart') continue; 35 if (new Path(file).extension != 'dart') continue;
36 var libName = new Path(file).filenameWithoutExtension; 36 var libName = new Path(basename(file)).filenameWithoutExtension;
37 _checkName(libName, 'The name of "$file", "$libName",'); 37 _checkName(libName, 'The name of "$file", "$libName",');
38 } 38 }
39 }); 39 });
40 } 40 }
41 41
42 void _checkName(String name, String description) { 42 void _checkName(String name, String description) {
43 if (name == "") { 43 if (name == "") {
44 errors.add("$description may not be empty."); 44 errors.add("$description may not be empty.");
45 } else if (!new RegExp(r"^[a-zA-Z0-9_]*$").hasMatch(name)) { 45 } else if (!new RegExp(r"^[a-zA-Z0-9_]*$").hasMatch(name)) {
46 errors.add("$description must be a valid Dart identifier: it may only " 46 errors.add("$description must be a valid Dart identifier: it may only "
(...skipping 17 matching lines...) Expand all
64 builder 64 builder
65 ..add(source.substring(lastMatchEnd, match.start + 1)) 65 ..add(source.substring(lastMatchEnd, match.start + 1))
66 ..add("_") 66 ..add("_")
67 ..add(match.group(1).toLowerCase()); 67 ..add(match.group(1).toLowerCase());
68 lastMatchEnd = match.end; 68 lastMatchEnd = match.end;
69 } 69 }
70 builder.add(source.substring(lastMatchEnd)); 70 builder.add(source.substring(lastMatchEnd));
71 return builder.toString().toLowerCase(); 71 return builder.toString().toLowerCase();
72 } 72 }
73 } 73 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698