OLD | NEW |
---|---|
(Empty) | |
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 | |
3 // BSD-style license that can be found in the LICENSE file. | |
4 | |
5 library analysis_server.utilities.change_builder_core; | |
6 | |
7 import 'package:analysis_server/src/utilities/change_builder_core.dart'; | |
8 import 'package:analysis_server/src/protocol.dart'; | |
9 import 'package:analyzer/src/generated/source.dart'; | |
10 | |
11 /** | |
12 * A builder used to build a [SourceChange]. | |
13 * | |
14 * Clients are not expected to subtype this class. | |
15 */ | |
16 abstract class ChangeBuilder { | |
17 /** | |
18 * Initialize a newly created change builder. | |
19 */ | |
20 factory ChangeBuilder() = ChangeBuilderImpl; | |
21 | |
22 /** | |
23 * Return the source change that was built. | |
24 */ | |
25 SourceChange get sourceChange; | |
26 | |
27 /** | |
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 | |
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. | |
32 */ | |
33 void addFileEdit(Source source, int timeStamp, | |
34 void buildFileEdit(FileEditBuilder builder)); | |
35 } | |
36 | |
37 /** | |
38 * A builder used to build a [SourceEdit] as part of a [SourceFileEdit]. | |
39 * | |
40 * Clients are not expected to subtype this class. | |
41 */ | |
42 abstract class EditBuilder { | |
43 /** | |
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 | |
46 * the region of text and to add suggestions for other possible values for | |
47 * that region. | |
48 */ | |
49 void addLinkedEdit( | |
50 String groupName, void buildLinkedEdit(LinkedEditBuilder builder)); | |
51 | |
52 /** | |
53 * Add the given [string] to the content of the current edit. | |
54 */ | |
55 void write(String string); | |
56 | |
57 /** | |
58 * Add the given [string] to the content of the current edit and then add an | |
59 * end-of-line marker. | |
60 */ | |
61 void writeln([String string]); | |
62 } | |
63 | |
64 /** | |
65 * A builder used to build a [SourceFileEdit] within a [SourceChange]. | |
66 * | |
67 * Clients are not expected to subtype this class. | |
68 */ | |
69 abstract class FileEditBuilder { | |
70 /** | |
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 | |
73 * be inserted. This is fully equivalent to | |
74 * | |
75 * addReplacement(offset, 0, buildEdit); | |
76 */ | |
77 void addInsertion(int offset, void buildEdit(EditBuilder builder)); | |
78 | |
79 /** | |
80 * Add the region of text starting at the given [offset] and continuing for | |
81 * the given [length] to the linked edit group with the given [groupName]. | |
82 * The [offset] is relative to the original source. This is typically used to | |
Paul Berry
2015/05/04 16:00:29
This seems incorrect to me. The implementation of
| |
83 * include pre-existing regions of text in a group. | |
84 */ | |
85 void addLinkedPosition(int offset, int length, String groupName); | |
86 | |
87 /** | |
88 * Add a replacement of text starting at the given [offset] and continuing for | |
89 * the given [length]. The [offset] is relative to the original source. The | |
90 * [buildEdit] function is used to write the text that will replace the | |
91 * specified region. | |
92 */ | |
93 void addReplacement( | |
94 int offset, int length, void buildEdit(EditBuilder builder)); | |
95 } | |
96 | |
97 /** | |
98 * A builder used to build a [LinkedEdit] region within an edit. | |
99 * | |
100 * Clients are not expected to subtype this class. | |
101 */ | |
102 abstract class LinkedEditBuilder { | |
103 /** | |
104 * Add the given [value] as a suggestion with the given [kind]. | |
105 */ | |
106 void addSuggestion(LinkedEditSuggestionKind kind, String value); | |
107 | |
108 /** | |
109 * Add each of the given [values] as a suggestion with the given [kind]. | |
110 */ | |
111 void addSuggestions(LinkedEditSuggestionKind kind, Iterable<String> values); | |
112 | |
113 /** | |
114 * Add the given [string] to the content of the current edit. | |
115 */ | |
116 void write(String string); | |
117 | |
118 /** | |
119 * Add the given [string] to the content of the current edit and then add an | |
120 * end-of-line marker. | |
121 */ | |
122 void writeln([String string]); | |
123 } | |
OLD | NEW |