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

Unified Diff: pkg/analysis_server/lib/src/edit/fix.dart

Issue 402333006: Implementation of the 'edit.getFixes' API in server. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 5 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/edit/fix.dart
diff --git a/pkg/analysis_server/lib/src/edit/fix.dart b/pkg/analysis_server/lib/src/edit/fix.dart
new file mode 100644
index 0000000000000000000000000000000000000000..5e765d4d2f067157633eafe440596cb4a226248c
--- /dev/null
+++ b/pkg/analysis_server/lib/src/edit/fix.dart
@@ -0,0 +1,44 @@
+// Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+library edit.fix;
+
+import 'package:analysis_server/src/computer/error.dart';
+import 'package:analysis_services/constants.dart';
+import 'package:analysis_services/correction/change.dart';
+import 'package:analysis_services/correction/fix.dart';
+import 'package:analysis_services/json.dart';
+
+
+class ErrorFixes implements HasToJson {
+ final AnalysisError error;
+ final List<Change> fixes = <Change>[];
+
+ ErrorFixes(this.error);
+
+ void addFix(Fix fix) {
+ Change change = fix.change;
+ fixes.add(change);
+ }
+
+ @override
+ Map<String, Object> toJson() {
+ return {
+ ERROR: error.toJson(),
+ FIXES: objectToJson(fixes)
+ };
+ }
+
+ @override
+ String toString() => 'ErrorFixes(error=$error, fixes=$fixes)';
+
+ static ErrorFixes fromJson(Map<String, Object> json) {
+ AnalysisError error = AnalysisError.fromJson(json[ERROR]);
+ ErrorFixes errorFixes = new ErrorFixes(error);
+ errorFixes.fixes.addAll((json[FIXES] as List).map((json) {
+ return Change.fromJson(json);
+ }));
+ return errorFixes;
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698