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

Unified Diff: sdk/lib/_internal/pub_generated/lib/src/validator/name.dart

Issue 887223007: Revert "Use native async/await support in pub." (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 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 side-by-side diff with in-line comments
Download patch
Index: sdk/lib/_internal/pub_generated/lib/src/validator/name.dart
diff --git a/sdk/lib/_internal/pub/lib/src/validator/name.dart b/sdk/lib/_internal/pub_generated/lib/src/validator/name.dart
similarity index 51%
copy from sdk/lib/_internal/pub/lib/src/validator/name.dart
copy to sdk/lib/_internal/pub_generated/lib/src/validator/name.dart
index cdee078b2ede942718d57a2a4c8a66b108eb6327..8b558846e3f7cdecab76867a3c1fae09aae1b415 100644
--- a/sdk/lib/_internal/pub/lib/src/validator/name.dart
+++ b/sdk/lib/_internal/pub_generated/lib/src/validator/name.dart
@@ -14,35 +14,66 @@ import '../validator.dart';
/// Dart reserved words, from the Dart spec.
final _RESERVED_WORDS = [
- "assert", "break", "case", "catch", "class", "const", "continue", "default",
- "do", "else", "extends", "false", "final", "finally", "for", "if", "in", "is",
- "new", "null", "return", "super", "switch", "this", "throw", "true", "try",
- "var", "void", "while", "with"
-];
+ "assert",
+ "break",
+ "case",
+ "catch",
+ "class",
+ "const",
+ "continue",
+ "default",
+ "do",
+ "else",
+ "extends",
+ "false",
+ "final",
+ "finally",
+ "for",
+ "if",
+ "in",
+ "is",
+ "new",
+ "null",
+ "return",
+ "super",
+ "switch",
+ "this",
+ "throw",
+ "true",
+ "try",
+ "var",
+ "void",
+ "while",
+ "with"];
/// A validator that validates the name of the package and its libraries.
class NameValidator extends Validator {
NameValidator(Entrypoint entrypoint)
- : super(entrypoint);
+ : super(entrypoint);
Future validate() {
return new Future.sync(() {
- _checkName(entrypoint.root.name, 'Package name "${entrypoint.root.name}"',
+ _checkName(
+ entrypoint.root.name,
+ 'Package name "${entrypoint.root.name}"',
isPackage: true);
var libraries = _libraries;
for (var library in libraries) {
var libName = path.basenameWithoutExtension(library);
- _checkName(libName, 'The name of "$library", "$libName",',
+ _checkName(
+ libName,
+ 'The name of "$library", "$libName",',
isPackage: false);
}
if (libraries.length == 1) {
var libName = path.basenameWithoutExtension(libraries[0]);
if (libName == entrypoint.root.name) return;
- warnings.add('The name of "${libraries[0]}", "$libName", should match '
- 'the name of the package, "${entrypoint.root.name}".\n'
- 'This helps users know what library to import.');
+ warnings.add(
+ 'The name of "${libraries[0]}", "$libName", should match '
+ 'the name of the package, "${entrypoint.root.name}".\n'
+ 'This helps users know what library to import.');
}
});
}
@@ -51,11 +82,15 @@ class NameValidator extends Validator {
/// to the package's root directory.
List<String> get _libraries {
var libDir = entrypoint.root.path("lib");
- return entrypoint.root.listFiles(beneath: "lib")
- .map((file) => path.relative(file, from: path.dirname(libDir)))
- .where((file) => !path.split(file).contains("src") &&
- path.extension(file) == '.dart')
- .toList();
+ return entrypoint.root.listFiles(
+ beneath: "lib").map(
+ (file) =>
+ path.relative(
+ file,
+ from: path.dirname(
+ libDir))).where(
+ (file) =>
+ !path.split(file).contains("src") && path.extension(file) == '.dart').toList();
}
void _checkName(String name, String description, {bool isPackage}) {
@@ -65,18 +100,20 @@ class NameValidator extends Validator {
if (name == "") {
errors.add("$description may not be empty.");
} else if (!new RegExp(r"^[a-zA-Z0-9_]*$").hasMatch(name)) {
- messages.add("$description may only contain letters, numbers, and "
- "underscores.\n"
- "Using a valid Dart identifier makes the name usable in Dart code.");
+ messages.add(
+ "$description may only contain letters, numbers, and " "underscores.\n"
+ "Using a valid Dart identifier makes the name usable in Dart code.");
} else if (!new RegExp(r"^[a-zA-Z_]").hasMatch(name)) {
- messages.add("$description must begin with a letter or underscore.\n"
- "Using a valid Dart identifier makes the name usable in Dart code.");
+ messages.add(
+ "$description must begin with a letter or underscore.\n"
+ "Using a valid Dart identifier makes the name usable in Dart code.");
} else if (_RESERVED_WORDS.contains(name.toLowerCase())) {
- messages.add("$description may not be a reserved word in Dart.\n"
- "Using a valid Dart identifier makes the name usable in Dart code.");
+ messages.add(
+ "$description may not be a reserved word in Dart.\n"
+ "Using a valid Dart identifier makes the name usable in Dart code.");
} else if (new RegExp(r"[A-Z]").hasMatch(name)) {
- warnings.add('$description should be lower-case. Maybe use '
- '"${_unCamelCase(name)}"?');
+ warnings.add(
+ '$description should be lower-case. Maybe use ' '"${_unCamelCase(name)}"?');
}
}
@@ -85,9 +122,9 @@ class NameValidator extends Validator {
var lastMatchEnd = 0;
for (var match in new RegExp(r"[a-z]([A-Z])").allMatches(source)) {
builder
- ..write(source.substring(lastMatchEnd, match.start + 1))
- ..write("_")
- ..write(match.group(1).toLowerCase());
+ ..write(source.substring(lastMatchEnd, match.start + 1))
+ ..write("_")
+ ..write(match.group(1).toLowerCase());
lastMatchEnd = match.end;
}
builder.write(source.substring(lastMatchEnd));

Powered by Google App Engine
This is Rietveld 408576698