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

Unified Diff: pkg/analysis_server/lib/src/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
Index: pkg/analysis_server/lib/src/protocol.dart
diff --git a/pkg/analysis_server/lib/src/protocol.dart b/pkg/analysis_server/lib/src/protocol.dart
index a10e74a07f5070a974d07c9a1a8f7730d9f17002..0d3da052527717d462efd3888e6f7116f3a46d6c 100644
--- a/pkg/analysis_server/lib/src/protocol.dart
+++ b/pkg/analysis_server/lib/src/protocol.dart
@@ -23,6 +23,10 @@ import 'package:analyzer/src/generated/source.dart' as engine;
part 'generated_protocol.dart';
+
+final Map<String, RefactoringKind> REQUEST_ID_REFACTORING_KINDS =
+ new HashMap<String, RefactoringKind>();
+
/**
* Translate the input [map], applying [keyCallback] to all its keys, and
* [valueCallback] to all its values.
@@ -396,6 +400,29 @@ OverriddenMember _overriddenMemberFromEngine(engine.Element member) {
/**
+ * Create a [RefactoringFeedback] corresponding the given [kind].
+ */
+RefactoringFeedback _refactoringFeedbackFromJson(JsonDecoder jsonDecoder,
+ String jsonPath, Object json, Map feedbackJson) {
+ String requestId;
+ if (jsonDecoder is ResponseDecoder) {
+ requestId = jsonDecoder.response.id;
+ }
+ RefactoringKind kind = REQUEST_ID_REFACTORING_KINDS[requestId];
+ if (kind == RefactoringKind.EXTRACT_LOCAL_VARIABLE) {
+ return new ExtractLocalVariableFeedback.fromJson(jsonDecoder, jsonPath, json);
+ }
+ if (kind == RefactoringKind.EXTRACT_METHOD) {
+ return new ExtractMethodFeedback.fromJson(jsonDecoder, jsonPath, json);
+ }
+ if (kind == RefactoringKind.RENAME) {
+ return new RenameFeedback.fromJson(jsonDecoder, jsonPath, json);
+ }
+ return null;
+}
+
+
+/**
* Create a [RefactoringOptions] corresponding the given [kind].
*/
RefactoringOptions _refactoringOptionsFromJson(JsonDecoder jsonDecoder,
@@ -856,7 +883,7 @@ class Response {
Object error = json[Response.ERROR];
RequestError decodedError;
if (error is Map) {
- decodedError = new RequestError.fromJson(new ResponseDecoder(),
+ decodedError = new RequestError.fromJson(new ResponseDecoder(null),
'.error', error);
}
Object result = json[Response.RESULT];
@@ -939,6 +966,10 @@ class Response {
* used only for testing. Errors are reported using bare [Exception] objects.
*/
class ResponseDecoder extends JsonDecoder {
+ final Response response;
+
+ ResponseDecoder(this.response);
+
@override
dynamic mismatch(String jsonPath, String expected) {
return new Exception('Expected $expected at $jsonPath');
« no previous file with comments | « pkg/analysis_server/lib/src/generated_protocol.dart ('k') | pkg/analysis_server/test/edit/refactoring_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698