|
org.netbeans.modules.editor.lib/1 1.14.0 3 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.netbeans.editor.ext.FormatSupport
public class FormatSupport
Format support presents a set of operations over the format-writer that is specific for the given set of formatting layers. It presents the way how to extend the low level methods offered by the format-writer. In general there can be more format-layers that use one type of the format-support.
Constructor Summary | |
---|---|
FormatSupport(FormatWriter formatWriter)
|
Method Summary | |
---|---|
boolean |
canInsertToken(TokenItem beforeToken)
Delegation to the same method in format-writer. |
boolean |
canModifyWhitespace(TokenItem inToken)
Check whether the given token enables modifying of a whitespace in it. |
boolean |
canRemoveToken(TokenItem token)
Whether the token-item can be removed. |
boolean |
canReplaceToken(TokenItem token)
Whether the given token can be replaced or not. |
String |
chainToString(TokenItem token)
Debug the current state of the chain. |
String |
chainToString(TokenItem token,
int maxDocumentTokens)
|
FormatTokenPosition |
changeLineIndent(FormatTokenPosition pos,
int indent)
Change the indentation of the line. |
boolean |
expandTabs()
|
TokenItem |
findFirstToken(TokenItem token)
Get the first token in chain. |
FormatTokenPosition |
findLineEnd(FormatTokenPosition pos)
Get the ending position of the line. |
FormatTokenPosition |
findLineEndWhitespace(FormatTokenPosition pos)
Return the ending whitespace on the line or null if there's no such token on the given line. |
FormatTokenPosition |
findLineFirstNonWhitespace(FormatTokenPosition pos)
Return the first non-whitespace character on the line or null if there is no non-WS char on the line. |
FormatTokenPosition |
findLineStart(FormatTokenPosition pos)
Get the starting position of the line. |
FormatTokenPosition |
findNextEOL(FormatTokenPosition pos)
Get the first EOL in forward direction. |
TokenItem |
findNonEmptyToken(TokenItem token,
boolean backward)
Check whether the given token has empty text and if so start searching for token with non-empty text in the given direction. |
FormatTokenPosition |
findNonWhitespace(FormatTokenPosition startPosition,
FormatTokenPosition limitPosition,
boolean stopOnEOL,
boolean backward)
Get the first non-whitespace position in the given direction. |
FormatTokenPosition |
findPreviousEOL(FormatTokenPosition pos)
Get the first EOL in backward direction. |
FormatTokenPosition |
getFormatStartPosition()
Delegation to the same method in format-writer. |
FormatWriter |
getFormatWriter()
Getter for the format-writer associated with this format-support. |
int |
getIndentShift()
Delegation to the same method in format-writer. |
String |
getIndentString(int indent)
This delegates to the same method in formatter. |
FormatTokenPosition |
getLastPosition()
|
TokenItem |
getLastToken()
Delegation to the same method in format-writer. |
int |
getLineIndent(FormatTokenPosition pos,
boolean zeroForWSLine)
Get the indentation of the line. |
FormatTokenPosition |
getNextPosition(FormatTokenPosition pos)
Get the next successive token-position after the given one. |
FormatTokenPosition |
getNextPosition(FormatTokenPosition pos,
Position.Bias bias)
Get the token-position preceeding the given one. |
FormatTokenPosition |
getNextPosition(TokenItem token,
int offset)
|
FormatTokenPosition |
getNextPosition(TokenItem token,
int offset,
Position.Bias bias)
Get the next position of the position given by parameters. |
FormatTokenPosition |
getPosition(TokenItem token,
int offset)
Get the token position that corresponds to the given token and offset. |
FormatTokenPosition |
getPosition(TokenItem token,
int offset,
Position.Bias bias)
|
FormatTokenPosition |
getPreviousPosition(FormatTokenPosition pos)
Get the token-position preceeding the given one. |
FormatTokenPosition |
getPreviousPosition(FormatTokenPosition pos,
Position.Bias bias)
Get the token-position preceeding the given one. |
FormatTokenPosition |
getPreviousPosition(TokenItem token,
int offset)
|
FormatTokenPosition |
getPreviousPosition(TokenItem token,
int offset,
Position.Bias bias)
Get the previous position of the position given by parameters. |
TokenItem |
getPreviousToken(TokenItem token)
Get the previous token or last token if the argument is null. |
boolean |
getSettingBoolean(String settingName,
boolean defaultValue)
|
boolean |
getSettingBoolean(String settingName,
Boolean defaultValue)
|
int |
getSettingInteger(String settingName,
int defaultValue)
|
int |
getSettingInteger(String settingName,
Integer defaultValue)
|
Object |
getSettingValue(String settingName)
|
Object |
getSettingValue(String settingName,
Object defaultValue)
|
int |
getShiftWidth()
|
int |
getSpacesPerTab()
|
int |
getTabSize()
|
FormatTokenPosition |
getTextStartPosition()
|
TokenContextPath |
getValidWhitespaceTokenContextPath()
Get the valid whitespace token-context-path by calling getWhitespaceTokenContextPath(). |
TokenID |
getValidWhitespaceTokenID()
Get the valid whitespace token-id by calling getWhitespaceTokenID(). |
int |
getVisualColumnOffset(FormatTokenPosition pos)
Get the column-offset of the tokenItem on its line. |
TokenContextPath |
getWhitespaceTokenContextPath()
Get the token-context-path that should be assigned to the token that consists of the indentation whitespace only. |
TokenID |
getWhitespaceTokenID()
Get the token-id that should be assigned to the token that consists of the indentation whitespace only. |
void |
insertSpaces(TokenItem beforeToken,
int spaceCount)
|
void |
insertString(FormatTokenPosition pos,
String text)
|
void |
insertString(TokenItem token,
int offset,
String text)
|
TokenItem |
insertToken(TokenItem beforeToken,
TokenID tokenID,
TokenContextPath tokenContextPath,
String tokenImage)
Delegation to the same method in format-writer. |
boolean |
isAfter(FormatTokenPosition testedPosition,
FormatTokenPosition afterPosition)
|
boolean |
isAfter(TokenItem testedToken,
TokenItem afterToken)
|
boolean |
isChainStartPosition(FormatTokenPosition pos)
|
boolean |
isIndentOnly()
Delegation to the same method in format-writer. |
boolean |
isLineEmpty(FormatTokenPosition pos)
Check whether there are no tokens except the ending EOL on the given line. |
boolean |
isLineWhite(FormatTokenPosition pos)
Check whether there are only the whitespace tokens on the given line. |
boolean |
isRestartFormat()
Delegation to the same method in format-writer. |
boolean |
isWhitespace(FormatTokenPosition pos)
|
boolean |
isWhitespace(TokenItem token,
int offset)
Decide whether the character at the given offset in the given token is whitespace. |
void |
remove(FormatTokenPosition pos,
int length)
|
void |
remove(TokenItem token,
int offset,
int length)
|
void |
removeToken(TokenItem token)
Remove the token-item from the chain. |
void |
removeTokenChain(TokenItem startToken,
TokenItem endToken)
Remove all the tokens between start and end token inclusive. |
void |
replaceToken(TokenItem originalToken,
TokenID tokenID,
TokenContextPath tokenContextPath,
String tokenImage)
Replace the given token with the new token. |
void |
setIndentShift(int indentShift)
Delegation to the same method in format-writer. |
void |
setRestartFormat(boolean restartFormat)
Delegation to the same method in format-writer. |
TokenItem |
splitEnd(TokenItem token,
int endLength,
TokenID newTokenID,
TokenContextPath newTokenContextPath)
|
TokenItem |
splitStart(TokenItem token,
int startLength,
TokenID newTokenID,
TokenContextPath newTokenContextPath)
|
boolean |
tokenEquals(TokenItem compareToken,
TokenID withTokenID)
Compare token-id of the compare-token with the given token-id. |
boolean |
tokenEquals(TokenItem compareToken,
TokenID withTokenID,
TokenContextPath withTokenContextPath)
Compare token-id of the compare-token with the given token-id and token-context-path. |
boolean |
tokenEquals(TokenItem compareToken,
TokenID withTokenID,
TokenContextPath withTokenContextPath,
String withTokenImage)
Compare token-id of the compare-token with the given token-id and given token-text. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public FormatSupport(FormatWriter formatWriter)
Method Detail |
---|
public FormatWriter getFormatWriter()
public int getTabSize()
public int getShiftWidth()
public boolean expandTabs()
public int getSpacesPerTab()
public Object getSettingValue(String settingName)
public Object getSettingValue(String settingName, Object defaultValue)
public boolean getSettingBoolean(String settingName, Boolean defaultValue)
public boolean getSettingBoolean(String settingName, boolean defaultValue)
public int getSettingInteger(String settingName, Integer defaultValue)
public int getSettingInteger(String settingName, int defaultValue)
public final boolean isIndentOnly()
public FormatTokenPosition getFormatStartPosition()
public FormatTokenPosition getTextStartPosition()
public TokenItem findFirstToken(TokenItem token)
public TokenItem getLastToken()
public FormatTokenPosition getLastPosition()
public boolean canInsertToken(TokenItem beforeToken)
public TokenItem insertToken(TokenItem beforeToken, TokenID tokenID, TokenContextPath tokenContextPath, String tokenImage)
public void insertSpaces(TokenItem beforeToken, int spaceCount)
public boolean canRemoveToken(TokenItem token)
public void removeToken(TokenItem token)
public void removeTokenChain(TokenItem startToken, TokenItem endToken)
public TokenItem splitStart(TokenItem token, int startLength, TokenID newTokenID, TokenContextPath newTokenContextPath)
public TokenItem splitEnd(TokenItem token, int endLength, TokenID newTokenID, TokenContextPath newTokenContextPath)
public void insertString(TokenItem token, int offset, String text)
public void insertString(FormatTokenPosition pos, String text)
public void remove(TokenItem token, int offset, int length)
public void remove(FormatTokenPosition pos, int length)
public TokenItem findNonEmptyToken(TokenItem token, boolean backward)
public FormatTokenPosition getPosition(TokenItem token, int offset)
token
- token for which the token-position is being created.offset
- offset inside the token.public FormatTokenPosition getPosition(TokenItem token, int offset, Position.Bias bias)
public FormatTokenPosition getNextPosition(TokenItem token, int offset, Position.Bias bias)
public FormatTokenPosition getPreviousPosition(TokenItem token, int offset, Position.Bias bias)
public FormatTokenPosition getPreviousPosition(FormatTokenPosition pos)
public FormatTokenPosition getPreviousPosition(FormatTokenPosition pos, Position.Bias bias)
bias
- bias that the returned position will have.public FormatTokenPosition getPreviousPosition(TokenItem token, int offset)
public FormatTokenPosition getNextPosition(FormatTokenPosition pos)
public FormatTokenPosition getNextPosition(FormatTokenPosition pos, Position.Bias bias)
bias
- bias that the returned position will have.public FormatTokenPosition getNextPosition(TokenItem token, int offset)
public boolean isAfter(TokenItem testedToken, TokenItem afterToken)
public boolean isAfter(FormatTokenPosition testedPosition, FormatTokenPosition afterPosition)
public boolean isChainStartPosition(FormatTokenPosition pos)
public boolean canReplaceToken(TokenItem token)
public void replaceToken(TokenItem originalToken, TokenID tokenID, TokenContextPath tokenContextPath, String tokenImage)
originalToken
- original token to be replaced.tokenID
- token-id of the new token-itemtokenContextPath
- token-context-path of the new token-itemtokenImage
- token-text of the new token-itempublic boolean isRestartFormat()
public void setRestartFormat(boolean restartFormat)
public int getIndentShift()
public void setIndentShift(int indentShift)
public boolean tokenEquals(TokenItem compareToken, TokenID withTokenID)
compareToken
- token to comparewithTokenID
- token-id with which the token's token-id is compared
public boolean tokenEquals(TokenItem compareToken, TokenID withTokenID, TokenContextPath withTokenContextPath)
compareToken
- token to comparewithTokenID
- token-id with which the token's token-id is compared.withTokenContextPath
- token-context-path to which
the token's token-context-path is compared.
public boolean tokenEquals(TokenItem compareToken, TokenID withTokenID, TokenContextPath withTokenContextPath, String withTokenImage)
compareToken
- token to comparewithTokenID
- token-id with which the token's token-id is compared.
It can be null in which case the token-id is ignored from comparison.withTokenContextPath
- token-context-path to which
the token's token-context-path is compared.
It can be null in which case the token-context-path is ignored from comparison.withTokenImage
- token-text with which the token's token-text is compared.
It can be null in which case the token-text is ignored from comparison.
public boolean isWhitespace(TokenItem token, int offset)
public boolean isWhitespace(FormatTokenPosition pos)
public FormatTokenPosition findLineStart(FormatTokenPosition pos)
pos
- any token-position on the line.public FormatTokenPosition findLineEnd(FormatTokenPosition pos)
pos
- any token-position on the line.public FormatTokenPosition findLineFirstNonWhitespace(FormatTokenPosition pos)
public FormatTokenPosition findLineEndWhitespace(FormatTokenPosition pos)
public FormatTokenPosition findPreviousEOL(FormatTokenPosition pos)
public FormatTokenPosition findNextEOL(FormatTokenPosition pos)
pos
- starting token-position that is ignored by the search
so it can be even EOL.
public boolean isLineEmpty(FormatTokenPosition pos)
pos
- any position on the linepublic boolean isLineWhite(FormatTokenPosition pos)
token
- any token on the line. It doesn't have to be the first one.public int getVisualColumnOffset(FormatTokenPosition pos)
public FormatTokenPosition findNonWhitespace(FormatTokenPosition startPosition, FormatTokenPosition limitPosition, boolean stopOnEOL, boolean backward)
startPosition
- position at which the search starts.
For the backward search the character right at startPosition
is not considered as part of the search.limitPosition
- 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 the char at the limitPosition
is not considered to be part of search,
but for backward search it is.stopOnEOL
- whether stop and return EOL position
or continue search if EOL token is found.backward
- whether search in backward direction.
public TokenItem getPreviousToken(TokenItem token)
public TokenID getWhitespaceTokenID()
public TokenID getValidWhitespaceTokenID()
public TokenContextPath getWhitespaceTokenContextPath()
public TokenContextPath getValidWhitespaceTokenContextPath()
public boolean canModifyWhitespace(TokenItem inToken)
public String getIndentString(int indent)
public int getLineIndent(FormatTokenPosition pos, boolean zeroForWSLine)
formatTokenPosition
- any position on the line.
It doesn't have to be the first one.zeroForWSLine
- If set to true the method will return zero
in case the line consist of whitespace only. If false
the method will return the indentation even for whitespace
lines.public FormatTokenPosition changeLineIndent(FormatTokenPosition pos, int indent)
pos
- any position on the line being checked.indent
- the indentation for the line.
public String chainToString(TokenItem token)
token
- mark this token as current one. It can be null.public String chainToString(TokenItem token, int maxDocumentTokens)
|
org.netbeans.modules.editor.lib/1 1.14.0 3 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |