站内搜索: 请输入搜索关键词
当前页面: 在线文档首页 > NetBeans API Javadoc (Current Development Version)

ExtFormatSupport (Editor Library) - NetBeans API Javadoc (Current Development Version)

org.netbeans.modules.editor.lib/1 1.14.0 3

org.netbeans.editor.ext
Class ExtFormatSupport

java.lang.Object
  extended by org.netbeans.editor.ext.FormatSupport
      extended by org.netbeans.editor.ext.ExtFormatSupport

public class ExtFormatSupport
extends FormatSupport

Extended format-support offers comment-token support, token-and-text operations and other support.


Constructor Summary
ExtFormatSupport(FormatWriter formatWriter)
           
 
Method Summary
 TokenItem findAnyToken(TokenItem startToken, TokenItem limitToken, TokenID[] tokenIDArray, TokenContextPath tokenContextPath, boolean backward)
          Search for any of the image tokens from the given array and return if the token matches any item from the array.
 FormatTokenPosition findImportant(FormatTokenPosition startPosition, FormatTokenPosition limitPosition, boolean stopOnEOL, boolean backward)
          Get the first position that is not whitespace and that is not comment.
 TokenItem findImportantToken(TokenItem startToken, TokenItem limitToken, boolean backward)
          Find the first non-whitespace and non-comment token in the given direction.
 int findLineDistance(FormatTokenPosition fromPosition, FormatTokenPosition toPosition)
          Find how many EOLs is between two token-position.
 FormatTokenPosition findLineEndNonImportant(FormatTokenPosition pos)
          Get the start of the area of line where there is only whitespace or comment till the end of the line.
 FormatTokenPosition findLineFirstImportant(FormatTokenPosition pos)
          Get the first non-whitespace and non-comment token or null.
 TokenItem findMatchingToken(TokenItem startToken, TokenItem limitToken, ImageTokenID matchTokenID, boolean backward)
           
 TokenItem findMatchingToken(TokenItem startToken, TokenItem limitToken, TokenID matchTokenID, String matchTokenImage, boolean backward)
          This method can be used to find a matching brace token.
 TokenItem findToken(TokenItem startToken, TokenItem limitToken, TokenID tokenID, TokenContextPath tokenContextPath, String tokenImage, boolean backward)
          Find the token either by token-id or token-text or both.
 char getChar(FormatTokenPosition pos)
          Get the character at the given position.
 int getIndex(TokenItem token, TokenID[] tokenIDArray)
          Get the index of the token in the given token-id-and-text array or -1 if the token is not in the array.
 TokenItem insertImageToken(TokenItem beforeToken, ImageTokenID tokenID, TokenContextPath tokenContextPath)
          Insert the token that has token-id containing image, so additional text is not necessary.
 boolean isComment(FormatTokenPosition pos)
           
 boolean isComment(TokenItem token, int offset)
          Is the given token a comment token? By default it returns false but it can be redefined in descendants.
 boolean isImportant(FormatTokenPosition pos)
           
 boolean isImportant(TokenItem token, int offset)
          Whether the given position is not a whitespace or comment.
 boolean isLineStart(FormatTokenPosition pos)
          Whether the given position is at the begining of the line.
 boolean isNewLine(FormatTokenPosition pos)
           
 FormatTokenPosition removeLineEndWhitespace(FormatTokenPosition pos)
          Remove the ending whitespace from the line.
 
Methods inherited from class org.netbeans.editor.ext.FormatSupport
canInsertToken, canModifyWhitespace, canRemoveToken, canReplaceToken, chainToString, chainToString, changeLineIndent, expandTabs, findFirstToken, findLineEnd, findLineEndWhitespace, findLineFirstNonWhitespace, findLineStart, findNextEOL, findNonEmptyToken, findNonWhitespace, findPreviousEOL, getFormatStartPosition, getFormatWriter, getIndentShift, getIndentString, getLastPosition, getLastToken, getLineIndent, getNextPosition, getNextPosition, getNextPosition, getNextPosition, getPosition, getPosition, getPreviousPosition, getPreviousPosition, getPreviousPosition, getPreviousPosition, getPreviousToken, getSettingBoolean, getSettingBoolean, getSettingInteger, getSettingInteger, getSettingValue, getSettingValue, getShiftWidth, getSpacesPerTab, getTabSize, getTextStartPosition, getValidWhitespaceTokenContextPath, getValidWhitespaceTokenID, getVisualColumnOffset, getWhitespaceTokenContextPath, getWhitespaceTokenID, insertSpaces, insertString, insertString, insertToken, isAfter, isAfter, isChainStartPosition, isIndentOnly, isLineEmpty, isLineWhite, isRestartFormat, isWhitespace, isWhitespace, remove, remove, removeToken, removeTokenChain, replaceToken, setIndentShift, setRestartFormat, splitEnd, splitStart, tokenEquals, tokenEquals, tokenEquals
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ExtFormatSupport

public ExtFormatSupport(FormatWriter formatWriter)
Method Detail

findLineDistance

public int findLineDistance(FormatTokenPosition fromPosition,
                            FormatTokenPosition toPosition)
Find how many EOLs is between two token-position.

Parameters:
fromPosition - the position from which to start counting. If it's EOL, it's counted.
toPosition - the ending position. If it points at EOL, it's ignored from the total count. It is necessary for the second position to follow the first one.

isComment

public boolean isComment(TokenItem token,
                         int offset)
Is the given token a comment token? By default it returns false but it can be redefined in descendants.


isComment

public boolean isComment(FormatTokenPosition pos)

isImportant

