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

Side by Side Diff: pkg/analysis_server/lib/src/edit/edit_domain.dart

Issue 1092653002: Fix "edit.format" to follow protocol when there is no selection. (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
« no previous file with comments | « no previous file | pkg/analysis_server/test/edit/format_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 edit.domain; 5 library edit.domain;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 8
9 import 'package:analysis_server/edit/assist/assist_core.dart'; 9 import 'package:analysis_server/edit/assist/assist_core.dart';
10 import 'package:analysis_server/edit/fix/fix_core.dart'; 10 import 'package:analysis_server/edit/fix/fix_core.dart';
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 103
104 List<SourceEdit> edits = <SourceEdit>[]; 104 List<SourceEdit> edits = <SourceEdit>[];
105 105
106 if (formattedSource != unformattedSource) { 106 if (formattedSource != unformattedSource) {
107 //TODO: replace full replacements with smaller, more targeted edits 107 //TODO: replace full replacements with smaller, more targeted edits
108 SourceEdit edit = 108 SourceEdit edit =
109 new SourceEdit(0, unformattedSource.length, formattedSource); 109 new SourceEdit(0, unformattedSource.length, formattedSource);
110 edits.add(edit); 110 edits.add(edit);
111 } 111 }
112 112
113 return new EditFormatResult(edits, formattedResult.selectionStart, 113 int newStart = formattedResult.selectionStart;
114 formattedResult.selectionLength).toResponse(request.id); 114 int newLength = formattedResult.selectionLength;
115
116 // Sending null start/length values would violate protocol, so convert back
117 // to 0.
118 if (newStart == null) {
119 newStart = 0;
120 }
121 if (newLength == null) {
122 newLength = 0;
123 }
124
125 return new EditFormatResult(edits, newStart,
126 newLength).toResponse(request.id);
115 } 127 }
116 128
117 Response getAssists(Request request) { 129 Response getAssists(Request request) {
118 EditGetAssistsParams params = new EditGetAssistsParams.fromRequest(request); 130 EditGetAssistsParams params = new EditGetAssistsParams.fromRequest(request);
119 ContextSourcePair pair = server.getContextSourcePair(params.file); 131 ContextSourcePair pair = server.getContextSourcePair(params.file);
120 engine.AnalysisContext context = pair.context; 132 engine.AnalysisContext context = pair.context;
121 Source source = pair.source; 133 Source source = pair.source;
122 List<SourceChange> changes = <SourceChange>[]; 134 List<SourceChange> changes = <SourceChange>[];
123 if (context != null && source != null) { 135 if (context != null && source != null) {
124 List<Assist> assists = computeAssists(plugin, context, 136 List<Assist> assists = computeAssists(plugin, context,
(...skipping 508 matching lines...) Expand 10 before | Expand all | Expand 10 after
633 } 645 }
634 if (refactoring is RenameRefactoring) { 646 if (refactoring is RenameRefactoring) {
635 RenameRefactoring renameRefactoring = refactoring; 647 RenameRefactoring renameRefactoring = refactoring;
636 RenameOptions renameOptions = params.options; 648 RenameOptions renameOptions = params.options;
637 renameRefactoring.newName = renameOptions.newName; 649 renameRefactoring.newName = renameOptions.newName;
638 return renameRefactoring.checkNewName(); 650 return renameRefactoring.checkNewName();
639 } 651 }
640 return new RefactoringStatus(); 652 return new RefactoringStatus();
641 } 653 }
642 } 654 }
OLDNEW
« no previous file with comments | « no previous file | pkg/analysis_server/test/edit/format_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698