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

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

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

org.netbeans.editor.ext
Class ExtSyntaxSupport

java.lang.Object
  extended by org.netbeans.editor.SyntaxSupport
      extended by org.netbeans.editor.ext.ExtSyntaxSupport

public class ExtSyntaxSupport
extends SyntaxSupport

Support methods for syntax analyzes


Nested Class Summary
 class ExtSyntaxSupport.BracketFinder
          Finder for the matching bracket.
static interface ExtSyntaxSupport.DeclarationTokenProcessor
          Token processor extended to get declaration position of the given variable.
static interface ExtSyntaxSupport.VariableMapTokenProcessor
           
 
Field Summary
static int COMPLETION_CANCEL
          Cancel request without changing completion visibility.
static int COMPLETION_HIDE
          Hide completion.
static int COMPLETION_POPUP
          Schedule content update making completion visible.
static int COMPLETION_POST_REFRESH
          Schedule content update if it's currently visible.
static int COMPLETION_REFRESH
          Update content immediatelly if it's currently visible.
 
Fields inherited from class org.netbeans.editor.SyntaxSupport
tokenNumericIDsValid
 
Constructor Summary
ExtSyntaxSupport(BaseDocument doc)
           
 
Method Summary
protected  Map buildGlobalVariableMap(int offset)
           
protected  Map buildLocalVariableMap(int offset)
           
 int checkCompletion(JTextComponent target, String typedText, boolean visible)
          Check and possibly popup, hide or refresh the completion
protected  ExtSyntaxSupport.DeclarationTokenProcessor createDeclarationTokenProcessor(String varName, int startPos, int endPos)
           
protected  ExtSyntaxSupport.VariableMapTokenProcessor createVariableMapTokenProcessor(int startPos, int endPos)
           
protected  void documentModified(DocumentEvent evt)
          Called when the document was modified by either the insert or removal.
 int findDeclarationPosition(String varName, int varPos)
          Find either the local or global declaration position.
 int findGlobalDeclarationPosition(String varName, int varPos)
          Get the position of the global declaration of a given variable.
 int findLocalDeclarationPosition(String varName, int varPos)
           
 int[] findMatchingBlock(int offset, boolean simpleSearch)
          Find matching bracket or more generally block that matches with the current position.
 Object findType(String varName, int varPos)
          Find the type of the variable.
protected  TokenID[] getBracketSkipTokens()
          Get the array of token IDs that should be skipped when searching for matching bracket.
 int[] getCommentBlocks(int startPos, int endPos)
          Get the blocks consisting of comments in a specified document area.
 TokenID[] getCommentTokens()
          Get the array of token IDs that denote the comments.
 int[] getFunctionBlock(int offset)
           
 int[] getFunctionBlock(int[] identifierBlock)
          Is the identifier at the position a function call? It first checks whether there is a identifier under the cursor and then it searches for the function call character - usually '('.
 Map getGlobalVariableMap(int offset)
           
 Map getLocalVariableMap(int offset)
           
protected  ExtSyntaxSupport.BracketFinder getMatchingBracketFinder(char bracketChar)
          Get the bracket finder that will search for the matching bracket or null if the bracket character doesn't belong to bracket characters.
protected  int getMethodStartPosition(int offset)
          Get the start position of the method or the area where the declaration can start.
 int getRowLastValidChar(int offset)
          Gets the last non-blank and non-comment character on the given line.
 TokenItem getTokenChain(int startOffset, int endOffset)
          Get the chain of the tokens for the given block of text.
 TokenID getTokenID(int offset)
          Gets the token-id of the token at the given position.
 boolean isCommentOrWhitespace(int startPos, int endPos)
           
 boolean isRowValid(int offset)
          Does the line contain some valid code besides of possible white space and comments?
 boolean isWhitespaceToken(TokenID tokenID, char[] buffer, int offset, int tokenLength)
           
 
Methods inherited from class org.netbeans.editor.SyntaxSupport
createSyntaxSupport, findInsideBlocks, findOutsideBlocks, get, getDocument, getTokenBlocks, getTokenChain, initSyntax, isAbbrevDisabled, isIdentifier, tokenizeText, tokenizeText
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

COMPLETION_POPUP

public static final int COMPLETION_POPUP
Schedule content update making completion visible.

See Also:
Constant Field Values

COMPLETION_CANCEL

public static final int COMPLETION_CANCEL
Cancel request without changing completion visibility.

See Also:
Constant Field Values

COMPLETION_REFRESH

public static final int COMPLETION_REFRESH
Update content immediatelly if it's currently visible.

See Also:
Constant Field Values

COMPLETION_POST_REFRESH

public static final int COMPLETION_POST_REFRESH
Schedule content update if it's currently visible.

See Also:
Constant Field Values

COMPLETION_HIDE

public static final int COMPLETION_HIDE
Hide completion.

See Also:
Constant Field Values
Constructor Detail

ExtSyntaxSupport

public ExtSyntaxSupport(BaseDocument doc)
Method Detail

getTokenChain

public TokenItem getTokenChain(int startOffset,
                               int endOffset)
                        throws BadLocationException
