forked from decaffeinate/decaffeinate
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
55 lines (44 loc) · 1.67 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import ConditionalPatcher from './patchers/ConditionalPatcher.js';
import ForInPatcher from './patchers/ForInPatcher.js';
import ForOfPatcher from './patchers/ForOfPatcher.js';
import FunctionApplicationPatcher from './patchers/FunctionApplicationPatcher.js';
import NodePatcher from '../../patchers/NodePatcher.js';
import PassthroughPatcher from '../../patchers/PassthroughPatcher.js';
import ProgramPatcher from './patchers/ProgramPatcher.js';
import TransformCoffeeScriptStage from '../TransformCoffeeScriptStage.js';
import WhilePatcher from './patchers/WhilePatcher.js';
import MemberAccessOpPatcher from './patchers/MemberAccessOpPatcher.js';
import FunctionPatcher from './patchers/FunctionPatcher.js';
import DefaultParamPatcher from './patchers/DefaultParamPatcher.js';
import type { Node } from '../../patchers/types.js';
export default class NormalizeStage extends TransformCoffeeScriptStage {
static get outputExtension(): string {
return '.coffee';
}
patcherConstructorForNode(node: Node): ?Class<NodePatcher> {
switch (node.type) {
case 'MemberAccessOp':
return MemberAccessOpPatcher;
case 'BoundFunction':
case 'Function':
return FunctionPatcher;
case 'Conditional':
return ConditionalPatcher;
case 'ForIn':
return ForInPatcher;
case 'ForOf':
return ForOfPatcher;
case 'FunctionApplication':
case 'NewOp':
return FunctionApplicationPatcher;
case 'While':
return WhilePatcher;
case 'Program':
return ProgramPatcher;
case 'DefaultParam':
return DefaultParamPatcher;
default:
return PassthroughPatcher;
}
}
}