public class PdePreprocessor extends Object
| Modifier and Type | Class and Description |
|---|---|
static class |
PdePreprocessor.Mode |
| Modifier and Type | Field and Description |
|---|---|
protected String |
indent |
protected static LinkedHashMap<String,Pattern> |
matchPatterns |
protected PdePreprocessor.Mode |
mode |
protected static String |
UNICODE_ESCAPES |
| Constructor and Description |
|---|
PdePreprocessor(String sketchName) |
PdePreprocessor(String sketchName,
int tabSize) |
| Modifier and Type | Method and Description |
|---|---|
void |
addMethod(String methodName) |
void |
debugAST(antlr.collections.AST ast,
boolean includeHidden) |
protected static MatchResult |
findInCurrentScope(Pattern pattern,
CharSequence code)
Calls
findInScope
on the whole string with min and max target scopes set to zero. |
protected static MatchResult |
findInCurrentScope(Pattern pattern,
CharSequence code,
int start)
Calls
findInScope
starting at start char with min and max target scopes set to zero. |
protected static MatchResult |
findInScope(Pattern pattern,
CharSequence code,
int start,
int stop,
int minTargetScopeDepth,
int maxTargetScopeDepth)
Looks for the pattern at a specified target scope depth relative
to the scope depth of the starting position.
|
String[] |
getCoreImports() |
String[] |
getDefaultImports() |
boolean |
hasMethod(String methodName) |
boolean |
ignoreImport(String pkg)
Return true if this import should be removed from the code.
|
SurfaceInfo |
initSketchSize(String code,
boolean sizeWarning) |
protected static String[] |
matchDensityMess(String searchArea) |
protected static String[] |
matchMethod(String methodName,
String searchArea)
Looks for the specified method in the base scope of the search area.
|
static PdePreprocessor.Mode |
parseMode(CharSequence code)
Parses the code and determines the mode of the sketch.
|
static SurfaceInfo |
parseSketchSize(String code,
boolean fussy)
Parse a chunk of code and extract the size() command and its contents.
|
protected static int |
scopeDepthDiff(CharSequence code,
int start,
int stop)
Walks the specified region (not including stop) and determines difference
in scope depth.
|
static String |
scrubComments(String what)
Replace all commented portions of a given String as spaces.
|
void |
setAdvClassName(String advClassName) |
void |
setMode(PdePreprocessor.Mode mode) |
PreprocessorResult |
write(Writer out,
String program) |
PreprocessorResult |
write(Writer out,
String program,
StringList codeFolderPackages) |
protected void |
writeDeclaration(PrintWriter out,
String className)
Write any required header material (eg imports, class decl stuff)
|
protected void |
writeFooter(PrintWriter out,
String className)
Write any necessary closing text.
|
protected int |
writeImportList(PrintWriter out,
List<String> imports) |
protected int |
writeImportList(PrintWriter out,
String[] imports) |
protected int |
writeImports(PrintWriter out,
List<String> programImports,
List<String> codeFolderImports) |
protected void |
writeParseTree(String filename,
antlr.collections.AST ast) |
protected static final String UNICODE_ESCAPES
protected final String indent
protected PdePreprocessor.Mode mode
protected static LinkedHashMap<String,Pattern> matchPatterns
public PdePreprocessor(String sketchName)
public PdePreprocessor(String sketchName, int tabSize)
public SurfaceInfo initSketchSize(String code, boolean sizeWarning) throws SketchException
SketchExceptionpublic static SurfaceInfo parseSketchSize(String code, boolean fussy) throws SketchException
code - The code from the main tab in the sketchfussy - true if it should show an error message if bad size()SketchExceptionpublic static PdePreprocessor.Mode parseMode(CharSequence code)
code - code without commentsprotected static MatchResult findInCurrentScope(Pattern pattern, CharSequence code)
findInScope
on the whole string with min and max target scopes set to zero.protected static MatchResult findInCurrentScope(Pattern pattern, CharSequence code, int start)
findInScope
starting at start char with min and max target scopes set to zero.protected static MatchResult findInScope(Pattern pattern, CharSequence code, int start, int stop, int minTargetScopeDepth, int maxTargetScopeDepth)
pattern - matching is realized by find() method of this patterncode - Java code without commentsstart - starting position in the code String (inclusive)stop - ending position in the code Sting (exclusive)minTargetScopeDepth - desired min scope depth of the match relative to the
scope of the starting positionmaxTargetScopeDepth - desired max scope depth of the match relative to the
scope of the starting positionprotected static int scopeDepthDiff(CharSequence code, int start, int stop)
code - code without commentsstart - start of the region, must not be in string literal,
char literal or second char of escaped sequencestop - end of the region (exclusive)protected static String[] matchMethod(String methodName, String searchArea)
public static String scrubComments(String what)
public void addMethod(String methodName)
public boolean hasMethod(String methodName)
public void setAdvClassName(String advClassName)
public void setMode(PdePreprocessor.Mode mode)
public PreprocessorResult write(Writer out, String program) throws SketchException, antlr.RecognitionException, antlr.TokenStreamException
SketchExceptionantlr.RecognitionExceptionantlr.TokenStreamExceptionpublic PreprocessorResult write(Writer out, String program, StringList codeFolderPackages) throws SketchException, antlr.RecognitionException, antlr.TokenStreamException
SketchExceptionantlr.RecognitionExceptionantlr.TokenStreamExceptionprotected void writeParseTree(String filename, antlr.collections.AST ast)
protected int writeImports(PrintWriter out, List<String> programImports, List<String> codeFolderImports)
out - programImports - codeFolderImports - protected int writeImportList(PrintWriter out, List<String> imports)
protected int writeImportList(PrintWriter out, String[] imports)
protected void writeDeclaration(PrintWriter out, String className)
out - PrintStream to write it to.exporting - Is this being exported from PDE?className - Name of the class being created.protected void writeFooter(PrintWriter out, String className)
out - PrintStream to write it to.public String[] getCoreImports()
public String[] getDefaultImports()
public boolean ignoreImport(String pkg)
pkg - something like processing.xml.XMLElement or processing.xml.*public void debugAST(antlr.collections.AST ast,
boolean includeHidden)
Copyright © 2001–2017 Processing Foundation. All rights reserved.