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

Unified Diff: lib/src/utils.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/pubspec.dart ('k') | lib/src/validator/name.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/src/utils.dart
diff --git a/lib/src/utils.dart b/lib/src/utils.dart
index 7fb513dcaa9a68fca2312e1a870db8cf86203680..5e97e4349729613399596b941b243bad5c0799fc 100644
--- a/lib/src/utils.dart
+++ b/lib/src/utils.dart
@@ -22,12 +22,20 @@ export 'asset/dart/utils.dart';
/// A regular expression matching a Dart identifier.
///
/// This also matches a package name, since they must be Dart identifiers.
-final identifierRegExp = new RegExp(r"[a-zA-Z_][a-zA-Z0-9_]+");
+final identifierRegExp = new RegExp(r"[a-zA-Z_]\w*");
/// Like [identifierRegExp], but anchored so that it only matches strings that
/// are *just* Dart identifiers.
final onlyIdentifierRegExp = new RegExp("^${identifierRegExp.pattern}\$");
+/// Dart reserved words, from the Dart spec.
+const reservedWords = const [
+ "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 pair of values.
class Pair<E, F> {
E first;
« no previous file with comments | « lib/src/pubspec.dart ('k') | lib/src/validator/name.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698