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

Side by Side Diff: pkg/analysis_server/lib/src/protocol.dart

Issue 1099633004: Fix error handling for formatting and update the spec (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 8 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 protocol; 5 library protocol;
6 6
7 import 'dart:collection'; 7 import 'dart:collection';
8 import 'dart:convert'; 8 import 'dart:convert';
9 9
10 part 'generated_protocol.dart'; 10 part 'generated_protocol.dart';
(...skipping 672 matching lines...) Expand 10 before | Expand all | Expand 10 after
683 /** 683 /**
684 * Initialize a newly created instance to represent a response to a request 684 * Initialize a newly created instance to represent a response to a request
685 * with the given [id]. If [_result] is provided, it will be used as the 685 * with the given [id]. If [_result] is provided, it will be used as the
686 * result; otherwise an empty result will be used. If an [error] is provided 686 * result; otherwise an empty result will be used. If an [error] is provided
687 * then the response will represent an error condition. 687 * then the response will represent an error condition.
688 */ 688 */
689 Response(this.id, {Map<String, Object> result, this.error}) 689 Response(this.id, {Map<String, Object> result, this.error})
690 : _result = result; 690 : _result = result;
691 691
692 /** 692 /**
693 * Initialize a newly created instance to represent the 693 * Initialize a newly created instance to represent the FORMAT_INVALID_FILE
694 * FORMAT_INVALID_FILE error condition. 694 * error condition.
695 */ 695 */
696 Response.formatInvalidFile(Request request) : this(request.id, 696 Response.formatInvalidFile(Request request) : this(request.id,
697 error: new RequestError(RequestErrorCode.FORMAT_INVALID_FILE, 697 error: new RequestError(RequestErrorCode.FORMAT_INVALID_FILE,
698 'Error during `edit.format`: invalid file.')); 698 'Error during `edit.format`: invalid file.'));
699 699
700 /** 700 /**
701 * Initialize a newly created instance to represent the FORMAT_WITH_ERROR
702 * error condition.
703 */
704 Response.formatWithErrors(Request request) : this(request.id,
705 error: new RequestError(RequestErrorCode.FORMAT_WITH_ERRORS,
706 'Error during `edit.format`: source contains syntax errors.'));
707
708 /**
701 * Initialize a newly created instance based upon the given JSON data 709 * Initialize a newly created instance based upon the given JSON data
702 */ 710 */
703 factory Response.fromJson(Map<String, Object> json) { 711 factory Response.fromJson(Map<String, Object> json) {
704 try { 712 try {
705 Object id = json[Response.ID]; 713 Object id = json[Response.ID];
706 if (id is! String) { 714 if (id is! String) {
707 return null; 715 return null;
708 } 716 }
709 Object error = json[Response.ERROR]; 717 Object error = json[Response.ERROR];
710 RequestError decodedError; 718 RequestError decodedError;
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
903 hash = 0x1fffffff & (hash + ((0x03ffffff & hash) << 3)); 911 hash = 0x1fffffff & (hash + ((0x03ffffff & hash) << 3));
904 hash = hash ^ (hash >> 11); 912 hash = hash ^ (hash >> 11);
905 return 0x1fffffff & (hash + ((0x00003fff & hash) << 15)); 913 return 0x1fffffff & (hash + ((0x00003fff & hash) << 15));
906 } 914 }
907 915
908 static int hash2(a, b) => finish(combine(combine(0, a), b)); 916 static int hash2(a, b) => finish(combine(combine(0, a), b));
909 917
910 static int hash4(a, b, c, d) => 918 static int hash4(a, b, c, d) =>
911 finish(combine(combine(combine(combine(0, a), b), c), d)); 919 finish(combine(combine(combine(combine(0, a), b), c), d));
912 } 920 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698