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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: pkg/analysis_services/lib/correction/change.dart
diff --git a/pkg/analysis_services/lib/correction/change.dart b/pkg/analysis_services/lib/correction/change.dart
index aead3627efa7ff591f40bcbcf58aabf7007dc6ae..086b1cf806469080ba48d51cb6506157d32cce0b 100644
--- a/pkg/analysis_services/lib/correction/change.dart
+++ b/pkg/analysis_services/lib/correction/change.dart
@@ -24,17 +24,31 @@ class Change {
*/
final List<FileEdit> edits = <FileEdit>[];
+ /**
+ * A list of the [PositionGroup]s in the change. 
+ */
+ final List<PositionGroup> positionGroups = <PositionGroup>[];
+
Change(this.message);
/**
- * Adds the given [FileEdit] to the list.
+ * Adds the given [FileEdit].
*/
void add(FileEdit edit) {
edits.add(edit);
}
+ /**
+ * Adds the given [PositionGroup].
+ */
+ void addPositionGroup(PositionGroup positionGroup) {
+ positionGroups.add(positionGroup);
+ }
+
@override
- String toString() => "Change(message=$message, edits=${edits.join(' ')})";
+ String toString() =>
+ 'Change(message=$message, edits=${edits.join(' ')}, '
+ 'positionGroups=${positionGroups.join(', ')})';
}
@@ -101,3 +115,59 @@ class FileEdit {
@override
String toString() => "FileEdit(file=$file, edits=${edits.join(' ')})";
}
+
+
+/**
+ * A position in a file.
+ */
+class Position {
+ final String file;
+ final int offset;
+ final int length;
+
+ Position(this.file, this.offset, this.length);
+
+ int get hashCode {
+ int hash = file.hashCode;
+ hash = hash * 31 + offset;
+ hash = hash * 31 + length;
+ return hash;
+ }
+
+ bool operator ==(other) {
+ if (other is Position) {
+ return other.file == file &&
+ other.offset == offset &&
+ other.length == length;
+ }
+ return false;
+ }
+
+ @override
+ String toString() => 'Position(file=$file, offset=$offset, length=$length)';
+}
+
+
+/**
+ * A group of linked [Position]s in multiple files that are simultaneously
+ * modified - if one gets edited, all other positions in a group are edited the
+ * same way. All linked positions in a group have the same content.
+ */
+class PositionGroup {
+ final String id;
+ final List<Position> positions = <Position>[];
+
+ PositionGroup(this.id);
+
+ void add(Position position) {
+ if (positions.isNotEmpty && position.length != positions[0].length) {
+ throw new ArgumentError(
+ 'All positions should have the same length. '
+ 'Was: ${positions[0].length}. New: ${position.length}');
+ }
+ positions.add(position);
+ }
+
+ @override
+ String toString() => 'PositionGroup(id=$id, positions=$positions)';
+}
« 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