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

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

Issue 452313004: Cleanup in CodegenJavaVisitor.javaType(...), no functional change. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: missed change in the docs 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
« 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/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 02b9085b4209905dcf765983833fab05123f42a2..f464eeec52cc3e210193505fe678231da0854b8b 100644
--- a/pkg/analysis_server/tool/spec/codegen_java.dart
+++ b/pkg/analysis_server/tool/spec/codegen_java.dart
@@ -28,6 +28,16 @@ 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 {
+ 'bool': 'boolean',
+ 'FilePath': 'String',
+ 'DebugContextId': 'String',
+ 'object': 'Object',
+ };
+
+ /**
* Visitor used to produce doc comments.
*/
final ToHtmlVisitor toHtmlVisitor;
@@ -82,18 +92,11 @@ class CodegenJavaVisitor extends HierarchicalApiVisitor with CodeGenerator {
String javaType(TypeDecl type) {
if (type is TypeReference) {
TypeReference resolvedType = resolveTypeReferenceChain(type);
- switch (resolvedType.typeName) {
- // TODO(jwren) make this into a type type renames map, like _variableRenames
- case 'bool':
- return 'boolean';
- case 'FilePath':
- return 'String';
- case 'DebugContextId':
- return 'String';
- case 'object':
- return 'Object';
- default:
- return resolvedType.typeName;
+ String typeName = resolvedType.typeName;
+ if (_typeRenames.containsKey(typeName)) {
+ return _typeRenames[typeName];
+ } else {
+ return typeName;
}
} else if (type is TypeList) {
return 'List<${javaType(type.itemType)}>';
« 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