forked from dsherret/ts-morph
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathForStatement.ts
50 lines (44 loc) · 1.68 KB
/
ForStatement.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
48
49
50
import * as errors from "../../../errors";
import { ts } from "../../../typescript";
import { Expression } from "../expression";
import { IterationStatement } from "./IterationStatement";
import { VariableDeclarationList } from "../variable";
export const ForStatementBase = IterationStatement;
export class ForStatement extends ForStatementBase<ts.ForStatement> {
/**
* Gets this for statement's initializer or undefined if none exists.
*/
getInitializer(): VariableDeclarationList | Expression | undefined {
return this._getNodeFromCompilerNodeIfExists(this.compilerNode.initializer);
}
/**
* Gets this for statement's initializer or throws if none exists.
*/
getInitializerOrThrow() {
return errors.throwIfNullOrUndefined(this.getInitializer(), "Expected to find an initializer.");
}
/**
* Gets this for statement's condition or undefined if none exists.
*/
getCondition(): Expression | undefined {
return this._getNodeFromCompilerNodeIfExists(this.compilerNode.condition);
}
/**
* Gets this for statement's condition or throws if none exists.
*/
getConditionOrThrow() {
return errors.throwIfNullOrUndefined(this.getCondition(), "Expected to find a condition.");
}
/**
* Gets this for statement's incrementor.
*/
getIncrementor(): Expression | undefined {
return this._getNodeFromCompilerNodeIfExists(this.compilerNode.incrementor);
}
/**
* Gets this for statement's incrementor or throws if none exists.
*/
getIncrementorOrThrow() {
return errors.throwIfNullOrUndefined(this.getIncrementor(), "Expected to find an incrementor.");
}
}