org.netbeans.modules.lexer/2 1.39.1 1

org.netbeans.spi.lexer
Class TokenHierarchyControl<I>

java.lang.Object
  extended by org.netbeans.spi.lexer.TokenHierarchyControl<I>

public final class TokenHierarchyControl<I>
extends Object

Control class for managing token hierarchy of a mutable text input.


Method Summary
 boolean isActive()
          Check whether the hierarchy is currently active or not.
 void rebuild()
          Rebuild token hierarchy completely.
 void setActive(boolean active)
          Making the token hierarchy inactive will release all the tokens in the hierarchy so that there will be no tokens.
 void textModified(int offset, int removedLength, CharSequence removedText, int insertedLength)
          Notify that the text of the mutable text input was modified.
 TokenHierarchy<I> tokenHierarchy()
          Get token hierarchy managed by this control object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

tokenHierarchy

public TokenHierarchy<I> tokenHierarchy()
Get token hierarchy managed by this control object.

Returns:
non-null token hierarchy.

textModified

public void textModified(int offset,
                         int removedLength,
                         CharSequence removedText,
                         int insertedLength)
Notify that the text of the mutable text input was modified.

This method should only be invoked under modification lock (write-lock) over the mutable input source.

Parameters:
offset - >=0 offset where the modification occurred.
removedLength - >=0 number of characters removed from the input.
removedText - text removed from the input. If it's not available to determine the removed text then this parameter may be null.
Providing of the removed text allows the incremental algorithm to use an efficient token validation if possible.
insertedLength - >=0 number of characters inserted at the offset after the removal.

setActive

public void setActive(boolean active)
Making the token hierarchy inactive will release all the tokens in the hierarchy so that there will be no tokens. The hierarchy can be made active again later.
Making the hierarchy inactive will free memory occupied by tokens. It can be done e.g. once a document is not edited for a long time (and is not showing on screen).

This method should only be invoked under modification lock (write-lock) over the mutable input source.

Parameters:
active - whether the hierarchy should become active or inactive.

isActive

public boolean isActive()
Check whether the hierarchy is currently active or not. Inactive hierarchy does not hold any tokens and its TokenHierarchy.tokenSequence() returns null.

This method should only be invoked under read/write lock over the mutable input source.

Returns:
true if the hierarchy is active or false when inactive.

rebuild

public void rebuild()
Rebuild token hierarchy completely.
This may be necessary if lexing depends on some input properties that get changed.
This method will drop all present tokens and let them to be lazily recreated.
This method should only be invoked under modification lock over the mutable input source (e.g. a document's write-lock). Otherwise all the active token sequences would fail with ConcurrentModificationException.


org.netbeans.modules.lexer/2 1.39.1 1

Built on December 5 2011.  |  Portions Copyright 1997-2011 Sun Microsystems, Inc. All rights reserved.