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

Side by Side Diff: pkg/analysis_services/lib/correction/change.dart

Issue 405483007: More fixes in the Fixes service. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 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 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 // This code was auto-generated, is not intended to be edited, and is subject to 5 // This code was auto-generated, is not intended to be edited, and is subject to
6 // significant change. Please see the README file for more information. 6 // significant change. Please see the README file for more information.
7 7
8 library services.correction.change; 8 library services.correction.change;
9 9
10 import 'package:analyzer/src/generated/source.dart'; 10 import 'package:analyzer/src/generated/source.dart';
11 11
12 12
13 /** 13 /**
14 * A description of a single change to one or more files.  14 * A description of a single change to one or more files. 
15 */ 15 */
16 class Change { 16 class Change {
17 /** 17 /**
18 * A textual description of the change to be applied.  18 * A textual description of the change to be applied. 
19 */ 19 */
20 final String message; 20 final String message;
21 21
22 /** 22 /**
23 * A list of the [FileEdit]s used to effect the change.  23 * A list of the [FileEdit]s used to effect the change. 
24 */ 24 */
25 final List<FileEdit> edits = <FileEdit>[]; 25 final List<FileEdit> edits = <FileEdit>[];
26 26
27 /**
28 * A list of the [PositionGroup]s in the change. 
29 */
30 final List<PositionGroup> positionGroups = <PositionGroup>[];
31
27 Change(this.message); 32 Change(this.message);
28 33
29 /** 34 /**
30 * Adds the given [FileEdit] to the list. 35 * Adds the given [FileEdit].
31 */ 36 */
32 void add(FileEdit edit) { 37 void add(FileEdit edit) {
33 edits.add(edit); 38 edits.add(edit);
34 } 39 }
35 40
41 /**
42 * Adds the given [PositionGroup].
43 */
44 void addPositionGroup(PositionGroup positionGroup) {
45 positionGroups.add(positionGroup);
46 }
47
36 @override 48 @override
37 String toString() => "Change(message=$message, edits=${edits.join(' ')})"; 49 String toString() =>
50 'Change(message=$message, edits=${edits.join(' ')}, '
51 'positionGroups=${positionGroups.join(', ')})';
38 } 52 }
39 53
40 54
41 /** 55 /**
42 * A description of a single change to a single file.  56 * A description of a single change to a single file. 
43 */ 57 */
44 class Edit { 58 class Edit {
45 /** 59 /**
46 * The offset of the region to be modified.  60 * The offset of the region to be modified. 
47 */ 61 */
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 /** 108 /**
95 * Adds the given [Edit] to the list. 109 * Adds the given [Edit] to the list.
96 */ 110 */
97 void add(Edit edit) { 111 void add(Edit edit) {
98 edits.add(edit); 112 edits.add(edit);
99 } 113 }
100 114
101 @override 115 @override
102 String toString() => "FileEdit(file=$file, edits=${edits.join(' ')})"; 116 String toString() => "FileEdit(file=$file, edits=${edits.join(' ')})";
103 } 117 }
118
119
120 /**
121 * A position in a file.
122 */
123 class Position {
124 final String file;
125 final int offset;
126 final int length;
127
128 Position(this.file, this.offset, this.length);
129
130 int get hashCode {
131 int hash = file.hashCode;
132 hash = hash * 31 + offset;
133 hash = hash * 31 + length;
134 return hash;
135 }
136
137 bool operator ==(other) {
138 if (other is Position) {
139 return other.file == file &&
140 other.offset == offset &&
141 other.length == length;
142 }
143 return false;
144 }
145
146 @override
147 String toString() => 'Position(file=$file, offset=$offset, length=$length)';
148 }
149
150
151 /**
152 * A group of linked [Position]s in multiple files that are simultaneously
153 * modified - if one gets edited, all other positions in a group are edited the
154 * same way. All linked positions in a group have the same content.
155 */
156 class PositionGroup {
157 final String id;
158 final List<Position> positions = <Position>[];
159
160 PositionGroup(this.id);
161
162 void add(Position position) {
163 if (positions.isNotEmpty && position.length != positions[0].length) {
164 throw new ArgumentError(
165 'All positions should have the same length. '
166 'Was: ${positions[0].length}. New: ${position.length}');
167 }
168 positions.add(position);
169 }
170
171 @override
172 String toString() => 'PositionGroup(id=$id, positions=$positions)';
173 }
OLDNEW
« no previous file with comments | « no previous file | pkg/analysis_services/lib/correction/fix.dart » ('j') | pkg/analysis_services/lib/src/correction/util.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698