MCPcopy Index your code
hub / github.com/antlr/codebuff / expandTabs

Method expandTabs

src/org/antlr/codebuff/Tool.java:504–527  ·  view source on GitHub ↗
(String s, int tabSize)

Source from the content-addressed store, hash-verified

502 }
503
504 public static String expandTabs(String s, int tabSize) {
505 if ( s==null ) return null;
506 StringBuilder buf = new StringBuilder();
507 int col = 0;
508 for (int i = 0; i<s.length(); i++) {
509 char c = s.charAt(i);
510 switch ( c ) {
511 case '\n' :
512 col = 0;
513 buf.append(c);
514 break;
515 case '\t' :
516 int n = tabSize-col%tabSize;
517 col+=n;
518 buf.append(spaces(n));
519 break;
520 default :
521 col++;
522 buf.append(c);
523 break;
524 }
525 }
526 return buf.toString();
527 }
528
529 public static String dumpWhiteSpace(String s) {
530 String[] whiteSpaces = new String[s.length()];

Callers 1

loadMethod · 0.95

Calls 4

spacesMethod · 0.95
toStringMethod · 0.65
lengthMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected