Skip to content

Commit 809f4f4

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 2703a85 commit 809f4f4

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

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

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

171+
protected void writeToWriter(ST code, Writer w) throws IOException{
172+
STWriter wr = new AutoIndentWriter(w);
173+
wr.setLineWidth(lineWidth);
174+
code.write(wr);
175+
}
176+
171177
public void write(ST code, String fileName) {
172178
try {
173179
// long start = System.currentTimeMillis();
174180
Writer w = tool.getOutputFileWriter(g, fileName);
175-
STWriter wr = new AutoIndentWriter(w);
176-
wr.setLineWidth(lineWidth);
177-
code.write(wr);
181+
writeToWriter(code, w);
178182
w.close();
179183
// long stop = System.currentTimeMillis();
180184
}

0 commit comments

Comments
 (0)