rpcProtocol.ts ×26

Frontier kind: Code frontier

unlabeled · c_4328dea1ec9b

3 tests · 8426 LOC · 37 files · introduces 0 tests · 87 LOC · 1 file

Introduces — evidence that enters the hierarchy at this concept

Code
26 ranges87 lines · 1 files
Tests
0 tests

Contains — complete concept membership

All code (extent)
1369 ranges8426 lines · 37 files · Browse complete extent
All tests (intent)
3 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: 87 introduced LOC across 26 ranges. Expand a file to inspect source; the > gutter marks introduced lines.

src/vs/workbench/services/extensions/common/rpcProtocol.ts 87 introduced LOC · 26 ranges

Open complete file

302 case MessageType.RequestMixedArgs:
303 case MessageType.RequestMixedArgsWithCancellation: {
304 > let { rpcId, method, args } = MessageIO.deserializeRequestMixedArgs(buff); rpcProtocol.ts
305 > if (this._uriTransformer) {
306 args = transformIncomingURIs(args, this._uriTransformer);
307 }
308 > this._receiveRequest(msgLength, req, rpcId, method, args, (messageType === MessageType.RequestMixedArgsWithCancellation)); rpcProtocol.ts
309 > break;
310 > }
311 case MessageType.Acknowledged: {
312 this._logger?.logIncoming(msgLength, req, RequestInitiator.LocalSide, `ack`);
616
617 public static sizeMixedArray(arr: readonly MixedArg[]): number {
618 > let size = 0; rpcProtocol.ts
619 > size += 1; // arr length
620 > for (let i = 0, len = arr.length; i < len; i++) {
621 > const el = arr[i];
622 > size += 1; // arg type
623 > switch (el.type) {
624 > case ArgType.String:
625 size += this.sizeLongString(el.value);
626 break;
627 > case ArgType.VSBuffer: rpcProtocol.ts
628 size += this.sizeVSBuffer(el.value);
629 break;
630 > case ArgType.SerializedObjectWithBuffers: rpcProtocol.ts
631 size += this.sizeUInt32; // buffer count
632 size += this.sizeLongString(el.value);
635 }
636 break;
637 > case ArgType.Undefined: rpcProtocol.ts
638 // empty...
639 break;
640 > } rpcProtocol.ts
641 > }
642 > return size;
643 > }
644
645 public writeMixedArray(arr: readonly MixedArg[]): void {
646 > this._buff.writeUInt8(arr.length, this._offset); this._offset += 1; rpcProtocol.ts
647 > for (let i = 0, len = arr.length; i < len; i++) {
648 > const el = arr[i];
649 > switch (el.type) {
650 > case ArgType.String:
651 this.writeUInt8(ArgType.String);
652 this.writeLongString(el.value);
653 break;
654 > case ArgType.VSBuffer: rpcProtocol.ts
655 this.writeUInt8(ArgType.VSBuffer);
656 this.writeVSBuffer(el.value);
657 break;
658 > case ArgType.SerializedObjectWithBuffers: rpcProtocol.ts
659 this.writeUInt8(ArgType.SerializedObjectWithBuffers);
660 this.writeUInt32(el.buffers.length);
664 }
665 break;
666 > case ArgType.Undefined: rpcProtocol.ts
667 this.writeUInt8(ArgType.Undefined);
668 break;
669 > } rpcProtocol.ts
670 > }
671 > }
672
673 public readMixedArray(): Array<string | VSBuffer | SerializableObjectWithBuffers<any> | undefined> {
674 > const arrLen = this._buff.readUInt8(this._offset); this._offset += 1; rpcProtocol.ts
675 > const arr: Array<string | VSBuffer | SerializableObjectWithBuffers<any> | undefined> = new Array(arrLen);
676 > for (let i = 0; i < arrLen; i++) {
677 > const argType = <ArgType>this.readUInt8();
678 > switch (argType) {
679 > case ArgType.String:
680 arr[i] = this.readLongString();
681 break;
682 > case ArgType.VSBuffer: rpcProtocol.ts
683 arr[i] = this.readVSBuffer();
684 break;
685 > case ArgType.SerializedObjectWithBuffers: { rpcProtocol.ts
686 const bufferCount = this.readUInt32();
687 const jsonString = this.readLongString();
693 break;
694 }
695 > case ArgType.Undefined: rpcProtocol.ts
696 arr[i] = undefined;
697 break;
698 > } rpcProtocol.ts
699 > }
700 > return arr;
701 > }
702 }
703
731 public static serializeRequestArguments(args: any[], replacer: JSONStringifyReplacer | null): SerializedRequestArguments {
732 if (this._useMixedArgSerialization(args)) {
733 > const massagedArgs: MixedArg[] = []; rpcProtocol.ts
734 > for (let i = 0, len = args.length; i < len; i++) {
735 > const arg = args[i];
736 > if (arg instanceof VSBuffer) {
737 massagedArgs[i] = { type: ArgType.VSBuffer, value: arg };
738 > } else if (typeof arg === 'undefined') { rpcProtocol.ts
739 massagedArgs[i] = { type: ArgType.Undefined };
740 > } else if (arg instanceof SerializableObjectWithBuffers) { rpcProtocol.ts
741 const { jsonString, referencedBuffers } = stringifyJsonWithBufferRefs(arg.value, replacer);
742 massagedArgs[i] = { type: ArgType.SerializedObjectWithBuffers, value: VSBuffer.fromString(jsonString), buffers: referencedBuffers };
743 > } else { rpcProtocol.ts
744 massagedArgs[i] = { type: ArgType.String, value: VSBuffer.fromString(stringify(arg, replacer)) };
745 }
746 > } rpcProtocol.ts
747 > return {
748 > type: SerializedRequestArgumentType.Mixed,
749 > args: massagedArgs,
750 > };
751 > }
752 return {
753 type: SerializedRequestArgumentType.Simple,
761 return this._requestJSONArgs(req, rpcId, method, serializedArgs.args, usesCancellationToken);
762 case SerializedRequestArgumentType.Mixed:
763 > return this._requestMixedArgs(req, rpcId, method, serializedArgs.args, usesCancellationToken); rpcProtocol.ts
764 }
765 }
793
794 private static _requestMixedArgs(req: number, rpcId: number, method: string, args: readonly MixedArg[], usesCancellationToken: boolean): VSBuffer {
795 > const methodBuff = VSBuffer.fromString(method); rpcProtocol.ts
796 >
797 > let len = 0;
798 > len += MessageBuffer.sizeUInt8();
799 > len += MessageBuffer.sizeShortString(methodBuff);
800 > len += MessageBuffer.sizeMixedArray(args);
801 >
802 > const result = MessageBuffer.alloc(usesCancellationToken ? MessageType.RequestMixedArgsWithCancellation : MessageType.RequestMixedArgs, req, len);
803 > result.writeUInt8(rpcId);
804 > result.writeShortString(methodBuff);
805 > result.writeMixedArray(args);
806 > return result.buffer;
807 > }
808
809 public static deserializeRequestMixedArgs(buff: MessageBuffer): { rpcId: number; method: string; args: any[] } {
810 > const rpcId = buff.readUInt8(); rpcProtocol.ts
811 > const method = buff.readShortString();
812 > const rawargs = buff.readMixedArray();
813 > const args: any[] = new Array(rawargs.length);
814 > for (let i = 0, len = rawargs.length; i < len; i++) {
815 > const rawarg = rawargs[i];
816 > if (typeof rawarg === 'string') {
817 args[i] = JSON.parse(rawarg);
818 > } else { rpcProtocol.ts
819 > args[i] = rawarg;
820 > }
821 > }
822 > return {
823 > rpcId: rpcId,
824 > method: method,
825 > args: args
826 > };
827 > }
828
829 public static serializeAcknowledged(req: number): VSBuffer {