|
|||||||||||||||||||
| Source file | Conditionals | Statements | Methods | TOTAL | |||||||||||||||
| IndentInfo.java | - | 0% | 0% | 0% |
|
||||||||||||||
| 1 | /*BEGIN_COPYRIGHT_BLOCK | |
| 2 | * | |
| 3 | * Copyright (c) 2001-2010, JavaPLT group at Rice University (drjava@rice.edu) | |
| 4 | * All rights reserved. | |
| 5 | * | |
| 6 | * Redistribution and use in source and binary forms, with or without | |
| 7 | * modification, are permitted provided that the following conditions are met: | |
| 8 | * * Redistributions of source code must retain the above copyright | |
| 9 | * notice, this list of conditions and the following disclaimer. | |
| 10 | * * Redistributions in binary form must reproduce the above copyright | |
| 11 | * notice, this list of conditions and the following disclaimer in the | |
| 12 | * documentation and/or other materials provided with the distribution. | |
| 13 | * * Neither the names of DrJava, the JavaPLT group, Rice University, nor the | |
| 14 | * names of its contributors may be used to endorse or promote products | |
| 15 | * derived from this software without specific prior written permission. | |
| 16 | * | |
| 17 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | |
| 18 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | |
| 19 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | |
| 20 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR | |
| 21 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | |
| 22 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | |
| 23 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | |
| 24 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF | |
| 25 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | |
| 26 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | |
| 27 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
| 28 | * | |
| 29 | * This software is Open Source Initiative approved Open Source Software. | |
| 30 | * Open Source Initative Approved is a trademark of the Open Source Initiative. | |
| 31 | * | |
| 32 | * This file is part of DrJava. Download the current version of this project | |
| 33 | * from http://www.drjava.org/ or http://sourceforge.net/projects/drjava/ | |
| 34 | * | |
| 35 | * END_COPYRIGHT_BLOCK*/ | |
| 36 | ||
| 37 | package edu.rice.cs.drjava.model.definitions.reducedmodel; | |
| 38 | ||
| 39 | /** Indent information block. | |
| 40 | * @version $Id: IndentInfo.java 5175 2010-01-20 08:46:32Z mgricken $ | |
| 41 | */ | |
| 42 | public class IndentInfo { | |
| 43 | private String _lineEnclosingBraceType; //the type of brace at the beginning of our line | |
| 44 | ||
| 45 | //the distance to the start of the line containing the brace that encloses the start of our line. | |
| 46 | //____\n|_____ | |
| 47 | private int _distToLineEnclosingBraceStart; /* formerly distToNewline */ | |
| 48 | ||
| 49 | //distance to the brace enclosing the start of our line ____|{_____ | |
| 50 | private int _distToLineEnclosingBrace; /* formerly distToBrace */ | |
| 51 | ||
| 52 | private String _enclosingBraceType; /* formely braceTypeCurrent */ // type of brace enclosing current location | |
| 53 | ||
| 54 | // distance to the start of the line containing the brace enclosing the current location | |
| 55 | private int _distToEnclosingBraceStart; /* formerly distToNewlineCurrent */ | |
| 56 | ||
| 57 | // distance to the brace enclosing the current location | |
| 58 | private int _distToEnclosingBrace; /* formerly distToBraceCurrent */ | |
| 59 | ||
| 60 | //the distance to the start of the current line | |
| 61 | private int _distToStart; /* formerly distToStart */ | |
| 62 | ||
| 63 | static public final String NONE = ""; /* formely noBrace */ | |
| 64 | static public final String OPEN_CURLY = "{"; /* formerly openCurly */ | |
| 65 | static public final String OPEN_PAREN = "("; /* formerly openParen */ | |
| 66 | static public final String OPEN_BRACKET = "["; /* formerly openBracket */ | |
| 67 | ||
| 68 | /** Creates an IndentInfo with default values. */ | |
| 69 | 0 | public IndentInfo() { |
| 70 | 0 | _lineEnclosingBraceType = NONE; |
| 71 | 0 | _distToLineEnclosingBraceStart = -1; |
| 72 | 0 | _distToLineEnclosingBrace = -1; |
| 73 | 0 | _enclosingBraceType = NONE; |
| 74 | 0 | _distToEnclosingBraceStart = -1; |
| 75 | 0 | _distToEnclosingBrace = -1; |
| 76 | 0 | _distToStart = -1; |
| 77 | } | |
| 78 | ||
| 79 | /** Creates an indent info with the specified parameters | |
| 80 | * @param lineEnclosingBraceType the enclosingBraceType | |
| 81 | * @param distToLineEnclosingBraceStart the distance to the next newline | |
| 82 | * @param distToLineEnclosingBrace the distance to a brace | |
| 83 | * @param distToStart the distance to the previous newline | |
| 84 | */ | |
| 85 | 0 | public IndentInfo(String lineEnclosingBraceType, int distToLineEnclosingBraceStart, int distToLineEnclosingBrace, |
| 86 | int distToStart) { | |
| 87 | 0 | _lineEnclosingBraceType = lineEnclosingBraceType; |
| 88 | 0 | _distToLineEnclosingBraceStart = distToLineEnclosingBraceStart; |
| 89 | 0 | _distToLineEnclosingBrace = distToLineEnclosingBrace; |
| 90 | 0 | _distToStart = distToStart; |
| 91 | } | |
| 92 | ||
| 93 | 0 | public String lineEnclosingBraceType() { return _lineEnclosingBraceType; } |
| 94 | 0 | public int distToLineEnclosingBraceStart() { return _distToLineEnclosingBraceStart; } |
| 95 | 0 | public int distToLineEnclosingBrace() { return _distToLineEnclosingBrace; } |
| 96 | 0 | public String enclosingBraceType() { return _enclosingBraceType; } |
| 97 | 0 | public int distToEnclosingBraceStart() { return _distToEnclosingBraceStart; } |
| 98 | 0 | public int distToEnclosingBrace() { return _distToEnclosingBrace; } |
| 99 | 0 | public int distToStart() { return _distToStart; } |
| 100 | ||
| 101 | 0 | public void setLineEnclosingBraceType(String t) { _lineEnclosingBraceType = t; } |
| 102 | 0 | public void setDistToLineEnclosingBraceStart(int d) { _distToLineEnclosingBraceStart = d; } |
| 103 | 0 | public void setDistToLineEnclosingBrace(int d) { _distToLineEnclosingBrace = d; } |
| 104 | 0 | public void setEnclosingBraceType(String t) { _enclosingBraceType = t; } |
| 105 | 0 | public void setDistToEnclosingBraceStart(int d) { _distToEnclosingBraceStart = d; } |
| 106 | 0 | public void setDistToEnclosingBrace(int d) { _distToEnclosingBrace = d; } |
| 107 | 0 | public void setDistToStart(int d) { _distToStart = d; } |
| 108 | ||
| 109 | 0 | public String toString() { |
| 110 | 0 | return "IdentInfo[" + _distToStart + ", " + _lineEnclosingBraceType + ", " + _distToLineEnclosingBrace + ", " + |
| 111 | _distToLineEnclosingBraceStart + ", " + _enclosingBraceType + ", " + _distToEnclosingBrace + ", " + | |
| 112 | _distToEnclosingBraceStart + "]"; | |
| 113 | } | |
| 114 | } | |
| 115 |
|
||||||||||