Skip to content

Commit 0f9ee46

Browse files
committed
refactor: DiffView::naive to produce raw text at last
1 parent c639530 commit 0f9ee46

1 file changed

Lines changed: 7 additions & 8 deletions

File tree

  • src/main/java/org/variantsync/diffdetective/variation/diff/view

src/main/java/org/variantsync/diffdetective/variation/diff/view/DiffView.java

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,12 @@ public static BiPredicate<Time, Projection> computeWhenNodesAreRelevant(final Di
4747
return (t, p) -> V.get(t).contains(p);
4848
}
4949

50-
public static DiffTree naive(final DiffTree d, final Query q, final String[] projectionViewText, final RawText[] text) throws IOException, DiffParseException {
50+
public static DiffTree naive(final DiffTree d, final Query q, final String[] projectionViewText) throws IOException, DiffParseException {
5151
// Logger.info("q = " + q);
52+
final RawText[] text = new RawText[] {
53+
new RawText(projectionViewText[Time.BEFORE.ordinal()].getBytes()),
54+
new RawText(projectionViewText[Time.AFTER.ordinal()].getBytes())
55+
};
5256

5357
// MYERS or HISTOGRAM
5458
final DiffAlgorithm diffAlgorithm = DiffAlgorithm.getAlgorithm(DiffAlgorithm.SupportedAlgorithm.MYERS);
@@ -63,7 +67,6 @@ public static DiffTree naive(final DiffTree d, final Query q, final String[] pro
6367
{
6468
final ByteArrayOutputStream os = new ByteArrayOutputStream();
6569

66-
6770
/*
6871
Using our own formatter without diff headers (paired with a maximum context (?))
6972
caused the formatter to crash due to index out of bounds exceptions.
@@ -114,7 +117,6 @@ Using our own formatter without diff headers (paired with a maximum context (?))
114117

115118
public static DiffTree naive(final DiffTree d, final Query q, final BiPredicate<Time, Projection> inView) throws IOException, DiffParseException {
116119
final String[] projectionViewText = new String[2];
117-
final RawText[] text = new RawText[2];
118120

119121
for (final Time t : Time.values()) {
120122
final int i = t.ordinal();
@@ -132,15 +134,13 @@ public static DiffTree naive(final DiffTree d, final Query q, final BiPredicate<
132134
final StringBuilder b = new StringBuilder();
133135
treeView.root().printSourceCode(b);
134136
projectionViewText[i] = b.toString();
135-
text[i] = new RawText(projectionViewText[i].getBytes());
136137
}
137138

138-
return naive(d, q, projectionViewText, text);
139+
return naive(d, q, projectionViewText);
139140
}
140141

141142
public static DiffTree naive(final DiffTree d, final Query q) throws IOException, DiffParseException {
142143
final String[] projectionViewText = new String[2];
143-
final RawText[] text = new RawText[2];
144144

145145
for (final Time t : Time.values()) {
146146
final int i = t.ordinal();
@@ -156,9 +156,8 @@ public static DiffTree naive(final DiffTree d, final Query q) throws IOException
156156
final StringBuilder b = new StringBuilder();
157157
projection.root().printSourceCode(b);
158158
projectionViewText[i] = b.toString();
159-
text[i] = new RawText(projectionViewText[i].getBytes());
160159
}
161-
return naive(d, q, projectionViewText, text);
160+
return naive(d, q, projectionViewText);
162161
}
163162

164163
public static DiffTree badgood(final DiffTree d, final Query q) {

0 commit comments

Comments
 (0)