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

Unified Diff: lib/src/validator/name.dart

Issue 1493463002: Disallow invalid package names in Pubspec. (Closed) Base URL: git@github.com:dart-lang/pub.git@master
Patch Set: Code review changes Created 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « lib/src/utils.dart ('k') | test/get/package_name_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/src/validator/name.dart
diff --git a/lib/src/validator/name.dart b/lib/src/validator/name.dart
index 94e2024f74d3a3df4da3b9ff627b4572fb551501..eb76603f09c777fd15b2553fcfc65b88ac73125e 100644
--- a/lib/src/validator/name.dart
+++ b/lib/src/validator/name.dart
@@ -9,16 +9,9 @@ import 'dart:async';
import 'package:path/path.dart' as path;
import '../entrypoint.dart';
+import '../utils.dart';
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"
-];
-
/// A validator that validates the name of the package and its libraries.
class NameValidator extends Validator {
NameValidator(Entrypoint entrypoint)
@@ -70,7 +63,7 @@ class NameValidator extends Validator {
} 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.");
- } else if (_RESERVED_WORDS.contains(name.toLowerCase())) {
+ } else if (reservedWords.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.");
} else if (new RegExp(r"[A-Z]").hasMatch(name)) {
« no previous file with comments | « lib/src/utils.dart ('k') | test/get/package_name_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698