| 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:html/dom.dart' as dom; | 9 import 'package:html/dom.dart' as dom; |
| 10 | 10 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 */ | 28 */ |
| 29 const Map<String, String> specialElementFlags = const { | 29 const Map<String, String> specialElementFlags = const { |
| 30 'abstract': '0x01', | 30 'abstract': '0x01', |
| 31 'const': '0x02', | 31 'const': '0x02', |
| 32 'final': '0x04', | 32 'final': '0x04', |
| 33 'static': '0x08', | 33 'static': '0x08', |
| 34 'private': '0x10', | 34 'private': '0x10', |
| 35 'deprecated': '0x20' | 35 'deprecated': '0x20' |
| 36 }; | 36 }; |
| 37 | 37 |
| 38 final GeneratedFile target = new GeneratedFile( | 38 final GeneratedFile target = |
| 39 '../../lib/src/generated_protocol.dart', () { | 39 new GeneratedFile('../../lib/src/generated_protocol.dart', () { |
| 40 CodegenProtocolVisitor visitor = new CodegenProtocolVisitor(readApi()); | 40 CodegenProtocolVisitor visitor = new CodegenProtocolVisitor(readApi()); |
| 41 return visitor.collectCode(visitor.visitApi); | 41 return visitor.collectCode(visitor.visitApi); |
| 42 }); | 42 }); |
| 43 | 43 |
| 44 /** | 44 /** |
| 45 * Callback type used to represent arbitrary code generation. | 45 * Callback type used to represent arbitrary code generation. |
| 46 */ | 46 */ |
| 47 typedef void CodegenCallback(); | 47 typedef void CodegenCallback(); |
| 48 | 48 |
| 49 typedef String FromJsonSnippetCallback(String jsonPath, String json); | 49 typedef String FromJsonSnippetCallback(String jsonPath, String json); |
| (...skipping 506 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 556 writeln('return _refactoringFeedbackFromJson(jsonDecoder, jsonPath, ' | 556 writeln('return _refactoringFeedbackFromJson(jsonDecoder, jsonPath, ' |
| 557 'json, responseJson);'); | 557 'json, responseJson);'); |
| 558 }); | 558 }); |
| 559 writeln('}'); | 559 writeln('}'); |
| 560 return; | 560 return; |
| 561 } | 561 } |
| 562 if (className == 'RefactoringOptions') { | 562 if (className == 'RefactoringOptions') { |
| 563 writeln('factory RefactoringOptions.fromJson(JsonDecoder jsonDecoder, ' | 563 writeln('factory RefactoringOptions.fromJson(JsonDecoder jsonDecoder, ' |
| 564 'String jsonPath, Object json, RefactoringKind kind) {'); | 564 'String jsonPath, Object json, RefactoringKind kind) {'); |
| 565 indent(() { | 565 indent(() { |
| 566 writeln( | 566 writeln('return _refactoringOptionsFromJson(jsonDecoder, jsonPath, ' |
| 567 'return _refactoringOptionsFromJson(jsonDecoder, jsonPath, ' 'json,
kind);'); | 567 'json, kind);'); |
| 568 }); | 568 }); |
| 569 writeln('}'); | 569 writeln('}'); |
| 570 return; | 570 return; |
| 571 } | 571 } |
| 572 writeln( | 572 writeln( |
| 573 'factory $className.fromJson(JsonDecoder jsonDecoder, String jsonPath, O
bject json) {'); | 573 'factory $className.fromJson(JsonDecoder jsonDecoder, String jsonPath, O
bject json) {'); |
| 574 indent(() { | 574 indent(() { |
| 575 writeln('if (json == null) {'); | 575 writeln('if (json == null) {'); |
| 576 indent(() { | 576 indent(() { |
| 577 writeln('json = {};'); | 577 writeln('json = {};'); |
| (...skipping 645 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1223 | 1223 |
| 1224 @override | 1224 @override |
| 1225 String get asClosure => '($type value) => ${callback('value')}'; | 1225 String get asClosure => '($type value) => ${callback('value')}'; |
| 1226 | 1226 |
| 1227 @override | 1227 @override |
| 1228 bool get isIdentity => false; | 1228 bool get isIdentity => false; |
| 1229 | 1229 |
| 1230 @override | 1230 @override |
| 1231 String asSnippet(String value) => callback(value); | 1231 String asSnippet(String value) => callback(value); |
| 1232 } | 1232 } |
| OLD | NEW |