MCPcopy
hub / github.com/angular/angular / LogicNodeBuilder

Class LogicNodeBuilder

packages/forms/signals/src/schema/logic_node.ts:90–226  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

88 * preserving the order of rule application.
89 */
90export class LogicNodeBuilder extends AbstractLogicNodeBuilder {
91 constructor(depth: number) {
92 super(depth);
93 }
94
95 /**
96 * The current `NonMergeableLogicNodeBuilder` being used to add rules directly to this
97 * `LogicNodeBuilder`. Do not use this directly, call `getCurrent()` which will create a current
98 * builder if there is none.
99 */
100 private current: NonMergeableLogicNodeBuilder | undefined;
101 /**
102 * Stores all builders that contribute to this node, along with any predicates
103 * that gate their application.
104 */
105 readonly all: {builder: AbstractLogicNodeBuilder; predicate?: Predicate}[] = [];
106
107 override addHiddenRule(logic: LogicFn<any, boolean>): void {
108 this.getCurrent().addHiddenRule(logic);
109 }
110
111 override addDisabledReasonRule(logic: LogicFn<any, DisabledReason | undefined>): void {
112 this.getCurrent().addDisabledReasonRule(logic);
113 }
114
115 override addReadonlyRule(logic: LogicFn<any, boolean>): void {
116 this.getCurrent().addReadonlyRule(logic);
117 }
118
119 override addSyncErrorRule(
120 logic: LogicFn<any, ValidationResult<ValidationError.WithFieldTree>>,
121 ): void {
122 this.getCurrent().addSyncErrorRule(logic);
123 }
124
125 override addSyncTreeErrorRule(
126 logic: LogicFn<any, ValidationResult<ValidationError.WithFieldTree>>,
127 ): void {
128 this.getCurrent().addSyncTreeErrorRule(logic);
129 }
130
131 override addAsyncErrorRule(
132 logic: LogicFn<any, AsyncValidationResult<ValidationError.WithFieldTree>>,
133 ): void {
134 this.getCurrent().addAsyncErrorRule(logic);
135 }
136
137 override addMetadataRule<T>(key: MetadataKey<unknown, T, any>, logic: LogicFn<any, T>): void {
138 this.getCurrent().addMetadataRule(key, logic);
139 }
140
141 override getChild(key: PropertyKey): LogicNodeBuilder {
142 // Close off the current builder if the key is DYNAMIC and the current builder already has logic
143 // for some non-DYNAMIC key. This guarantees that all of the DYNAMIC logic always comes before
144 // all of the specific-key logic for any given instance of `NonMergeableLogicNodeBuilder`.
145 // We rely on this fact in `getAllChildBuilder` to know that we can return the DYNAMIC logic,
146 // followed by the property-specific logic, in that order.
147 if (key === DYNAMIC) {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…