MCPcopy Create free account
hub / github.com/microsoft/typescript-go / bindCaseBlock

Method bindCaseBlock

internal/binder/binder.go:2095–2124  ·  view source on GitHub ↗
(node *ast.Node)

Source from the content-addressed store, hash-verified

2093}
2094
2095func (b *Binder) bindCaseBlock(node *ast.Node) {
2096 switchStatement := node.Parent
2097 clauses := node.AsCaseBlock().Clauses.Nodes
2098 isNarrowingSwitch := switchStatement.Expression().Kind == ast.KindTrueKeyword || isNarrowingExpression(switchStatement.Expression())
2099 var fallthroughFlow *ast.FlowNode = b.unreachableFlow
2100 for i := 0; i < len(clauses); i++ {
2101 clauseStart := i
2102 for len(clauses[i].Statements()) == 0 && i+1 < len(clauses) {
2103 if fallthroughFlow == b.unreachableFlow {
2104 b.currentFlow = b.preSwitchCaseFlow
2105 }
2106 b.bind(clauses[i])
2107 i++
2108 }
2109 preCaseLabel := b.createBranchLabel()
2110 preCaseFlow := b.preSwitchCaseFlow
2111 if isNarrowingSwitch {
2112 preCaseFlow = b.createFlowSwitchClause(b.preSwitchCaseFlow, switchStatement, clauseStart, i+1)
2113 }
2114 b.addAntecedent(preCaseLabel, preCaseFlow)
2115 b.addAntecedent(preCaseLabel, fallthroughFlow)
2116 b.currentFlow = b.finishFlowLabel(preCaseLabel)
2117 clause := clauses[i]
2118 b.bind(clause)
2119 fallthroughFlow = b.currentFlow
2120 if b.currentFlow.Flags&ast.FlowFlagsUnreachable == 0 && i != len(clauses)-1 {
2121 clause.AsCaseOrDefaultClause().FallthroughFlowNode = b.currentFlow
2122 }
2123 }
2124}
2125
2126func (b *Binder) bindCaseOrDefaultClause(node *ast.Node) {
2127 clause := node.AsCaseOrDefaultClause()

Callers 1

bindChildrenMethod · 0.95

Calls 11

bindMethod · 0.95
createBranchLabelMethod · 0.95
addAntecedentMethod · 0.95
finishFlowLabelMethod · 0.95
isNarrowingExpressionFunction · 0.85
lenFunction · 0.85
AsCaseBlockMethod · 0.80
ExpressionMethod · 0.80
StatementsMethod · 0.80
AsCaseOrDefaultClauseMethod · 0.80

Tested by

no test coverage detected