CodePathState Class — react Architecture
Architecture documentation for the CodePathState class in code-path-state.js from the react codebase.
Entity Profile
Dependency Diagram
graph TD d3cee22c_5e2d_f853_c075_2c7c55e5d22c["CodePathState"] 6e2aa007_860b_49d4_8a7b_6b55d63818e5["code-path-state.js"] d3cee22c_5e2d_f853_c075_2c7c55e5d22c -->|defined in| 6e2aa007_860b_49d4_8a7b_6b55d63818e5 55fda85d_f10e_7e7f_11dd_a4ad601ffd62["constructor()"] d3cee22c_5e2d_f853_c075_2c7c55e5d22c -->|method| 55fda85d_f10e_7e7f_11dd_a4ad601ffd62 bd687f98_25d4_57b8_62e6_038d11abc9b3["headSegments()"] d3cee22c_5e2d_f853_c075_2c7c55e5d22c -->|method| bd687f98_25d4_57b8_62e6_038d11abc9b3 a427b291_d59e_8b98_a606_06f6b34161b8["parentForkContext()"] d3cee22c_5e2d_f853_c075_2c7c55e5d22c -->|method| a427b291_d59e_8b98_a606_06f6b34161b8 fcc7c411_4c84_b9a2_79b5_df3d388d50fc["pushForkContext()"] d3cee22c_5e2d_f853_c075_2c7c55e5d22c -->|method| fcc7c411_4c84_b9a2_79b5_df3d388d50fc 4581c407_1b84_6f80_c60d_80725b7a3917["popForkContext()"] d3cee22c_5e2d_f853_c075_2c7c55e5d22c -->|method| 4581c407_1b84_6f80_c60d_80725b7a3917 211ed457_b318_9fbf_ab5f_2fce956e40f8["forkPath()"] d3cee22c_5e2d_f853_c075_2c7c55e5d22c -->|method| 211ed457_b318_9fbf_ab5f_2fce956e40f8 c9bd3fa0_9a37_6446_ae50_3ac0a70bdaf1["forkBypassPath()"] d3cee22c_5e2d_f853_c075_2c7c55e5d22c -->|method| c9bd3fa0_9a37_6446_ae50_3ac0a70bdaf1 f6f7a515_92f3_1128_a333_ef52d2269bc9["pushChoiceContext()"] d3cee22c_5e2d_f853_c075_2c7c55e5d22c -->|method| f6f7a515_92f3_1128_a333_ef52d2269bc9 5da27dd3_9948_dd4b_f283_32a2cdeec34e["popChoiceContext()"] d3cee22c_5e2d_f853_c075_2c7c55e5d22c -->|method| 5da27dd3_9948_dd4b_f283_32a2cdeec34e 3baa501e_7ce6_0b8a_6f79_b6010731c7dd["makeLogicalRight()"] d3cee22c_5e2d_f853_c075_2c7c55e5d22c -->|method| 3baa501e_7ce6_0b8a_6f79_b6010731c7dd 747e38ff_afa2_6314_d554_04624db30f3e["makeIfConsequent()"] d3cee22c_5e2d_f853_c075_2c7c55e5d22c -->|method| 747e38ff_afa2_6314_d554_04624db30f3e 89448ede_e4a2_b438_764f_09fc0f4bb23f["makeIfAlternate()"] d3cee22c_5e2d_f853_c075_2c7c55e5d22c -->|method| 89448ede_e4a2_b438_764f_09fc0f4bb23f dbab03d8_bc8f_fc93_1c4d_024cee9afb09["pushChainContext()"] d3cee22c_5e2d_f853_c075_2c7c55e5d22c -->|method| dbab03d8_bc8f_fc93_1c4d_024cee9afb09
Relationship Graph
Source Code
packages/eslint-plugin-react-hooks/src/code-path-analysis/code-path-state.js lines 222–1439
class CodePathState {
/**
* @param {IdGenerator} idGenerator An id generator to generate id for code
* path segments.
* @param {Function} onLooped A callback function to notify looping.
*/
constructor(idGenerator, onLooped) {
this.idGenerator = idGenerator;
this.notifyLooped = onLooped;
this.forkContext = ForkContext.newRoot(idGenerator);
this.choiceContext = null;
this.switchContext = null;
this.tryContext = null;
this.loopContext = null;
this.breakContext = null;
this.chainContext = null;
this.currentSegments = [];
this.initialSegment = this.forkContext.head[0];
// returnedSegments and thrownSegments push elements into finalSegments also.
const final = (this.finalSegments = []);
const returned = (this.returnedForkContext = []);
const thrown = (this.thrownForkContext = []);
returned.add = addToReturnedOrThrown.bind(null, returned, thrown, final);
thrown.add = addToReturnedOrThrown.bind(null, thrown, returned, final);
}
/**
* The head segments.
* @type {CodePathSegment[]}
*/
get headSegments() {
return this.forkContext.head;
}
/**
* The parent forking context.
* This is used for the root of new forks.
* @type {ForkContext}
*/
get parentForkContext() {
const current = this.forkContext;
return current && current.upper;
}
/**
* Creates and stacks new forking context.
* @param {boolean} forkLeavingPath A flag which shows being in a
* "finally" block.
* @returns {ForkContext} The created context.
*/
pushForkContext(forkLeavingPath) {
this.forkContext = ForkContext.newEmpty(this.forkContext, forkLeavingPath);
return this.forkContext;
}
/**
* Pops and merges the last forking context.
* @returns {ForkContext} The last context.
*/
popForkContext() {
const lastContext = this.forkContext;
this.forkContext = lastContext.upper;
this.forkContext.replaceHead(lastContext.makeNext(0, -1));
return lastContext;
}
/**
* Creates a new path.
* @returns {void}
*/
forkPath() {
this.forkContext.add(this.parentForkContext.makeNext(-1, -1));
}
Source
Frequently Asked Questions
What is the CodePathState class?
CodePathState is a class in the react codebase, defined in packages/eslint-plugin-react-hooks/src/code-path-analysis/code-path-state.js.
Where is CodePathState defined?
CodePathState is defined in packages/eslint-plugin-react-hooks/src/code-path-analysis/code-path-state.js at line 222.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free