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

Method write

output/java8/1.4.17/AutoIndentWriter.java:133–163  ·  view source on GitHub ↗

Write out a string literal or attribute expression or expression element.

(String str)

Source from the content-addressed store, hash-verified

131 /** Write out a string literal or attribute expression or expression element. */
132
133 @Override
134 public int write(String str) throws IOException {
135 int n = 0;
136 int nll = newline.length();
137 int sl = str.length();
138 for (int i = 0; i< sl; i++) {
139 char c = str.charAt(i);
140 // found \n or \r\n newline?
141 if ( c=='\r' ) continue;
142 if ( c=='\n' ) {
143 atStartOfLine = true;
144 charPosition = -nll; // set so the write below sets to 0
145 out.write(newline);
146 n += nll;
147 charIndex += nll;
148 charPosition += n; // wrote n more char
149 continue;
150 }
151 // normal character
152 // check to see if we are at the start of a line; need indent if so
153 if ( atStartOfLine ) {
154 n += indent();
155 atStartOfLine = false;
156 }
157 n++;
158 out.write(c);
159 charPosition++;
160 charIndex++;
161 }
162 return n;
163 }
164
165 @Override
166 public int writeSeparator(String str) throws IOException {

Callers 1

writeSeparatorMethod · 0.95

Calls 4

indentMethod · 0.95
writeWrapMethod · 0.95
writeMethod · 0.65
lengthMethod · 0.45

Tested by

no test coverage detected