Get the chain of the tokens for the given block of text. The returned chain of token-items reflects the tokens as they occur in the text and therefore the first token can start at the slightly lower position than the requested one. The chain itself can be extended automatically when reaching the first chain item and calling getPrevious() on it. Another chunk of the tokens will be parsed and the head of the chain will be extended. However this happens only in case there was no modification performed to the document between the creation of the chain and this moment. Otherwise this call throws IllegalStateException.

Parameters:
startOffset - starting position of the block
endOffset - ending position of the block
Returns:
the first item of the token-item chain or null if there are no tokens in the given area or the area is so small that it lays inside one token. To prevent this provide the area that spans a new-line.
Throws:
BadLocationException

documentModified

protected void documentModified(DocumentEvent evt)
Called when the document was modified by either the insert or removal.

Parameters:
evt - event received with the modification notification. getType() can be used to obtain the type of the event.

getMatchingBracketFinder

protected ExtSyntaxSupport.BracketFinder getMatchingBracketFinder(char bracketChar)
Get the bracket finder that will search for the matching bracket or null if the bracket character doesn't belong to bracket characters.


findMatchingBlock

public int[] findMatchingBlock(int offset,
                               boolean simpleSearch)
                        throws BadLocationException
Find matching bracket or more generally block that matches with the current position.

Parameters:
offset - position of the starting bracket
simple - whether the search should skip comment and possibly other areas. This can be useful when the speed is critical, because the simple search is faster.
Returns:
array of integers containing starting and ending position of the block in the document. Null is returned if there's no matching block.
Throws:
BadLocationException

getBracketSkipTokens

protected TokenID[] getBracketSkipTokens()
Get the array of token IDs that should be skipped when searching for matching bracket. It usually includes comments and character and string constants. Returns empty array by default.


getTokenID

public TokenID getTokenID(int offset)
                   throws BadLocationException
Gets the token-id of the token at the given position.

Parameters:
offset - position at which the token should be returned
Returns:
token-id of the token at the requested position. If there's no more tokens in the text, the Syntax.INVALID is returned.
Throws:
BadLocationException

getFunctionBlock

public int[] getFunctionBlock(int[] identifierBlock)
                       throws BadLocationException
Is the identifier at the position a function call? It first checks whether there is a identifier under the cursor and then it searches for the function call character - usually '('. Note: Java 1.5 annotations are not taken as function calls.

Parameters:
identifierBlock - int[2] block delimiting the identifier
Returns:
int[2] block or null if there's no function call
Throws:
BadLocationException

getFunctionBlock

public int[] getFunctionBlock(int offset)
                       throws BadLocationException
Throws:
BadLocationException

isWhitespaceToken

public boolean isWhitespaceToken(TokenID tokenID,
                                 char[] buffer,
                                 int offset,
                                 int tokenLength)

isCommentOrWhitespace

public boolean isCommentOrWhitespace(int startPos,
                                     int endPos)
                              throws BadLocationException
Throws:
BadLocationException

getRowLastValidChar

public int getRowLastValidChar(int offset)
                        throws BadLocationException
Gets the last non-blank and non-comment character on the given line.

Throws:
BadLocationException

isRowValid

public boolean isRowValid(int offset)
                   throws BadLocationException
Does the line contain some valid code besides of possible white space and comments?

Throws:
BadLocationException

getCommentTokens

public TokenID[] getCommentTokens()
Get the array of token IDs that denote the comments. Returns empty array by default.


getCommentBlocks

public int[] getCommentBlocks(int startPos,
                              int endPos)
                       throws BadLocationException
Get the blocks consisting of comments in a specified document area.

Parameters:
doc - document to work with
startPos - starting position of the searched document area
endPos - ending position of the searched document area
Throws:
BadLocationException

findType

public Object findType(String varName,
                       int varPos)
Find the type of the variable. The default behavior is to first search for the local variable declaration and then possibly for the global declaration and if the declaration position is found to get the first word on that position.

Returns:
it returns Object to enable the custom implementations to return the appropriate instances.

getLocalVariableMap

public Map getLocalVariableMap(int offset)

buildLocalVariableMap

protected Map buildLocalVariableMap(int offset)

getGlobalVariableMap

public Map getGlobalVariableMap(int offset)

buildGlobalVariableMap

protected Map buildGlobalVariableMap(int offset)

getMethodStartPosition

protected int getMethodStartPosition(int offset)
Get the start position of the method or the area where the declaration can start.


findDeclarationPosition

public int findDeclarationPosition(String varName,
                                   int varPos)
Find either the local or global declaration position. First try the local declaration and if it doesn't succeed, then try the global declaration.


findLocalDeclarationPosition

public int findLocalDeclarationPosition(String varName,
                                        int varPos)

findGlobalDeclarationPosition

public int findGlobalDeclarationPosition(String varName,
                                         int varPos)
Get the position of the global declaration of a given variable. By default it's implemented to use the same token processor as for the local variables but the whole file is searched.


createDeclarationTokenProcessor

protected ExtSyntaxSupport.DeclarationTokenProcessor createDeclarationTokenProcessor(String varName,
                                                                                     int startPos,
                                                                                     int endPos)

createVariableMapTokenProcessor

protected ExtSyntaxSupport.VariableMapTokenProcessor createVariableMapTokenProcessor(int startPos,
                                                                                     int endPos)

checkCompletion

public int checkCompletion(JTextComponent target,
                           String typedText,
                           boolean visible)
Check and possibly popup, hide or refresh the completion


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.