public class JavaScriptParser
extends AbstractParser
RSyntaxTextArea.
Like all RSTA Parsers, a JavaScriptParser instance is
notified when the RSTA's text content changes. After a small delay, it will
parse the content as JS code, building an AST and looking for any errors.
When parsing is complete, a property change event of type
PROPERTY_AST is fired. Listeners can check the new value of the
property for the AstRoot built that represents the source code
in the text area.
This parser cannot be shared amongst multiple instances of
RSyntaxTextArea.
Please keep in mind that this class is a work-in-progress!
| Modifier and Type | Class and Description |
|---|---|
static class |
JavaScriptParser.JSErrorReporter
Error reporter for Rhino-based parsing.
|
| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
PROPERTY_AST
The property change event that's fired when the document is re-parsed.
|
| Constructor and Description |
|---|
JavaScriptParser(JavaScriptLanguageSupport langSupport,
RSyntaxTextArea textArea)
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addPropertyChangeListener(java.lang.String prop,
java.beans.PropertyChangeListener l)
Registers a property change listener on this parser.
|
static org.mozilla.javascript.CompilerEnvirons |
createCompilerEnvironment(org.mozilla.javascript.ErrorReporter errorHandler,
JavaScriptLanguageSupport langSupport)
Creates options for Rhino based off of the user's preferences.
|
org.mozilla.javascript.ast.AstRoot |
getAstRoot()
Returns the AST, or
null if the editor's content has not
yet been parsed. |
int |
getJsHintIndent() |
java.io.File |
getJsHintRCFile(RSyntaxTextArea textArea)
Returns the location of the
.jshintrc file to use if using
JsHint as your error parser. |
VariableResolver |
getVariablesAndFunctions() |
ParseResult |
parse(RSyntaxDocument doc,
java.lang.String style) |
void |
removePropertyChangeListener(java.lang.String prop,
java.beans.PropertyChangeListener l)
Removes a property change listener from this parser.
|
void |
setVariablesAndFunctions(VariableResolver variableResolver) |
public static final java.lang.String PROPERTY_AST
org.mozilla.javascript.ast.AstRoot.public JavaScriptParser(JavaScriptLanguageSupport langSupport, RSyntaxTextArea textArea)
public void addPropertyChangeListener(java.lang.String prop,
java.beans.PropertyChangeListener l)
PROPERTY_AST.prop - The property to listen for changes in.l - The listener to add.removePropertyChangeListener(String, PropertyChangeListener)public static org.mozilla.javascript.CompilerEnvirons createCompilerEnvironment(org.mozilla.javascript.ErrorReporter errorHandler,
JavaScriptLanguageSupport langSupport)
errorHandler - The container for errors found while parsing.public org.mozilla.javascript.ast.AstRoot getAstRoot()
null if the editor's content has not
yet been parsed.null.public int getJsHintIndent()
public java.io.File getJsHintRCFile(RSyntaxTextArea textArea)
.jshintrc file to use if using
JsHint as your error parser. This property is ignored if
#getErrorParser() does not return JsErrorParser.JSHINT.textArea - The text component..jshintrc file, or null if none;
in that case, the JsHint defaults will be used.#setJsHintRCFile(File),
#setErrorParser(JsErrorParser)public ParseResult parse(RSyntaxDocument doc,
java.lang.String style)
public void setVariablesAndFunctions(VariableResolver variableResolver)
public VariableResolver getVariablesAndFunctions()
public void removePropertyChangeListener(java.lang.String prop,
java.beans.PropertyChangeListener l)
prop - The property that was being listened to.l - The listener to remove.addPropertyChangeListener(String, PropertyChangeListener)