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 b1e07c1a2895537d213ea6dbee2f14dd06ff8169..08997261f25863e43a48fac0baf787e0a29dfbab 100644 |
| --- a/pkg/analysis_server/tool/spec/codegen_java.dart |
| +++ b/pkg/analysis_server/tool/spec/codegen_java.dart |
| @@ -31,9 +31,10 @@ class CodegenJavaVisitor extends HierarchicalApiVisitor with CodeGenerator { |
| * Type references in the spec that are named something else in Java. |
| */ |
| static const Map<String, String> _typeRenames = const { |
| - // TODO (jwren) in some situations we want to use Boolean while other |
| - // situations we want to use boolean... |
| + // TODO (jwren) in some situations we want to use Boolean/Integer while |
| + // other situations we want to use boolean/int... |
| 'bool': 'Boolean', |
| + 'int': 'Integer', |
| 'FilePath': 'String', |
| 'DebugContextId': 'String', |
| 'object': 'Object', |
| @@ -113,7 +114,7 @@ class CodegenJavaVisitor extends HierarchicalApiVisitor with CodeGenerator { |
| } |
| // constructors |
| - List<String> allConstructors =_state.constructors.values.toList(); |
| + List<String> allConstructors = _state.constructors.values.toList(); |
| for (String constructor in allConstructors) { |
| writeln(); |
| write(constructor); |
| @@ -168,12 +169,34 @@ class CodegenJavaVisitor extends HierarchicalApiVisitor with CodeGenerator { |
| bool isPrimitive(TypeDecl type) { |
| if (type is TypeReference) { |
| String typeStr = javaType(type); |
| - return typeStr == 'int' || typeStr == 'boolean'; |
| + return typeStr == 'Integer' || typeStr == 'boolean'; |
| } |
| return false; |
| } |
| /** |
| + * Return true iff the passed [TypeDecl] is a type declared in the spec_input. |
| + */ |
| + bool isDeclaredInSpec(TypeDecl type) { |
| + if (type is TypeReference) { |
|
Paul Berry
2014/08/19 20:51:12
You could also do:
if (type is TypeReference) {
jwren
2014/08/20 20:51:21
Acknowledged.
|
| + String typeStr = javaType(type); |
| + return typeStr != 'Integer' && typeStr != 'Boolean' && typeStr != 'String'; |
| + } |
| + return false; |
| + } |
| + |
| + /** |
| + * Return true iff the passed [TypeDecl] will be represented as Object in Java. |
| + */ |
| + bool isObject(TypeDecl type) { |
| + if (type is TypeReference) { |
| + String typeStr = javaType(type); |
| + return typeStr == 'Object'; |
| + } |
| + return true; |
| + } |
| + |
| + /** |
| * Return true iff the passed [TypeDecl] will represent an array in Java. |
| */ |
| bool isList(TypeDecl type) { |