Package org.fife.rsta.ac.java
Class JavaParser
- java.lang.Object
-
- org.fife.ui.rsyntaxtextarea.parser.AbstractParser
-
- org.fife.rsta.ac.java.JavaParser
-
- All Implemented Interfaces:
org.fife.ui.rsyntaxtextarea.parser.Parser
public class JavaParser extends org.fife.ui.rsyntaxtextarea.parser.AbstractParserParses Java code in an RSyntaxTextArea.Like all RSTA Parsers, a JavaParser instance is notified when the RSTA's text content changes. After a small delay, it will parse the content as Java code, building an AST and looking for any errors. When parsing is complete, a property change event of type
PROPERTY_COMPILATION_UNITis fired. Listeners can check the new value of the property for theCompilationUnitbuilt that represents the source code in the text area. Note that the CompilationUnit may be incomplete if there were parsing/syntax errors (it will usually be complete "up to" the error in the content).This parser cannot be shared amongst multiple instances of RSyntaxTextArea.
Please keep in mind that this class is a work-in-progress!
- Version:
- 0.5
-
-
Field Summary
Fields Modifier and Type Field Description private CompilationUnitcustatic java.lang.StringPROPERTY_COMPILATION_UNITThe property change event that's fired when the document is re-parsed.private org.fife.ui.rsyntaxtextarea.parser.DefaultParseResultresultprivate java.beans.PropertyChangeSupportsupport
-
Constructor Summary
Constructors Constructor Description JavaParser(org.fife.ui.rsyntaxtextarea.RSyntaxTextArea textArea)Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private voidaddNotices(org.fife.ui.rsyntaxtextarea.RSyntaxDocument doc)Adds all notices from the Java parser to the results object.voidaddPropertyChangeListener(java.lang.String prop, java.beans.PropertyChangeListener l)Adds a listener to this parser.CompilationUnitgetCompilationUnit()Returns the compilation unit from the last time the text area was parsed.intgetOffset(org.fife.ui.rsyntaxtextarea.RSyntaxDocument doc, ParserNotice notice)Returns the offset into the document of a parser notice.org.fife.ui.rsyntaxtextarea.parser.ParseResultparse(org.fife.ui.rsyntaxtextarea.RSyntaxDocument doc, java.lang.String style)voidremovePropertyChangeListener(java.lang.String prop, java.beans.PropertyChangeListener l)Removes a property change listener from this parser.
-
-
-
Field Detail
-
PROPERTY_COMPILATION_UNIT
public static final java.lang.String PROPERTY_COMPILATION_UNIT
The property change event that's fired when the document is re-parsed. Applications can listen for this property change and update themselves accordingly.- See Also:
- Constant Field Values
-
cu
private CompilationUnit cu
-
support
private java.beans.PropertyChangeSupport support
-
result
private org.fife.ui.rsyntaxtextarea.parser.DefaultParseResult result
-
-
Method Detail
-
addNotices
private void addNotices(org.fife.ui.rsyntaxtextarea.RSyntaxDocument doc)
Adds all notices from the Java parser to the results object.
-
addPropertyChangeListener
public void addPropertyChangeListener(java.lang.String prop, java.beans.PropertyChangeListener l)Adds a listener to this parser.- Parameters:
prop- The property to listen for changes to.l- The listener to add.- See Also:
removePropertyChangeListener(String, PropertyChangeListener)
-
getCompilationUnit
public CompilationUnit getCompilationUnit()
Returns the compilation unit from the last time the text area was parsed.- Returns:
- The compilation unit, or
nullif it hasn't yet been parsed or an unexpected error occurred while parsing.
-
getOffset
public int getOffset(org.fife.ui.rsyntaxtextarea.RSyntaxDocument doc, ParserNotice notice)Returns the offset into the document of a parser notice.- Parameters:
doc- The document.notice- The parser notice.- Returns:
- The offset, or
-1if it is invalid.
-
parse
public org.fife.ui.rsyntaxtextarea.parser.ParseResult parse(org.fife.ui.rsyntaxtextarea.RSyntaxDocument doc, java.lang.String style)
-
removePropertyChangeListener
public void removePropertyChangeListener(java.lang.String prop, java.beans.PropertyChangeListener l)Removes a property change listener from this parser.- Parameters:
prop- The property being listened to.l- The listener to remove.- See Also:
addPropertyChangeListener(String, PropertyChangeListener)
-
-