Chromium Code Reviews| Index: pkg/analysis_server/lib/src/domain_analysis.dart |
| diff --git a/pkg/analysis_server/lib/src/domain_analysis.dart b/pkg/analysis_server/lib/src/domain_analysis.dart |
| index ed21d0af1f60e16b3813063d9b44463065c64897..8c1252bdef8e6ac581fe26236a42de59e6800104 100644 |
| --- a/pkg/analysis_server/lib/src/domain_analysis.dart |
| +++ b/pkg/analysis_server/lib/src/domain_analysis.dart |
| @@ -171,18 +171,30 @@ class AnalysisDomainHandler implements RequestHandler { |
| Response updateContent(Request request) { |
| var changes = new HashMap<String, ContentChange>(); |
| RequestDatum filesDatum = request.getRequiredParameter(FILES); |
| + Response errorResponse; |
| filesDatum.forEachMap((file, changeDatum) { |
| - var change = new ContentChange(); |
| - change.content = changeDatum[CONTENT].isNull ? |
| - null : |
| - changeDatum[CONTENT].asString(); |
| - if (changeDatum.hasKey(OFFSET)) { |
| - change.offset = changeDatum[OFFSET].asInt(); |
| - change.oldLength = changeDatum[OLD_LENGTH].asInt(); |
| - change.newLength = changeDatum[NEW_LENGTH].asInt(); |
| + ContentChange change = new ContentChange(); |
| + switch (changeDatum[TYPE].asString()) { |
| + case 'add': |
| + change.content = changeDatum[CONTENT].asString(); |
| + break; |
| + case 'change': |
| + change.offset = changeDatum[OFFSET].asInt(); |
| + change.oldLength = changeDatum[OLD_LENGTH].asInt(); |
| + change.content = changeDatum[REPLACEMENT].asString(); |
| + break; |
| + case 'remove': |
| + break; |
| + default: |
| + errorResponse = new Response.invalidParameter(request, |
| + changeDatum[TYPE].path, 'be one of "add", "change", or "remove"'); |
| + return; |
|
Brian Wilkerson
2014/08/07 22:15:22
I think we want to return the errorResponse at thi
Paul Berry
2014/08/07 23:58:09
Unfortunately, that doesn't work, because we are i
Brian Wilkerson
2014/08/08 00:14:58
What I want is non-local returns.
What I need is
|
| } |
| changes[file] = change; |
| }); |
| + if (errorResponse != null) { |
|
Brian Wilkerson
2014/08/07 22:15:22
In which case errorResponse will never be non-null
|
| + return errorResponse; |
| + } |
| server.updateContent(changes); |
| return new Response(request.id); |
| } |
| @@ -250,5 +262,4 @@ class ContentChange { |
| String content; |
|
Brian Wilkerson
2014/08/07 22:15:22
Perhaps change 'content' to 'replacement'?
Paul Berry
2014/08/07 23:58:09
I'm not sure that would be an improvement, because
Brian Wilkerson
2014/08/08 00:14:58
A bit wordy, but I would have understood what the
|
| int offset; |
| int oldLength; |
|
Brian Wilkerson
2014/08/07 22:15:22
Perhaps rename 'oldLength' to 'length'?
Paul Berry
2014/08/07 23:58:09
Done.
|
| - int newLength; |
| } |