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

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

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

org.netbeans.editor
Class SyntaxSupport

java.lang.Object
  extended by org.netbeans.editor.SyntaxSupport
Direct Known Subclasses:
ExtSyntaxSupport

public class SyntaxSupport
extends Object

Support methods for syntax analyzes


Field Summary
protected  boolean tokenNumericIDsValid
          Whether all the token-ids this class deals with have valid numeric-ids.
 
Constructor Summary
SyntaxSupport(BaseDocument doc)
           
 
Method Summary
protected  SyntaxSupport createSyntaxSupport(Class syntaxSupportClass)
           
 int findInsideBlocks(Finder finder, int startPos, int endPos, int[] blocks)
           
 int findOutsideBlocks(Finder finder, int startPos, int endPos, int[] blocks)
           
 SyntaxSupport get(Class syntaxSupportClass)
          Get the support that fits the requested support class in the best way.
 BaseDocument getDocument()
          Getter for the document that this support is associated to.
 int[] getTokenBlocks(int startPos, int endPos, TokenID[] tokenIDArray)
          Get position pairs covering the blocks that include only the tokens from the given token array.
 TokenItem getTokenChain(int offset)
          Get the member of the chain of the tokens for the given document position.
 void initSyntax(Syntax syntax, int startPos, int endPos, boolean forceLastBuffer, boolean forceNotLastBuffer)
          Initialize the syntax so it's ready to scan the given area.
protected  boolean isAbbrevDisabled(int offset)
          Check whether the abbreviation expansion should be disabled at the given offset.
 boolean isIdentifier(String word)
          Check whether the given word is identifier or not.
 void tokenizeText(TokenProcessor tp, int startOffset, int endOffset, boolean forceLastBuffer)
          Parse the text and pass the resulting tokens to the token processor.
 void tokenizeText(TokenProcessor tp, String text)
          Parse the text and pass the resulting tokens to the token processor.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

tokenNumericIDsValid

protected boolean tokenNumericIDsValid
Whether all the token-ids this class deals with have valid numeric-ids. It's not necessary to set this flag, however it presents an optimization in testing whether a token belongs to some group of tokens or not. The testing whether the particular token belongs to some group is improved by creating a boolean array in which the numeric-ids serve as the array indexes.

Constructor Detail

SyntaxSupport

public SyntaxSupport(BaseDocument doc)
Method Detail

getDocument

public final BaseDocument getDocument()
Getter for the document that this support is associated to.


get

public SyntaxSupport get(Class syntaxSupportClass)
Get the support that fits the requested support class in the best way. The value returned will be either instance of the requested class or its descendant or it will be null.

Parameters:
syntaxSupportClass - returned value will be instance of this class (or its descendant) or it will be null
Returns:
instance of syntaxSupportClass (or its descendant) or null if there's no fitting support.

createSyntaxSupport

protected SyntaxSupport createSyntaxSupport(Class syntaxSupportClass)

getTokenBlocks

public int[] getTokenBlocks(int startPos,
                            int endPos,
                            TokenID[] tokenIDArray)
                     throws BadLocationException
Get position pairs covering the blocks that include only the tokens from the given token array. Although the startPos can be greater than endPos, the blocks are always returned in the natural order.

Parameters:
doc - document to work with
startPos - starting position of the requested document area.
endPos - ending position of the requested document area
tokenIDArray - the array of the token IDs that should be in the blocks.
Throws:
BadLocationException

findInsideBlocks

public int findInsideBlocks(Finder finder,
                            int startPos,
                            int endPos,
                            int[] blocks)
                     throws BadLocationException
Throws:
BadLocationException

findOutsideBlocks

public int findOutsideBlocks(Finder finder,
                             int startPos,
                             int endPos,
                             int[] blocks)
                      throws BadLocationException
Throws:
BadLocationException

initSyntax

public void initSyntax(Syntax syntax,
                       int startPos,
                       int endPos,
                       boolean forceLastBuffer,
                       boolean forceNotLastBuffer)
                throws BadLocationException
Initialize the syntax so it's ready to scan the given area.

Parameters:
syntax - lexical analyzer to prepare
startPos - starting position of the scanning
endPos - ending position of the scanning
forceLastBuffer - force the syntax to think that the scanned area is the last in the document. This is useful for forcing the syntax to process all the characters in the given area.
forceNotLastBuffer - force the syntax to think that the scanned area is NOT the last buffer in the document. This is useful when the syntax will continue scanning on another buffer.
Throws:
BadLocationException

isIdentifier

public boolean isIdentifier(String word)
Check whether the given word is identifier or not.


tokenizeText

public void tokenizeText(TokenProcessor tp,
                         int startOffset,
                         int endOffset,
                         boolean forceLastBuffer)
                  throws BadLocationException
Parse the text and pass the resulting tokens to the token processor.

Parameters:
tp - token processor that will be informed about the found tokens.
startOffset - starting position in the text
endOffset - ending position in the text
forceLastBuffer - force the syntax scanner to think that the requested area is the last in the document.
Throws:
BadLocationException

tokenizeText

public void tokenizeText(TokenProcessor tp,
                         String text)
Parse the text and pass the resulting tokens to the token processor.

Parameters:
tp - token processor that will be informed about the found tokens.
text - text to parse

getTokenChain

public TokenItem getTokenChain(int offset)
                        throws BadLocationException
Get the member of the chain of the tokens for the given document position.

Parameters:
offset - position in the document for which the chain is being retrieved.
Returns:
token-item around the offset or right at the offset. Null is returned if offset is equal to document length.
Throws:
BadLocationException

isAbbrevDisabled

protected boolean isAbbrevDisabled(int offset)
Check whether the abbreviation expansion should be disabled at the given offset.

Parameters:
offset - offset at which the situation should be checked.
Returns:
true if the abbreviation expansion should be disabled at the given offset or false otherwise.

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.