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

Unified Diff: pkg/analyzer_plugin/tool/spec/codegen_protocol_constants.dart

Issue 2960073002: Generate constants in server as we do in plugin (Closed)
Patch Set: improve names Created 3 years, 6 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 | « pkg/analyzer_plugin/lib/protocol/protocol_constants.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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);
}
/**
« no previous file with comments | « pkg/analyzer_plugin/lib/protocol/protocol_constants.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698