Package processing.mode.java.preproc
Class PdePreprocessor
java.lang.Object
processing.mode.java.preproc.PdePreprocessor
Utility to preprocess sketches prior to compilation.
This preprocessor assists with
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumThe mode that the sketch uses to run.static interfaceFactory which creates parse tree traversal listeners.static classBuilder to help instantiate a PdePreprocessor. -
Constructor Summary
ConstructorsConstructorDescriptionPdePreprocessor(String newSketchName, int newTabSize, boolean newIsTesting, PdePreprocessor.ParseTreeListenerFactory newFactory, List<String> newDefaultImports, List<String> newCoreImports, Optional<String> newDestinationPackage) Create a new preprocessor. -
Method Summary
Modifier and TypeMethodDescriptionbuilderFor(String sketchName) Create a new PdePreprocessorBuilder for a sketch of the given name.Get the more or processing-required imports that this preprocessor is using.Get convenience imports provided on the user's behalf.booleanhasMain()Determine if the main method was found during preprocessing.Create the preprocessed sketch code without any code folder packages.Create the preprocessed sketch code.
-
Constructor Details
-
PdePreprocessor
public PdePreprocessor(String newSketchName, int newTabSize, boolean newIsTesting, PdePreprocessor.ParseTreeListenerFactory newFactory, List<String> newDefaultImports, List<String> newCoreImports, Optional<String> newDestinationPackage) Create a new preprocessor. Create a new preprocessor that will use the following set of configuration values to process a parse tree. This object can be instantiated by calling {builderFor}.- Parameters:
newSketchName- The name of the sketch.newTabSize- The number of spaces within a tab.newIsTesting- Flag indicating if this is running in unit tests (true) or in production (false).newFactory- The factory to use for building the ANTLR tree traversal listener where preprocessing edits should be made.newDefaultImports- Imports provided for user convenience.newCoreImports- Imports required for core or processing itself.
-
-
Method Details
-
builderFor
Create a new PdePreprocessorBuilder for a sketch of the given name. Create a new builder to help instantiate a preprocessor for a sketch of the given name. Use this builder to configure settings of the preprocessor before building.- Parameters:
sketchName- The name of the sketch for which a preprocessor will be built.- Returns:
- Builder to create a preprocessor for the sketch of the given name.
-
write
Create the preprocessed sketch code without any code folder packages.- Parameters:
out- The writer into which the preprocessed code should be written. This is preferred over returning the full string result as this string may be large.program- The sketch ("PDE") code.- Returns:
- Information about the preprocessing operation.
- Throws:
processing.utils.SketchException
-
write
public PreprocessorResult write(Writer outWriter, String inProgram, Iterable<String> codeFolderPackages) throws processing.utils.SketchException Create the preprocessed sketch code.- Parameters:
outWriter- The writer into which the preprocessed code should be written. This is preferred over returning the full string result as this string may be large.inProgram- The sketch ("PDE") code.codeFolderPackages- The packages included by default for the user by virtue of those packages being in the code folder.- Returns:
- Information about the preprocessing operation.
- Throws:
processing.utils.SketchException
-
hasMain
public boolean hasMain()Determine if the main method was found during preprocessing.- Returns:
- True if a main method was found. False otherwise.
-
getCoreImports
Get the more or processing-required imports that this preprocessor is using.- Returns:
- List of imports required by processing or this mode.
-
getDefaultImports
Get convenience imports provided on the user's behalf.- Returns:
- Imports included by default but not required by processing or the mode.
-