| 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 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 } | 107 } |
| 108 return _validateLowerCamelCase(name, "Import prefix"); | 108 return _validateLowerCamelCase(name, "Import prefix"); |
| 109 } | 109 } |
| 110 | 110 |
| 111 /** | 111 /** |
| 112 * Returns the [RefactoringStatus] with severity: | 112 * Returns the [RefactoringStatus] with severity: |
| 113 * OK if the name is valid; | 113 * OK if the name is valid; |
| 114 * WARNING if the name is discouraged; | 114 * WARNING if the name is discouraged; |
| 115 * ERROR if the name is illegal. | 115 * ERROR if the name is illegal. |
| 116 */ | 116 */ |
| 117 RefactoringStatus validateLabelName(String name) { |
| 118 return _validateLowerCamelCase(name, "Label"); |
| 119 } |
| 120 |
| 121 /** |
| 122 * Returns the [RefactoringStatus] with severity: |
| 123 * OK if the name is valid; |
| 124 * WARNING if the name is discouraged; |
| 125 * ERROR if the name is illegal. |
| 126 */ |
| 117 RefactoringStatus validateLibraryName(String name) { | 127 RefactoringStatus validateLibraryName(String name) { |
| 118 // null | 128 // null |
| 119 if (name == null) { | 129 if (name == null) { |
| 120 return new RefactoringStatus.fatal("Library name must not be null."); | 130 return new RefactoringStatus.fatal("Library name must not be null."); |
| 121 } | 131 } |
| 122 // blank | 132 // blank |
| 123 if (isBlank(name)) { | 133 if (isBlank(name)) { |
| 124 return new RefactoringStatus.fatal("Library name must not be blank."); | 134 return new RefactoringStatus.fatal("Library name must not be blank."); |
| 125 } | 135 } |
| 126 // check identifiers | 136 // check identifiers |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 271 } | 281 } |
| 272 // does not start with upper case | 282 // does not start with upper case |
| 273 if (!isUpperCase(identifier.codeUnitAt(0))) { | 283 if (!isUpperCase(identifier.codeUnitAt(0))) { |
| 274 // By convention, class names usually start with an uppercase letter | 284 // By convention, class names usually start with an uppercase letter |
| 275 String message = "$desc should start with an uppercase letter."; | 285 String message = "$desc should start with an uppercase letter."; |
| 276 return new RefactoringStatus.warning(message); | 286 return new RefactoringStatus.warning(message); |
| 277 } | 287 } |
| 278 // OK | 288 // OK |
| 279 return new RefactoringStatus(); | 289 return new RefactoringStatus(); |
| 280 } | 290 } |
| OLD | NEW |