Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 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 | 37885x 8477x 200x 200x 200x 200x 29208x | import type IAssignmentSyntax from "../types/syntax/IAssignmentSyntax";
import type TStatement from "../types/syntax/TStatement";
/**
* The assignments a statement performs itself, in source order (#2010): an
* assignment statement, or a `for` header's init and update. Not those of the
* statements nested inside it (`StatementChildren`). Every kind has an arm, so
* a new kind does not compile until it is placed.
*/
class StatementWrites {
static of(statement: TStatement): readonly IAssignmentSyntax[] {
switch (statement.kind) {
case "assignment":
return [statement];
case "for": {
const writes: IAssignmentSyntax[] = [];
if (statement.init?.kind === "assignment") writes.push(statement.init);
if (statement.update !== null) writes.push(statement.update);
return writes;
}
case "variableDeclaration":
case "constructorDeclaration":
case "expression":
case "if":
case "while":
case "doWhile":
case "forever":
case "switch":
case "return":
case "critical":
case "block":
case "missing":
return [];
default: {
const unplaced: never = statement;
return unplaced;
}
}
}
}
export default StatementWrites;
|