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

Unified Diff: pkg/analysis_server/lib/src/protocol.dart

Issue 1232683003: Issue 23640. Implement 'analysis.getNavigation' request. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 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/protocol.dart
diff --git a/pkg/analysis_server/lib/src/protocol.dart b/pkg/analysis_server/lib/src/protocol.dart
index 8a15ebe9e9418a6863555ef60c323afff56e7e8f..f633eb8d7460738887d4b29067ea0e32c59a9ce4 100644
--- a/pkg/analysis_server/lib/src/protocol.dart
+++ b/pkg/analysis_server/lib/src/protocol.dart
@@ -513,7 +513,7 @@ class Request {
: _params = params != null ? params : new HashMap<String, Object>();
/**
- * Return a request parsed from the given [data], or `null` if the [data] is
+ * Return a request parsed from the given json, or `null` if the [data] is
* not a valid json representation of a request. The [data] is expected to
* have the following format:
*
@@ -531,20 +531,26 @@ class Request {
* The clientRequestTime must be an int representing the time at which
* the client issued the request (milliseconds since epoch).
*/
- factory Request.fromString(String data) {
- try {
- var result = JSON.decode(data);
- if (result is Map) {
- return new Request.fromJson(result);
- }
+ factory Request.fromJson(Map<String, dynamic> result) {
+ var id = result[Request.ID];
+ var method = result[Request.METHOD];
+ if (id is! String || method is! String) {
return null;
- } catch (exception) {
+ }
+ var time = result[Request.CLIENT_REQUEST_TIME];
+ if (time != null && time is! int) {
+ return null;
+ }
+ var params = result[Request.PARAMS];
+ if (params is Map || params == null) {
+ return new Request(id, method, params, time);
+ } else {
return null;
}
}
/**
- * Return a request parsed from the given json, or `null` if the [data] is
+ * Return a request parsed from the given [data], or `null` if the [data] is
* not a valid json representation of a request. The [data] is expected to
* have the following format:
*
@@ -562,20 +568,14 @@ class Request {
* The clientRequestTime must be an int representing the time at which
* the client issued the request (milliseconds since epoch).
*/
- factory Request.fromJson(Map<String, dynamic> result) {
- var id = result[Request.ID];
- var method = result[Request.METHOD];
- if (id is! String || method is! String) {
- return null;
- }
- var time = result[Request.CLIENT_REQUEST_TIME];
- if (time != null && time is! int) {
+ factory Request.fromString(String data) {
+ try {
+ var result = JSON.decode(data);
+ if (result is Map) {
+ return new Request.fromJson(result);
+ }
return null;
- }
- var params = result[Request.PARAMS];
- if (params is Map || params == null) {
- return new Request(id, method, params, time);
- } else {
+ } catch (exception) {
return null;
}
}
@@ -763,6 +763,14 @@ class Response {
'Error during `analysis.getErrors`: invalid file.'));
/**
+ * Initialize a newly created instance to represent the
+ * GET_NAVIGATION_INVALID_FILE error condition.
+ */
+ Response.getNavigationInvalidFile(Request request) : this(request.id,
+ error: new RequestError(RequestErrorCode.GET_NAVIGATION_INVALID_FILE,
+ 'Error during `analysis.getNavigation`: invalid file.'));
+
+ /**
* Initialize a newly created instance to represent an error condition caused
* by an analysis.reanalyze [request] that specifies an analysis root that is
* not in the current list of analysis roots.

Powered by Google App Engine
This is Rietveld 408576698