MCPcopy
hub / github.com/jquery/esprima / skipSingleLineComment

Method skipSingleLineComment

src/scanner.ts:112–169  ·  view source on GitHub ↗
(offset: number)

Source from the content-addressed store, hash-verified

110 // https://tc39.github.io/ecma262/#sec-comments
111
112 private skipSingleLineComment(offset: number): Comment[] {
113 let comments: Comment[] = [];
114 let start, loc;
115
116 if (this.trackComment) {
117 comments = [];
118 start = this.index - offset;
119 loc = {
120 start: {
121 line: this.lineNumber,
122 column: this.index - this.lineStart - offset
123 },
124 end: {}
125 };
126 }
127
128 while (!this.eof()) {
129 const ch = this.source.charCodeAt(this.index);
130 ++this.index;
131 if (Character.isLineTerminator(ch)) {
132 if (this.trackComment) {
133 loc.end = {
134 line: this.lineNumber,
135 column: this.index - this.lineStart - 1
136 };
137 const entry: Comment = {
138 multiLine: false,
139 slice: [start + offset, this.index - 1],
140 range: [start, this.index - 1],
141 loc: loc
142 };
143 comments.push(entry);
144 }
145 if (ch === 13 && this.source.charCodeAt(this.index) === 10) {
146 ++this.index;
147 }
148 ++this.lineNumber;
149 this.lineStart = this.index;
150 return comments;
151 }
152 }
153
154 if (this.trackComment) {
155 loc.end = {
156 line: this.lineNumber,
157 column: this.index - this.lineStart
158 };
159 const entry: Comment = {
160 multiLine: false,
161 slice: [start + offset, this.index],
162 range: [start, this.index],
163 loc: loc
164 };
165 comments.push(entry);
166 }
167
168 return comments;
169 }

Callers 1

scanCommentsMethod · 0.95

Calls 2

eofMethod · 0.95
pushMethod · 0.80

Tested by

no test coverage detected