public abstract class AbstractBraceProvider extends java.lang.Object implements BraceProvider
GenericBraceProvider
implementation provides brace
matching support for "generic" languages that implement the
generic Language
API to describe the language.BraceProvider
,
BraceMatchingPlugin
Modifier and Type | Field and Description |
---|---|
protected int[] |
braceArray
Stores the array containing start and end offsets of brace tokens, as
well as brace indexes.
|
protected int |
braceCount
Stores the count of brace tokens in the buffer.
|
BALANCED_MATCH, MISMATCH, UNBALANCED_MATCH
Constructor and Description |
---|
AbstractBraceProvider() |
Modifier and Type | Method and Description |
---|---|
protected int[] |
expandBraceArray(int[] braceArray)
Utility routine to expand the brace array.
|
protected void |
fillBraceArray()
Utility routine to fill the contents of the brace array.
|
int |
findMatchingBrace(int braceType,
NumberRange braceLocation,
NumberRange matchingLocation)
Finds the brace matching the given brace identified by
isPartOfBrace().
|
protected abstract java.lang.String |
getBraceCharacters()
Gets a string of all brace characters.
|
protected abstract BraceHelper |
getBraceHelper()
Gets the BraceHelper that gives information about the braces in this
file.
|
protected abstract Lexer |
getLexer()
Gets (or creates) the lexer we'll use for lexing.
|
protected abstract TextBuffer |
getTextBuffer()
Gets the TextBuffer we are working on.
|
protected int |
guessBraceCount(int length)
Utility routine to guess the brace count for a given size file.
|
protected abstract boolean |
isBraceToken(int token)
True if the token is a brace token (open or close).
|
int |
isPartOfBrace(int offset,
NumberRange braceLocation)
Determines whether the character at the given offset is
considered a brace or part of a brace in this language.
|
protected int[] braceArray
protected int braceCount
protected abstract TextBuffer getTextBuffer()
protected abstract BraceHelper getBraceHelper()
protected abstract Lexer getLexer()
protected abstract boolean isBraceToken(int token)
token
- A token value returned by the lexer during lexing.protected abstract java.lang.String getBraceCharacters()
public int isPartOfBrace(int offset, NumberRange braceLocation)
NumberRange
object passed in by the caller is filled in by this routine to
indicate the start and end of the brace at the given offset
provided. This routine returns a language-specific token
type corresponding to the given brace at the offset, or -1
(Lexer.NOT_FOUND) if the offset is not part of a brace.isPartOfBrace
in interface BraceProvider
offset
- the offset in the document associated with the
specific LanguageSupport to check if it is a bracebraceLocation
- an out parameter to pass start and end
offset information to the caller if the provided
brace offset is indeed part of a bracepublic int findMatchingBrace(int braceType, NumberRange braceLocation, NumberRange matchingLocation)
findMatchingBrace
in interface BraceProvider
braceType
- the language-specific token type returned by
isPartOfBrace().braceLocation
- the brace location filled in by isPartOfBrace()matchingLocation
- an out parameter to pass start and end
offset information to the caller if a matching brace was foundprotected int guessBraceCount(int length)
length
- the length of the fileprotected int[] expandBraceArray(int[] braceArray)
braceArray
- the old brace arrayprotected void fillBraceArray() throws java.lang.InterruptedException
java.lang.InterruptedException
- if interrupted when filling the array