| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 services.src.refactoring.naming_conventions; | 5 library services.src.refactoring.naming_conventions; |
| 6 | 6 |
| 7 import 'package:analysis_server/src/services/correction/status.dart'; | 7 import 'package:analysis_server/src/services/correction/status.dart'; |
| 8 import 'package:analysis_server/src/services/correction/strings.dart'; | 8 import 'package:analysis_server/src/services/correction/strings.dart'; |
| 9 | 9 |
| 10 | 10 |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 if (name == null) { | 95 if (name == null) { |
| 96 return new RefactoringStatus.fatal("Library name must not be null."); | 96 return new RefactoringStatus.fatal("Library name must not be null."); |
| 97 } | 97 } |
| 98 // blank | 98 // blank |
| 99 if (isBlank(name)) { | 99 if (isBlank(name)) { |
| 100 return new RefactoringStatus.fatal("Library name must not be blank."); | 100 return new RefactoringStatus.fatal("Library name must not be blank."); |
| 101 } | 101 } |
| 102 // check identifiers | 102 // check identifiers |
| 103 List<String> identifiers = name.split('.'); | 103 List<String> identifiers = name.split('.'); |
| 104 for (String identifier in identifiers) { | 104 for (String identifier in identifiers) { |
| 105 RefactoringStatus status = | 105 RefactoringStatus status = _validateIdentifier( |
| 106 _validateIdentifier( | 106 identifier, |
| 107 identifier, | 107 "Library name identifier", |
| 108 "Library name identifier", | 108 "a lowercase letter or underscore"); |
| 109 "a lowercase letter or underscore"); | |
| 110 if (!status.isOK) { | 109 if (!status.isOK) { |
| 111 return status; | 110 return status; |
| 112 } | 111 } |
| 113 } | 112 } |
| 114 // should not have upper-case letters | 113 // should not have upper-case letters |
| 115 for (String identifier in identifiers) { | 114 for (String identifier in identifiers) { |
| 116 for (int c in identifier.codeUnits) { | 115 for (int c in identifier.codeUnits) { |
| 117 if (isUpperCase(c)) { | 116 if (isUpperCase(c)) { |
| 118 return new RefactoringStatus.warning( | 117 return new RefactoringStatus.warning( |
| 119 "Library name should consist of lowercase identifier separated by do
ts."); | 118 "Library name should consist of lowercase identifier separated by do
ts."); |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 247 } | 246 } |
| 248 // does not start with upper case | 247 // does not start with upper case |
| 249 if (!isUpperCase(identifier.codeUnitAt(0))) { | 248 if (!isUpperCase(identifier.codeUnitAt(0))) { |
| 250 // By convention, class names usually start with an uppercase letter | 249 // By convention, class names usually start with an uppercase letter |
| 251 String message = "$desc should start with an uppercase letter."; | 250 String message = "$desc should start with an uppercase letter."; |
| 252 return new RefactoringStatus.warning(message); | 251 return new RefactoringStatus.warning(message); |
| 253 } | 252 } |
| 254 // OK | 253 // OK |
| 255 return new RefactoringStatus(); | 254 return new RefactoringStatus(); |
| 256 } | 255 } |
| OLD | NEW |