|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectedu.rice.cs.drjava.model.definitions.reducedmodel.ReducedModelControl
public class ReducedModelControl
This class provides an implementation of the BraceReduction interface for brace matching. In order to correctly match, this class keeps track of what is commented (line and block) and what is inside double quotes (strings). To avoid unnecessary complication, this class maintains a few invariants for its consistent states, i.e., between top-level function calls.
| Field Summary | |
|---|---|
(package private) int |
_offset
|
(package private) ReducedModelBrace |
_rmb
|
(package private) ReducedModelComment |
_rmc
|
| Constructor Summary | |
|---|---|
ReducedModelControl()
Standard constructor. |
|
| Method Summary | |
|---|---|
BraceInfo |
_getEnclosingBrace()
Gets info about the brace enclosing this location. |
BraceInfo |
_getLineEnclosingBrace()
Gets info about the brace enclosing the beginning of this line. |
int |
absOffset()
Gets the absolute character offset into the document represented by the reduced model. |
(package private) boolean |
atEnd()
Determines if the cursor is at the end of the reduced model. |
(package private) boolean |
atStart()
Determines if the cursor is at the start of the reduced model. |
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. |
int |
braceCursorOffset()
|
int |
commentCursorOffset()
|
ReducedToken |
currentToken()
Gets the token currently pointed at by the cursor. |
void |
delete(int count)
Updates the BraceReduction to reflect text deletion. |
(package private) int |
getBlockOffset()
Gets the offset within the current token. |
int |
getDistToEnclosingBraceStart()
|
int |
getDistToIdentNewline()
|
int |
getDistToNextNewline()
Gets distance to next new line. |
int |
getDistToStart()
Gets distance to the new newline character (not including the newline). |
int |
getDistToStart(int relLoc)
Gets distance to previous newline character (not including the newline). |
ArrayList<HighlightStatus> |
getHighlightStatus(int start,
int length)
Return all highlight status info for text between the current location and current location + length. |
(package private) int |
getSize()
Gets the size of the current token. |
(package private) int |
getSize(ReducedToken rmbToken,
ReducedToken rmcToken)
|
ReducedModelState |
getStateAtCurrent()
Gets the shadowing state at the current caret position. |
(package private) String |
getType()
Get a string representation of the current token's type. |
void |
insertChar(char ch)
Insert a character into the BraceReduction. |
boolean |
isShadowed()
Determines if cursor position is shadowed by comment or string (does not include opening comment or quotation "brace"). |
boolean |
isWeaklyShadowed()
Determines if current token is either shadowed or an opening comment brace ("//" or "/*"). |
void |
move(int count)
Updates the BraceReduction to reflect cursor movement. |
ReducedModelState |
moveWalkerGetState(int relDistance)
Returns the state at the relDistance, where relDistance is relative to the last time it was called. |
(package private) void |
next()
Move the reduced model to the next token (with 0 offset) and update the cursor information. |
ReducedToken |
nextItem()
Get the next token. |
(package private) void |
prev()
Move the reduced model to the previous token and update the cursor information. |
ReducedToken |
prevItem()
Get the previous token. |
void |
resetLocation()
This function resets the location of the walker in the comment list to where the current cursor is. |
String |
simpleString()
A toString() substitute. |
int |
walkerOffset()
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
final ReducedModelBrace _rmb
final ReducedModelComment _rmc
volatile int _offset
| Constructor Detail |
|---|
public ReducedModelControl()
| Method Detail |
|---|
public int braceCursorOffset()
public int commentCursorOffset()
public int walkerOffset()
public void insertChar(char ch)
BraceReduction
insertChar in interface BraceReductionch - the character to be insertedpublic void move(int count)
move in interface BraceReductioncount - indicates the direction and magnitude of cursor movementpublic void delete(int count)
delete in interface BraceReductioncount - A number indicating the size and direction of text deletion. Negative values delete text to the left
of the cursor, positive values delete text to the right.public boolean isShadowed()
public boolean isWeaklyShadowed()
public int balanceForward()
balanceForward in interface BraceReductionbalanceBackward()public int balanceBackward()
balanceBackward in interface BraceReductionbalanceForward()public ReducedModelState moveWalkerGetState(int relDistance)
moveWalkerGetState in interface BraceReductionrelDistance - distance from walker to get state at.public void resetLocation()
resetLocation in interface BraceReductionpublic ReducedToken currentToken()
currentToken in interface BraceReductionpublic ReducedModelState getStateAtCurrent()
getStateAtCurrent in interface BraceReductionString getType()
int getSize()
int getSize(ReducedToken rmbToken,
ReducedToken rmcToken)
void next()
void prev()
public ReducedToken prevItem()
public ReducedToken nextItem()
boolean atEnd()
boolean atStart()
int getBlockOffset()
public int absOffset()
absOffset in interface BraceReductionpublic String simpleString()
simpleString in interface BraceReductionpublic int getDistToIdentNewline()
public int getDistToEnclosingBraceStart()
public BraceInfo _getLineEnclosingBrace()
public BraceInfo _getEnclosingBrace()
public int getDistToStart()
public int getDistToStart(int relLoc)
getDistToStart in interface BraceReductionpublic int getDistToNextNewline()
BraceReduction
getDistToNextNewline in interface BraceReduction
public ArrayList<HighlightStatus> getHighlightStatus(int start,
int length)
getHighlightStatus in interface BraceReductionstart - The start location of the area being inspected. The reduced model cursor is already set at this
position, but this value is needed to compute the absolute positions of HighlightStatus objects.length - The length of the text segment for which status information must be generated.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||