Skip navigation links

Oracle Fusion Middleware Java API Reference for Oracle Extension SDK Reference
11g Release 1 (11.1.1.7.2)

E13403-10


oracle.javatools.editor.language
Class AbstractBraceProvider

java.lang.Object
  extended by oracle.javatools.editor.language.AbstractBraceProvider

All Implemented Interfaces:
BraceProvider
Direct Known Subclasses:
GenericBraceProvider

public abstract class AbstractBraceProvider
extends java.lang.Object
implements BraceProvider

The GenericBraceProvider implementation provides brace matching support for "generic" languages that implement the generic Language API to describe the language.

See Also:
BraceProvider, BraceMatchingPlugin

Field Summary
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.

 

Fields inherited from interface oracle.javatools.editor.language.BraceProvider
BALANCED_MATCH, MISMATCH, UNBALANCED_MATCH

 

Constructor Summary
AbstractBraceProvider()
           

 

Method Summary
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.

 

Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

 

Field Detail

braceArray

protected int[] braceArray
Stores the array containing start and end offsets of brace tokens, as well as brace indexes. This means each entry is stored as a triplet (start, end, index). So the array indexes 0, 3, 6, ... are start offsets (inclusive), the indexes 1, 4, 7, ... are end offsets (exclusive), and the indexes 2, 5, 8 are brace index values.

braceCount

protected int braceCount
Stores the count of brace tokens in the buffer.

Constructor Detail

AbstractBraceProvider

public AbstractBraceProvider()

Method Detail

getTextBuffer

protected abstract TextBuffer getTextBuffer()
Gets the TextBuffer we are working on.

getBraceHelper

protected abstract BraceHelper getBraceHelper()
Gets the BraceHelper that gives information about the braces in this file.

getLexer

protected abstract Lexer getLexer()
Gets (or creates) the lexer we'll use for lexing.

isBraceToken

protected abstract boolean isBraceToken(int token)
True if the token is a brace token (open or close).
Parameters:
token - A token value returned by the lexer during lexing.

getBraceCharacters

protected abstract java.lang.String getBraceCharacters()
Gets a string of all brace characters. Used to quickly determine if the character under the current insertion point (in the text buffer) might be a brace.

isPartOfBrace

public 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. It is conceivable that the brace may consist of multiple characters in certain languages. The 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.
Specified by:
isPartOfBrace in interface BraceProvider
Parameters:
offset - the offset in the document associated with the specific LanguageSupport to check if it is a brace
braceLocation - an out parameter to pass start and end offset information to the caller if the provided brace offset is indeed part of a brace
Returns:
a language-specific token type (which should not be interpreted by callers) that should be passed to findMatchingBrace() to find the matching brace.

findMatchingBrace

public int findMatchingBrace(int braceType,
                             NumberRange braceLocation,
                             NumberRange matchingLocation)
Finds the brace matching the given brace identified by isPartOfBrace(). If a matching brace is found, the matchingLocation is filled in with the start and end offsets of the matching brace, and either BALANCED_MATCH or UNBALANCED_MATCH returned depending on whether the braces in between are balanced. If a matching brace is not found, then MISMATCH will be returned, and the contents of matchingLocation are undefined.
Specified by:
findMatchingBrace in interface BraceProvider
Parameters:
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 found
Returns:
BALANCED_MATCH, UNBALANCED_MATCH, or MISMATCH to indicate the result of the match operation

guessBraceCount

protected int guessBraceCount(int length)
Utility routine to guess the brace count for a given size file. This is used to size our brace array buffer.
Parameters:
length - the length of the file
Returns:
the guess of the number of brace tokens in the file

expandBraceArray

protected int[] expandBraceArray(int[] braceArray)
Utility routine to expand the brace array. We assume that all of the brace array contents are valid, as that's the only reason we would need to expand it (it is full.)
Parameters:
braceArray - the old brace array
Returns:
a new brace array of expanded size, with the old contents copied over

fillBraceArray

protected void fillBraceArray()
                       throws java.lang.InterruptedException
Utility routine to fill the contents of the brace array.
Throws:
java.lang.InterruptedException - if interrupted when filling the array

Skip navigation links

Oracle Fusion Middleware Java API Reference for Oracle Extension SDK Reference
11g Release 1 (11.1.1.7.2)

E13403-10


Copyright © 1997, 2013, Oracle. All rights reserved.