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

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

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

org.netbeans.editor.ext
Class MultiSyntax

java.lang.Object
  extended by org.netbeans.editor.Syntax
      extended by org.netbeans.editor.ext.MultiSyntax

public class MultiSyntax
extends Syntax

Composition of several syntaxes together. There are several different situations in which this class can be used efficiently: 1) Syntax that wants to use some other syntax internally for recognizing one or more tokens. Example is java analyzer that would like to use html-syntax for detail parsing block comments. 2) Master syntax that will manage two or more slave syntaxes. Example is the master syntax managing java-syntax and html-syntax. The result would be the same like in the previous example but it's more independent. 3) Master syntax that handles switching of the two or more other syntaxes. Only one slave syntax is active at one time. 4) An aribitrary combination and nesting of the previous examples.


Nested Class Summary
static class MultiSyntax.MultiStateInfo
          Class that can contain any number of the additional state infos from other syntaxes.
 
Nested classes/interfaces inherited from class org.netbeans.editor.Syntax
Syntax.BaseStateInfo, Syntax.StateInfo
 
Field Summary
 
Fields inherited from class org.netbeans.editor.Syntax
buffer, DIFFERENT_STATE, EQUAL_STATE, INIT, lastBuffer, offset, state, stopOffset, stopPosition, supposedTokenID, tokenContextPath, tokenLength, tokenOffset
 
Constructor Summary
MultiSyntax()
           
 
Method Summary
 int compareState(Syntax.StateInfo stateInfo)
          Compare state of this analyzer to given state info.
 Syntax.StateInfo createStateInfo()
          Create state info appropriate for particular analyzer
 void load(Syntax.StateInfo stateInfo, char[] buffer, int offset, int len, boolean lastBuffer, int stopPosition)
          Load the state from syntax mark into analyzer.
 void loadInitState()
          Initialize the analyzer when scanning from the begining of the document or when the state stored in syntax mark is null for some reason or to explicitly reset the analyzer to the initial state.
protected  void registerSyntax(Syntax slaveSyntax)
          Register a particular slave syntax.
 void storeState(Syntax.StateInfo stateInfo)
          Store state of this analyzer into given mark state.
 
Methods inherited from class org.netbeans.editor.Syntax
getBuffer, getOffset, getPreScan, getStateName, getSupposedTokenID, getTokenContextPath, getTokenLength, getTokenOffset, loadState, nextToken, parseToken, relocate, reset, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

MultiSyntax

public MultiSyntax()
Method Detail

registerSyntax

protected void registerSyntax(Syntax slaveSyntax)
Register a particular slave syntax.


storeState

public void storeState(Syntax.StateInfo stateInfo)
Store state of this analyzer into given mark state.

Overrides:
storeState in class Syntax

loadInitState

public void loadInitState()
Description copied from class: Syntax
Initialize the analyzer when scanning from the begining of the document or when the state stored in syntax mark is null for some reason or to explicitly reset the analyzer to the initial state. The offsets must not be touched by this method.

Overrides:
loadInitState in class Syntax

load

public void load(Syntax.StateInfo stateInfo,
                 char[] buffer,
                 int offset,
                 int len,
                 boolean lastBuffer,
                 int stopPosition)
Description copied from class: Syntax
Load the state from syntax mark into analyzer. This method is used when

Overrides:
load in class Syntax
Parameters:
stateInfo - info about the state of the lexical analyzer to load. It can be null to indicate there's no previous state so the analyzer starts from its initial state.
buffer - buffer that will be scanned
offset - offset of the first character that will be scanned
len - length of the area to be scanned
lastBuffer - whether this is the last buffer in the document. All the tokens will be returned including the last possibly incomplete one. If the data come from the document, the simple rule for this parameter is (doc.getLength() == stop-position) where stop-position is the position corresponding to the (offset + len) in the buffer that comes from the document data.
stopPosition - position in the document that corresponds to (offset + len) offset in the provided buffer. It has only sense if the data in the buffer come from the document. It helps in writing the advanced analyzers that need to interact with some other data in the document than only those provided in the character buffer. If there is no relation to the document data, the stopPosition parameter must be filled with -1 which means an invalid value. The stop-position is passed (instead of start-position) because it doesn't change through the analyzer operation. It corresponds to the stopOffset that also doesn't change through the analyzer operation so any buffer-offset can be transferred to position by computing stopPosition + buffer-offset - stopOffset where stopOffset is the instance variable that is assigned to offset + len in the body of relocate().

createStateInfo

public Syntax.StateInfo createStateInfo()
Description copied from class: Syntax
Create state info appropriate for particular analyzer

Overrides:
createStateInfo in class Syntax

compareState

public int compareState(Syntax.StateInfo stateInfo)
Compare state of this analyzer to given state info. The basic implementation does the following: 1. state info of the main syntax is compared 2. if the result is EQUAL_STATE then go through all the registered slave syntaxes: a) get the info

Overrides:
compareState in class Syntax

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.