()
| 250 | } |
| 251 | |
| 252 | collectComments() { |
| 253 | if (!this.config.comment) { |
| 254 | this.scanner.scanComments(); |
| 255 | } else { |
| 256 | const comments: Comment[] = this.scanner.scanComments(); |
| 257 | if (comments.length > 0 && this.delegate) { |
| 258 | for (let i = 0; i < comments.length; ++i) { |
| 259 | const e: Comment = comments[i]; |
| 260 | let node; |
| 261 | node = { |
| 262 | type: e.multiLine ? 'BlockComment' : 'LineComment', |
| 263 | value: this.scanner.source.slice(e.slice[0], e.slice[1]) |
| 264 | }; |
| 265 | if (this.config.range) { |
| 266 | node.range = e.range; |
| 267 | } |
| 268 | if (this.config.loc) { |
| 269 | node.loc = e.loc; |
| 270 | } |
| 271 | const metadata = { |
| 272 | start: { |
| 273 | line: e.loc.start.line, |
| 274 | column: e.loc.start.column, |
| 275 | offset: e.range[0] |
| 276 | }, |
| 277 | end: { |
| 278 | line: e.loc.end.line, |
| 279 | column: e.loc.end.column, |
| 280 | offset: e.range[1] |
| 281 | } |
| 282 | }; |
| 283 | this.delegate(node, metadata); |
| 284 | } |
| 285 | } |
| 286 | } |
| 287 | } |
| 288 | |
| 289 | // From internal representation to an external structure |
| 290 |
no test coverage detected