Index: pkg/analyzer_plugin/tool/spec/codegen_protocol_constants.dart |
diff --git a/pkg/analyzer_plugin/tool/spec/codegen_protocol_constants.dart b/pkg/analyzer_plugin/tool/spec/codegen_protocol_constants.dart |
index c8d1c733bf440fd37ff3fda18b2a02bbf3386d21..223d59b54df74097dd9a3ae5bc56a4ffa64cd9c1 100644 |
--- a/pkg/analyzer_plugin/tool/spec/codegen_protocol_constants.dart |
+++ b/pkg/analyzer_plugin/tool/spec/codegen_protocol_constants.dart |
@@ -124,12 +124,22 @@ class _ConstantVisitor extends HierarchicalApiVisitor { |
} |
type.fields.forEach((TypeObjectField field) { |
String name = field.name; |
- String fieldConstantName = parentName + '_' + name.toUpperCase(); |
+ List<String> components = <String>[]; |
+ components.add(parentName); |
+ components.addAll(_split(name)); |
+ String fieldConstantName = _fromComponents(components); |
constants.add(new _Constant(fieldConstantName, "'$name'")); |
}); |
} |
/** |
+ * Return a name generated by converting each of the given [components] to an |
+ * uppercase equivalent, then joining them with underscores. |
+ */ |
+ String _fromComponents(List<String> components) => |
+ components.map((String component) => component.toUpperCase()).join('_'); |
+ |
+ /** |
* Generate a name from the [domainName], [kind] and [name] components. |
*/ |
String _generateName(String domainName, String kind, String name) { |
@@ -137,9 +147,7 @@ class _ConstantVisitor extends HierarchicalApiVisitor { |
components.addAll(_split(domainName)); |
components.add(kind); |
components.addAll(_split(name)); |
- return components |
- .map((String component) => component.toUpperCase()) |
- .join('_'); |
+ return _fromComponents(components); |
} |
/** |