forked from dsherret/ts-morph
-
Notifications
You must be signed in to change notification settings - Fork 0
/
SwitchStatement.ts
47 lines (42 loc) · 1.39 KB
/
SwitchStatement.ts
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
import { ts } from "../../../typescript";
import { CaseOrDefaultClause } from "../aliases";
import { ChildOrderableNode } from "../base";
import { Expression } from "../expression";
import { CaseBlock } from "./CaseBlock";
import { Statement } from "./Statement";
export const SwitchStatementBase = ChildOrderableNode(Statement);
export class SwitchStatement extends SwitchStatementBase<ts.SwitchStatement> {
/**
* Gets this switch statement's expression.
*/
getExpression(): Expression {
return this._getNodeFromCompilerNode(this.compilerNode.expression);
}
/**
* Gets this switch statement's case block.
*/
getCaseBlock(): CaseBlock {
return this._getNodeFromCompilerNode(this.compilerNode.caseBlock);
}
/**
* Gets the switch statement's case block's clauses.
*/
getClauses(): CaseOrDefaultClause[] {
// convenience method
return this.getCaseBlock().getClauses();
}
/**
* Removes the specified clause based on the provided index.
* @param index - Index.
*/
removeClause(index: number) {
return this.getCaseBlock().removeClause(index);
}
/**
* Removes the specified clauses based on the provided index range.
* @param indexRange - Index range.
*/
removeClauses(indexRange: [number, number]) {
return this.getCaseBlock().removeClauses(indexRange);
}
}