Skip to content

Commit 879df14

Browse files
committed
Move a part of CodeGenerator.write into a separate reusable method writeToWriter to be able to reuse it later.
Signed-off-by: KOLANICH <[email protected]>
1 parent ffb96b9 commit 879df14

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

tool/src/org/antlr/v4/codegen/CodeGenerator.java

+8-3
Original file line numberDiff line numberDiff line change
@@ -168,13 +168,18 @@ public void writeVocabFile() {
168168
}
169169
}
170170

171+
// Don't inline: used in https://github.com/antlr/antlr4/issues/3874
172+
protected void writeToWriter(ST code, Writer w) throws IOException{
173+
STWriter wr = new AutoIndentWriter(w);
174+
wr.setLineWidth(lineWidth);
175+
code.write(wr);
176+
}
177+
171178
public void write(ST code, String fileName) {
172179
try {
173180
// long start = System.currentTimeMillis();
174181
Writer w = tool.getOutputFileWriter(g, fileName);
175-
STWriter wr = new AutoIndentWriter(w);
176-
wr.setLineWidth(lineWidth);
177-
code.write(wr);
182+
writeToWriter(code, w);
178183
w.close();
179184
// long stop = System.currentTimeMillis();
180185
}

0 commit comments

Comments
 (0)