-
-
Notifications
You must be signed in to change notification settings - Fork 183
Expand file tree
/
Copy pathRewriteResultBuilder.java
More file actions
67 lines (57 loc) · 1.26 KB
/
Copy pathRewriteResultBuilder.java
File metadata and controls
67 lines (57 loc) · 1.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
package processing.mode.java.preproc;
import java.util.ArrayList;
import java.util.List;
/**
* Builder to help create a {RewriteResult}.
*/
public class RewriteResultBuilder {
private int lineOffset;
private List<TextTransform.Edit> edits;
/**
* Create a new rewrite result builder.
*/
public RewriteResultBuilder() {
lineOffset = 0;
edits = new ArrayList<>();
}
/**
* Indicate that lines were added to the sketch.
*
* @param offset By how much to change the current offset.
*/
public void addOffset(int offset) {
lineOffset += offset;
}
/**
* Record an edit made during rewrite.
*
* @param edit The edit made.
*/
public void addEdit(TextTransform.Edit edit) {
edits.add(edit);
}
/**
* Get the number of lines written.
*
* @return The offset to add to current preprocessor offset.
*/
public int getLineOffset() {
return lineOffset;
}
/**
* Get the edits generated during rewrite.
*
* @return The edits generated during rewrite.
*/
public List<TextTransform.Edit> getEdits() {
return edits;
}
/**
* Build a new rewrite result.
*
* @return Immutable rewrite result.
*/
public RewriteResult build() {
return new RewriteResult(lineOffset, edits);
}
}