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

Method add

output/java_guava/1.4.17/LineBuffer.java:53–85  ·  view source on GitHub ↗

Process additional characters from the stream. When a line separator is found the contents of the line and the line separator itself are passed to the abstract #handleLine method. @param cbuf the character buffer to process @param off the offset into the buffer @param len the number of char

(char[] cbuf, int off, int len)

Source from the content-addressed store, hash-verified

51
52
53 protected void add(char[] cbuf, int off, int len) throws IOException {
54 int pos = off;
55 if (sawReturn && len > 0) {
56 // Last call to add ended with a CR; we can handle the line now.
57 if (finishLine(cbuf[pos] == '\n')) {
58 pos++;
59 }
60 }
61 int start = pos;
62 for (int end = off + len; pos < end; pos++) {
63 switch (cbuf [pos]) {
64 case '\r':
65 line.append(cbuf, start, pos - start);
66 sawReturn = true;
67 if (pos + 1 < end) {
68 if (finishLine(cbuf[pos + 1] == '\n')) {
69 pos++;
70 }
71 }
72 start = pos + 1;
73 break;
74 case '\n':
75 line.append(cbuf, start, pos - start);
76 finishLine(true);
77 start = pos + 1;
78 break;
79 default:
80 // do nothing
81
82 }
83 }
84 line.append(cbuf, start, off + len - start);
85 }
86
87 /** Called when a line is complete. */
88

Callers

nothing calls this directly

Calls 2

finishLineMethod · 0.95
appendMethod · 0.45

Tested by

no test coverage detected