Chromium Code Reviews| Index: pkg/analysis_server/tool/spec/codegen_java.dart |
| diff --git a/pkg/analysis_server/tool/spec/codegen_java.dart b/pkg/analysis_server/tool/spec/codegen_java.dart |
| index a4bcbf9f0e75e387b896c38d824c57ec9860c1f4..6d5002ba9395696e1fa85022830f86434d879988 100644 |
| --- a/pkg/analysis_server/tool/spec/codegen_java.dart |
| +++ b/pkg/analysis_server/tool/spec/codegen_java.dart |
| @@ -55,6 +55,13 @@ class CodegenJavaVisitor extends HierarchicalApiVisitor with CodeGenerator { |
| } |
| /** |
| + * Create a public field, using [callback] to create its contents. |
| + */ |
| + void publicField(String fieldName, void callback()) { |
| + _state.publicFields[fieldName] = collectCode(callback); |
| + } |
| + |
| + /** |
| * Create a private field, using [callback] to create its contents. |
| */ |
| void privateField(String fieldName, void callback()) { |
| @@ -96,22 +103,21 @@ class CodegenJavaVisitor extends HierarchicalApiVisitor with CodeGenerator { |
| writeln('$header {'); |
| indent(() { |
| // fields |
| - List<String> allFields = |
| - _valuesSortedByKey(_state.privateFields).toList(); |
| + List<String> allFields = _state.publicFields.values.toList(); |
| + allFields.addAll(_state.privateFields.values.toList()); |
|
Paul Berry
2014/08/14 05:58:29
I believe ".toList()" can be omitted since _state.
jwren
2014/08/14 06:20:29
I thought so too, but this comes out of the VM if
Paul Berry
2014/08/14 12:47:37
That happens if you remove the toList() on line 10
|
| for (String field in allFields) { |
| writeln(); |
| write(field); |
| } |
| // constructors |
| - List<String> allConstructors = |
| - _valuesSortedByKey(_state.constructors).toList(); |
| + List<String> allConstructors =_state.constructors.values.toList(); |
| for (String constructor in allConstructors) { |
| writeln(); |
| write(constructor); |
| } |
| - // methods |
| + // methods (ordered by method name) |
| List<String> allMethods = |
| _valuesSortedByKey(_state.publicMethods).toList(); |
| allMethods.addAll(_valuesSortedByKey(_state.privateMethods)); |
| @@ -119,6 +125,7 @@ class CodegenJavaVisitor extends HierarchicalApiVisitor with CodeGenerator { |
| writeln(); |
| write(method); |
| } |
| + writeln(); |
| }); |
| writeln('}'); |
| } finally { |
| @@ -231,6 +238,11 @@ class _CodegenJavaState { |
| /** |
| * Temporary storage for private fields. |
|
Paul Berry
2014/08/14 05:58:29
s/private/public/
jwren
2014/08/14 06:20:29
Done.
|
| */ |
| + Map<String, String> publicFields = <String, String>{}; |
| + |
| + /** |
| + * Temporary storage for private fields. |
| + */ |
| Map<String, String> privateFields = <String, String>{}; |
| /** |