Chromium Code Reviews| Index: pkg/analysis_server/lib/src/domain_edit.dart |
| diff --git a/pkg/analysis_server/lib/src/domain_edit.dart b/pkg/analysis_server/lib/src/domain_edit.dart |
| index cbc34ddaeb1901b815f75cdae267db218480a0dc..493472b5a570b2669bc673f07c4f2fb13651e89a 100644 |
| --- a/pkg/analysis_server/lib/src/domain_edit.dart |
| +++ b/pkg/analysis_server/lib/src/domain_edit.dart |
| @@ -100,7 +100,7 @@ class EditDomainHandler implements RequestHandler { |
| // errors |
| RequestDatum errorsDatum = request.getRequiredParameter(ERRORS); |
| List<AnalysisError> errors = errorsDatum.asList((RequestDatum datum) { |
| - return _createAnalysisError(datum); |
| + return _createAnalysisError(request, datum); |
| }); |
| // TODO(brianwilkerson) implement |
| return null; |
| @@ -128,7 +128,105 @@ class EditDomainHandler implements RequestHandler { |
| return null; |
| } |
| - AnalysisError _createAnalysisError(RequestDatum datum) { |
| - // TODO(brianwilkerson) implement |
| + /** |
| + * Convert the given data from a request into an analysis error. |
| + */ |
| + AnalysisError _createAnalysisError(Request request, RequestDatum datum) { |
| + String file; |
| + String errorCodeName; |
| + int offset; |
| + int length; |
| + String message; |
| + String correction; |
| + datum.forEachMap((String key, RequestDatum value) { |
| + if (key == FILE) { |
| + file = value.asString(); |
| + } else if (key == ERROR_CODE) { |
| + errorCodeName = value.asString(); |
| + } else if (key == OFFSET) { |
| + offset = value.asInt(); |
| + } else if (key == LENGTH) { |
| + length = value.asInt(); |
| + } else if (key == MESSAGE) { |
| + message = value.asString(); |
| + } else if (key == CORRECTION) { |
| + correction = value.asString(); |
| + } |
| + }); |
| + if (file == null) { |
| + throw new RequestFailure( |
| + new Response.missingRequiredParameter(request, 'file')); |
| + } |
| + if (errorCodeName == null) { |
| + throw new RequestFailure( |
| + new Response.missingRequiredParameter(request, 'errorCode')); |
| + } |
| + if (offset == null) { |
| + throw new RequestFailure( |
| + new Response.missingRequiredParameter(request, 'offset')); |
| + } |
| + if (length == null) { |
| + throw new RequestFailure( |
| + new Response.missingRequiredParameter(request, 'length')); |
| + } |
| + if (message == null) { |
| + throw new RequestFailure( |
| + new Response.missingRequiredParameter(request, 'message')); |
| + } |
|
Paul Berry
2014/06/16 23:43:16
RequestDatum was intended to make this sort of err
Brian Wilkerson
2014/06/17 17:46:16
Thanks! That's much cleaner.
|
| + ErrorCode errorCode = convertErrorCode(errorCodeName); |
| + if (errorCode == null) { |
| + |
| + } |
| + // TODO(brianwilkerson) Implement this. |
| +// return new AnalysisError.con2( |
| +// server.sourceFromFile(file), |
| +// offset, |
| +// length, |
| +// errorCode, |
| +// null); |
| + return null; |
| + } |
| + |
| + /** |
| + * Return the error code corresponding to the given [errorCodeName], or `null` |
| + * if the given name is not a valid error code. |
| + */ |
| + ErrorCode convertErrorCode(String errorCodeName) { |
| + // TODO(brianwilkerson) Implement this. |
| +// Enum2 errorCode = Enum2.valueOf(AngularCode.values, errorCodeName); |
| +// if (errorCode == null) { |
| +// errorCode = Enum2.valueOf(CompileTimeErrorCode.values, errorCodeName); |
| +// } |
| +// if (errorCode == null) { |
| +// errorCode = Enum2.valueOf(HintCode.values, errorCodeName); |
| +// } |
| +// if (errorCode == null) { |
| +// errorCode = Enum2.valueOf(HtmlWarningCode.values, errorCodeName); |
| +// } |
| +// if (errorCode == null) { |
| +// errorCode = Enum2.valueOf(ParserErrorCode.values, errorCodeName); |
| +// } |
| +// if (errorCode == null) { |
| +// errorCode = Enum2.valueOf(PolymerCode.values, errorCodeName); |
| +// } |
| +// if (errorCode == null) { |
| +// errorCode = Enum2.valueOf(PubSuggestionCode.values, errorCodeName); |
| +// } |
| +// if (errorCode == null) { |
| +// errorCode = Enum2.valueOf(ResolverErrorCode.values, errorCodeName); |
| +// } |
| +// if (errorCode == null) { |
| +// errorCode = Enum2.valueOf(ScannerErrorCode.values, errorCodeName); |
| +// } |
| +// if (errorCode == null) { |
| +// errorCode = Enum2.valueOf(StaticTypeErrorCode.values, errorCodeName); |
| +// } |
| +// if (errorCode == null) { |
| +// errorCode = Enum2.valueOf(StaticWarningErrorCode.values, errorCodeName); |
| +// } |
| +// if (errorCode == null) { |
| +// errorCode = Enum2.valueOf(TodoCode.values, errorCodeName); |
| +// } |
| + return null; |
| } |
| } |