edu.rice.cs.drjava.model.definitions.reducedmodel
Interface BraceReduction

All Known Implementing Classes:
ReducedModelControl

public interface BraceReduction

The interface BraceReduction serves as the template for our reduced view of a java document, which stores only the information necessary for parenthesis matching.

Version:
$Id: BraceReduction.java 4653 2008-08-26 14:46:35Z rcartwright $
Author:
JavaPLT

Method Summary
 int absOffset()
          Get the absolute character offset of the document represented by BraceReduction.
 int balanceBackward()
          Finds the open brace that matches the previous significant brace iff that brace is an closing brace.
 int balanceForward()
          Finds the closing brace that matches the next significant brace iff that brace is an open brace.
 ReducedToken currentToken()
          Get the current token in the BraceReduction.
 void delete(int count)
          Update the BraceReduction to reflect text deletion.
 int getDistToNextNewline()
          Gets distance to next new line.
 int getDistToStart(int relativeLoc)
          Gets distance to enclosing new line
 ArrayList<HighlightStatus> getHighlightStatus(int start, int length)
          Return all highlight status info for text between the current location and current location + end.
 ReducedModelState getStateAtCurrent()
          Get the state of the token at the current cursor position.
 void insertChar(char ch)
          Insert a character into the BraceReduction.
 void move(int count)
          Updates the BraceReduction to reflect cursor movement.
 ReducedModelState moveWalkerGetState(int relLocation)
          Returns the state at the relLocation, where relLocation is the location relative to the walker
 void resetLocation()
          Resets the location of the walker in the comment list to where the current cursor is.
 String simpleString()
          A simplified toString() method.
 

Method Detail

absOffset

int absOffset()
Get the absolute character offset of the document represented by BraceReduction.


currentToken

ReducedToken currentToken()
Get the current token in the BraceReduction.

Returns:
the current token

getStateAtCurrent

ReducedModelState getStateAtCurrent()
Get the state of the token at the current cursor position.

Returns:
the current state

insertChar

void insertChar(char ch)
Insert a character into the BraceReduction.

Parameters:
ch - the character to be inserted

move

void move(int count)

Updates the BraceReduction to reflect cursor movement. Negative values move left from the cursor, positive values move right.

Parameters:
count - indicates the direction and magnitude of cursor movement

delete

void delete(int count)

Update the BraceReduction to reflect text deletion.

Parameters:
count - indicates the size and direction of text deletion. Negative values delete text to the left of the cursor, positive values delete text to the right.

balanceForward

int balanceForward()

Finds the closing brace that matches the next significant brace iff that brace is an open brace.

Returns:
the distance until the matching closing brace. On failure, returns -1.
See Also:
balanceBackward()

balanceBackward

int balanceBackward()

Finds the open brace that matches the previous significant brace iff that brace is an closing brace.

Returns:
the distance until the matching open brace. On failure, returns -1.
See Also:
balanceForward()

getDistToStart

int getDistToStart(int relativeLoc)
Gets distance to enclosing new line


getDistToNextNewline

int getDistToNextNewline()
Gets distance to next new line.


simpleString

String simpleString()
A simplified toString() method.


getHighlightStatus

ArrayList<HighlightStatus> getHighlightStatus(int start,
                                              int length)
Return all highlight status info for text between the current location and current location + end. This should collapse adjoining blocks with the same status into one.

Parameters:
start - The start location of the area being inspected. The reduced model cursor is already located at this position, but the parameter is needed to determine the absolute positions needed in the HighlightStatus objects we return.
length - The length of the text area being inspected.

moveWalkerGetState

ReducedModelState moveWalkerGetState(int relLocation)
Returns the state at the relLocation, where relLocation is the location relative to the walker

Parameters:
relLocation - distance from walker to get state at.

resetLocation

void resetLocation()
Resets the location of the walker in the comment list to where the current cursor is.