derivedImpl.ts ×13

Frontier kind: Code frontier

unlabeled · c_17ea166147da

774 tests · 6567 LOC · 59 files · introduces 0 tests · 74 LOC · 1 file

Introduces — evidence that enters the hierarchy at this concept

Code
13 ranges74 lines · 1 files
Tests
0 tests

Contains — complete concept membership

All code (extent)
960 ranges6567 lines · 59 files · Browse complete extent
All tests (intent)
774 testsBrowse complete intent

Neighbourhood graph

The orange circle is the focus. Violet and green circles are every ancestor and descendant, broader and narrower, at any distance; blue squares and pink diamonds are the introduced files and exact introduced tests of every visible concept, not only the focus's. Arrows point from broader to narrower concepts and bridge only concepts omitted from this view. Undirected links show source or test introduction. Concept and file size follows LOC; exact test nodes use test-count units.

Introduced files, introduced tests, and structurally relevant concept specialization

In the embedded map, ordinary wheel input scrolls the page; use the visible controls to zoom and drag to pan. Open the full-screen map for canvas navigation: wheel pans, Ctrl/Command plus wheel zooms, and arrow keys pan when this region is focused. On touch screens, open the full-screen map to pan or pinch. If JavaScript or WebGL is unavailable, use the native relationship evidence on this page.

Graph controls are ready.

Interactive rendering requires JavaScript and WebGL. Use the native relationship evidence on this page while the interactive map is unavailable.

Native relationship evidence

Every exact file and test below is linked only from the concept that introduces it.

Introduced tests

Every collected test enters the hierarchy at exactly one concept.

No tests are introduced at this concept. Its intent tests are introduced by other concepts.

Introduced code

Every collected source range enters the hierarchy at exactly one concept.

1 file ranked by introduced lines: 74 introduced LOC across 13 ranges. Expand a file to inspect source; the > gutter marks introduced lines.

src/vs/base/common/observableInternal/observables/derivedImpl.ts 74 introduced LOC · 13 ranges

Open complete file

135
136 } else {
137 > do { derivedImpl.ts
138 > // We might not get a notification for a dependency that changed while it is updating,
139 > // thus we also have to ask all our depedencies if they changed in this case.
140 > if (this._state === DerivedState.dependenciesMightHaveChanged) {
141 for (const d of this._dependencies) {
142 /** might call {@link handleChange} indirectly, which could make us stale */
149 }
150 }
152 > // We called report changes of all dependencies.
153 > // If we are still not stale, we can assume to be up to date again.
154 > if (this._state === DerivedState.dependenciesMightHaveChanged) {
155 this._state = DerivedState.upToDate;
156 }
158 > if (this._state !== DerivedState.upToDate) {
159 > this._recompute();
160 > }
161 > // In case recomputation changed one of our dependencies, we need to recompute again.
162 > } while (this._state !== DerivedState.upToDate);
163 > return this._value!;
164 > }
165 }
166
167 private _recompute() {
168 > let didChange = false; derivedImpl.ts
169 > this._isComputing = true;
170 > this._didReportChange = false;
171 >
172 > const emptySet = this._dependenciesToBeRemoved;
173 > this._dependenciesToBeRemoved = this._dependencies;
174 > this._dependencies = emptySet;
175 >
176 > try {
177 > const changeSummary = this._changeSummary!;
178 >
179 > this._isReaderValid = true;
180 > if (this._changeTracker) {
181 this._isInBeforeUpdate = true;
182 this._changeTracker.beforeUpdate?.(this, changeSummary);
184 this._changeSummary = this._changeTracker?.createChangeSummary(changeSummary);
185 }
187 > const hadValue = this._state !== DerivedState.initial;
188 > const oldValue = this._value;
189 > this._state = DerivedState.upToDate;
190 >
191 > const delayedStore = this._delayedStore;
192 > if (delayedStore !== undefined) {
193 this._delayedStore = undefined;
194 }
195 > try { derivedImpl.ts
196 > if (this._store !== undefined) {
197 this._store.dispose();
198 this._store = undefined;
199 }
200 > /** might call {@link handleChange} indirectly, which could invalidate us */ derivedImpl.ts
201 > this._value = this._computeFn(this, changeSummary);
202 >
203 > } finally {
204 > this._isReaderValid = false;
205 > // We don't want our observed observables to think that they are (not even temporarily) not being observed.
206 > // Thus, we only unsubscribe from observables that are definitely not read anymore.
207 > for (const o of this._dependenciesToBeRemoved) {
208 o.removeObserver(this);
209 }
210 > this._dependenciesToBeRemoved.clear(); derivedImpl.ts
211 >
212 > if (delayedStore !== undefined) {
213 delayedStore.dispose();
214 }
215 > } derivedImpl.ts
216 >
217 > didChange = this._didReportChange || (hadValue && !(this._equalityComparator(oldValue!, this._value)));
218 >
219 > getLogger()?.handleObservableUpdated(this, {
220 > oldValue,
221 > newValue: this._value,
222 > change: undefined,
223 > didChange,
224 > hadValue,
225 > });
226 > } catch (e) {
227 onBugIndicatingError(e);
228 }
230 > this._isComputing = false;
231 >
232 > if (!this._didReportChange && didChange) {
233 for (const r of this._observers) {
234 r.handleChange(this, undefined);
235 }
236 > } else { derivedImpl.ts
237 > this._didReportChange = false;
238 > }
239 > }
240
241 public override toString(): string {
378
379 public override addObserver(observer: IObserver): void {
380 > const shouldCallBeginUpdate = !this._observers.has(observer) && this._updateCount > 0; derivedImpl.ts
381 > super.addObserver(observer);
382 >
383 > if (shouldCallBeginUpdate) {
384 if (!this._removedObserverToCallEndUpdateOn?.delete(observer)) {
385 observer.beginUpdate(this);
386 }
387 }
388 > } derivedImpl.ts
389
390 public override removeObserver(observer: IObserver): void {