CodePathSegment Class — react Architecture
Architecture documentation for the CodePathSegment class in code-path-segment.js from the react codebase.
Entity Profile
Dependency Diagram
graph TD 94915e97_e9c3_c422_6269_4bbf858b3cf3["CodePathSegment"] ac438c23_5a5b_6b11_2226_aa2b177dbbeb["code-path-segment.js"] 94915e97_e9c3_c422_6269_4bbf858b3cf3 -->|defined in| ac438c23_5a5b_6b11_2226_aa2b177dbbeb 88af2f4b_0846_386a_d921_aee947ed2667["constructor()"] 94915e97_e9c3_c422_6269_4bbf858b3cf3 -->|method| 88af2f4b_0846_386a_d921_aee947ed2667 28bf7901_4048_1e5a_7681_d40e167a7c60["isLoopedPrevSegment()"] 94915e97_e9c3_c422_6269_4bbf858b3cf3 -->|method| 28bf7901_4048_1e5a_7681_d40e167a7c60 7caab13e_99f5_81d9_9255_4404f333523c["newRoot()"] 94915e97_e9c3_c422_6269_4bbf858b3cf3 -->|method| 7caab13e_99f5_81d9_9255_4404f333523c 41574e9a_279d_8634_73bc_065ceb2fdbd5["newNext()"] 94915e97_e9c3_c422_6269_4bbf858b3cf3 -->|method| 41574e9a_279d_8634_73bc_065ceb2fdbd5 6c672222_212c_f636_461c_cc6d37bc9347["newUnreachable()"] 94915e97_e9c3_c422_6269_4bbf858b3cf3 -->|method| 6c672222_212c_f636_461c_cc6d37bc9347 a68b1752_ba73_ac86_858b_7530a1854e43["newDisconnected()"] 94915e97_e9c3_c422_6269_4bbf858b3cf3 -->|method| a68b1752_ba73_ac86_858b_7530a1854e43 0fb6e129_9f7c_9df0_9e75_b9fd2992f912["markUsed()"] 94915e97_e9c3_c422_6269_4bbf858b3cf3 -->|method| 0fb6e129_9f7c_9df0_9e75_b9fd2992f912 ec3be71b_59a5_8f95_30fe_02549507d081["markPrevSegmentAsLooped()"] 94915e97_e9c3_c422_6269_4bbf858b3cf3 -->|method| ec3be71b_59a5_8f95_30fe_02549507d081 3f78bfce_0dd7_08fe_731e_35240fc9240b["flattenUnusedSegments()"] 94915e97_e9c3_c422_6269_4bbf858b3cf3 -->|method| 3f78bfce_0dd7_08fe_731e_35240fc9240b
Relationship Graph
Source Code
packages/eslint-plugin-react-hooks/src/code-path-analysis/code-path-segment.js lines 27–223
class CodePathSegment {
/**
* @param {string} id An identifier.
* @param {CodePathSegment[]} allPrevSegments An array of the previous segments.
* This array includes unreachable segments.
* @param {boolean} reachable A flag which shows this is reachable.
*/
constructor(id, allPrevSegments, reachable) {
/**
* The identifier of this code path.
* Rules use it to store additional information of each rule.
* @type {string}
*/
this.id = id;
/**
* An array of the next segments.
* @type {CodePathSegment[]}
*/
this.nextSegments = [];
/**
* An array of the previous segments.
* @type {CodePathSegment[]}
*/
this.prevSegments = allPrevSegments.filter(isReachable);
/**
* An array of the next segments.
* This array includes unreachable segments.
* @type {CodePathSegment[]}
*/
this.allNextSegments = [];
/**
* An array of the previous segments.
* This array includes unreachable segments.
* @type {CodePathSegment[]}
*/
this.allPrevSegments = allPrevSegments;
/**
* A flag which shows this is reachable.
* @type {boolean}
*/
this.reachable = reachable;
// Internal data.
Object.defineProperty(this, 'internal', {
value: {
used: false,
loopedPrevSegments: [],
},
});
}
/**
* Checks a given previous segment is coming from the end of a loop.
* @param {CodePathSegment} segment A previous segment to check.
* @returns {boolean} `true` if the segment is coming from the end of a loop.
*/
isLoopedPrevSegment(segment) {
return this.internal.loopedPrevSegments.includes(segment);
}
/**
* Creates the root segment.
* @param {string} id An identifier.
* @returns {CodePathSegment} The created segment.
*/
static newRoot(id) {
return new CodePathSegment(id, [], true);
}
/**
* Creates a segment that follows given segments.
* @param {string} id An identifier.
* @param {CodePathSegment[]} allPrevSegments An array of the previous segments.
* @returns {CodePathSegment} The created segment.
*/
static newNext(id, allPrevSegments) {
Source
Frequently Asked Questions
What is the CodePathSegment class?
CodePathSegment is a class in the react codebase, defined in packages/eslint-plugin-react-hooks/src/code-path-analysis/code-path-segment.js.
Where is CodePathSegment defined?
CodePathSegment is defined in packages/eslint-plugin-react-hooks/src/code-path-analysis/code-path-segment.js at line 27.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free