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

Unified Diff: pkg/analyzer/tool/summary/generate.dart

Issue 1533213002: Allow String and List<String> in summary IDL. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years 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 | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer/tool/summary/generate.dart
diff --git a/pkg/analyzer/tool/summary/generate.dart b/pkg/analyzer/tool/summary/generate.dart
index 8007f38bc35f3a0841eb3b21caf42049db33109b..42cf94ba7948bd05dbd7e77b6995f601c0e6fe81 100644
--- a/pkg/analyzer/tool/summary/generate.dart
+++ b/pkg/analyzer/tool/summary/generate.dart
@@ -13,7 +13,7 @@
* - A "builder" class which can be used to generate serialized summary data.
* This class has write-only semantics.
*
- * Each of the "builder" classess has a single `finish` method which finalizes
+ * Each of the "builder" classes has a single `finish` method which finalizes
* the entity being built and returns it as an [Object]. This object should
* only be passed to other builders (or to [BuilderContext.getBuffer]);
* otherwise the client should treat it as opaque, since it exposes
@@ -89,6 +89,8 @@ class _CodeGenerator {
// List of classes is ok
} else if (type.typeName == 'int') {
// List of ints is ok
+ } else if (type.typeName == 'String') {
+ // List of strings is ok
} else {
throw new Exception(
'$name.$fieldName: illegal type (list of ${type.typeName})');
@@ -195,7 +197,7 @@ class _CodeGenerator {
enm.values.add(constDecl.name.name);
}
} else if (decl is TopLevelVariableDeclaration) {
- // Ignore top leve variable declarations; they are present just to make
+ // Ignore top level variable declarations; they are present just to make
// the IDL analyze without warnings.
} else {
throw new Exception('Unexpected declaration `$decl`');
@@ -269,11 +271,13 @@ class _CodeGenerator {
List<String> initializers = <String>[];
cls.fields.forEach((String fieldName, idlModel.FieldType type) {
String convert = 'json[${quoted(fieldName)}]';
- if (type.isList && type.typeName == 'int') {
- // No conversion necessary.
- } else if (type.isList) {
- convert =
- '$convert?.map((x) => new ${type.typeName}.fromJson(x))?.toList()';
+ if (type.isList) {
+ if (type.typeName == 'int' || type.typeName == 'String') {
+ // No conversion necessary.
+ } else {
+ convert =
+ '$convert?.map((x) => new ${type.typeName}.fromJson(x))?.toList()';
+ }
} else if (_idl.classes.containsKey(type.typeName)) {
convert =
'$convert == null ? null : new ${type.typeName}.fromJson($convert)';
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698