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

Side by Side Diff: pkg/analysis_server/test/services/correction/change_test.dart

Issue 495733002: Don't use LinkedEditGroup.id. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 4 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
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 test.services.correction.change; 5 library test.services.correction.change;
6 6
7 import 'package:analysis_server/src/constants.dart'; 7 import 'package:analysis_server/src/constants.dart';
8 import 'package:analysis_server/src/protocol2.dart' show SourceEdit; 8 import 'package:analysis_server/src/protocol2.dart' show SourceEdit;
9 import 'package:analysis_server/src/services/correction/change.dart'; 9 import 'package:analysis_server/src/services/correction/change.dart';
10 import 'package:analysis_testing/reflective_tests.dart'; 10 import 'package:analysis_testing/reflective_tests.dart';
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 55
56 void test_toJson() { 56 void test_toJson() {
57 Change change = new Change('msg'); 57 Change change = new Change('msg');
58 change.addFileEdit(new FileEdit('/a.dart') 58 change.addFileEdit(new FileEdit('/a.dart')
59 ..add(new SourceEdit(1, 2, 'aaa')) 59 ..add(new SourceEdit(1, 2, 'aaa'))
60 ..add(new SourceEdit(10, 20, 'bbb'))); 60 ..add(new SourceEdit(10, 20, 'bbb')));
61 change.addFileEdit(new FileEdit('/b.dart') 61 change.addFileEdit(new FileEdit('/b.dart')
62 ..add(new SourceEdit(21, 22, 'xxx')) 62 ..add(new SourceEdit(21, 22, 'xxx'))
63 ..add(new SourceEdit(210, 220, 'yyy'))); 63 ..add(new SourceEdit(210, 220, 'yyy')));
64 { 64 {
65 var group = new LinkedEditGroup('id-a'); 65 var group = new LinkedEditGroup();
66 change.addLinkedEditGroup(group 66 change.addLinkedEditGroup(group
67 ..addPosition(new Position('/ga.dart', 1), 2) 67 ..addPosition(new Position('/ga.dart', 1), 2)
68 ..addPosition(new Position('/ga.dart', 10), 2)); 68 ..addPosition(new Position('/ga.dart', 10), 2));
69 group.addSuggestion( 69 group.addSuggestion(
70 new LinkedEditSuggestion(LinkedEditSuggestionKind.TYPE, 'AA')); 70 new LinkedEditSuggestion(LinkedEditSuggestionKind.TYPE, 'AA'));
71 group.addSuggestion( 71 group.addSuggestion(
72 new LinkedEditSuggestion(LinkedEditSuggestionKind.TYPE, 'BB')); 72 new LinkedEditSuggestion(LinkedEditSuggestionKind.TYPE, 'BB'));
73 } 73 }
74 change.addLinkedEditGroup(new LinkedEditGroup('id-b') 74 change.addLinkedEditGroup(new LinkedEditGroup()
75 ..addPosition(new Position('/gb.dart', 10), 5) 75 ..addPosition(new Position('/gb.dart', 10), 5)
76 ..addPosition(new Position('/gb.dart', 100), 5)); 76 ..addPosition(new Position('/gb.dart', 100), 5));
77 change.selection = new Position('/selection.dart', 42); 77 change.selection = new Position('/selection.dart', 42);
78 var expectedJson = { 78 var expectedJson = {
79 'message': 'msg', 79 'message': 'msg',
80 'edits': [{ 80 'edits': [{
81 'file': '/a.dart', 81 'file': '/a.dart',
82 'edits': [{ 82 'edits': [{
83 'offset': 10, 83 'offset': 10,
84 'length': 20, 84 'length': 20,
85 'replacement': 'bbb' 85 'replacement': 'bbb'
86 }, { 86 }, {
87 'offset': 1, 87 'offset': 1,
88 'length': 2, 88 'length': 2,
89 'replacement': 'aaa' 89 'replacement': 'aaa'
90 }] 90 }]
91 }, { 91 }, {
92 'file': '/b.dart', 92 'file': '/b.dart',
93 'edits': [{ 93 'edits': [{
94 'offset': 210, 94 'offset': 210,
95 'length': 220, 95 'length': 220,
96 'replacement': 'yyy' 96 'replacement': 'yyy'
97 }, { 97 }, {
98 'offset': 21, 98 'offset': 21,
99 'length': 22, 99 'length': 22,
100 'replacement': 'xxx' 100 'replacement': 'xxx'
101 }] 101 }]
102 }], 102 }],
103 'linkedEditGroups': [{ 103 'linkedEditGroups': [{
104 'id': 'id-a',
105 'length': 2, 104 'length': 2,
106 'positions': [{ 105 'positions': [{
107 'file': '/ga.dart', 106 'file': '/ga.dart',
108 'offset': 1 107 'offset': 1
109 }, { 108 }, {
110 'file': '/ga.dart', 109 'file': '/ga.dart',
111 'offset': 10 110 'offset': 10
112 }], 111 }],
113 'suggestions': [{ 112 'suggestions': [{
114 'kind': 'TYPE', 113 'kind': 'TYPE',
115 'value': 'AA' 114 'value': 'AA'
116 }, { 115 }, {
117 'kind': 'TYPE', 116 'kind': 'TYPE',
118 'value': 'BB' 117 'value': 'BB'
119 }] 118 }]
120 }, { 119 }, {
121 'id': 'id-b',
122 'length': 5, 120 'length': 5,
123 'positions': [{ 121 'positions': [{
124 'file': '/gb.dart', 122 'file': '/gb.dart',
125 'offset': 10 123 'offset': 10
126 }, { 124 }, {
127 'file': '/gb.dart', 125 'file': '/gb.dart',
128 'offset': 100 126 'offset': 100
129 }], 127 }],
130 'suggestions': [] 128 'suggestions': []
131 }], 129 }],
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
243 },] 241 },]
244 }; 242 };
245 expect(fileEdit.toJson(), expectedJson); 243 expect(fileEdit.toJson(), expectedJson);
246 } 244 }
247 } 245 }
248 246
249 247
250 @ReflectiveTestCase() 248 @ReflectiveTestCase()
251 class LinkedEditGroupTest { 249 class LinkedEditGroupTest {
252 void test_new() { 250 void test_new() {
253 LinkedEditGroup group = new LinkedEditGroup('my-id'); 251 LinkedEditGroup group = new LinkedEditGroup();
254 group.addPosition(new Position('/a.dart', 1), 2); 252 group.addPosition(new Position('/a.dart', 1), 2);
255 group.addPosition(new Position('/b.dart', 10), 2); 253 group.addPosition(new Position('/b.dart', 10), 2);
256 expect( 254 expect(
257 group.toString(), 255 group.toString(),
258 'LinkedEditGroup(id=my-id, length=2, positions=[' 256 'LinkedEditGroup(length=2, positions=['
259 'Position(file=/a.dart, offset=1), ' 257 'Position(file=/a.dart, offset=1), '
260 'Position(file=/b.dart, offset=10)], suggestions=[])'); 258 'Position(file=/b.dart, offset=10)], suggestions=[])');
261 } 259 }
262 260
263 void test_toJson() { 261 void test_toJson() {
264 LinkedEditGroup group = new LinkedEditGroup('my-id'); 262 LinkedEditGroup group = new LinkedEditGroup();
265 group.addPosition(new Position('/a.dart', 1), 2); 263 group.addPosition(new Position('/a.dart', 1), 2);
266 group.addPosition(new Position('/b.dart', 10), 2); 264 group.addPosition(new Position('/b.dart', 10), 2);
267 group.addSuggestion( 265 group.addSuggestion(
268 new LinkedEditSuggestion(LinkedEditSuggestionKind.TYPE, 'AA')); 266 new LinkedEditSuggestion(LinkedEditSuggestionKind.TYPE, 'AA'));
269 group.addSuggestion( 267 group.addSuggestion(
270 new LinkedEditSuggestion(LinkedEditSuggestionKind.TYPE, 'BB')); 268 new LinkedEditSuggestion(LinkedEditSuggestionKind.TYPE, 'BB'));
271 expect(group.toJson(), { 269 expect(group.toJson(), {
272 'id': 'my-id',
273 'length': 2, 270 'length': 2,
274 'positions': [{ 271 'positions': [{
275 'file': '/a.dart', 272 'file': '/a.dart',
276 'offset': 1 273 'offset': 1
277 }, { 274 }, {
278 'file': '/b.dart', 275 'file': '/b.dart',
279 'offset': 10 276 'offset': 10
280 }], 277 }],
281 'suggestions': [{ 278 'suggestions': [{
282 'kind': 'TYPE', 279 'kind': 'TYPE',
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
332 329
333 void test_toJson() { 330 void test_toJson() {
334 Position position = new Position('/test.dart', 1); 331 Position position = new Position('/test.dart', 1);
335 var expectedJson = { 332 var expectedJson = {
336 FILE: '/test.dart', 333 FILE: '/test.dart',
337 OFFSET: 1 334 OFFSET: 1
338 }; 335 };
339 expect(position.toJson(), expectedJson); 336 expect(position.toJson(), expectedJson);
340 } 337 }
341 } 338 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698