Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add "deno ast" subcommand #6867

Closed
wants to merge 28 commits into from
Closed
Changes from 1 commit
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
1e82d10
feat: add AST command flags and parser
littledivy Jul 24, 2020
cfc71f6
feat: implement swc_util ast parser
littledivy Jul 24, 2020
4584b2c
chores: add debug log end
littledivy Jul 24, 2020
67b025e
chores: fmt
littledivy Jul 24, 2020
943b0cb
fix: remove other args
littledivy Jul 24, 2020
cfa7433
fix: flags and suggestions
littledivy Jul 24, 2020
e6fe05f
chores: fmt
littledivy Jul 25, 2020
e43ea5a
Merge branch 'master' into feat/deno-ast-parser
littledivy Jul 25, 2020
03874a9
fix
littledivy Jul 25, 2020
db58565
fix: tests
littledivy Jul 25, 2020
95017a5
feat: pretty print ast
littledivy Jul 25, 2020
560e876
fix: LR assertion
littledivy Jul 25, 2020
584e900
tests(ast): add integration test
littledivy Jul 26, 2020
59c7cd1
tests: add expected output to tests
littledivy Jul 26, 2020
5a7d8dc
feat: integration tests
littledivy Jul 26, 2020
6da64c6
fix: output is not matching
littledivy Jul 26, 2020
9f485ba
fix: eslint with new test example
littledivy Jul 26, 2020
c1bca03
chores: fmt
littledivy Jul 26, 2020
e272049
fix: forgot flags
littledivy Jul 26, 2020
4e601eb
fix: out
littledivy Jul 26, 2020
8e17324
fix: newline issue
littledivy Jul 26, 2020
25ac535
Adjust help text
ry Jul 26, 2020
bc371b3
add unstable flag
ry Jul 26, 2020
0bcc5c2
unstable flag comes before source file
ry Jul 26, 2020
0172247
Merge remote-tracking branch 'origin/master' into feat/deno-ast-parser
littledivy Sep 17, 2020
3c209cb
merge
littledivy Sep 17, 2020
85219ab
chores: merge api changes
littledivy Sep 17, 2020
cab2116
use new ast parser
littledivy Sep 17, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
146 changes: 141 additions & 5 deletions cli/tests/integration_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -694,16 +694,152 @@ fn ts_reload() {

#[test]
fn test_ast() {
let mod1 = util::root_path().join("cli/tests/subdir/mod1.ts");
let mod1 = util::root_path().join("cli/tests/subdir/print_hello.ts");
assert!(mod1.is_file());
let mut deno = util::deno_cmd()
let output = util::deno_cmd()
.current_dir(util::root_path())
.arg("ast")
.arg(mod1)
.spawn()
.output()
.expect("failed to spawn script");
let status = deno.wait().expect("failed to wait for the child process");
assert!(status.success());
assert_eq!(
std::str::from_utf8(&output.stdout).unwrap().trim(),
r#"{
"type": "Module",
"span": {
"start": 0,
"end": 62,
"ctxt": 0
},
"body": [
{
"type": "ExportDeclaration",
"span": {
"start": 0,
"end": 62,
"ctxt": 0
},
"declaration": {
"type": "FunctionDeclaration",
"identifier": {
"type": "Identifier",
"span": {
"start": 16,
"end": 26,
"ctxt": 0
},
"value": "printHello",
"typeAnnotation": null,
"optional": false
},
"declare": false,
"params": [],
"decorators": [],
"span": {
"start": 7,
"end": 62,
"ctxt": 0
},
"body": {
"type": "BlockStatement",
"span": {
"start": 35,
"end": 62,
"ctxt": 0
},
"stmts": [
{
"type": "ExpressionStatement",
"span": {
"start": 39,
"end": 60,
"ctxt": 0
},
"expression": {
"type": "CallExpression",
"span": {
"start": 39,
"end": 59,
"ctxt": 0
},
"callee": {
"type": "MemberExpression",
"span": {
"start": 39,
"end": 50,
"ctxt": 0
},
"object": {
"type": "Identifier",
"span": {
"start": 39,
"end": 46,
"ctxt": 0
},
"value": "console",
"typeAnnotation": null,
"optional": false
},
"property": {
"type": "Identifier",
"span": {
"start": 47,
"end": 50,
"ctxt": 0
},
"value": "log",
"typeAnnotation": null,
"optional": false
},
"computed": false
},
"arguments": [
{
"spread": null,
"expression": {
"type": "StringLiteral",
"span": {
"start": 51,
"end": 58,
"ctxt": 0
},
"value": "Hello",
"hasEscape": false
}
}
],
"typeArguments": null
}
}
]
},
"generator": false,
"async": false,
"typeParameters": null,
"returnType": {
"type": "TsTypeAnnotation",
"span": {
"start": 28,
"end": 34,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 30,
"end": 34,
"ctxt": 0
},
"kind": "void"
}
}
}
}
],
"interpreter": null
}"#
);
assert_eq!(output.stderr, b"");
}

#[test]
Expand Down