Skip to content

Commit 28044e1

Browse files
committed
Moved first pass visitor to archive.
1 parent 371c771 commit 28044e1

File tree

1 file changed

+85
-0
lines changed

1 file changed

+85
-0
lines changed

src/_archived/firstPassVisitor.ts

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
// function firstPassVisitor(node: ts.Node, mc: MutationContext, tc: ts.TransformationContext): void {
2+
// if (!node) return;
3+
// let checker = program.getTypeChecker();
4+
// ts.forEachChild(node, n => {
5+
//
6+
//
7+
// // let type = checker.getTypeAtLocation(n);
8+
// // // console.log('TYPE', type);
9+
// // let typeString = checker.typeToString(type);
10+
// // console.log('TYPESTRING', typeString);
11+
// // let source = `let temp: ${typeString};`;
12+
// // console.log('SRC', source);
13+
// // console.log('\n\n\n');
14+
// // let sf = ts.createSourceFile('temp', source, ts.ScriptTarget.ES2015);
15+
// // let typeNode = (sf.statements[0] as ts.VariableStatement).declarationList.declarations[0].type;
16+
//
17+
// switch (n.kind) {
18+
// case ts.SyntaxKind.BinaryExpression:
19+
// // console.log((n as ts.BinaryExpression).getText());
20+
// // let s = program.getTypeChecker().getSymbolAtLocation(n);
21+
// // let t = program.getTypeChecker().getContextualType(n as ts.BinaryExpression);
22+
// // console.log(s);
23+
// // console.log(t);
24+
// // console.log('\n\n');
25+
// break;
26+
// case ts.SyntaxKind.Identifier:
27+
// console.log((n as ts.Identifier).text);
28+
// console.log('-----------------------');
29+
//
30+
//
31+
//
32+
// // let t = checker.getTypeAtLocation(n);
33+
// // // console.log(checker.getPropertiesOfType(t));
34+
// // // t = checker.getWidenedType(t);
35+
// // //
36+
// // console.log(ts.TypeFlags[t.flags]);
37+
//
38+
// let type = checker.getTypeAtLocation(n);
39+
//
40+
// let typeString = checker.typeToString(type);
41+
// console.log(typeString);
42+
// let source = `let temp: ${typeString};`;
43+
//
44+
// let sf = ts.createSourceFile('temp', source, ts.ScriptTarget.ES2015);
45+
// let typeNode = (sf.statements[0] as ts.VariableStatement).declarationList.declarations[0].type;
46+
//
47+
// //
48+
// // let asm = type.aliasSymbol;
49+
// //
50+
// // if (asm) {
51+
// // if (asm.declarations && asm.declarations[0]) {
52+
// // console.log(asm.declarations.length);
53+
// // let asmi = asm.declarations[0] as ts.VariableDeclaration;
54+
// // if (asmi.type) {
55+
// // console.log('has type');
56+
// // console.log(ts.SyntaxKind[asmi.type.kind]);
57+
// // }
58+
// // }
59+
// // }
60+
// //
61+
// console.log(ts.TypeFlags[type.flags]);
62+
// console.log('\n\n');
63+
//
64+
// // console.log('KIND:', (n as ts.Identifier).text);
65+
// // console.log((n as ts.Identifier).originalKeywordKind);
66+
// // console.log('');
67+
//
68+
// // if (mc.names.indexOf((n as ts.Identifier).text) === -1) {
69+
// // // mc.names.push((n as ts.Identifier).text);
70+
// // // console.log('KIND:', (n as ts.Identifier).text);
71+
// // // console.log((n as ts.Identifier).originalKeywordKind);
72+
// // // console.log('');
73+
// // }
74+
// break;
75+
// case ts.SyntaxKind.VariableDeclaration:
76+
// // const dec = n as ts.VariableDeclaration;
77+
// // if (dec.name.kind === ts.SyntaxKind.Identifier) {
78+
// // mc.declarations.set((dec.name as ts.Identifier).text, dec.type);
79+
// // }
80+
// break;
81+
// }
82+
//
83+
// firstPassVisitor(n, mc, tc);
84+
// });
85+
// }

0 commit comments

Comments
 (0)