OLD | NEW |
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 /** | 5 /** |
6 * Tools for Java code generation. | 6 * Tools for Java code generation. |
7 */ | 7 */ |
8 library CodegenJava; | 8 library CodegenJava; |
9 | 9 |
10 import 'package:analyzer/src/codegen/tools.dart'; | 10 import 'package:analyzer/src/codegen/tools.dart'; |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 }; | 61 }; |
62 | 62 |
63 _CodegenJavaState _state; | 63 _CodegenJavaState _state; |
64 | 64 |
65 /** | 65 /** |
66 * Visitor used to produce doc comments. | 66 * Visitor used to produce doc comments. |
67 */ | 67 */ |
68 final ToHtmlVisitor toHtmlVisitor; | 68 final ToHtmlVisitor toHtmlVisitor; |
69 | 69 |
70 CodegenJavaVisitor(Api api) | 70 CodegenJavaVisitor(Api api) |
71 : super(api), | 71 : toHtmlVisitor = new ToHtmlVisitor(api), |
72 toHtmlVisitor = new ToHtmlVisitor(api); | 72 super(api); |
73 | 73 |
74 /** | 74 /** |
75 * Create a constructor, using [callback] to create its contents. | 75 * Create a constructor, using [callback] to create its contents. |
76 */ | 76 */ |
77 void constructor(String name, void callback()) { | 77 void constructor(String name, void callback()) { |
78 _state.constructors[name] = collectCode(callback); | 78 _state.constructors[name] = collectCode(callback); |
79 } | 79 } |
80 | 80 |
81 /** | 81 /** |
82 * Return true iff the passed [TypeDecl] will represent an array in Java. | 82 * Return true iff the passed [TypeDecl] will represent an array in Java. |
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
255 } | 255 } |
256 | 256 |
257 /** | 257 /** |
258 * Create a public method, using [callback] to create its contents. | 258 * Create a public method, using [callback] to create its contents. |
259 */ | 259 */ |
260 void publicMethod(String methodName, void callback()) { | 260 void publicMethod(String methodName, void callback()) { |
261 _state.publicMethods[methodName] = collectCode(callback); | 261 _state.publicMethods[methodName] = collectCode(callback); |
262 } | 262 } |
263 | 263 |
264 @override | 264 @override |
265 TypeReference resolveTypeReferenceChain(TypeReference type) { | 265 TypeDecl resolveTypeReferenceChain(TypeDecl type) { |
266 TypeDecl typeDecl = super.resolveTypeReferenceChain(type); | 266 TypeDecl typeDecl = super.resolveTypeReferenceChain(type); |
267 if (typeDecl is TypeEnum) { | 267 if (typeDecl is TypeEnum) { |
268 return new TypeReference('String', null); | 268 return new TypeReference('String', null); |
269 } | 269 } |
270 return type; | 270 return type; |
271 } | 271 } |
272 } | 272 } |
273 | 273 |
274 /** | 274 /** |
275 * State used by [CodegenJavaVisitor]. | 275 * State used by [CodegenJavaVisitor]. |
(...skipping 17 matching lines...) Expand all Loading... |
293 /** | 293 /** |
294 * Temporary storage for private fields. | 294 * Temporary storage for private fields. |
295 */ | 295 */ |
296 Map<String, String> privateFields = <String, String>{}; | 296 Map<String, String> privateFields = <String, String>{}; |
297 | 297 |
298 /** | 298 /** |
299 * Temporary storage for constructors. | 299 * Temporary storage for constructors. |
300 */ | 300 */ |
301 Map<String, String> constructors = <String, String>{}; | 301 Map<String, String> constructors = <String, String>{}; |
302 } | 302 } |
OLD | NEW |