Skip to content

Commit

Permalink
Remove text from ast
Browse files Browse the repository at this point in the history
  • Loading branch information
sosukesuzuki committed Sep 14, 2021
1 parent 41e8d83 commit fe3be6b
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/cli/format.js
Expand Up @@ -127,7 +127,7 @@ function format(context, input, opt) {
}

if (context.argv["debug-print-ast"]) {
const ast = prettier.__debug.parse(input, opt);
const { ast } = prettier.__debug.parse(input, opt);
return {
formatted: JSON.stringify(ast),
};
Expand Down
@@ -1,5 +1,5 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`prints information for debugging AST --debug-print-comments (stdout) 1`] = `"{\\"text\\":\\"const foo = 'foo';\\",\\"ast\\":{\\"type\\":\\"File\\",\\"start\\":0,\\"end\\":18,\\"loc\\":{\\"start\\":{\\"line\\":1,\\"column\\":0},\\"end\\":{\\"line\\":1,\\"column\\":18}},\\"range\\":[0,18],\\"errors\\":[],\\"program\\":{\\"type\\":\\"Program\\",\\"start\\":0,\\"end\\":18,\\"loc\\":{\\"start\\":{\\"line\\":1,\\"column\\":0},\\"end\\":{\\"line\\":1,\\"column\\":18}},\\"range\\":[0,18],\\"sourceType\\":\\"module\\",\\"interpreter\\":null,\\"body\\":[{\\"type\\":\\"VariableDeclaration\\",\\"start\\":0,\\"end\\":18,\\"loc\\":{\\"start\\":{\\"line\\":1,\\"column\\":0},\\"end\\":{\\"line\\":1,\\"column\\":18}},\\"range\\":[0,18],\\"declarations\\":[{\\"type\\":\\"VariableDeclarator\\",\\"start\\":6,\\"end\\":17,\\"loc\\":{\\"start\\":{\\"line\\":1,\\"column\\":6},\\"end\\":{\\"line\\":1,\\"column\\":17}},\\"range\\":[6,17],\\"id\\":{\\"type\\":\\"Identifier\\",\\"start\\":6,\\"end\\":9,\\"loc\\":{\\"start\\":{\\"line\\":1,\\"column\\":6},\\"end\\":{\\"line\\":1,\\"column\\":9},\\"identifierName\\":\\"foo\\"},\\"range\\":[6,9],\\"name\\":\\"foo\\"},\\"init\\":{\\"type\\":\\"StringLiteral\\",\\"start\\":12,\\"end\\":17,\\"loc\\":{\\"start\\":{\\"line\\":1,\\"column\\":12},\\"end\\":{\\"line\\":1,\\"column\\":17}},\\"range\\":[12,17],\\"extra\\":{\\"rawValue\\":\\"foo\\",\\"raw\\":\\"'foo'\\"},\\"value\\":\\"foo\\"}}],\\"kind\\":\\"const\\"}],\\"directives\\":[]},\\"comments\\":[],\\"tokens\\":[{\\"type\\":{\\"label\\":\\"const\\",\\"keyword\\":\\"const\\",\\"beforeExpr\\":false,\\"startsExpr\\":false,\\"rightAssociative\\":false,\\"isLoop\\":false,\\"isAssign\\":false,\\"prefix\\":false,\\"postfix\\":false,\\"binop\\":null,\\"updateContext\\":null},\\"value\\":\\"const\\",\\"start\\":0,\\"end\\":5,\\"loc\\":{\\"start\\":{\\"line\\":1,\\"column\\":0},\\"end\\":{\\"line\\":1,\\"column\\":5}}},{\\"type\\":{\\"label\\":\\"name\\",\\"beforeExpr\\":false,\\"startsExpr\\":true,\\"rightAssociative\\":false,\\"isLoop\\":false,\\"isAssign\\":false,\\"prefix\\":false,\\"postfix\\":false,\\"binop\\":null,\\"updateContext\\":null},\\"value\\":\\"foo\\",\\"start\\":6,\\"end\\":9,\\"loc\\":{\\"start\\":{\\"line\\":1,\\"column\\":6},\\"end\\":{\\"line\\":1,\\"column\\":9}}},{\\"type\\":{\\"label\\":\\"=\\",\\"beforeExpr\\":true,\\"startsExpr\\":false,\\"rightAssociative\\":false,\\"isLoop\\":false,\\"isAssign\\":true,\\"prefix\\":false,\\"postfix\\":false,\\"binop\\":null,\\"updateContext\\":null},\\"value\\":\\"=\\",\\"start\\":10,\\"end\\":11,\\"loc\\":{\\"start\\":{\\"line\\":1,\\"column\\":10},\\"end\\":{\\"line\\":1,\\"column\\":11}}},{\\"type\\":{\\"label\\":\\"string\\",\\"beforeExpr\\":false,\\"startsExpr\\":true,\\"rightAssociative\\":false,\\"isLoop\\":false,\\"isAssign\\":false,\\"prefix\\":false,\\"postfix\\":false,\\"binop\\":null,\\"updateContext\\":null},\\"value\\":\\"foo\\",\\"start\\":12,\\"end\\":17,\\"loc\\":{\\"start\\":{\\"line\\":1,\\"column\\":12},\\"end\\":{\\"line\\":1,\\"column\\":17}}},{\\"type\\":{\\"label\\":\\";\\",\\"beforeExpr\\":true,\\"startsExpr\\":false,\\"rightAssociative\\":false,\\"isLoop\\":false,\\"isAssign\\":false,\\"prefix\\":false,\\"postfix\\":false,\\"binop\\":null,\\"updateContext\\":null},\\"start\\":17,\\"end\\":18,\\"loc\\":{\\"start\\":{\\"line\\":1,\\"column\\":17},\\"end\\":{\\"line\\":1,\\"column\\":18}}},{\\"type\\":{\\"label\\":\\"eof\\",\\"beforeExpr\\":false,\\"startsExpr\\":false,\\"rightAssociative\\":false,\\"isLoop\\":false,\\"isAssign\\":false,\\"prefix\\":false,\\"postfix\\":false,\\"binop\\":null,\\"updateContext\\":null},\\"start\\":18,\\"end\\":18,\\"loc\\":{\\"start\\":{\\"line\\":1,\\"column\\":18},\\"end\\":{\\"line\\":1,\\"column\\":18}}}]}}"`;
exports[`prints information for debugging AST --debug-print-comments (stdout) 1`] = `"{\\"type\\":\\"File\\",\\"start\\":0,\\"end\\":18,\\"loc\\":{\\"start\\":{\\"line\\":1,\\"column\\":0},\\"end\\":{\\"line\\":1,\\"column\\":18}},\\"range\\":[0,18],\\"errors\\":[],\\"program\\":{\\"type\\":\\"Program\\",\\"start\\":0,\\"end\\":18,\\"loc\\":{\\"start\\":{\\"line\\":1,\\"column\\":0},\\"end\\":{\\"line\\":1,\\"column\\":18}},\\"range\\":[0,18],\\"sourceType\\":\\"module\\",\\"interpreter\\":null,\\"body\\":[{\\"type\\":\\"VariableDeclaration\\",\\"start\\":0,\\"end\\":18,\\"loc\\":{\\"start\\":{\\"line\\":1,\\"column\\":0},\\"end\\":{\\"line\\":1,\\"column\\":18}},\\"range\\":[0,18],\\"declarations\\":[{\\"type\\":\\"VariableDeclarator\\",\\"start\\":6,\\"end\\":17,\\"loc\\":{\\"start\\":{\\"line\\":1,\\"column\\":6},\\"end\\":{\\"line\\":1,\\"column\\":17}},\\"range\\":[6,17],\\"id\\":{\\"type\\":\\"Identifier\\",\\"start\\":6,\\"end\\":9,\\"loc\\":{\\"start\\":{\\"line\\":1,\\"column\\":6},\\"end\\":{\\"line\\":1,\\"column\\":9},\\"identifierName\\":\\"foo\\"},\\"range\\":[6,9],\\"name\\":\\"foo\\"},\\"init\\":{\\"type\\":\\"StringLiteral\\",\\"start\\":12,\\"end\\":17,\\"loc\\":{\\"start\\":{\\"line\\":1,\\"column\\":12},\\"end\\":{\\"line\\":1,\\"column\\":17}},\\"range\\":[12,17],\\"extra\\":{\\"rawValue\\":\\"foo\\",\\"raw\\":\\"'foo'\\"},\\"value\\":\\"foo\\"}}],\\"kind\\":\\"const\\"}],\\"directives\\":[]},\\"comments\\":[],\\"tokens\\":[{\\"type\\":{\\"label\\":\\"const\\",\\"keyword\\":\\"const\\",\\"beforeExpr\\":false,\\"startsExpr\\":false,\\"rightAssociative\\":false,\\"isLoop\\":false,\\"isAssign\\":false,\\"prefix\\":false,\\"postfix\\":false,\\"binop\\":null,\\"updateContext\\":null},\\"value\\":\\"const\\",\\"start\\":0,\\"end\\":5,\\"loc\\":{\\"start\\":{\\"line\\":1,\\"column\\":0},\\"end\\":{\\"line\\":1,\\"column\\":5}}},{\\"type\\":{\\"label\\":\\"name\\",\\"beforeExpr\\":false,\\"startsExpr\\":true,\\"rightAssociative\\":false,\\"isLoop\\":false,\\"isAssign\\":false,\\"prefix\\":false,\\"postfix\\":false,\\"binop\\":null,\\"updateContext\\":null},\\"value\\":\\"foo\\",\\"start\\":6,\\"end\\":9,\\"loc\\":{\\"start\\":{\\"line\\":1,\\"column\\":6},\\"end\\":{\\"line\\":1,\\"column\\":9}}},{\\"type\\":{\\"label\\":\\"=\\",\\"beforeExpr\\":true,\\"startsExpr\\":false,\\"rightAssociative\\":false,\\"isLoop\\":false,\\"isAssign\\":true,\\"prefix\\":false,\\"postfix\\":false,\\"binop\\":null,\\"updateContext\\":null},\\"value\\":\\"=\\",\\"start\\":10,\\"end\\":11,\\"loc\\":{\\"start\\":{\\"line\\":1,\\"column\\":10},\\"end\\":{\\"line\\":1,\\"column\\":11}}},{\\"type\\":{\\"label\\":\\"string\\",\\"beforeExpr\\":false,\\"startsExpr\\":true,\\"rightAssociative\\":false,\\"isLoop\\":false,\\"isAssign\\":false,\\"prefix\\":false,\\"postfix\\":false,\\"binop\\":null,\\"updateContext\\":null},\\"value\\":\\"foo\\",\\"start\\":12,\\"end\\":17,\\"loc\\":{\\"start\\":{\\"line\\":1,\\"column\\":12},\\"end\\":{\\"line\\":1,\\"column\\":17}}},{\\"type\\":{\\"label\\":\\";\\",\\"beforeExpr\\":true,\\"startsExpr\\":false,\\"rightAssociative\\":false,\\"isLoop\\":false,\\"isAssign\\":false,\\"prefix\\":false,\\"postfix\\":false,\\"binop\\":null,\\"updateContext\\":null},\\"start\\":17,\\"end\\":18,\\"loc\\":{\\"start\\":{\\"line\\":1,\\"column\\":17},\\"end\\":{\\"line\\":1,\\"column\\":18}}},{\\"type\\":{\\"label\\":\\"eof\\",\\"beforeExpr\\":false,\\"startsExpr\\":false,\\"rightAssociative\\":false,\\"isLoop\\":false,\\"isAssign\\":false,\\"prefix\\":false,\\"postfix\\":false,\\"binop\\":null,\\"updateContext\\":null},\\"start\\":18,\\"end\\":18,\\"loc\\":{\\"start\\":{\\"line\\":1,\\"column\\":18},\\"end\\":{\\"line\\":1,\\"column\\":18}}}]}"`;

exports[`prints information for debugging AST --debug-print-comments (write) 1`] = `Array []`;

0 comments on commit fe3be6b

Please sign in to comment.