|
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.Syntax
org.netbeans.editor.ext.MultiSyntax
public class MultiSyntax
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 |
---|
public MultiSyntax()
Method Detail |
---|
protected void registerSyntax(Syntax slaveSyntax)
public void storeState(Syntax.StateInfo stateInfo)
storeState
in class Syntax
public void loadInitState()
Syntax
loadInitState
in class Syntax
public void load(Syntax.StateInfo stateInfo, char[] buffer, int offset, int len, boolean lastBuffer, int stopPosition)
Syntax
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 scannedoffset
- offset of the first character that will be scannedlen
- length of the area to be scannedlastBuffer
- 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().public Syntax.StateInfo createStateInfo()
Syntax
createStateInfo
in class Syntax
public int compareState(Syntax.StateInfo stateInfo)
compareState
in class Syntax
|
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 |