Index: sdk/lib/developer/extension.dart |
diff --git a/sdk/lib/developer/extension.dart b/sdk/lib/developer/extension.dart |
index e50a88d8f356f245f702847c870a9c1fcf64cda4..1ec74249a09dbc8ed523811fc3a7b71e6fbe6d0a 100644 |
--- a/sdk/lib/developer/extension.dart |
+++ b/sdk/lib/developer/extension.dart |
@@ -38,31 +38,39 @@ class ServiceExtensionResponse { |
_errorDetail = errorDetail { |
_validateErrorCode(_errorCode); |
if (_errorDetail is! String) { |
- throw new ArgumentError.value(_errorDetail, |
- "errorDetail", |
- "Must be a String"); |
+ throw new ArgumentError.value( |
+ _errorDetail, "errorDetail", "Must be a String"); |
} |
} |
/// Invalid method parameter(s) error code. |
- @deprecated static const kInvalidParams = invalidParams; |
+ @deprecated |
+ static const kInvalidParams = invalidParams; |
+ |
/// Generic extension error code. |
- @deprecated static const kExtensionError = extensionError; |
+ @deprecated |
+ static const kExtensionError = extensionError; |
+ |
/// Maximum extension provided error code. |
- @deprecated static const kExtensionErrorMax = extensionErrorMax; |
+ @deprecated |
+ static const kExtensionErrorMax = extensionErrorMax; |
+ |
/// Minimum extension provided error code. |
- @deprecated static const kExtensionErrorMin = extensionErrorMin; |
+ @deprecated |
+ static const kExtensionErrorMin = extensionErrorMin; |
/// Invalid method parameter(s) error code. |
static const invalidParams = -32602; |
+ |
/// Generic extension error code. |
static const extensionError = -32000; |
+ |
/// Maximum extension provided error code. |
static const extensionErrorMax = -32000; |
+ |
/// Minimum extension provided error code. |
static const extensionErrorMin = -32016; |
- |
static String _errorCodeMessage(int errorCode) { |
_validateErrorCode(errorCode); |
if (errorCode == kInvalidParams) { |
@@ -78,8 +86,7 @@ class ServiceExtensionResponse { |
if (errorCode == invalidParams) { |
return; |
} |
- if ((errorCode >= extensionErrorMin) && |
- (errorCode <= extensionErrorMax)) { |
+ if ((errorCode >= extensionErrorMin) && (errorCode <= extensionErrorMax)) { |
return; |
} |
throw new ArgumentError.value(errorCode, "errorCode", "Out of range"); |
@@ -96,9 +103,7 @@ class ServiceExtensionResponse { |
return JSON.encode({ |
'code': _errorCode, |
'message': _errorCodeMessage(_errorCode), |
- 'data': { |
- 'details': _errorDetail |
- } |
+ 'data': {'details': _errorDetail} |
}); |
} |
} |
@@ -112,8 +117,8 @@ class ServiceExtensionResponse { |
/// [parameters] - A map holding the parameters to the service protocol request. |
/// |
/// *NOTE*: All parameter names and values are **encoded as strings**. |
-typedef Future<ServiceExtensionResponse> |
- ServiceExtensionHandler(String method, Map<String, String> parameters); |
+typedef Future<ServiceExtensionResponse> ServiceExtensionHandler( |
+ String method, Map<String, String> parameters); |
/// Register a [ServiceExtensionHandler] that will be invoked in this isolate |
/// for [method]. *NOTE*: Service protocol extensions must be registered |
@@ -129,22 +134,17 @@ typedef Future<ServiceExtensionResponse> |
/// must always include an 'isolateId' parameter with each RPC. |
void registerExtension(String method, ServiceExtensionHandler handler) { |
if (method is! String) { |
- throw new ArgumentError.value(method, |
- 'method', |
- 'Must be a String'); |
+ throw new ArgumentError.value(method, 'method', 'Must be a String'); |
} |
if (!method.startsWith('ext.')) { |
- throw new ArgumentError.value(method, |
- 'method', |
- 'Must begin with ext.'); |
+ throw new ArgumentError.value(method, 'method', 'Must begin with ext.'); |
} |
if (_lookupExtension(method) != null) { |
throw new ArgumentError('Extension already registered: $method'); |
} |
if (handler is! ServiceExtensionHandler) { |
- throw new ArgumentError.value(handler, |
- 'handler', |
- 'Must be a ServiceExtensionHandler'); |
+ throw new ArgumentError.value( |
+ handler, 'handler', 'Must be a ServiceExtensionHandler'); |
} |
_registerExtension(method, handler); |
} |
@@ -153,14 +153,10 @@ void registerExtension(String method, ServiceExtensionHandler handler) { |
/// event stream. |
void postEvent(String eventKind, Map eventData) { |
if (eventKind is! String) { |
- throw new ArgumentError.value(eventKind, |
- 'eventKind', |
- 'Must be a String'); |
+ throw new ArgumentError.value(eventKind, 'eventKind', 'Must be a String'); |
} |
if (eventData is! Map) { |
- throw new ArgumentError.value(eventData, |
- 'eventData', |
- 'Must be a Map'); |
+ throw new ArgumentError.value(eventData, 'eventData', 'Must be a Map'); |
} |
String eventDataAsString = JSON.encode(eventData); |
_postEvent(eventKind, eventDataAsString); |