Chromium Code Reviews| Index: pkg/analysis_server/lib/src/services/correction/change.dart |
| diff --git a/pkg/analysis_server/lib/src/services/correction/change.dart b/pkg/analysis_server/lib/src/services/correction/change.dart |
| index 456573d6eeef7ea968da0b3f3cc5247111a7f3b9..a20c00ec145ab7fd3a4b3cf927affbebddc6e7ac 100644 |
| --- a/pkg/analysis_server/lib/src/services/correction/change.dart |
| +++ b/pkg/analysis_server/lib/src/services/correction/change.dart |
| @@ -21,7 +21,7 @@ class Change implements HasToJson { |
| /** |
| * A list of the [FileEdit]s used to effect the change. |
| */ |
| - final List<FileEdit> fileEdits = <FileEdit>[]; |
| + final List<SourceFileEdit> fileEdits = <SourceFileEdit>[]; |
| /** |
| * A list of the [LinkedEditGroup]s in the change. |
| @@ -39,9 +39,9 @@ class Change implements HasToJson { |
| * Adds [edit] to the [FileEdit] for the given [file]. |
| */ |
| void addEdit(String file, SourceEdit edit) { |
| - FileEdit fileEdit = getFileEdit(file); |
| + SourceFileEdit fileEdit = getFileEdit(file); |
| if (fileEdit == null) { |
| - fileEdit = new FileEdit(file); |
| + fileEdit = new SourceFileEdit(file, <SourceEdit>[]); |
|
scheglov
2014/08/21 18:03:22
Can we get rid of the second parameter in the cons
Paul Berry
2014/08/21 20:00:44
I think so. I'll work on this in a separate CL.
|
| addFileEdit(fileEdit); |
| } |
| fileEdit.add(edit); |
| @@ -50,7 +50,7 @@ class Change implements HasToJson { |
| /** |
| * Adds the given [FileEdit]. |
| */ |
| - void addFileEdit(FileEdit edit) { |
| + void addFileEdit(SourceFileEdit edit) { |
| fileEdits.add(edit); |
| } |
| @@ -64,8 +64,8 @@ class Change implements HasToJson { |
| /** |
| * Returns the [FileEdit] for the given [file], maybe `null`. |
| */ |
| - FileEdit getFileEdit(String file) { |
| - for (FileEdit fileEdit in fileEdits) { |
| + SourceFileEdit getFileEdit(String file) { |
| + for (SourceFileEdit fileEdit in fileEdits) { |
| if (fileEdit.file == file) { |
| return fileEdit; |
| } |
| @@ -94,56 +94,6 @@ class Change implements HasToJson { |
| /** |
| - * A description of a set of changes to a single file. |
| - * |
| - * [Edit]s are added in the order of decreasing offset, so they are easy to |
| - * apply to the original file content without correcting offsets. |
| - */ |
| -class FileEdit implements HasToJson { |
| - /** |
| - * The file to be modified. |
| - */ |
| - final String file; |
| - |
| - /** |
| - * A list of the [Edit]s used to effect the change. |
| - */ |
| - final List<SourceEdit> edits = <SourceEdit>[]; |
| - |
| - FileEdit(this.file); |
| - |
| - /** |
| - * Adds the given [Edit] to the list. |
| - */ |
| - void add(SourceEdit edit) { |
| - int index = 0; |
| - while (index < edits.length && edits[index].offset > edit.offset) { |
| - index++; |
| - } |
| - edits.insert(index, edit); |
| - } |
| - |
| - /** |
| - * Adds the given [Edit]s. |
| - */ |
| - void addAll(Iterable<SourceEdit> edits) { |
| - edits.forEach(add); |
| - } |
| - |
| - @override |
| - Map<String, Object> toJson() { |
| - return { |
| - FILE: file, |
| - EDITS: objectToJson(edits) |
| - }; |
| - } |
| - |
| - @override |
| - String toString() => "FileEdit(file=$file, edits=$edits)"; |
| -} |
| - |
| - |
| -/** |
| * 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. |
| @@ -222,38 +172,3 @@ class LinkedEditSuggestionKind { |
| @override |
| String toString() => name; |
| } |
| - |
| - |
| -/** |
| - * A position in a file. |
| - */ |
| -class Position implements HasToJson { |
| - final String file; |
| - final int offset; |
| - |
| - Position(this.file, this.offset); |
| - |
| - int get hashCode { |
| - int hash = file.hashCode; |
| - hash = hash * 31 + offset; |
| - return hash; |
| - } |
| - |
| - bool operator ==(other) { |
| - if (other is Position) { |
| - return other.file == file && other.offset == offset; |
| - } |
| - return false; |
| - } |
| - |
| - @override |
| - Map<String, Object> toJson() { |
| - return { |
| - FILE: file, |
| - OFFSET: offset |
| - }; |
| - } |
| - |
| - @override |
| - String toString() => 'Position(file=$file, offset=$offset)'; |
| -} |