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

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

Issue 12255016: Get rid of old redundant methods in io.dart. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Revise and update to latest. 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/license.dart ('k') | utils/tests/pub/test_pub.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
11 import '../entrypoint.dart'; 12 import '../entrypoint.dart';
12 import '../io.dart'; 13 import '../io.dart';
13 import '../utils.dart'; 14 import '../utils.dart';
14 import '../validator.dart'; 15 import '../validator.dart';
15 16
16 /// Dart reserved words, from the Dart spec. 17 /// Dart reserved words, from the Dart spec.
17 final _RESERVED_WORDS = [ 18 final _RESERVED_WORDS = [
18 "abstract", "as", "dynamic", "export", "external", "factory", "get", 19 "abstract", "as", "dynamic", "export", "external", "factory", "get",
19 "implements", "import", "library", "operator", "part", "set", "static", 20 "implements", "import", "library", "operator", "part", "set", "static",
20 "typedef" 21 "typedef"
(...skipping 25 matching lines...) Expand all
46 47
47 /// Returns a list of all libraries in the current package as paths relative 48 /// Returns a list of all libraries in the current package as paths relative
48 /// to the package's root directory. 49 /// to the package's root directory.
49 Future<List<String>> get _libraries { 50 Future<List<String>> get _libraries {
50 var libDir = join(entrypoint.root.dir, "lib"); 51 var libDir = join(entrypoint.root.dir, "lib");
51 return defer(() { 52 return defer(() {
52 if (!dirExists(libDir)) return []; 53 if (!dirExists(libDir)) return [];
53 return listDir(libDir, recursive: true); 54 return listDir(libDir, recursive: true);
54 }).then((files) { 55 }).then((files) {
55 return files 56 return files
56 .map((file) => relativeTo(file, dirname(libDir))) 57 .map((file) => path.relative(file, from: path.dirname(libDir)))
57 .where((file) => !splitPath(file).contains("src") && 58 .where((file) => !path.split(file).contains("src") &&
58 path.extension(file) == '.dart') 59 path.extension(file) == '.dart')
59 .toList(); 60 .toList();
60 }); 61 });
61 } 62 }
62 63
63 void _checkName(String name, String description) { 64 void _checkName(String name, String description) {
64 if (name == "") { 65 if (name == "") {
65 errors.add("$description may not be empty."); 66 errors.add("$description may not be empty.");
66 } else if (!new RegExp(r"^[a-zA-Z0-9_]*$").hasMatch(name)) { 67 } else if (!new RegExp(r"^[a-zA-Z0-9_]*$").hasMatch(name)) {
67 errors.add("$description may only contain letters, numbers, and " 68 errors.add("$description may only contain letters, numbers, and "
(...skipping 18 matching lines...) Expand all
86 builder 87 builder
87 ..add(source.substring(lastMatchEnd, match.start + 1)) 88 ..add(source.substring(lastMatchEnd, match.start + 1))
88 ..add("_") 89 ..add("_")
89 ..add(match.group(1).toLowerCase()); 90 ..add(match.group(1).toLowerCase());
90 lastMatchEnd = match.end; 91 lastMatchEnd = match.end;
91 } 92 }
92 builder.add(source.substring(lastMatchEnd)); 93 builder.add(source.substring(lastMatchEnd));
93 return builder.toString().toLowerCase(); 94 return builder.toString().toLowerCase();
94 } 95 }
95 } 96 }
OLDNEW
« no previous file with comments | « utils/pub/validator/license.dart ('k') | utils/tests/pub/test_pub.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698