public boolean isImportant(TokenItem token,
                           int offset)
Whether the given position is not a whitespace or comment.


isImportant

public boolean isImportant(FormatTokenPosition pos)

findImportant

public FormatTokenPosition findImportant(FormatTokenPosition startPosition,
                                         FormatTokenPosition limitPosition,
                                         boolean stopOnEOL,
                                         boolean backward)
Get the first position that is not whitespace and that is not comment.

Parameters:
startPosition - position from which the search starts. For the backward search the character right at startPosition is not considered as part of the search.
limitPosition - position where the search will be broken reporting that nothing was found. It can be null to search till the end or begining of the chain (depending on direction).
stopOnEOL - whether stop and return EOL token or continue search if EOL token is found.
backward - whether search in backward direction.
Returns:
first non-whitespace token or EOL or null if all the tokens till the begining of the chain are whitespaces.

findLineFirstImportant

public FormatTokenPosition findLineFirstImportant(FormatTokenPosition pos)
Get the first non-whitespace and non-comment token or null.

Parameters:
pos - any position on the line.

findLineEndNonImportant

public FormatTokenPosition findLineEndNonImportant(FormatTokenPosition pos)
Get the start of the area of line where there is only whitespace or comment till the end of the line.

Parameters:
pos - any position on the line. Return null if there's no such area.

insertImageToken

public TokenItem insertImageToken(TokenItem beforeToken,
                                  ImageTokenID tokenID,
                                  TokenContextPath tokenContextPath)
Insert the token that has token-id containing image, so additional text is not necessary.


findToken

public TokenItem findToken(TokenItem startToken,
                           TokenItem limitToken,
                           TokenID tokenID,
                           TokenContextPath tokenContextPath,
                           String tokenImage,
                           boolean backward)
Find the token either by token-id or token-text or both.

Parameters:
startToken - token from which to start searching. For backward search this token is excluded from the search.
limitToken - the token where the search will be broken reporting that nothing was found. It can be null to search till the end or begining of the chain (depending on direction). For forward search this token is not considered to be part of search, but for backward search it is.
tokenID - token-id to be searched. If null the token-id of the tokens inspected will be ignored.
tokenImage - text of the token to find. If null the text of the tokens inspected will be ignored.
backward - true for searching in backward direction or false to serach in forward direction.
Returns:
return the matching token or null if nothing was found

findImportantToken

public TokenItem findImportantToken(TokenItem startToken,
                                    TokenItem limitToken,
                                    boolean backward)
Find the first non-whitespace and non-comment token in the given direction. This is similair to findImportant() but it operates over the tokens.

Parameters:
startToken - token from which to start searching. For backward search this token is excluded from the search.
limitToken - the token where the search will be broken reporting that nothing was found. It can be null to search till the end or begining of the chain (depending on direction). For forward search this token is not considered to be part of search, but for backward search it is.
backward - true for searching in backward direction or false to serach in forward direction.
Returns:
return the matching token or null if nothing was found

findMatchingToken

public TokenItem findMatchingToken(TokenItem startToken,
                                   TokenItem limitToken,
                                   TokenID matchTokenID,
                                   String matchTokenImage,
                                   boolean backward)
This method can be used to find a matching brace token. Both the token-id and token-text are used for comparison of the starting token.

Parameters:
startToken - token from which to start. It cannot be null. For backward search this token is ignored and the previous one is used.
limitToken - the token where the search will be broken reporting that nothing was found. It can be null to search till the end or begining of the chain (depending on direction). For forward search this token is not considered to be part of search, but for backward search it is.
matchTokenID - matching token-id for the start token.
matchTokenImage - matching token-text for the start token.
backward - true for searching in backward direction or false to serach in forward direction.

findMatchingToken

public TokenItem findMatchingToken(TokenItem startToken,
                                   TokenItem limitToken,
                                   ImageTokenID matchTokenID,
                                   boolean backward)

findAnyToken

public TokenItem findAnyToken(TokenItem startToken,
                              TokenItem limitToken,
                              TokenID[] tokenIDArray,
                              TokenContextPath tokenContextPath,
                              boolean backward)
Search for any of the image tokens from the given array and return if the token matches any item from the array. The index of the item from the array that matched can be found by calling getIndex() method. It is suitable mainly for the image-token-ids.

Parameters:
startToken - token from which to start. For backward search this token is excluded from the search.
limitToken - the token where the search will be broken reporting that nothing was found. It can be null to search till the end or begining of the chain (depending on direction). For forward search this token is not considered to be part of search, but for backward search it is.
tokenIDArray - array of the token-ids for which to search.
tokenContextPath - context path that the found token must have. It can be null.
backward - true for searching in backward direction or false to serach in forward direction.

getIndex

public int getIndex(TokenItem token,
                    TokenID[] tokenIDArray)
Get the index of the token in the given token-id-and-text array or -1 if the token is not in the array.


removeLineEndWhitespace

public FormatTokenPosition removeLineEndWhitespace(FormatTokenPosition pos)
Remove the ending whitespace from the line.

Parameters:
pos - position on the line to be checked.
Returns:
position of the EOL on the line or end of chain position

getChar

public char getChar(FormatTokenPosition pos)
Get the character at the given position. The caller must care about not to pass the end-of-chain position to this method.


isLineStart

public boolean isLineStart(FormatTokenPosition pos)
Whether the given position is at the begining of the line.


isNewLine

public boolean isNewLine(FormatTokenPosition pos)

org.netbeans.modules.editor.lib/1 1.14.0 3

Built on May 28 2007.  |  Portions Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.