(value: any, offset: number, length: number, pathSupplier: () => jsonc.JSONPath)
| 253 | } |
| 254 | |
| 255 | onLiteralValue(value: any, offset: number, length: number, pathSupplier: () => jsonc.JSONPath) { |
| 256 | if (this.parseErrors.length > 0) { |
| 257 | return; |
| 258 | } |
| 259 | |
| 260 | let node: ParseNode | undefined = undefined; |
| 261 | let errors = undefined; |
| 262 | const path = this.genPath(pathSupplier); |
| 263 | |
| 264 | if (this.options?.nest && maybeIterable(value)) { |
| 265 | const { root, nodeMap, parseErrors } = doParseJSON(value, this.options, { path }); |
| 266 | node = root; |
| 267 | errors = parseErrors; |
| 268 | |
| 269 | if (node && isEmpty(errors)) { |
| 270 | for (const key in nodeMap) { |
| 271 | const nd = nodeMap[key]; |
| 272 | this.nodeMap[nd.id] = nd; |
| 273 | } |
| 274 | |
| 275 | // boundOffset and boundLength will be fixed in stringifyNestNodes or stringify |
| 276 | node.offset = offset; |
| 277 | node.length = length; |
| 278 | this.nestNodeMap[node.id] = node; |
| 279 | } else { |
| 280 | node = undefined; |
| 281 | } |
| 282 | } |
| 283 | |
| 284 | if (node === undefined) { |
| 285 | node = this.newNode(path, getNodeType(value), offset, length); |
| 286 | this.setValue(node, value, offset, length); |
| 287 | } |
| 288 | |
| 289 | this.addChild(node); |
| 290 | } |
| 291 | |
| 292 | onError(error: jsonc.ParseErrorCode, offset: number, length: number) { |
| 293 | this.parseErrors.push({ error, offset, length }); |
no test coverage detected