rpcProtocol.ts ×13

Frontier kind: Code frontier

unlabeled · c_2d55a8d0f7e2

14 tests · 8039 LOC · 37 files · introduces 0 tests · 61 LOC · 1 file

Introduces — evidence that enters the hierarchy at this concept

Code
13 ranges61 lines · 1 files
Tests
0 tests

Contains — complete concept membership

All code (extent)
1241 ranges8039 lines · 37 files · Browse complete extent
All tests (intent)
14 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: 61 introduced LOC across 13 ranges. Expand a file to inspect source; the > gutter marks introduced lines.

src/vs/workbench/services/extensions/common/rpcProtocol.ts 61 introduced LOC · 13 ranges

Open complete file

83 }
84
85 > function createURIReplacer(transformer: IURITransformer | null): JSONStringifyReplacer | null { rpcProtocol.ts
86 > if (!transformer) {
87 > return null;
88 > }
89 return (key: string, value: any): any => {
90 if (value && value.$mid === MarshalledId.Uri) {
140
141 constructor(protocol: IMessagePassingProtocol, logger: IRPCProtocolLogger | null = null, transformer: IURITransformer | null = null) {
142 > super(); rpcProtocol.ts
143 > this._protocol = protocol;
144 > this._logger = logger;
145 > this._uriTransformer = transformer;
146 > this._uriReplacer = createURIReplacer(this._uriTransformer);
147 > this._isDisposed = false;
148 > this._locals = [];
149 > this._proxies = [];
150 > for (let i = 0, len = ProxyIdentifier.count; i < len; i++) {
151 this._locals[i] = null;
152 this._proxies[i] = null;
153 }
154 > this._lastMessageId = 0; rpcProtocol.ts
155 > this._cancelInvokedHandlers = Object.create(null);
156 > this._pendingRPCReplies = {};
157 > this._responsiveState = ResponsiveState.Responsive;
158 > this._unacknowledgedCount = 0;
159 > this._unresponsiveTime = 0;
160 > this._asyncCheckUresponsive = this._register(new RunOnceScheduler(() => this._checkUnresponsive(), 1000));
161 > this._register(this._protocol.onMessage((msg) => this._receiveOneMessage(msg)));
162 > }
163
164 public override dispose(): void {
165 > this._isDisposed = true; rpcProtocol.ts
166 >
167 > // Release all outstanding promises with a canceled error
168 > Object.keys(this._pendingRPCReplies).forEach((msgId) => {
169 const pending = this._pendingRPCReplies[msgId];
170 delete this._pendingRPCReplies[msgId];
171 pending.resolveErr(errors.canceled());
172 > }); rpcProtocol.ts
173 >
174 > super.dispose();
175 > }
176
177 public drain(): Promise<void> {
242
243 public getProxy<T>(identifier: ProxyIdentifier<T>): Proxied<T> {
244 > const { nid: rpcId, sid } = identifier; rpcProtocol.ts
245 > if (!this._proxies[rpcId]) {
246 > this._proxies[rpcId] = this._createProxy(rpcId, sid);
247 > }
248 > return this._proxies[rpcId];
249 > }
250
251 private _createProxy<T>(rpcId: number, debugName: string): T {
252 > const handler = { rpcProtocol.ts
253 > get: (target: any, name: PropertyKey) => {
254 > if (typeof name === 'string' && !target[name] && name.charCodeAt(0) === CharCode.DollarSign) {
255 > target[name] = (...myArgs: any[]) => {
256 > return this._remoteCall(rpcId, name, myArgs);
257 > };
258 > }
259 > if (name === _RPCProxySymbol) {
260 return debugName;
261 }
262 > return target[name]; rpcProtocol.ts
263 > }
264 > };
265 > return new Proxy(Object.create(null), handler);
266 > }
267
268 public set<T, R extends T>(identifier: ProxyIdentifier<T>, value: R): R {
269 > this._locals[identifier.nid] = value; rpcProtocol.ts
270 > return value;
271 > }
272
273 public assertRegistered(identifiers: ProxyIdentifier<any>[]): void {
460
461 private _remoteCall(rpcId: number, methodName: string, args: any[]): Promise<any> {
462 > if (this._isDisposed) { rpcProtocol.ts
463 return new CanceledLazyPromise();
464 }
465 > let cancellationToken: CancellationToken | null = null; rpcProtocol.ts
466 > if (args.length > 0 && CancellationToken.isCancellationToken(args[args.length - 1])) {
467 cancellationToken = args.pop();
468 }
470 > if (cancellationToken && cancellationToken.isCancellationRequested) {
471 // No need to do anything...
472 return Promise.reject<any>(errors.canceled());
491 this._onWillSendRequest(req);
492 const msg = MessageIO.serializeRequest(req, rpcId, methodName, serializedRequestArguments, !!cancellationToken);
493 > this._logger?.logOutgoing(msg.byteLength, req, RequestInitiator.LocalSide, `request: ${getStringIdentifierForProxy(rpcId)}.${methodName}(`, args); rpcProtocol.ts
494 > this._protocol.send(msg);
495 > return result;
496 > }
497 }
498