1 33 34 package edu.rice.cs.drjava.model.definitions.reducedmodel; 35 36 40 public abstract class ReducedToken implements ReducedModelStates { 41 private ReducedModelState _state; 42 43 public ReducedToken(ReducedModelState state) { 44 _state = state; 45 } 46 47 50 public abstract int getSize(); 51 52 55 public abstract String getType(); 56 57 60 public abstract void setType(String type); 61 62 63 public abstract void flip(); 64 65 69 public abstract boolean isMatch(ReducedToken other); 70 71 74 public ReducedModelState getState() { return _state; } 75 76 79 public int getHighlightState() { 80 String type = getType(); 81 if (type.equals("//") || (_state == INSIDE_LINE_COMMENT) || type.equals("/*") 82 || type.equals("*/") || (_state == INSIDE_BLOCK_COMMENT)) { 83 return HighlightStatus.COMMENTED; 84 } 85 if ((type.equals("'") && (_state == FREE)) || (_state == INSIDE_SINGLE_QUOTE)) { 86 return HighlightStatus.SINGLE_QUOTED; 87 } 88 if ((type.equals("\"") && (_state == FREE)) || (_state == INSIDE_DOUBLE_QUOTE)) { 89 return HighlightStatus.DOUBLE_QUOTED; 90 } 91 return HighlightStatus.NORMAL; 92 } 93 94 97 public void setState(ReducedModelState state) { 98 _state = state; 99 } 100 101 105 public boolean isShadowed() { return _state != FREE; } 106 107 110 public boolean isQuoted() { 111 return _state == INSIDE_DOUBLE_QUOTE; 112 } 113 114 117 public boolean isCommented() { return inBlockComment() || inLineComment(); } 118 119 122 public boolean inBlockComment() { return _state == INSIDE_BLOCK_COMMENT; } 123 124 127 public boolean inLineComment() { return _state == INSIDE_LINE_COMMENT; } 128 129 132 public abstract boolean isMultipleCharBrace(); 133 134 137 public abstract boolean isGap(); 138 139 142 public abstract boolean isLineComment(); 143 144 147 public abstract boolean isBlockCommentStart(); 148 149 152 public abstract boolean isBlockCommentEnd(); 153 154 158 public abstract boolean isNewline(); 159 160 163 public abstract boolean isSlash(); 164 165 168 public abstract boolean isStar(); 169 170 173 public abstract boolean isDoubleQuote(); 174 175 178 public abstract boolean isSingleQuote(); 179 180 183 public abstract boolean isDoubleEscapeSequence(); 184 185 188 public abstract boolean isDoubleEscape(); 189 190 193 public abstract boolean isEscapedSingleQuote(); 194 195 198 public abstract boolean isEscapedDoubleQuote(); 199 200 203 public abstract void grow(int delta); 204 205 208 public abstract void shrink(int delta); 209 210 213 public abstract boolean isOpen(); 214 215 218 public abstract boolean isClosed(); 219 220 223 public abstract boolean isOpenBrace(); 224 225 228 public abstract boolean isClosedBrace(); 229 } 230 231 232 233 | Popular Tags |