Skip to content

Commit c48ee99

Browse files
committed
Remove some dead code
------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=170079734
1 parent 6383c39 commit c48ee99

File tree

2 files changed

+2
-59
lines changed

2 files changed

+2
-59
lines changed

core/src/main/java/com/google/googlejavaformat/InputOutput.java

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -53,15 +53,9 @@ public final String getLine(int lineI) {
5353
return lines.get(lineI);
5454
}
5555

56-
/** The {@link Range}s of the tokens or comments beginning on each line. */
57-
protected final List<Range<Integer>> range0s = new ArrayList<>();
58-
5956
/** The {@link Range}s of the tokens or comments lying on each line, in any part. */
6057
protected final List<Range<Integer>> ranges = new ArrayList<>();
6158

62-
/** The {@link Range}s of the tokens or comments ending on each line. */
63-
protected final List<Range<Integer>> range1s = new ArrayList<>();
64-
6559
private static void addToRanges(List<Range<Integer>> ranges, int i, int k) {
6660
while (ranges.size() <= i) {
6761
ranges.add(EMPTY_RANGE);
@@ -78,11 +72,9 @@ protected final void computeRanges(List<? extends Input.Tok> toks) {
7872
lineI += Newlines.count(txt);
7973
int k = tok.getIndex();
8074
if (k >= 0) {
81-
addToRanges(range0s, lineI0, k);
8275
for (int i = lineI0; i <= lineI; i++) {
8376
addToRanges(ranges, i, k);
8477
}
85-
addToRanges(range1s, lineI0, k);
8678
}
8779
}
8880
}
@@ -111,16 +103,6 @@ public static Map<Integer, Range<Integer>> makeKToIJ(InputOutput put, int kN) {
111103
return map;
112104
}
113105

114-
/**
115-
* Get the {@link Range} of {@link Input.Tok}s beginning on a line.
116-
*
117-
* @param lineI the line number
118-
* @return the {@link Range} of {@link Input.Tok}s beginning on the specified line
119-
*/
120-
public final Range<Integer> getRange0s(int lineI) {
121-
return 0 <= lineI && lineI < range0s.size() ? range0s.get(lineI) : EMPTY_RANGE;
122-
}
123-
124106
/**
125107
* Get the {@link Range} of {@link Input.Tok}s lying in any part on a line.
126108
*
@@ -131,27 +113,13 @@ public final Range<Integer> getRanges(int lineI) {
131113
return 0 <= lineI && lineI < ranges.size() ? ranges.get(lineI) : EMPTY_RANGE;
132114
}
133115

134-
/**
135-
* Get the {@link Range} of {@link Input.Tok}s ending on a line.
136-
*
137-
* @param lineI the line number
138-
* @return the {@link Range} of {@link Input.Tok}s ending on the specified line
139-
*/
140-
public final Range<Integer> getRange1s(int lineI) {
141-
return 0 <= lineI && lineI < range1s.size() ? range1s.get(lineI) : EMPTY_RANGE;
142-
}
143-
144116
@Override
145117
public String toString() {
146118
return "InputOutput{"
147119
+ "lines="
148120
+ lines
149-
+ ", range0s="
150-
+ range0s
151121
+ ", ranges="
152122
+ ranges
153-
+ ", range1s="
154-
+ range1s
155123
+ '}';
156124
}
157125
}

core/src/main/java/com/google/googlejavaformat/java/JavaOutput.java

Lines changed: 2 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,8 @@ public void append(String text, Range<Integer> range) {
9898
// Skip over input line we've passed.
9999
int iN = javaInput.getLineCount();
100100
while (iLine < iN
101-
&& (javaInput.getRange1s(iLine).isEmpty()
102-
|| javaInput.getRange1s(iLine).upperEndpoint() <= range.lowerEndpoint())) {
101+
&& (javaInput.getRanges(iLine).isEmpty()
102+
|| javaInput.getRanges(iLine).upperEndpoint() <= range.lowerEndpoint())) {
103103
if (javaInput.getRanges(iLine).isEmpty()) {
104104
// Skipped over a blank line.
105105
sawNewlines = true;
@@ -125,7 +125,6 @@ public void append(String text, Range<Integer> range) {
125125
}
126126
spacesPending = 0;
127127
} else {
128-
boolean range0sSet = false;
129128
boolean rangesSet = false;
130129
int textN = text.length();
131130
for (int i = 0; i < textN; i++) {
@@ -159,15 +158,6 @@ public void append(String text, Range<Integer> range) {
159158
}
160159
lineBuilder.append(c);
161160
if (!range.isEmpty()) {
162-
if (!range0sSet) {
163-
if (!range.isEmpty()) {
164-
while (range0s.size() <= mutableLines.size()) {
165-
range0s.add(Formatter.EMPTY_RANGE);
166-
}
167-
range0s.set(mutableLines.size(), union(range0s.get(mutableLines.size()), range));
168-
range0sSet = true;
169-
}
170-
}
171161
if (!rangesSet) {
172162
while (ranges.size() <= mutableLines.size()) {
173163
ranges.add(Formatter.EMPTY_RANGE);
@@ -178,13 +168,6 @@ public void append(String text, Range<Integer> range) {
178168
}
179169
}
180170
}
181-
// TODO(jdd): Move others down here. Use common method for these.
182-
if (!range.isEmpty()) {
183-
while (range1s.size() <= mutableLines.size()) {
184-
range1s.add(Formatter.EMPTY_RANGE);
185-
}
186-
range1s.set(mutableLines.size(), union(range1s.get(mutableLines.size()), range));
187-
}
188171
}
189172
if (!range.isEmpty()) {
190173
lastK = range.upperEndpoint();
@@ -204,18 +187,10 @@ void flush() {
204187
}
205188
int jN = mutableLines.size();
206189
Range<Integer> eofRange = Range.closedOpen(kN, kN + 1);
207-
while (range0s.size() < jN) {
208-
range0s.add(Formatter.EMPTY_RANGE);
209-
}
210-
range0s.add(eofRange);
211190
while (ranges.size() < jN) {
212191
ranges.add(Formatter.EMPTY_RANGE);
213192
}
214193
ranges.add(eofRange);
215-
while (range1s.size() < jN) {
216-
range1s.add(Formatter.EMPTY_RANGE);
217-
}
218-
range1s.add(eofRange);
219194
setLines(ImmutableList.copyOf(mutableLines));
220195
}
221196

0 commit comments

Comments
 (0)