MCPcopy
hub / github.com/eslint/eslint / makeWhileBody

Method makeWhileBody

lib/linter/code-path-analysis/code-path-state.js:1985–2004  ·  view source on GitHub ↗

* Makes a code path segment for the body part of a WhileStatement. * @returns {void}

()

Source from the content-addressed store, hash-verified

1983 * @returns {void}
1984 */
1985 makeWhileBody() {
1986 const context = this.loopContext;
1987 const choiceContext = this.choiceContext;
1988 const forkContext = this.forkContext;
1989
1990 if (!choiceContext.processed) {
1991 choiceContext.trueForkContext.add(forkContext.head);
1992 choiceContext.falseForkContext.add(forkContext.head);
1993 }
1994
1995 /*
1996 * If this isn't a hardcoded `true` condition, then `break`
1997 * should continue down the path as if the condition evaluated
1998 * to false.
1999 */
2000 if (context.test !== true) {
2001 context.brokenForkContext.addAll(choiceContext.falseForkContext);
2002 }
2003 forkContext.replaceHead(choiceContext.trueForkContext.makeNext(0, -1));
2004 }
2005
2006 /**
2007 * Makes a code path segment for the body part of a DoWhileStatement.

Callers 1

preprocessFunction · 0.80

Calls 4

addAllMethod · 0.80
replaceHeadMethod · 0.80
makeNextMethod · 0.80
addMethod · 0.45

Tested by

no test coverage detected