MCPcopy Create free account
hub / github.com/antlr/codebuff / write

Method write

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

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