Changeset 37 in default for trunk/de.ugoe.cs.swe.bnftools.ebnf.ui/src/de/ugoe/cs/swe/bnftools/ui/formatter/EbnfFormatterVisitor.java
- Timestamp:
- 11/04/10 11:24:11 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/de.ugoe.cs.swe.bnftools.ebnf.ui/src/de/ugoe/cs/swe/bnftools/ui/formatter/EbnfFormatterVisitor.java
r34 r37 69 69 } 70 70 71 pr ivateboolean isCommentNode(LeafNode node) {71 protected boolean isCommentNode(LeafNode node) { 72 72 if ((node.getText().trim().startsWith("//") || node.getText().trim().startsWith("/*")) && (node.isHidden())) 73 73 return true; … … 75 75 } 76 76 77 pr ivatevoid collectAllComments(CompositeNode node) {77 protected void collectAllComments(CompositeNode node) { 78 78 for (int i=0; i < node.getChildren().size(); i++) { 79 79 AbstractNode currentNode = node.getChildren().get(i); … … 91 91 } 92 92 93 pr ivateboolean isSingleLineComment(String str) {93 protected boolean isSingleLineComment(String str) { 94 94 if (str.startsWith("//")) 95 95 return true; … … 97 97 } 98 98 99 pr ivateboolean isMultiLineComment(String str) {99 protected boolean isMultiLineComment(String str) { 100 100 if (str.startsWith("/*")) 101 101 return true; … … 103 103 } 104 104 105 pr ivateboolean isWhitespace(char ch) {105 protected boolean isWhitespace(char ch) { 106 106 if ((ch==' ') || (ch == '\t') || (ch == '\n') || (ch == '\r')) 107 107 return true; … … 109 109 } 110 110 111 pr ivatevoid skipWhitespacesOriginalText() {111 protected void skipWhitespacesOriginalText() { 112 112 while (bufferPositionOriginalText < originalText.length() && isWhitespace(originalText.charAt(bufferPositionOriginalText))) { 113 113 bufferPositionOriginalText++; … … 115 115 } 116 116 117 pr ivatevoid skipWhitespacesFormattedText(StringBuffer result) {117 protected void skipWhitespacesFormattedText(StringBuffer result) { 118 118 while (bufferPositionFormattedText < formattedText.length() && isWhitespace(formattedText.charAt(bufferPositionFormattedText))) { 119 119 result.append(formattedText.substring(bufferPositionFormattedText, bufferPositionFormattedText+1)); … … 122 122 } 123 123 124 pr ivateboolean isSingleLineCommentNext(String str, int position) {124 protected boolean isSingleLineCommentNext(String str, int position) { 125 125 if ((str.charAt(position) == '/') && (str.charAt(position) == '/')) 126 126 return true; … … 128 128 } 129 129 130 pr ivateboolean isMultiLineCommentNext(String str, int position) {130 protected boolean isMultiLineCommentNext(String str, int position) { 131 131 if ((str.charAt(position) == '/') && (str.charAt(position) == '*')) 132 132 return true; … … 134 134 } 135 135 136 pr ivateboolean isCommentNext(String str, int position) {136 protected boolean isCommentNext(String str, int position) { 137 137 if (isSingleLineCommentNext(str, position) || isMultiLineCommentNext(str, position)) 138 138 return true; … … 141 141 } 142 142 143 pr ivateString scanBackWhitespaces(String str, int position) {143 protected String scanBackWhitespaces(String str, int position) { 144 144 StringBuffer whiteSpaces = new StringBuffer(); 145 145 int currentPosition = position; … … 151 151 } 152 152 153 pr ivateString stripEndingNewline(String str) {153 protected String stripEndingNewline(String str) { 154 154 int position = str.length() - 1; 155 155 while ((str.charAt(position) == '\n') || (str.charAt(position) == '\r')) { … … 159 159 } 160 160 161 pr ivateint scanBackNewlinesCount(String str, int position) {161 protected int scanBackNewlinesCount(String str, int position) { 162 162 int newLinesCount = 0; 163 163 int currentPosition = position; … … 179 179 } 180 180 181 pr ivatevoid weaveComments() {181 protected void weaveComments() { 182 182 bufferPositionOriginalText = 0; 183 183 bufferPositionFormattedTextNoWhitespaces = 0; … … 255 255 } 256 256 257 pr ivatevoid newLine() {257 protected void newLine() { 258 258 buf.append("\n"); 259 259 if ((ruleSpacingStack != null) && (!ruleSpacingStack.empty())) { … … 264 264 } 265 265 266 pr ivatevoid text(String str) {266 protected void text(String str) { 267 267 buf.append(str); 268 268 newLineOffsetCounter += str.length(); 269 269 } 270 270 271 pr ivatevoid space() {271 protected void space() { 272 272 buf.append(" "); 273 273 newLineOffsetCounter++; 274 274 } 275 275 276 pr ivatevoid spaces(int count) {276 protected void spaces(int count) { 277 277 for (int i=0; i < count; i++) { 278 278 buf.append(" "); … … 280 280 } 281 281 282 pr ivateboolean lastIsClosingParentheses() {282 protected boolean lastIsClosingParentheses() { 283 283 char ch = buf.toString().charAt(buf.toString().length()-1); 284 284 if ((ch == ')') || (ch == ']') || (ch == '}')) … … 287 287 } 288 288 289 pr ivatevoid wrap() {289 protected void wrap() { 290 290 if ((config.isWrapAfterThreshold()) && (newLineOffsetCounter > config.getWrapThreshold())) { 291 291 char last = buf.toString().charAt(buf.toString().length()-1);
Note: See TracChangeset
for help on using the changeset viewer.