Refactor within PdePreprocessor to allow for override of edits.

In response to https://github.com/processing/processing4/issues/11, allow client code to override preprocessing edit behabior by providing a subclass of PdeParseTreeListener. This does make the construction for PdePreprocessor.java a little bit messier but a builder may help and moving dependent types within enclosing classes can hopefully keep things coherent.
This commit is contained in:
A Pottinger
2019-10-10 08:36:34 -07:00
parent 54bdd37c88
commit 5faf2a10a6
9 changed files with 232 additions and 120 deletions

View File

@@ -39,7 +39,13 @@ public class ProcessingTestUtil {
throws SketchException {
final String program = read(resource);
final StringWriter out = new StringWriter();
PreprocessorResult result = new PdePreprocessor(name, 4, true).write(out, program);
PdePreprocessor preprocessor = PdePreprocessor.builderFor(name)
.setTabSize(4)
.setIsTesting(true)
.build();
PreprocessorResult result = preprocessor.write(out, program);
if (result.getPreprocessIssues().size() > 0) {
throw new PdePreprocessIssueException(result.getPreprocessIssues().get(0));