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

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

Issue 541823004: Decode RefactoringFeedback automatically. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/analysis_server/test/protocol_test.dart ('k') | pkg/analysis_server/tool/spec/codegen_java_types.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analysis_server/tool/spec/codegen_dart_protocol.dart
diff --git a/pkg/analysis_server/tool/spec/codegen_dart_protocol.dart b/pkg/analysis_server/tool/spec/codegen_dart_protocol.dart
index 0d742a483be2c7daccbd97da3575763660b3765d..43fc138473a4f629891144af34f466a087381cc7 100644
--- a/pkg/analysis_server/tool/spec/codegen_dart_protocol.dart
+++ b/pkg/analysis_server/tool/spec/codegen_dart_protocol.dart
@@ -292,6 +292,9 @@ class CodegenProtocolVisitor extends HierarchicalApiVisitor with CodeGenerator {
}
}));
write('class $className');
+ if (impliedType.kind == 'refactoringFeedback') {
+ write(' extends RefactoringFeedback');
+ }
if (impliedType.kind == 'refactoringOptions') {
write(' extends RefactoringOptions');
}
@@ -968,6 +971,16 @@ class CodegenProtocolVisitor extends HierarchicalApiVisitor with CodeGenerator {
ImpliedType impliedType) {
String humanReadableNameString =
literalString(impliedType.humanReadableName);
+ if (className == 'RefactoringFeedback') {
+ writeln('factory RefactoringFeedback.fromJson(JsonDecoder jsonDecoder, '
+ 'String jsonPath, Object json, Map responseJson) {');
+ indent(() {
+ writeln('return _refactoringFeedbackFromJson(jsonDecoder, jsonPath, '
+ 'json, responseJson);');
+ });
+ writeln('}');
+ return;
+ }
if (className == 'RefactoringOptions') {
writeln('factory RefactoringOptions.fromJson(JsonDecoder jsonDecoder, '
'String jsonPath, Object json, RefactoringKind kind) {');
@@ -1090,7 +1103,9 @@ class CodegenProtocolVisitor extends HierarchicalApiVisitor with CodeGenerator {
return new FromJsonSnippet(
(String jsonPath, String json) {
String typeName = dartType(type);
- if (typeName == 'RefactoringOptions') {
+ if (typeName == 'RefactoringFeedback') {
+ return 'new $typeName.fromJson(jsonDecoder, $jsonPath, $json, json)';
+ } else if (typeName == 'RefactoringOptions') {
return 'new $typeName.fromJson(jsonDecoder, $jsonPath, $json, kind)';
} else {
return 'new $typeName.fromJson(jsonDecoder, $jsonPath, $json)';
@@ -1203,23 +1218,16 @@ class CodegenProtocolVisitor extends HierarchicalApiVisitor with CodeGenerator {
inputType = 'Response';
inputName = 'response';
fieldName = '_result';
- makeDecoder = 'new ResponseDecoder()';
+ makeDecoder = 'new ResponseDecoder(response)';
constructorName = 'fromResponse';
break;
case 'notificationParams':
inputType = 'Notification';
inputName = 'notification';
fieldName = '_params';
- makeDecoder = 'new ResponseDecoder()';
+ makeDecoder = 'new ResponseDecoder(null)';
constructorName = 'fromNotification';
break;
- case 'refactoringFeedback':
- inputType = 'EditGetRefactoringResult';
- inputName = 'refactoringResult';
- fieldName = 'feedback';
- makeDecoder = 'new ResponseDecoder()';
- constructorName = 'fromRefactoringResult';
- break;
case 'refactoringOptions':
inputType = 'EditGetRefactoringParams';
inputName = 'refactoringParams';
@@ -1237,8 +1245,15 @@ class CodegenProtocolVisitor extends HierarchicalApiVisitor with CodeGenerator {
indent(() {
String fieldNameString =
literalString(fieldName.replaceFirst(new RegExp('^_'), ''));
- writeln('return new $className.fromJson(');
- writeln(' $makeDecoder, $fieldNameString, $inputName.$fieldName);');
+ if (className == 'EditGetRefactoringParams') {
+ writeln('var params = new $className.fromJson(');
+ writeln(' $makeDecoder, $fieldNameString, $inputName.$fieldName);');
+ writeln('REQUEST_ID_REFACTORING_KINDS[request.id] = params.kind;');
+ writeln('return params;');
+ } else {
+ writeln('return new $className.fromJson(');
+ writeln(' $makeDecoder, $fieldNameString, $inputName.$fieldName);');
+ }
});
writeln('}');
return true;
« no previous file with comments | « pkg/analysis_server/test/protocol_test.dart ('k') | pkg/analysis_server/tool/spec/codegen_java_types.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698