com.ibm.lpex.java
Class JavaParser
java.lang.Object
com.ibm.lpex.core.LpexCommonParser
com.ibm.lpex.java.JavaParser
- All Implemented Interfaces:
- LpexConstants, LpexParser
- Direct Known Subclasses:
- JavaSqlParser
- public class JavaParser
- extends LpexCommonParser
Document parser for Java.
Actions and assigned keys added by this document parser:
- comment (Ctrl+/) - to comment the visible selected elements
- doc - to generate a class/method javadoc comment-block template
- errors - for a selective view of the errors in the document
- javaAmp (Ctrl+&) - to insert an ampersand
character entity reference (&) in javadoc comments.
Note: on most keyboards, also press the Shift key
- javaAt (Ctrl+@) - to insert an at-condition
character (@) in javadoc comments.
Note: on most keyboards, also press the Shift key
- javaB (Ctrl+B) - to set the bold text style to the
currently selected text in javadoc comments.
This action uses HtmlParser.tagSelection(com.ibm.lpex.core.LpexView, java.lang.String)
- javaGt (Ctrl+>) - to insert a greater-than sign
character entity reference (>) in javadoc comments.
Note: on most keyboards, also press the Shift key
- javaLt (Ctrl+<) - to insert a less-than sign
character entity reference (<) in javadoc comments.
Note: on most keyboards, also press the Shift key
- methods (Ctrl+G) - for a selective view of the methods
in the document
- outline - for a logical-outline view of the document
- trace - to insert tracing statements for a method
- uncomment (Ctrl+\) - to uncomment the visible selected elements.
Keys already defined (e.g., by the active base profile) to an action
different from nullAction are not redefined in here.
Actions modified by this document parser:
- split - for handling javadoc comment-blocks editing
- join - for handling javadoc comment-blocks editing
- delete - for handling javadoc comment-blocks editing
- contextHome - to skip comment-defining characters when determining
the start of the text.
Actions redefined by LpexCommonParser and further modified by this
document parser:
- openLine - for handling javadoc comment-block editing
- splitLine - for handling javadoc comment-block editing.
Template expansion (proto action, Ctrl+R) for an empty document and
for the following keywords is provided in this parser's profile:
- case
- do
- doc
- /**
- err
- for
- if
- iter
- main
- out
- switch
- try
- while
- LpexAction
- LpexCommand.
Fields inherited from class com.ibm.lpex.core.LpexCommonParser |
ATTRIBUTES_COMMENT, ATTRIBUTES_COMMENT_KEYWORD, ATTRIBUTES_COMMENT1, ATTRIBUTES_DEFAULT, ATTRIBUTES_DIRECTIVE, ATTRIBUTES_ERROR, ATTRIBUTES_KEYWORD, ATTRIBUTES_KEYWORD1, ATTRIBUTES_LIBRARY, ATTRIBUTES_NONSOURCE, ATTRIBUTES_NUMERAL, ATTRIBUTES_STRING, ATTRIBUTES_STRING1, BACKGROUND_COLOR, CLASS_MESSAGE, LANGUAGE_CCPP, LANGUAGE_CICS, LANGUAGE_CL, LANGUAGE_COBOL, LANGUAGE_DDS, LANGUAGE_FORTRAN, LANGUAGE_HLASM, LANGUAGE_HTML, LANGUAGE_JAVA, LANGUAGE_JCL, LANGUAGE_LISP, LANGUAGE_PERL, LANGUAGE_PLI, LANGUAGE_REXX, LANGUAGE_RPG, LANGUAGE_SABRETALK, LANGUAGE_SQL, LANGUAGE_XMI, LANGUAGE_XML, LANGUAGE_XSL, LEXER_RC_END, LEXER_RC_EOF, LEXER_RC_MORE, LEXER_RC_OK, POPUP_END, POPUP_FILTERVIEW, POPUP_SOURCE, POPUP_TOP, PROTOKEY_EMPTY, STYLE_MESSAGE, STYLE_NAME, view
|
Fields inherited from interface com.ibm.lpex.core.LpexConstants |
HELP_COMMAND_MAP, LPEX_VERSION, MSG_POPUP_ERRORS, MSG_POPUP_EXCLUDESELECTION, MSG_POPUP_FILTERVIEWMENU, MSG_POPUP_INSERTMENU, MSG_POPUP_SELECTEDMENU, MSG_POPUP_SHOWALL, MSG_POPUP_SOURCEMENU, PARSE_PENDING_CHANGE_MASK, PARSE_PENDING_NEXT_DELETED_MASK, PARSE_PENDING_NEXT_SHOW_DELETED_MASK, PARSE_PENDING_PREV_DELETED_MASK, PARSE_PENDING_PREV_SHOW_DELETED_MASK, PLATFORM_AWT, PLATFORM_SWT, PLATFORM_SWT_KEY, STATUS_FILE_ERRORREADING, STATUS_FILE_INCORRECTENCODING, STATUS_FILE_NOTFOUND, STATUS_FINDTEXT_INVALIDPATTERN, STATUS_FINDTEXT_NOTFOUND, STATUS_FINDTEXT_ONLYOCCURRENCE, STATUS_FINDTEXT_READONLY, STATUS_FINDTEXT_WRAPPED, STATUS_LOCATE_NOSEQUENCETEXT, STATUS_LOCATE_NOTFOUND, STATUS_LOCATE_WRAPPED, STATUS_SAVE_CANCELLED, STATUS_SAVE_FAILED, STATUS_TEXTLIMIT_ENFORCED
|
Method Summary |
protected void
| addErrorMessage(int element,
String message)
Display an embedded error message for an element.
|
protected void
| delete()
Flow text inside a comment block during a delete which joins lines.
|
protected void
| document(LpexDocumentLocation cursor)
Documents a class / interface / method - add a detailed javadoc comment
block.
|
protected void
| expandProtoKeyword(int s,
int e,
String p)
Subclassed in order to effectively run the doc action when the
prototype keyword to expand is "/**".
|
String
| getCommentStyleCharacters()
Return the style characters used for styling comments ("cCt").
|
String
| getLanguage()
Returns "Java", the language supported by this parser.
|
String
| getLanguage(LpexDocumentLocation loc)
Retrieve a string identifying the language segment at the specified
location.
|
protected String
| getPopupItems(int popupLocation)
Retrieve parser's contribution to the popup.
|
ResourceBundle
| getProfile()
Returns this parser's profile resource bundle.
|
String
| getProperty(String key)
Expand LpexCommonParser's getProperty() to substitute arguments for
key PROTOKEY_EMPTY.
|
protected SqlLexer
| getSqlLexer(LpexCharStream sqlLexerStream)
Retrieve the SqlLexer.
|
boolean
| isTokenDelimiter(char ch)
Returns true if the specified character is a token delimiter.
|
protected void
| join()
Flow text inside a comment block during a join.
|
protected void
| methods()
Filter view to the methods in the source code.
|
protected void
| openLine()
Continue comment for a line opened inside a comment block.
|
protected void
| outline()
Filter view to a logical outline of the source code.
|
void
| parseAll()
Total parse of the entire document.
|
void
| parseElement(int element)
Incremental parse.
|
protected boolean
| setLexer(int newLexer)
Set/switch the active lexer.
|
protected void
| setStyleAttributes()
Define parser's style attributes.
|
protected void
| split()
Continue comment for a line split inside a comment block.
|
protected void
| splitLine()
Continue comment for a line split inside a comment block.
|
protected void
| trace(LpexDocumentLocation cursor)
Insert trace call(s) for a method.
|
Methods inherited from class com.ibm.lpex.core.LpexCommonParser |
addMessage, addMessage, addMessage, blockMarkWord, cursorIndent, getInstallStyleAttributes, getLshToken, getPopupParserItems, getPopupViewItems, getStyleName, getStyles, getTextIndent, getToken, getTokenLocation, indentText, indentText, indentText, isDebuggable, lineComment, lpexView, matchToken, newLine, parse, removeMessages, removeMessages, resetParser, setProperty, setStyle, styleString, terminateParser, tokenBegin, tokenEnd, totalParse
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
|
JavaParser
public JavaParser(LpexView lpexView)
- Constructor for the parser.
Adds all of the parser specifics to the LPEX document view.
Initializes the view for the parser: sets up all the style
attributes, classes, etc. for the language-sensitive edit features
supported.
- Parameters:
- lpexView - the document view associated with this parser
parseAll
public void parseAll()
- Total parse of the entire document.
Done initially, after a document has been loaded in the editor,
and after an updateProfile command.
- Specified by:
- parseAll in class LpexCommonParser
- See Also:
- Total and incremental parse
parseElement
public void parseElement(int element)
- Incremental parse.
- Specified by:
- parseElement in class LpexCommonParser
- Parameters:
- element - the (first) element whose committed change triggered the
parse, or the element that precedes/follows a deleted block.
The parser may identify other neighbouring elements that
will have to be reparsed as a unit
- See Also:
- LpexView.parsePending(int),
LpexView.elementParsed(int),
Total and incremental parse
getProfile
public ResourceBundle getProfile()
- Returns this parser's profile resource bundle.
- Overrides:
- getProfile in class LpexCommonParser
- See Also:
- LpexCommonParser.getProperty(java.lang.String),
Parser properties
getLanguage
public String getLanguage()
- Returns "Java", the language supported by this parser.
- Overrides:
- getLanguage in class LpexCommonParser
- See Also:
- LpexCommonParser.LANGUAGE_JAVA
getLanguage
public String getLanguage(LpexDocumentLocation loc)
- Retrieve a string identifying the language segment at the specified
location. In mixed-content documents, this may differ from the main
language of the document.
The method assumes that no parse is pending for the location element.
- Overrides:
- getLanguage in class LpexCommonParser
- Returns:
- one of: LpexCommonParser.LANGUAGE_JAVA,
LpexCommonParser.LANGUAGE_SQL
- See Also:
- LpexCommonParser.getLanguage()
getPopupItems
protected String getPopupItems(int popupLocation)
- Retrieve parser's contribution to the popup.
This parser contributes to the "Filter view" submenu (Methods,
Logic outline, Errors) and to the "Source" submenu (Comment, Uncomment,
Document, Trace).
- Overrides:
- getPopupItems in class LpexCommonParser
- Parameters:
- popupLocation - the location on the popup menu of the items
requested, one of:
LpexCommonParser.POPUP_TOP, LpexCommonParser.POPUP_FILTERVIEW,
LpexCommonParser.POPUP_SOURCE, LpexCommonParser.POPUP_END
- Returns:
- this parser's contribution to the popup menu, or
null if none
setStyleAttributes
protected void setStyleAttributes()
- Define parser's style attributes.
The following style characters are set:
'_' (layout blanks),
'k' (keyword),
'i' (identifier),
'n' (constant),
'q' (string literal),
'o' (operator),
'p' (punctuation),
'c' (comment),
'C' (javadoc comment),
't' (javadoc comment tag),
'b' (brace),
'u' (Unicode sequence),
'e' (error).
getCommentStyleCharacters
public String getCommentStyleCharacters()
- Return the style characters used for styling comments ("cCt").
This method is used by compare sessions when the
compare.ignoreComments option is in effect.
- Overrides:
- getCommentStyleCharacters in class LpexCommonParser
openLine
protected void openLine()
- Continue comment for a line opened inside a comment block.
- Overrides:
- openLine in class LpexCommonParser
splitLine
protected void splitLine()
- Continue comment for a line split inside a comment block.
- Overrides:
- splitLine in class LpexCommonParser
- See Also:
- LpexCommonParser.getTextIndent(int)
split
protected void split()
- Continue comment for a line split inside a comment block.
join
protected void join()
- Flow text inside a comment block during a join.
delete
protected void delete()
- Flow text inside a comment block during a delete which joins lines.
isTokenDelimiter
public boolean isTokenDelimiter(char ch)
- Returns true if the specified character is a token delimiter.
- Overrides:
- isTokenDelimiter in class LpexCommonParser
- See Also:
- LpexCommonParser.getToken(com.ibm.lpex.core.LpexDocumentLocation)
getProperty
public String getProperty(String key)
- Expand LpexCommonParser's getProperty() to substitute arguments for
key PROTOKEY_EMPTY. Argument {0} is the package name, {1} is the class
name. The substitutions are based on the name parameter of the
document.
- Specified by:
- getProperty in interface LpexParser
- Overrides:
- getProperty in class LpexCommonParser
- Parameters:
- key - property name, for example, "proto.doc" for this parser's expansion
of the keyword "doc" by the proto action, or
"view.proto.doc" for this property as defined in the current view's
instance of the parser
- See Also:
- LpexCommonParser.getLanguage(),
LpexCommonParser.getProfile()
addErrorMessage
protected void addErrorMessage(int element,
String message)
- Display an embedded error message for an element.
- Parameters:
- element - the element in error
- message - error message key in LPEX's Resources.properties
methods
protected void methods()
- Filter view to the methods in the source code.
outline
protected void outline()
- Filter view to a logical outline of the source code.
expandProtoKeyword
protected void expandProtoKeyword(int s,
int e,
String p)
- Subclassed in order to effectively run the doc action when the
prototype keyword to expand is "/**".
- Overrides:
- expandProtoKeyword in class LpexCommonParser
- Parameters:
- s - ZERO-based keyword start offset in the current element
- e - ZERO-based keyword end offset in the current element
- p - the prototype expansion string
- See Also:
- document(LpexDocumentLocation)
document
protected void document(LpexDocumentLocation cursor)
- Documents a class / interface / method - add a detailed javadoc comment
block. Assumes that the class / interface / method we try to document
starts on a new line, and any type / qualifier and its id are on the same
line.
- Parameters:
- cursor - document location in the scope of the class / interface /
method to document
trace
protected void trace(LpexDocumentLocation cursor)
- Insert trace call(s) for a method.
- Parameters:
- cursor - document location in the scope of the method to document
setLexer
protected boolean setLexer(int newLexer)
- Set/switch the active lexer.
- Parameters:
- newLexer - the new lexer, one of: LEXER_JAVA, LEXER_SQL
- Returns:
- true = new lexer has been set as the active lexer,
and initialized in its DEFAULT lexical state
getSqlLexer
protected SqlLexer getSqlLexer(LpexCharStream sqlLexerStream)
- Retrieve the SqlLexer.
The document parser extending JavaParser to support embedded SQL
statements must override this method to construct and return an SqlLexer
object.
The implementation of this method provided by the JavaParser class does
nothing, except return null.
- Parameters:
- sqlLexerStream - input character stream for the SQL lexer