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

Side by Side Diff: pkg/analysis_server/tool/spec/codegen_dart_protocol.dart

Issue 574573002: Add SourceFileEdit.time field. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: tweak Created 6 years, 3 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 'api.dart'; 9 import 'api.dart';
10 import 'codegen_tools.dart'; 10 import 'codegen_tools.dart';
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 typedef void CodegenCallback(); 183 typedef void CodegenCallback();
184 184
185 /** 185 /**
186 * Visitor which produces Dart code representing the API. 186 * Visitor which produces Dart code representing the API.
187 */ 187 */
188 class CodegenProtocolVisitor extends HierarchicalApiVisitor with CodeGenerator { 188 class CodegenProtocolVisitor extends HierarchicalApiVisitor with CodeGenerator {
189 /** 189 /**
190 * Type references in the spec that are named something else in Dart. 190 * Type references in the spec that are named something else in Dart.
191 */ 191 */
192 static const Map<String, String> _typeRenames = const { 192 static const Map<String, String> _typeRenames = const {
193 'long': 'int',
193 'object': 'Map', 194 'object': 'Map',
194 }; 195 };
195 196
196 /** 197 /**
197 * Class members for which the constructor argument should be optional, even 198 * Class members for which the constructor argument should be optional, even
198 * if the member is not an optional part of the protocol. For list types, 199 * if the member is not an optional part of the protocol. For list types,
199 * the constructor will default the member to the empty list. 200 * the constructor will default the member to the empty list.
200 */ 201 */
201 static const Map<String, List<String>> _optionalConstructorArguments = const { 202 static const Map<String, List<String>> _optionalConstructorArguments = const {
202 'AnalysisErrorFixes': const ['fixes'], 203 'AnalysisErrorFixes': const ['fixes'],
(...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after
552 docComment([new dom.Text('Add a new suggestion.')]); 553 docComment([new dom.Text('Add a new suggestion.')]);
553 writeln('void addSuggestion(LinkedEditSuggestion suggestion) {'); 554 writeln('void addSuggestion(LinkedEditSuggestion suggestion) {');
554 indent(() { 555 indent(() {
555 writeln('suggestions.add(suggestion);'); 556 writeln('suggestions.add(suggestion);');
556 }); 557 });
557 writeln('}'); 558 writeln('}');
558 return true; 559 return true;
559 case 'SourceChange': 560 case 'SourceChange':
560 docComment( 561 docComment(
561 [new dom.Text('Adds [edit] to the [FileEdit] for the given [file].') ]); 562 [new dom.Text('Adds [edit] to the [FileEdit] for the given [file].') ]);
562 writeln('void addEdit(String file, SourceEdit edit) =>'); 563 writeln('void addEdit(String file, int fileStamp, SourceEdit edit) =>');
563 writeln(' _addEditToSourceChange(this, file, edit);'); 564 writeln(' _addEditToSourceChange(this, file, fileStamp, edit);');
564 writeln(); 565 writeln();
565 docComment([new dom.Text('Adds the given [FileEdit].')]); 566 docComment([new dom.Text('Adds the given [FileEdit].')]);
566 writeln('void addFileEdit(SourceFileEdit edit) {'); 567 writeln('void addFileEdit(SourceFileEdit edit) {');
567 indent(() { 568 indent(() {
568 writeln('edits.add(edit);'); 569 writeln('edits.add(edit);');
569 }); 570 });
570 writeln('}'); 571 writeln('}');
571 writeln(); 572 writeln();
572 docComment([new dom.Text('Adds the given [LinkedEditGroup].')]); 573 docComment([new dom.Text('Adds the given [LinkedEditGroup].')]);
573 writeln('void addLinkedEditGroup(LinkedEditGroup linkedEditGroup) {'); 574 writeln('void addLinkedEditGroup(LinkedEditGroup linkedEditGroup) {');
(...skipping 540 matching lines...) Expand 10 before | Expand all | Expand 10 after
1114 } else { 1115 } else {
1115 return fromJsonCode(referencedType); 1116 return fromJsonCode(referencedType);
1116 } 1117 }
1117 } else { 1118 } else {
1118 switch (type.typeName) { 1119 switch (type.typeName) {
1119 case 'String': 1120 case 'String':
1120 return new FromJsonFunction('jsonDecoder._decodeString'); 1121 return new FromJsonFunction('jsonDecoder._decodeString');
1121 case 'bool': 1122 case 'bool':
1122 return new FromJsonFunction('jsonDecoder._decodeBool'); 1123 return new FromJsonFunction('jsonDecoder._decodeBool');
1123 case 'int': 1124 case 'int':
1125 case 'long':
1124 return new FromJsonFunction('jsonDecoder._decodeInt'); 1126 return new FromJsonFunction('jsonDecoder._decodeInt');
1125 case 'object': 1127 case 'object':
1126 return new FromJsonIdentity(); 1128 return new FromJsonIdentity();
1127 default: 1129 default:
1128 throw new Exception('Unexpected type name ${type.typeName}'); 1130 throw new Exception('Unexpected type name ${type.typeName}');
1129 } 1131 }
1130 } 1132 }
1131 } else if (type is TypeMap) { 1133 } else if (type is TypeMap) {
1132 FromJsonCode keyCode; 1134 FromJsonCode keyCode;
1133 if (dartType(type.keyType) != 'String') { 1135 if (dartType(type.keyType) != 'String') {
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
1301 CodegenProtocolVisitor visitor = new CodegenProtocolVisitor(readApi()); 1303 CodegenProtocolVisitor visitor = new CodegenProtocolVisitor(readApi());
1302 return visitor.collectCode(visitor.visitApi); 1304 return visitor.collectCode(visitor.visitApi);
1303 }); 1305 });
1304 1306
1305 /** 1307 /**
1306 * Translate spec_input.html into protocol_matchers.dart. 1308 * Translate spec_input.html into protocol_matchers.dart.
1307 */ 1309 */
1308 main() { 1310 main() {
1309 target.generate(); 1311 target.generate();
1310 } 1312 }
OLDNEW
« no previous file with comments | « pkg/analysis_server/test/services/correction/change_test.dart ('k') | pkg/analysis_server/tool/spec/codegen_java.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698