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

Unified Diff: pkg/analysis_server/lib/src/services/refactoring/naming_conventions.dart

Issue 1011613002: Issue 22845. Rename should prevent the use of invalid identifiers. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 9 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
« no previous file with comments | « no previous file | pkg/analysis_server/test/services/refactoring/naming_conventions_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analysis_server/lib/src/services/refactoring/naming_conventions.dart
diff --git a/pkg/analysis_server/lib/src/services/refactoring/naming_conventions.dart b/pkg/analysis_server/lib/src/services/refactoring/naming_conventions.dart
index 35033117be0bc2d99512d7bb82c49ba4deabb26c..aac52754c741badc30a5c0c30db99e3bc55b8b62 100644
--- a/pkg/analysis_server/lib/src/services/refactoring/naming_conventions.dart
+++ b/pkg/analysis_server/lib/src/services/refactoring/naming_conventions.dart
@@ -6,6 +6,7 @@ library services.src.refactoring.naming_conventions;
import 'package:analysis_server/src/services/correction/status.dart';
import 'package:analysis_server/src/services/correction/strings.dart';
+import 'package:analyzer/src/generated/scanner.dart';
/**
* Returns the [RefactoringStatus] with severity:
@@ -164,6 +165,15 @@ RefactoringStatus _validateIdentifier(
String message = "$desc must not be empty.";
return new RefactoringStatus.fatal(message);
}
+ // keyword
+ {
+ Keyword keyword = Keyword.keywords[identifier];
+ if (keyword != null && !keyword.isPseudoKeyword) {
+ String message = "$desc must not be a keyword.";
+ return new RefactoringStatus.fatal(message);
+ }
+ }
+ // first character
int currentChar = identifier.codeUnitAt(0);
if (!isLetter(currentChar) &&
currentChar != CHAR_UNDERSCORE &&
@@ -171,6 +181,7 @@ RefactoringStatus _validateIdentifier(
String message = "$desc must begin with $beginDesc.";
return new RefactoringStatus.fatal(message);
}
+ // other characters
for (int i = 1; i < length; i++) {
currentChar = identifier.codeUnitAt(i);
if (!isLetterOrDigit(currentChar) &&
@@ -181,6 +192,7 @@ RefactoringStatus _validateIdentifier(
return new RefactoringStatus.fatal(message);
}
}
+ // OK
return new RefactoringStatus();
}
« no previous file with comments | « no previous file | pkg/analysis_server/test/services/refactoring/naming_conventions_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698