| java.lang.Object edu.rice.cs.drjava.model.definitions.reducedmodel.AbstractReducedModel edu.rice.cs.drjava.model.definitions.reducedmodel.ReducedModelBrace
ReducedModelBrace | public class ReducedModelBrace extends AbstractReducedModel (Code) | | Keeps track of the true braces (i.e., "() {}[]"). This reduced sub-model is used to balance braces for both
indenting and highlighting purposes. For example, when the user's caret is immediately after a closing brace,
this allows the DefinitionsPane to produced a highlight extending from the closing brace to its match.
version: $Id: ReducedModelBrace.java 4255 2007-08-28 19:17:37Z mgricken $ author: JavaPLT |
Method Summary | |
public int | balanceBackward() | public int | balanceForward() If the current ReducedToken is an open significant brace and the offset is 0 (i.e., if we're immediately left of
said brace), push the current Brace onto a Stack and iterate forwards, keeping track of the distance covered.
- For every closed significant Brace, if it matches the top of the Stack, pop the Stack. | public boolean | closedBraceImmediatelyLeft() | public void | delete(int count) Updates ReducedModelBrace to reflect text deletion.
Negative values mean text left of the cursor, positive values mean
text to the right. | protected void | getDistToEnclosingBrace(IndentInfo braceInfo) Finds distance to enclosing brace on a preceding line. | protected void | getDistToEnclosingBraceCurrent(IndentInfo braceInfo) Find the enclosing brace enclosing our current location. | public void | insertChar(char ch) | protected void | insertGapBetweenMultiCharBrace(int length) Inserts a gap between the characters in a multiple character brace. | public void | move(int count) Updates ReducedModelBrace to reflect cursor movement.
Negative values move left from the cursor, positive values move
right. | protected ReducedModelState | moveWalkerGetState(int relDistance) | public int | nextBrace() Goes to the location before the brace. | public boolean | openBraceImmediatelyLeft() | public int | previousBrace() Returns distance from current location of cursor to the location of the
previous significant brace.
ex. | protected void | resetWalkerLocationToCursor() |
balanceBackward | public int balanceBackward()(Code) | | |
balanceForward | public int balanceForward()(Code) | | If the current ReducedToken is an open significant brace and the offset is 0 (i.e., if we're immediately left of
said brace), push the current Brace onto a Stack and iterate forwards, keeping track of the distance covered.
- For every closed significant Brace, if it matches the top of the Stack, pop the Stack. Increase the distance
by the size of the Brace. If the Stack is Empty, we have a balance. Return distance. If the closed Brace does
not match the top of the Stack, return -1; We have an unmatched open Brace at the top of the Stack.
- For every open significant Brace, push onto the Stack. Increase distance by size of the Brace, continue.
- Anything else, increase distance by size of the ReducedToken, continue.
|
closedBraceImmediatelyLeft | public boolean closedBraceImmediatelyLeft()(Code) | | |
delete | public void delete(int count)(Code) | | Updates ReducedModelBrace to reflect text deletion.
Negative values mean text left of the cursor, positive values mean
text to the right. All functionality has been refactored into TokenList.
|
getDistToEnclosingBrace | protected void getDistToEnclosingBrace(IndentInfo braceInfo)(Code) | | Finds distance to enclosing brace on a preceding line. The field braceInfo.distToNewline holds the distance to
the previous newline. To find the enclosing brace one must first move past this newline. The distance held in
this variable is only to the space in front of the newline hence you must move back that distance + 1.
|
getDistToEnclosingBraceCurrent | protected void getDistToEnclosingBraceCurrent(IndentInfo braceInfo)(Code) | | Find the enclosing brace enclosing our current location.
|
insertChar | public void insertChar(char ch)(Code) | | |
insertGapBetweenMultiCharBrace | protected void insertGapBetweenMultiCharBrace(int length)(Code) | | Inserts a gap between the characters in a multiple character brace.
However, since ReducedModelBrace doesn't keep track of the comment
braces and escape sequences, we just throw an exception since the
condition in insertGap that spawns this method doesn't arise.
|
move | public void move(int count)(Code) | | Updates ReducedModelBrace to reflect cursor movement.
Negative values move left from the cursor, positive values move
right. All functionality has been refactored into TokenList.
Parameters: count - indicates the direction and magnitude of cursor movement |
nextBrace | public int nextBrace()(Code) | | Goes to the location before the brace. |...( where | is the cursor,
returns three since it is three moves to the location of the (
NOTE: /|* returns the next brace. It does not return this brace because
you are past it.
|
openBraceImmediatelyLeft | public boolean openBraceImmediatelyLeft()(Code) | | |
previousBrace | public int previousBrace()(Code) | | Returns distance from current location of cursor to the location of the
previous significant brace.
ex. (...|) where | signifies the cursor. previousBrace returns 4 because
it goes to the spot behind the (.
/|* returns this brace since you're in the middle of it and going
backward can find it.
|
resetWalkerLocationToCursor | protected void resetWalkerLocationToCursor()(Code) | | |
|
|