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

Unified Diff: pkg/analysis_server/tool/spec/codegen_java_types.dart

Issue 475673002: Generate public static EMPTY_ARRAY fields for each object. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 4 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
Index: pkg/analysis_server/tool/spec/codegen_java_types.dart
diff --git a/pkg/analysis_server/tool/spec/codegen_java_types.dart b/pkg/analysis_server/tool/spec/codegen_java_types.dart
index 07d2dd5178f4c82d40cff6f58d973c44a63532f8..39e78c46df79f6dcd294fa8a68d98b108e9fd61d 100644
--- a/pkg/analysis_server/tool/spec/codegen_java_types.dart
+++ b/pkg/analysis_server/tool/spec/codegen_java_types.dart
@@ -55,12 +55,22 @@ class CodegenJavaType extends CodegenJavaVisitor {
}));
writeln('@SuppressWarnings("unused")');
makeClass('public class ${className}', () {
+ //
+ // public static final "EMPTY_ARRAY" field
+ // i.e. "public static final Parameter[] EMPTY_ARRAY = new Parameter[0];"
+ //
+ publicField(javaName("EMPTY_ARRAY"), () {
+ javadocComment(toHtmlVisitor.collectHtml(() {
+ toHtmlVisitor.write('An empty array of {@link ${className}}s.');
+ }));
+ writeln(
+ 'public static final ${className}[] EMPTY_ARRAY = new ${className}[0];');
+ });
+
TypeObject typeObject = typeDef.type as TypeObject;
List<TypeObjectField> fields = typeObject.fields;
// TODO (jwren) we need to possibly remove fields such as "type" in
// these objects: AddContentOverlay | ChangeContentOverlay | RemoveContentOverlay
- // TODO (jwren) In this case, we don't want to sort the ordering of the
- // fields, the order from the spec would be better.
//
// fields
//
@@ -155,7 +165,6 @@ class CodegenJavaType extends CodegenJavaVisitor {
writeln('return builder.toString();');
});
writeln('}');
- writeln();
});
});
}

Powered by Google App Engine
This is Rietveld 408576698