From bbdc18652c309d7766d7fa06ddb416c36c40ddb3 Mon Sep 17 00:00:00 2001 From: joeduffy Date: Sat, 21 Jan 2017 12:08:44 -0800 Subject: [PATCH] Add missing kind specifiers The prior checkin failed to place kind specifiers on the token AST nodes. I'm surprised TypeScript let this fly. --- tools/mujs/lib/compiler/transform.ts | 21 ++++++++++++------- .../tests/output/modules/export/Mu.out.json | 4 ++++ .../tests/output/modules/func_1/Mu.out.json | 2 ++ .../output/modules/func_exp_1/Mu.out.json | 2 ++ .../output/modules/func_exp_def_1/Mu.out.json | 2 ++ .../tests/output/modules/reexport/Mu.out.json | 4 ++++ .../output/modules/reexport_all/Mu.out.json | 4 ++++ .../modules/reexport_rename/Mu.out.json | 4 ++++ .../tests/output/modules/var_1/Mu.out.json | 1 + .../output/modules/var_exp_1/Mu.out.json | 1 + .../tests/output/scenarios/point/Mu.out.json | 6 ++++++ 11 files changed, 44 insertions(+), 7 deletions(-) diff --git a/tools/mujs/lib/compiler/transform.ts b/tools/mujs/lib/compiler/transform.ts index ba0566ffd..85ea89a1d 100644 --- a/tools/mujs/lib/compiler/transform.ts +++ b/tools/mujs/lib/compiler/transform.ts @@ -436,7 +436,8 @@ export class Transformer { let ty: ts.Type = this.checker().getTypeAtLocation(node); contract.assert(!!ty); return this.withLocation(node, { - tok: this.resolveTypeToken(ty), + kind: ast.typeTokenKind, + tok: this.resolveTypeToken(ty), }); } @@ -618,7 +619,8 @@ export class Transformer { name: name, access: symbols.publicAccessibility, referent: this.withLocation(exportClause.propertyName, { - tok: this.createModuleMemberToken(sourceModule, propertyName.ident), + kind: ast.tokenKind, + tok: this.createModuleMemberToken(sourceModule, propertyName.ident), }), })); } @@ -631,7 +633,8 @@ export class Transformer { name: name, access: symbols.publicAccessibility, referent: this.withLocation(exportClause.name, { - tok: this.createModuleMemberToken(sourceModule, name.ident), + kind: ast.tokenKind, + tok: this.createModuleMemberToken(sourceModule, name.ident), }), })); } @@ -656,7 +659,8 @@ export class Transformer { name: name, access: symbols.publicAccessibility, referent: this.withLocation(exportClause, { - tok: this.createModuleToken(otherModule!), + kind: ast.tokenKind, + tok: this.createModuleToken(otherModule!), }), })); } @@ -680,7 +684,8 @@ export class Transformer { }, access: symbols.publicAccessibility, referent: this.withLocation(node, { - tok: name, + kind: ast.tokenKind, + tok: name, }), })); } @@ -699,7 +704,8 @@ export class Transformer { let importModule: ModuleReference = this.resolveModuleReferenceByName((node.moduleSpecifier).text); let importModuleToken: ast.ModuleToken = this.withLocation(node.moduleSpecifier, { - tok: this.createModuleToken(importModule), + kind: ast.moduleTokenKind, + tok: this.createModuleToken(importModule), }); // Figure out what kind of import statement this is (there are many, see below). @@ -1829,7 +1835,8 @@ export class Transformer { if (node.expression.kind === ts.SyntaxKind.Identifier) { let ident: ast.Identifier = this.transformIdentifier(node.expression); ty = this.withLocation(node.expression, { - tok: ident.ident, + kind: ast.typeTokenKind, + tok: ident.ident, }); } else { diff --git a/tools/mujs/tests/output/modules/export/Mu.out.json b/tools/mujs/tests/output/modules/export/Mu.out.json index 06688448e..d6e18f57e 100644 --- a/tools/mujs/tests/output/modules/export/Mu.out.json +++ b/tools/mujs/tests/output/modules/export/Mu.out.json @@ -92,6 +92,7 @@ }, "access": "public", "type": { + "kind": "TypeToken", "tok": "number", "loc": { "file": "other.ts", @@ -203,6 +204,7 @@ }, "imports": [ { + "kind": "ModuleToken", "tok": "other", "loc": { "file": "index.ts", @@ -237,6 +239,7 @@ }, "access": "public", "referent": { + "kind": "Token", "tok": "other", "loc": { "file": "index.ts", @@ -345,6 +348,7 @@ }, "access": "public", "type": { + "kind": "TypeToken", "tok": "number", "loc": { "file": "index.ts", diff --git a/tools/mujs/tests/output/modules/func_1/Mu.out.json b/tools/mujs/tests/output/modules/func_1/Mu.out.json index ea4a5b778..a615da7c4 100644 --- a/tools/mujs/tests/output/modules/func_1/Mu.out.json +++ b/tools/mujs/tests/output/modules/func_1/Mu.out.json @@ -46,6 +46,7 @@ } }, "type": { + "kind": "TypeToken", "tok": "number", "loc": { "file": "index.ts", @@ -78,6 +79,7 @@ } }, "type": { + "kind": "TypeToken", "tok": "string", "loc": { "file": "index.ts", diff --git a/tools/mujs/tests/output/modules/func_exp_1/Mu.out.json b/tools/mujs/tests/output/modules/func_exp_1/Mu.out.json index 6a3df5762..071dbd9d1 100644 --- a/tools/mujs/tests/output/modules/func_exp_1/Mu.out.json +++ b/tools/mujs/tests/output/modules/func_exp_1/Mu.out.json @@ -46,6 +46,7 @@ } }, "type": { + "kind": "TypeToken", "tok": "number", "loc": { "file": "index.ts", @@ -78,6 +79,7 @@ } }, "type": { + "kind": "TypeToken", "tok": "string", "loc": { "file": "index.ts", diff --git a/tools/mujs/tests/output/modules/func_exp_def_1/Mu.out.json b/tools/mujs/tests/output/modules/func_exp_def_1/Mu.out.json index 889ecdbf9..702a21b35 100644 --- a/tools/mujs/tests/output/modules/func_exp_def_1/Mu.out.json +++ b/tools/mujs/tests/output/modules/func_exp_def_1/Mu.out.json @@ -35,6 +35,7 @@ } }, "type": { + "kind": "TypeToken", "tok": "number", "loc": { "file": "index.ts", @@ -67,6 +68,7 @@ } }, "type": { + "kind": "TypeToken", "tok": "string", "loc": { "file": "index.ts", diff --git a/tools/mujs/tests/output/modules/reexport/Mu.out.json b/tools/mujs/tests/output/modules/reexport/Mu.out.json index 733bf96b4..97062cf4a 100644 --- a/tools/mujs/tests/output/modules/reexport/Mu.out.json +++ b/tools/mujs/tests/output/modules/reexport/Mu.out.json @@ -92,6 +92,7 @@ }, "access": "public", "type": { + "kind": "TypeToken", "tok": "number", "loc": { "file": "other.ts", @@ -222,6 +223,7 @@ }, "access": "public", "referent": { + "kind": "Token", "tok": "other:C", "loc": { "file": "index.ts", @@ -266,6 +268,7 @@ }, "access": "public", "referent": { + "kind": "Token", "tok": "other:I", "loc": { "file": "index.ts", @@ -310,6 +313,7 @@ }, "access": "public", "referent": { + "kind": "Token", "tok": "other:v", "loc": { "file": "index.ts", diff --git a/tools/mujs/tests/output/modules/reexport_all/Mu.out.json b/tools/mujs/tests/output/modules/reexport_all/Mu.out.json index 04c79a510..c947d6ffc 100644 --- a/tools/mujs/tests/output/modules/reexport_all/Mu.out.json +++ b/tools/mujs/tests/output/modules/reexport_all/Mu.out.json @@ -92,6 +92,7 @@ }, "access": "public", "type": { + "kind": "TypeToken", "tok": "number", "loc": { "file": "other.ts", @@ -211,6 +212,7 @@ }, "access": "public", "referent": { + "kind": "Token", "tok": "other:C", "loc": { "file": "index.ts", @@ -244,6 +246,7 @@ }, "access": "public", "referent": { + "kind": "Token", "tok": "other:I", "loc": { "file": "index.ts", @@ -277,6 +280,7 @@ }, "access": "public", "referent": { + "kind": "Token", "tok": "other:v", "loc": { "file": "index.ts", diff --git a/tools/mujs/tests/output/modules/reexport_rename/Mu.out.json b/tools/mujs/tests/output/modules/reexport_rename/Mu.out.json index 5497502ef..4b5d39b73 100644 --- a/tools/mujs/tests/output/modules/reexport_rename/Mu.out.json +++ b/tools/mujs/tests/output/modules/reexport_rename/Mu.out.json @@ -92,6 +92,7 @@ }, "access": "public", "type": { + "kind": "TypeToken", "tok": "number", "loc": { "file": "other.ts", @@ -222,6 +223,7 @@ }, "access": "public", "referent": { + "kind": "Token", "tok": "other:C", "loc": { "file": "index.ts", @@ -266,6 +268,7 @@ }, "access": "public", "referent": { + "kind": "Token", "tok": "other:I", "loc": { "file": "index.ts", @@ -310,6 +313,7 @@ }, "access": "public", "referent": { + "kind": "Token", "tok": "other:v", "loc": { "file": "index.ts", diff --git a/tools/mujs/tests/output/modules/var_1/Mu.out.json b/tools/mujs/tests/output/modules/var_1/Mu.out.json index 3e5ed18bc..c4dbc6694 100644 --- a/tools/mujs/tests/output/modules/var_1/Mu.out.json +++ b/tools/mujs/tests/output/modules/var_1/Mu.out.json @@ -28,6 +28,7 @@ }, "access": "private", "type": { + "kind": "TypeToken", "tok": "number", "loc": { "file": "index.ts", diff --git a/tools/mujs/tests/output/modules/var_exp_1/Mu.out.json b/tools/mujs/tests/output/modules/var_exp_1/Mu.out.json index dd601cef3..bb3b3c43f 100644 --- a/tools/mujs/tests/output/modules/var_exp_1/Mu.out.json +++ b/tools/mujs/tests/output/modules/var_exp_1/Mu.out.json @@ -28,6 +28,7 @@ }, "access": "public", "type": { + "kind": "TypeToken", "tok": "number", "loc": { "file": "index.ts", diff --git a/tools/mujs/tests/output/scenarios/point/Mu.out.json b/tools/mujs/tests/output/scenarios/point/Mu.out.json index c7f07da08..e95c193f9 100644 --- a/tools/mujs/tests/output/scenarios/point/Mu.out.json +++ b/tools/mujs/tests/output/scenarios/point/Mu.out.json @@ -54,6 +54,7 @@ } }, "type": { + "kind": "TypeToken", "tok": "number", "loc": { "file": "index.ts", @@ -86,6 +87,7 @@ } }, "type": { + "kind": "TypeToken", "tok": "number", "loc": { "file": "index.ts", @@ -378,6 +380,7 @@ } }, "type": { + "kind": "TypeToken", "tok": "Point", "loc": { "file": "index.ts", @@ -401,6 +404,7 @@ "expression": { "kind": "NewExpression", "type": { + "kind": "TypeToken", "tok": "Point", "loc": { "file": "index.ts", @@ -729,6 +733,7 @@ "readonly": true, "static": false, "type": { + "kind": "TypeToken", "tok": "number", "loc": { "file": "index.ts", @@ -764,6 +769,7 @@ "readonly": true, "static": false, "type": { + "kind": "TypeToken", "tok": "number", "loc": { "file": "index.ts",