• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1//// [parserRealSource13.ts]
2// Copyright (c) Microsoft. All rights reserved. Licensed under the Apache License, Version 2.0.
3// See LICENSE.txt in the project root for complete license information.
4
5///<reference path='typescript.ts' />
6
7module TypeScript.AstWalkerWithDetailCallback {
8    export interface AstWalkerDetailCallback {
9        EmptyCallback? (pre, ast: AST): boolean;
10        EmptyExprCallback? (pre, ast: AST): boolean;
11        TrueCallback? (pre, ast: AST): boolean;
12        FalseCallback? (pre, ast: AST): boolean;
13        ThisCallback? (pre, ast: AST): boolean;
14        SuperCallback? (pre, ast: AST): boolean;
15        QStringCallback? (pre, ast: AST): boolean;
16        RegexCallback? (pre, ast: AST): boolean;
17        NullCallback? (pre, ast: AST): boolean;
18        ArrayLitCallback? (pre, ast: AST): boolean;
19        ObjectLitCallback? (pre, ast: AST): boolean;
20        VoidCallback? (pre, ast: AST): boolean;
21        CommaCallback? (pre, ast: AST): boolean;
22        PosCallback? (pre, ast: AST): boolean;
23        NegCallback? (pre, ast: AST): boolean;
24        DeleteCallback? (pre, ast: AST): boolean;
25        AwaitCallback? (pre, ast: AST): boolean;
26        InCallback? (pre, ast: AST): boolean;
27        DotCallback? (pre, ast: AST): boolean;
28        FromCallback? (pre, ast: AST): boolean;
29        IsCallback? (pre, ast: AST): boolean;
30        InstOfCallback? (pre, ast: AST): boolean;
31        TypeofCallback? (pre, ast: AST): boolean;
32        NumberLitCallback? (pre, ast: AST): boolean;
33        NameCallback? (pre, identifierAst: Identifier): boolean;
34        TypeRefCallback? (pre, ast: AST): boolean;
35        IndexCallback? (pre, ast: AST): boolean;
36        CallCallback? (pre, ast: AST): boolean;
37        NewCallback? (pre, ast: AST): boolean;
38        AsgCallback? (pre, ast: AST): boolean;
39        AsgAddCallback? (pre, ast: AST): boolean;
40        AsgSubCallback? (pre, ast: AST): boolean;
41        AsgDivCallback? (pre, ast: AST): boolean;
42        AsgMulCallback? (pre, ast: AST): boolean;
43        AsgModCallback? (pre, ast: AST): boolean;
44        AsgAndCallback? (pre, ast: AST): boolean;
45        AsgXorCallback? (pre, ast: AST): boolean;
46        AsgOrCallback? (pre, ast: AST): boolean;
47        AsgLshCallback? (pre, ast: AST): boolean;
48        AsgRshCallback? (pre, ast: AST): boolean;
49        AsgRs2Callback? (pre, ast: AST): boolean;
50        QMarkCallback? (pre, ast: AST): boolean;
51        LogOrCallback? (pre, ast: AST): boolean;
52        LogAndCallback? (pre, ast: AST): boolean;
53        OrCallback? (pre, ast: AST): boolean;
54        XorCallback? (pre, ast: AST): boolean;
55        AndCallback? (pre, ast: AST): boolean;
56        EqCallback? (pre, ast: AST): boolean;
57        NeCallback? (pre, ast: AST): boolean;
58        EqvCallback? (pre, ast: AST): boolean;
59        NEqvCallback? (pre, ast: AST): boolean;
60        LtCallback? (pre, ast: AST): boolean;
61        LeCallback? (pre, ast: AST): boolean;
62        GtCallback? (pre, ast: AST): boolean;
63        GeCallback? (pre, ast: AST): boolean;
64        AddCallback? (pre, ast: AST): boolean;
65        SubCallback? (pre, ast: AST): boolean;
66        MulCallback? (pre, ast: AST): boolean;
67        DivCallback? (pre, ast: AST): boolean;
68        ModCallback? (pre, ast: AST): boolean;
69        LshCallback? (pre, ast: AST): boolean;
70        RshCallback? (pre, ast: AST): boolean;
71        Rs2Callback? (pre, ast: AST): boolean;
72        NotCallback? (pre, ast: AST): boolean;
73        LogNotCallback? (pre, ast: AST): boolean;
74        IncPreCallback? (pre, ast: AST): boolean;
75        DecPreCallback? (pre, ast: AST): boolean;
76        IncPostCallback? (pre, ast: AST): boolean;
77        DecPostCallback? (pre, ast: AST): boolean;
78        TypeAssertionCallback? (pre, ast: AST): boolean;
79        FuncDeclCallback? (pre, funcDecl: FuncDecl): boolean;
80        MemberCallback? (pre, ast: AST): boolean;
81        VarDeclCallback? (pre, varDecl: VarDecl): boolean;
82        ArgDeclCallback? (pre, ast: AST): boolean;
83        ReturnCallback? (pre, ast: AST): boolean;
84        BreakCallback? (pre, ast: AST): boolean;
85        ContinueCallback? (pre, ast: AST): boolean;
86        ThrowCallback? (pre, ast: AST): boolean;
87        ForCallback? (pre, ast: AST): boolean;
88        ForInCallback? (pre, ast: AST): boolean;
89        IfCallback? (pre, ast: AST): boolean;
90        WhileCallback? (pre, ast: AST): boolean;
91        DoWhileCallback? (pre, ast: AST): boolean;
92        BlockCallback? (pre, block: Block): boolean;
93        CaseCallback? (pre, ast: AST): boolean;
94        SwitchCallback? (pre, ast: AST): boolean;
95        TryCallback? (pre, ast: AST): boolean;
96        TryCatchCallback? (pre, ast: AST): boolean;
97        TryFinallyCallback? (pre, ast: AST): boolean;
98        FinallyCallback? (pre, ast: AST): boolean;
99        CatchCallback? (pre, ast: AST): boolean;
100        ListCallback? (pre, astList: ASTList): boolean;
101        ScriptCallback? (pre, script: Script): boolean;
102        ClassDeclarationCallback? (pre, ast: AST): boolean;
103        InterfaceDeclarationCallback? (pre, interfaceDecl: InterfaceDeclaration): boolean;
104        ModuleDeclarationCallback? (pre, moduleDecl: ModuleDeclaration): boolean;
105        ImportDeclarationCallback? (pre, ast: AST): boolean;
106        WithCallback? (pre, ast: AST): boolean;
107        LabelCallback? (pre, labelAST: AST): boolean;
108        LabeledStatementCallback? (pre, ast: AST): boolean;
109        EBStartCallback? (pre, ast: AST): boolean;
110        GotoEBCallback? (pre, ast: AST): boolean;
111        EndCodeCallback? (pre, ast: AST): boolean;
112        ErrorCallback? (pre, ast: AST): boolean;
113        CommentCallback? (pre, ast: AST): boolean;
114        DebuggerCallback? (pre, ast: AST): boolean;
115        DefaultCallback? (pre, ast: AST): boolean;
116    }
117
118    export function walk(script: Script, callback: AstWalkerDetailCallback): void {
119        var pre = (cur: AST, parent: AST) => {
120            walker.options.goChildren = AstWalkerCallback(true, cur, callback);
121            return cur;
122        }
123
124        var post = (cur: AST, parent: AST) => {
125            AstWalkerCallback(false, cur, callback);
126            return cur;
127        }
128
129        var walker = TypeScript.getAstWalkerFactory().getWalker(pre, post);
130        walker.walk(script, null);
131    }
132
133    function AstWalkerCallback(pre: boolean, ast: AST, callback: AstWalkerDetailCallback): boolean {
134        // See if the Callback needs to be handled using specific one or default one
135        var nodeType = ast.nodeType;
136        var callbackString = (<any>NodeType)._map[nodeType] + "Callback";
137        if (callback[callbackString]) {
138            return callback[callbackString](pre, ast);
139        }
140
141        if (callback.DefaultCallback) {
142            return callback.DefaultCallback(pre, ast);
143        }
144
145        return true;
146    }
147}
148
149//// [parserRealSource13.js]
150// Copyright (c) Microsoft. All rights reserved. Licensed under the Apache License, Version 2.0.
151// See LICENSE.txt in the project root for complete license information.
152///<reference path='typescript.ts' />
153var TypeScript;
154(function (TypeScript) {
155    var AstWalkerWithDetailCallback;
156    (function (AstWalkerWithDetailCallback) {
157        function walk(script, callback) {
158            var pre = function (cur, parent) {
159                walker.options.goChildren = AstWalkerCallback(true, cur, callback);
160                return cur;
161            };
162            var post = function (cur, parent) {
163                AstWalkerCallback(false, cur, callback);
164                return cur;
165            };
166            var walker = TypeScript.getAstWalkerFactory().getWalker(pre, post);
167            walker.walk(script, null);
168        }
169        AstWalkerWithDetailCallback.walk = walk;
170        function AstWalkerCallback(pre, ast, callback) {
171            // See if the Callback needs to be handled using specific one or default one
172            var nodeType = ast.nodeType;
173            var callbackString = NodeType._map[nodeType] + "Callback";
174            if (callback[callbackString]) {
175                return callback[callbackString](pre, ast);
176            }
177            if (callback.DefaultCallback) {
178                return callback.DefaultCallback(pre, ast);
179            }
180            return true;
181        }
182    })(AstWalkerWithDetailCallback = TypeScript.AstWalkerWithDetailCallback || (TypeScript.AstWalkerWithDetailCallback = {}));
183})(TypeScript || (TypeScript = {}));
184