| OLD | NEW |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 analysis_server.plugin.edit.utilities.change_builder_core; | 5 library analysis_server.plugin.edit.utilities.change_builder_core; |
| 6 | 6 |
| 7 import 'package:analysis_server/plugin/protocol/protocol.dart'; | 7 import 'package:analysis_server/plugin/protocol/protocol.dart'; |
| 8 import 'package:analysis_server/src/utilities/change_builder_core.dart'; | 8 import 'package:analysis_server/src/utilities/change_builder_core.dart'; |
| 9 import 'package:analyzer/src/generated/source.dart'; | 9 import 'package:analyzer/src/generated/source.dart'; |
| 10 | 10 |
| 11 /** | 11 /** |
| 12 * A builder used to build a [SourceChange]. | 12 * A builder used to build a [SourceChange]. |
| 13 * | 13 * |
| 14 * Clients are not expected to subtype this class. | 14 * Clients may not extend, implement or mix-in this class. |
| 15 */ | 15 */ |
| 16 abstract class ChangeBuilder { | 16 abstract class ChangeBuilder { |
| 17 /** | 17 /** |
| 18 * Initialize a newly created change builder. | 18 * Initialize a newly created change builder. |
| 19 */ | 19 */ |
| 20 factory ChangeBuilder() = ChangeBuilderImpl; | 20 factory ChangeBuilder() = ChangeBuilderImpl; |
| 21 | 21 |
| 22 /** | 22 /** |
| 23 * Return the source change that was built. | 23 * Return the source change that was built. |
| 24 */ | 24 */ |
| 25 SourceChange get sourceChange; | 25 SourceChange get sourceChange; |
| 26 | 26 |
| 27 /** | 27 /** |
| 28 * Use the [buildFileEdit] function to create a collection of edits to the | 28 * Use the [buildFileEdit] function to create a collection of edits to the |
| 29 * given [source]. The edits will be added to the source change that is being | 29 * given [source]. The edits will be added to the source change that is being |
| 30 * built. The [timeStamp] is the time at which the [source] was last modified | 30 * built. The [timeStamp] is the time at which the [source] was last modified |
| 31 * and is used by clients to ensure that it is safe to apply the edits. | 31 * and is used by clients to ensure that it is safe to apply the edits. |
| 32 */ | 32 */ |
| 33 void addFileEdit(Source source, int timeStamp, | 33 void addFileEdit(Source source, int timeStamp, |
| 34 void buildFileEdit(FileEditBuilder builder)); | 34 void buildFileEdit(FileEditBuilder builder)); |
| 35 } | 35 } |
| 36 | 36 |
| 37 /** | 37 /** |
| 38 * A builder used to build a [SourceEdit] as part of a [SourceFileEdit]. | 38 * A builder used to build a [SourceEdit] as part of a [SourceFileEdit]. |
| 39 * | 39 * |
| 40 * Clients are not expected to subtype this class. | 40 * Clients may not extend, implement or mix-in this class. |
| 41 */ | 41 */ |
| 42 abstract class EditBuilder { | 42 abstract class EditBuilder { |
| 43 /** | 43 /** |
| 44 * Add a region of text that is part of the linked edit group with the given | 44 * Add a region of text that is part of the linked edit group with the given |
| 45 * [groupName]. The [buildLinkedEdit] function is used to write the content of | 45 * [groupName]. The [buildLinkedEdit] function is used to write the content of |
| 46 * the region of text and to add suggestions for other possible values for | 46 * the region of text and to add suggestions for other possible values for |
| 47 * that region. | 47 * that region. |
| 48 */ | 48 */ |
| 49 void addLinkedEdit( | 49 void addLinkedEdit( |
| 50 String groupName, void buildLinkedEdit(LinkedEditBuilder builder)); | 50 String groupName, void buildLinkedEdit(LinkedEditBuilder builder)); |
| 51 | 51 |
| 52 /** | 52 /** |
| 53 * Add the given [string] to the content of the current edit. | 53 * Add the given [string] to the content of the current edit. |
| 54 */ | 54 */ |
| 55 void write(String string); | 55 void write(String string); |
| 56 | 56 |
| 57 /** | 57 /** |
| 58 * Add the given [string] to the content of the current edit and then add an | 58 * Add the given [string] to the content of the current edit and then add an |
| 59 * end-of-line marker. | 59 * end-of-line marker. |
| 60 */ | 60 */ |
| 61 void writeln([String string]); | 61 void writeln([String string]); |
| 62 } | 62 } |
| 63 | 63 |
| 64 /** | 64 /** |
| 65 * A builder used to build a [SourceFileEdit] within a [SourceChange]. | 65 * A builder used to build a [SourceFileEdit] within a [SourceChange]. |
| 66 * | 66 * |
| 67 * Clients are not expected to subtype this class. | 67 * Clients may not extend, implement or mix-in this class. |
| 68 */ | 68 */ |
| 69 abstract class FileEditBuilder { | 69 abstract class FileEditBuilder { |
| 70 /** | 70 /** |
| 71 * Add an insertion of text at the given [offset]. The [offset] is relative to | 71 * Add an insertion of text at the given [offset]. The [offset] is relative to |
| 72 * the original source. The [buildEdit] function is used to write the text to | 72 * the original source. The [buildEdit] function is used to write the text to |
| 73 * be inserted. This is fully equivalent to | 73 * be inserted. This is fully equivalent to |
| 74 * | 74 * |
| 75 * addReplacement(offset, 0, buildEdit); | 75 * addReplacement(offset, 0, buildEdit); |
| 76 */ | 76 */ |
| 77 void addInsertion(int offset, void buildEdit(EditBuilder builder)); | 77 void addInsertion(int offset, void buildEdit(EditBuilder builder)); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 90 * [buildEdit] function is used to write the text that will replace the | 90 * [buildEdit] function is used to write the text that will replace the |
| 91 * specified region. | 91 * specified region. |
| 92 */ | 92 */ |
| 93 void addReplacement( | 93 void addReplacement( |
| 94 int offset, int length, void buildEdit(EditBuilder builder)); | 94 int offset, int length, void buildEdit(EditBuilder builder)); |
| 95 } | 95 } |
| 96 | 96 |
| 97 /** | 97 /** |
| 98 * A builder used to build a [LinkedEdit] region within an edit. | 98 * A builder used to build a [LinkedEdit] region within an edit. |
| 99 * | 99 * |
| 100 * Clients are not expected to subtype this class. | 100 * Clients may not extend, implement or mix-in this class. |
| 101 */ | 101 */ |
| 102 abstract class LinkedEditBuilder { | 102 abstract class LinkedEditBuilder { |
| 103 /** | 103 /** |
| 104 * Add the given [value] as a suggestion with the given [kind]. | 104 * Add the given [value] as a suggestion with the given [kind]. |
| 105 */ | 105 */ |
| 106 void addSuggestion(LinkedEditSuggestionKind kind, String value); | 106 void addSuggestion(LinkedEditSuggestionKind kind, String value); |
| 107 | 107 |
| 108 /** | 108 /** |
| 109 * Add each of the given [values] as a suggestion with the given [kind]. | 109 * Add each of the given [values] as a suggestion with the given [kind]. |
| 110 */ | 110 */ |
| 111 void addSuggestions(LinkedEditSuggestionKind kind, Iterable<String> values); | 111 void addSuggestions(LinkedEditSuggestionKind kind, Iterable<String> values); |
| 112 | 112 |
| 113 /** | 113 /** |
| 114 * Add the given [string] to the content of the current edit. | 114 * Add the given [string] to the content of the current edit. |
| 115 */ | 115 */ |
| 116 void write(String string); | 116 void write(String string); |
| 117 | 117 |
| 118 /** | 118 /** |
| 119 * Add the given [string] to the content of the current edit and then add an | 119 * Add the given [string] to the content of the current edit and then add an |
| 120 * end-of-line marker. | 120 * end-of-line marker. |
| 121 */ | 121 */ |
| 122 void writeln([String string]); | 122 void writeln([String string]); |
| 123 } | 123 } |
| OLD | NEW |