assignmentContextFilter.ts ×6

Frontier kind: Code frontier

unlabeled · c_261ef8959a76

82 tests · 12380 LOC · 51 files · introduces 0 tests · 59 LOC · 1 file

Introduces — evidence that enters the hierarchy at this concept

Code
6 ranges59 lines · 1 files
Tests
0 tests

Contains — complete concept membership

All code (extent)
1740 ranges12380 lines · 51 files · Browse complete extent
All tests (intent)
82 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: 59 introduced LOC across 6 ranges. Expand a file to inspect source; the > gutter marks introduced lines.

src/vs/workbench/services/assignment/common/assignmentContextFilter.ts 59 introduced LOC · 6 ranges

Open complete file

1 > /*--------------------------------------------------------------------------------------------- assignmentContextFilter.ts
2 > * Copyright (c) Microsoft Corporation. All rights reserved.
3 > * Licensed under the MIT License. See License.txt in the project root for license information.
4 > *--------------------------------------------------------------------------------------------*/
5 >
6 > import { Emitter, Event } from '../../../../base/common/event.js';
7 > import { Disposable, DisposableStore } from '../../../../base/common/lifecycle.js';
8 > import { IStorageService, StorageScope, StorageTarget } from '../../../../platform/storage/common/storage.js';
9 > import type { IAssignmentFilter } from './assignmentService.js';
10 >
11 > /**
12 > * Applies the registered {@link IAssignmentFilter assignment filters} to the assignment context
13 > * and remembers, per filter, which assignment-context ids each filter excluded.
14 > *
15 > * The excluded ids are persisted so that they stay filtered out across reloads even before the
16 > * owning filter has been registered again. Once a filter is registered it becomes authoritative
17 > * for its own id: the persisted state is repopulated from the ids it currently excludes and any
18 > * id that is no longer excluded is dropped from storage.
19 > */
20 > export class AssignmentContextFilter extends Disposable {
21 >
22 > private static readonly STORAGE_KEY = 'workbench.assignment.filteredOutAssignmentContextIds';
23 >
24 > private readonly _filters: IAssignmentFilter[] = [];
25 > private readonly _filterDisposables = this._register(new DisposableStore());
26 >
27 > /**
28 > * Assignment-context ids that were filtered out, keyed by the id of the filter that
29 > * excluded them. Entries owned by a filter that has not been registered yet are honored
30 > * across reloads so those ids stay excluded until the filter takes over.
31 > */
32 > private _cachedFilteredOutIds: Map<string, Set<string>>;
33 >
34 > /**
35 > * Ids of filters that have been registered this session. Once a filter is registered it
36 > * becomes authoritative for its own id and the persisted cache is repopulated from the
37 > * ids it actually excludes.
38 > */
39 > private readonly _registeredFilterIds = new Set<string>();
40 >
41 > private readonly _onDidChange = this._register(new Emitter<void>());
42 > /** Fires when a filter is added or an already registered filter changes its exclusions. */
43 > readonly onDidChange: Event<void> = this._onDidChange.event;
44 >
45 > constructor(
46 private readonly storageService: IStorageService
47 ) {
50 this._cachedFilteredOutIds = this._loadFilteredOutIds();
51 }
53 > addFilter(filter: IAssignmentFilter): void {
54 this._filters.push(filter);
55
66 this._onDidChange.fire();
67 }
69 > /**
70 > * Removes the excluded assignment-context ids from the given context and persists the
71 > * reconciled per-filter cache.
72 > */
73 > filter(assignmentContext: string): string {
74 const assignments = assignmentContext.split(';');
75
121 return filteredAssignments.join(';');
122 }
124 > private _loadFilteredOutIds(): Map<string, Set<string>> {
125 const result = new Map<string, Set<string>>();
126 const raw = this.storageService.get(AssignmentContextFilter.STORAGE_KEY, StorageScope.APPLICATION);
147 return result;
148 }
150 > private _storeFilteredOutIds(next: Map<string, Set<string>>): void {
151 // Drop empty entries so an id disappears from storage once nothing is filtered out for it.
152 const normalized = new Map<string, Set<string>>();
173 }
174 }
176 >
177 function areCachesEqual(a: Map<string, Set<string>>, b: Map<string, Set<string>>): boolean {
178 if (a.size !== b.size) {