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 library codegen.protocol; | 5 library codegen.protocol; |
6 | 6 |
7 import 'dart:convert'; | 7 import 'dart:convert'; |
8 | 8 |
9 import 'package:analyzer/src/codegen/tools.dart'; | 9 import 'package:analyzer/src/codegen/tools.dart'; |
10 import 'package:html/dom.dart' as dom; | 10 import 'package:html/dom.dart' as dom; |
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
209 */ | 209 */ |
210 void emitEmptyObjectClass(String className, ImpliedType impliedType) { | 210 void emitEmptyObjectClass(String className, ImpliedType impliedType) { |
211 docComment(toHtmlVisitor.collectHtml(() { | 211 docComment(toHtmlVisitor.collectHtml(() { |
212 toHtmlVisitor.p(() { | 212 toHtmlVisitor.p(() { |
213 toHtmlVisitor.write(impliedType.humanReadableName); | 213 toHtmlVisitor.write(impliedType.humanReadableName); |
214 }); | 214 }); |
215 toHtmlVisitor.p(() { | 215 toHtmlVisitor.p(() { |
216 toHtmlVisitor.write(disclaimer); | 216 toHtmlVisitor.write(disclaimer); |
217 }); | 217 }); |
218 })); | 218 })); |
219 writeln('class $className {'); | 219 write('class $className'); |
| 220 if (impliedType.kind == 'refactoringFeedback') { |
| 221 writeln(' extends RefactoringFeedback {'); |
| 222 } else if (impliedType.kind == 'refactoringOptions') { |
| 223 writeln(' extends RefactoringOptions {'); |
| 224 } else { |
| 225 writeln(' {'); |
| 226 } |
220 indent(() { | 227 indent(() { |
221 if (emitToRequestMember(impliedType)) { | 228 if (emitToRequestMember(impliedType)) { |
222 writeln(); | 229 writeln(); |
223 } | 230 } |
224 if (emitToResponseMember(impliedType)) { | 231 if (emitToResponseMember(impliedType)) { |
225 writeln(); | 232 writeln(); |
226 } | 233 } |
227 if (emitToNotificationMember(impliedType)) { | 234 if (emitToNotificationMember(impliedType)) { |
228 writeln(); | 235 writeln(); |
229 } | 236 } |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
371 }); | 378 }); |
372 if (impliedType.type != null) { | 379 if (impliedType.type != null) { |
373 toHtmlVisitor.showType(null, impliedType.type); | 380 toHtmlVisitor.showType(null, impliedType.type); |
374 } | 381 } |
375 toHtmlVisitor.p(() { | 382 toHtmlVisitor.p(() { |
376 toHtmlVisitor.write(disclaimer); | 383 toHtmlVisitor.write(disclaimer); |
377 }); | 384 }); |
378 })); | 385 })); |
379 write('class $className'); | 386 write('class $className'); |
380 if (impliedType.kind == 'refactoringFeedback') { | 387 if (impliedType.kind == 'refactoringFeedback') { |
381 write(' extends RefactoringFeedback'); | 388 writeln(' extends RefactoringFeedback {'); |
| 389 } else if (impliedType.kind == 'refactoringOptions') { |
| 390 writeln(' extends RefactoringOptions {'); |
| 391 } else { |
| 392 writeln(' implements HasToJson {'); |
382 } | 393 } |
383 if (impliedType.kind == 'refactoringOptions') { | |
384 write(' extends RefactoringOptions'); | |
385 } | |
386 writeln(' implements HasToJson {'); | |
387 indent(() { | 394 indent(() { |
388 if (emitSpecialStaticMembers(className)) { | 395 if (emitSpecialStaticMembers(className)) { |
389 writeln(); | 396 writeln(); |
390 } | 397 } |
391 for (TypeObjectField field in type.fields) { | 398 for (TypeObjectField field in type.fields) { |
392 if (field.value != null) { | 399 if (field.value != null) { |
393 continue; | 400 continue; |
394 } | 401 } |
395 writeln('${dartType(field.type)} _${field.name};'); | 402 writeln('${dartType(field.type)} _${field.name};'); |
396 writeln(); | 403 writeln(); |
(...skipping 836 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1233 | 1240 |
1234 @override | 1241 @override |
1235 String get asClosure => '($type value) => ${callback('value')}'; | 1242 String get asClosure => '($type value) => ${callback('value')}'; |
1236 | 1243 |
1237 @override | 1244 @override |
1238 bool get isIdentity => false; | 1245 bool get isIdentity => false; |
1239 | 1246 |
1240 @override | 1247 @override |
1241 String asSnippet(String value) => callback(value); | 1248 String asSnippet(String value) => callback(value); |
1242 } | 1249 } |
OLD | NEW |