1 | "use strict";
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 | Object.defineProperty(exports, "__esModule", { value: true });
|
16 | const document_1 = require("../parser/document");
|
17 | class ParsedJsonDocument extends document_1.ParsedDocument {
|
18 | constructor() {
|
19 | super(...arguments);
|
20 | this.type = 'json';
|
21 | }
|
22 | visit(visitors) {
|
23 | this._visit(this.ast, visitors);
|
24 | }
|
25 | _visit(node, visitors) {
|
26 | for (const visitor of visitors) {
|
27 | visitor.visit(node);
|
28 | }
|
29 | if (Array.isArray(node)) {
|
30 | for (const value of node) {
|
31 | this._visit(value, visitors);
|
32 | }
|
33 | }
|
34 | else if (typeof node === 'object' && node !== null) {
|
35 | for (const value of Object.values(node)) {
|
36 | this._visit(value, visitors);
|
37 | }
|
38 | }
|
39 | }
|
40 | _sourceRangeForNode(_node) {
|
41 | throw new Error('Not Implemented.');
|
42 | }
|
43 | stringify(options = {}) {
|
44 | const { prettyPrint = true, indent = 2 } = options;
|
45 | return JSON.stringify(this.ast, null, prettyPrint ? indent : 0);
|
46 | }
|
47 | }
|
48 | exports.ParsedJsonDocument = ParsedJsonDocument;
|
49 |
|
\ | No newline at end of file |