Class SyntaxChecker
- java.lang.Object
-
- ca.cgjennings.apps.arkham.plugins.engine.AbstractUtilityParser
-
- ca.cgjennings.apps.arkham.plugins.engine.SyntaxChecker
-
- Direct Known Subclasses:
JavaScriptNavigator
public class SyntaxChecker extends AbstractUtilityParser
Determines the compile-time errors and warnings in a script without executing the script.- Since:
- 3.0
- Author:
- Chris Jennings
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
SyntaxChecker.SyntaxError
Describes a syntax error that has been detected during syntax checking.
-
Constructor Summary
Constructors Constructor Description SyntaxChecker()
Creates a new syntax checker.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected boolean
acceptError(java.lang.String message, boolean warning, int offset, int length)
Subclasses may use this to filter for specific error messages.SyntaxChecker.SyntaxError[]
getErrors()
Returns an array of the errors and warnings generated by the most-recently parsed script.void
parse(java.lang.String script)
Parses the specified script.protected void
processTree(org.mozilla.javascript.ast.AstRoot rootNode)
This is called after each script is parsed to allow the utility access to the resulting abstract syntax tree.-
Methods inherited from class ca.cgjennings.apps.arkham.plugins.engine.AbstractUtilityParser
setErrorReporter
-
-
-
-
Method Detail
-
parse
public void parse(java.lang.String script)
Description copied from class:AbstractUtilityParser
Parses the specified script.- Overrides:
parse
in classAbstractUtilityParser
- Parameters:
script
- the script to process
-
getErrors
public SyntaxChecker.SyntaxError[] getErrors()
Returns an array of the errors and warnings generated by the most-recently parsed script.- Returns:
- a (possibly empty) array of errors
-
acceptError
protected boolean acceptError(java.lang.String message, boolean warning, int offset, int length)
Subclasses may use this to filter for specific error messages.- Parameters:
message
- the error messagewarning
-true
if the message is a warning rather than an erroroffset
- the offset into the scriptlength
- the length of code that is affected- Returns:
true
if the error should be included in the results
-
processTree
protected void processTree(org.mozilla.javascript.ast.AstRoot rootNode)
Description copied from class:AbstractUtilityParser
This is called after each script is parsed to allow the utility access to the resulting abstract syntax tree. In the event of a serious parser error that prevents the tree from being generated, the root node will benull
.- Specified by:
processTree
in classAbstractUtilityParser
- Parameters:
rootNode
- the root of the parse tree
-
-