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

Method writeWrap

output/java8/1.4.17/AutoIndentWriter.java:184–216  ·  view source on GitHub ↗
(String wrap)

Source from the content-addressed store, hash-verified

182 }
183
184 @Override
185 public int writeWrap(String wrap) throws IOException {
186 int n = 0;
187 // if want wrap and not already at start of line (last char was \n)
188 // and we have hit or exceeded the threshold
189 if ( lineWidth!= NO_WRAP && wrap!=null && !atStartOfLine && charPosition>=lineWidth ) {
190 // ok to wrap
191 // Walk wrap string and look for A\nB. Spit out A\n
192 // then spit indent or anchor, whichever is larger
193 // then spit out B.
194 for (int i = 0; i< wrap.length(); i++) {
195 char c = wrap.charAt(i);
196 if ( c=='\r' ) {
197 continue;
198 }
199 else if ( c=='\n' ) {
200 out.write(newline);
201 n += newline.length();
202 charPosition = 0;
203 charIndex += newline.length();
204 n += indent();
205 // continue writing any chars out
206 }
207 else { // write A or B part
208 n++;
209 out.write(c);
210 charPosition++;
211 charIndex++;
212 }
213 }
214 }
215 return n;
216 }
217
218 public int indent() throws IOException {
219 int n = 0;

Callers 1

writeMethod · 0.95

Calls 3

indentMethod · 0.95
writeMethod · 0.65
lengthMethod · 0.45

Tested by

no test coverage detected