|
||||||||||
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.
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. |
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. |
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. |
ReducedModelState |
getStateAtCurrent()
Gets the shadowing state at the current caret position. |
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. |
ReducedToken |
nextItem()
Get the next token. |
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 |
Constructor Detail |
---|
public ReducedModelControl()
Method Detail |
---|
public int braceCursorOffset()
public int commentCursorOffset()
public int walkerOffset()
public void insertChar(char ch)
BraceReduction
insertChar
in interface BraceReduction
ch
- the character to be insertedpublic void move(int count)
move
in interface BraceReduction
count
- indicates the direction and magnitude of cursor movementpublic void delete(int count)
delete
in interface BraceReduction
count
- 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 BraceReduction
balanceBackward()
public int balanceBackward()
balanceBackward
in interface BraceReduction
balanceForward()
public ReducedModelState moveWalkerGetState(int relDistance)
moveWalkerGetState
in interface BraceReduction
relDistance
- distance from walker to get state at.public void resetLocation()
resetLocation
in interface BraceReduction
public ReducedToken currentToken()
currentToken
in interface BraceReduction
public ReducedModelState getStateAtCurrent()
getStateAtCurrent
in interface BraceReduction
public ReducedToken prevItem()
public ReducedToken nextItem()
public int absOffset()
absOffset
in interface BraceReduction
public String simpleString()
simpleString
in interface BraceReduction
public int getDistToIdentNewline()
public int getDistToEnclosingBraceStart()
public BraceInfo _getLineEnclosingBrace()
public BraceInfo _getEnclosingBrace()
public int getDistToStart()
public int getDistToStart(int relLoc)
getDistToStart
in interface BraceReduction
public int getDistToNextNewline()
BraceReduction
getDistToNextNewline
in interface BraceReduction
public ArrayList<HighlightStatus> getHighlightStatus(int start, int length)
getHighlightStatus
in interface BraceReduction
start
- 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 |