Skip to content

Commit c2ebb97

Browse files
committed
rename tool->dbg (a shitty name still) must refactor. add Tool as the main tool usage.
1 parent 6839868 commit c2ebb97

33 files changed

Lines changed: 1008 additions & 852 deletions

src/org/antlr/codebuff/Corpus.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@
1919
import java.util.Map;
2020
import java.util.Random;
2121

22-
import static org.antlr.codebuff.Tool.getFilenames;
23-
import static org.antlr.codebuff.Tool.getLexer;
24-
import static org.antlr.codebuff.Tool.getParser;
25-
import static org.antlr.codebuff.Tool.load;
26-
import static org.antlr.codebuff.Tool.showFileNames;
22+
import static org.antlr.codebuff.Dbg.getFilenames;
23+
import static org.antlr.codebuff.Dbg.getLexer;
24+
import static org.antlr.codebuff.Dbg.getParser;
25+
import static org.antlr.codebuff.Dbg.load;
26+
import static org.antlr.codebuff.Dbg.showFileNames;
2727

2828
public class Corpus {
2929
public static final int FEATURE_VECTOR_RANDOM_SEED = 314159; // need randomness but use same seed to get reproducibility

src/org/antlr/codebuff/Dbg.java

Lines changed: 735 additions & 0 deletions
Large diffs are not rendered by default.

src/org/antlr/codebuff/Formatter.java

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@
1818
import java.util.Map;
1919
import java.util.Vector;
2020

21-
import static org.antlr.codebuff.Tool.normalizedLevenshteinDistance;
22-
import static org.antlr.codebuff.Tool.tokenText;
23-
import static org.antlr.codebuff.Tool.tokenize;
21+
import static org.antlr.codebuff.Dbg.normalizedLevenshteinDistance;
22+
import static org.antlr.codebuff.Dbg.tokenText;
23+
import static org.antlr.codebuff.Dbg.tokenize;
2424
import static org.antlr.codebuff.Trainer.CAT_ALIGN;
2525
import static org.antlr.codebuff.Trainer.CAT_ALIGN_WITH_ANCESTOR_CHILD;
2626
import static org.antlr.codebuff.Trainer.CAT_INDENT;
@@ -147,7 +147,7 @@ public String format(InputDocument doc, boolean collectAnalysis) throws Exceptio
147147

148148
String prefix = originalTokens.getText(Interval.of(0, firstToken.getTokenIndex())); // gets any comments in front + first real token
149149
charPosInLine = firstToken.getCharPositionInLine()+firstToken.getText().length()+1; // start where first token left off
150-
line = Tool.count(prefix, '\n') + 1;
150+
line = Dbg.count(prefix, '\n') + 1;
151151
output.append(prefix);
152152

153153
// first identify oversize lists with separators
@@ -210,7 +210,7 @@ else if ( (injectNL_WS&0xFF)==CAT_INJECT_WS ) {
210210
int alignOrIndent = CAT_ALIGN;
211211

212212
if ( newlines>0 ) {
213-
output.append(Tool.newlines(newlines));
213+
output.append(Dbg.newlines(newlines));
214214
line+=newlines;
215215
charPosInLine = 0;
216216

@@ -231,7 +231,7 @@ else if ( (alignOrIndent&0xFF)==CAT_ALIGN ) {
231231
Token firstTokenOnPrevLine = tokensOnPreviousLine.get(0);
232232
int indentCol = firstTokenOnPrevLine.getCharPositionInLine();
233233
charPosInLine = indentCol;
234-
output.append(Tool.spaces(indentCol));
234+
output.append(Dbg.spaces(indentCol));
235235
}
236236
}
237237
else if ( (alignOrIndent&0xFF)==CAT_INDENT ) {
@@ -240,7 +240,7 @@ else if ( (alignOrIndent&0xFF)==CAT_INDENT ) {
240240
}
241241
else {
242242
// inject whitespace instead of \n?
243-
output.append(Tool.spaces(ws));
243+
output.append(Dbg.spaces(ws));
244244
charPosInLine += ws;
245245
}
246246

@@ -275,12 +275,12 @@ public void indent(int indentCat, TerminalNode node) {
275275
if ( firstTokenOnPrevLine!=null ) { // if not on first line, we cannot indent
276276
int indentedCol = firstTokenOnPrevLine.getCharPositionInLine()+indentSize;
277277
charPosInLine = indentedCol;
278-
output.append(Tool.spaces(indentedCol));
278+
output.append(Dbg.spaces(indentedCol));
279279
}
280280
else {
281281
// no prev token? ok, just indent from left edge
282282
charPosInLine = indentSize;
283-
output.append(Tool.spaces(indentSize));
283+
output.append(Dbg.spaces(indentSize));
284284
}
285285
return;
286286
}
@@ -309,7 +309,7 @@ else if ( child instanceof TerminalNode ) {
309309
if ( start!=null ) {
310310
int indentCol = start.getCharPositionInLine()+indentSize;
311311
charPosInLine = indentCol;
312-
output.append(Tool.spaces(indentCol));
312+
output.append(Dbg.spaces(indentCol));
313313
}
314314
}
315315

@@ -339,7 +339,7 @@ else if (child instanceof TerminalNode) {
339339
if ( start!=null ) {
340340
int indentCol = start.getCharPositionInLine();
341341
charPosInLine = indentCol;
342-
output.append(Tool.spaces(indentCol));
342+
output.append(Dbg.spaces(indentCol));
343343
}
344344
}
345345

@@ -402,7 +402,7 @@ public int emitCommentsToTheLeft(int tokenIndexInStream, int injectNL_WS) {
402402
String hiddenText = hidden.getText();
403403
output.append(hiddenText);
404404
if ( hiddenText.matches("\\n+") ) {
405-
line += Tool.count(hiddenText, '\n');
405+
line += Dbg.count(hiddenText, '\n');
406406
charPosInLine = 0;
407407
}
408408
else {

src/org/antlr/codebuff/InputDocument.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public class InputDocument {
2525

2626
public static InputDocument dup(InputDocument old) throws Exception {
2727
// reparse to get new tokens, tree
28-
return Tool.parse(old.fileName, old.language);
28+
return Dbg.parse(old.fileName, old.language);
2929
}
3030

3131
public InputDocument(String fileName, String content, LangDescriptor language) {

0 commit comments

Comments
 (0)