001: /*BEGIN_COPYRIGHT_BLOCK
002: *
003: * Copyright (c) 2001-2007, JavaPLT group at Rice University (javaplt@rice.edu)
004: * All rights reserved.
005: *
006: * Redistribution and use in source and binary forms, with or without
007: * modification, are permitted provided that the following conditions are met:
008: * * Redistributions of source code must retain the above copyright
009: * notice, this list of conditions and the following disclaimer.
010: * * Redistributions in binary form must reproduce the above copyright
011: * notice, this list of conditions and the following disclaimer in the
012: * documentation and/or other materials provided with the distribution.
013: * * Neither the names of DrJava, the JavaPLT group, Rice University, nor the
014: * names of its contributors may be used to endorse or promote products
015: * derived from this software without specific prior written permission.
016: *
017: * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
018: * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
019: * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
020: * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
021: * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
022: * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
023: * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
024: * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
025: * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
026: * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
027: * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
028: *
029: * This software is Open Source Initiative approved Open Source Software.
030: * Open Source Initative Approved is a trademark of the Open Source Initiative.
031: *
032: * This file is part of DrJava. Download the current version of this project
033: * from http://www.drjava.org/ or http://sourceforge.net/projects/drjava/
034: *
035: * END_COPYRIGHT_BLOCK*/
036:
037: package edu.rice.cs.drjava.model.definitions.reducedmodel;
038:
039: import java.util.Vector;
040:
041: /**
042: * The interface BraceReduction serves as the template for our reduced
043: * view of a java document, which stores only the information necessary
044: * for parenthesis matching.
045: * @version $Id: BraceReduction.java 4255 2007-08-28 19:17:37Z mgricken $
046: * @author JavaPLT
047: */
048:
049: public interface BraceReduction {
050: /**
051: * Get the absolute character offset of the document represented by BraceReduction.
052: */
053: public int absOffset();
054:
055: /**
056: * Get the current token in the BraceReduction.
057: * @return the current token
058: */
059: ReducedToken currentToken();
060:
061: /**
062: * Get the state of the token at the current cursor position.
063: * @return the current state
064: */
065: ReducedModelState getStateAtCurrent();
066:
067: /**
068: * Insert a character into the BraceReduction.
069: * @param ch the character to be inserted
070: */
071: public void insertChar(char ch);
072:
073: /**
074: * <P>Updates the BraceReduction to reflect cursor movement.
075: * Negative values move left from the cursor, positive values move
076: * right. </P>
077: * @param count indicates the direction and magnitude of cursor movement
078: */
079: public void move(int count);
080:
081: /**
082: * <P>Update the BraceReduction to reflect text deletion.</P>
083: * @param count indicates the size and direction of text deletion.
084: * Negative values delete text to the left of the cursor, positive
085: * values delete text to the right.
086: */
087: public void delete(int count);
088:
089: /**
090: * <P>Finds the closing brace that matches the next significant
091: * brace iff that brace is an open brace.</P>
092: * @return the distance until the matching closing brace. On
093: * failure, returns -1.
094: * @see #balanceBackward()
095: */
096: public int balanceForward();
097:
098: /**
099: * <P>Finds the open brace that matches the previous significant
100: * brace iff that brace is an closing brace.</P>
101: * @return the distance until the matching open brace. On
102: * failure, returns -1.
103: * @see #balanceForward()
104: */
105: public int balanceBackward();
106:
107: /** Gets the distance to the enclosing brace. */
108: public IndentInfo getIndentInformation();
109:
110: /** Gets distance to enclosing new line */
111: public int getDistToPreviousNewline(int relativeLoc);
112:
113: /** Gets distance to next new line. */
114: public int getDistToNextNewline();
115:
116: /** A simplified toString() method. */
117: public String simpleString();
118:
119: /**
120: * Return all highlight status info for text between the current
121: * location and current location + end.
122: * This should collapse adjoining blocks with the same status into one.
123: * @param start The starting location of the area we want to get status of.
124: * The reduced model is already at this position, but the
125: * parameter is needed to determine the absolute positions
126: * needed in the HighlightStatus objects we return.
127: * @param length How far should we generate info for?
128: */
129: public Vector<HighlightStatus> getHighlightStatus(int start,
130: int length);
131:
132: /**
133: *Returns the state at the relLocation, where relLocation is the location
134: *relative to the walker
135: *@param relLocation distance from walker to get state at.
136: */
137: public ReducedModelState moveWalkerGetState(int relLocation);
138:
139: /**
140: * Resets the location of the walker in the comment list to where the
141: * current cursor is.
142: */
143: public void resetLocation();
144: }
|