extHostTypes.ts ×270

Frontier kind: Code frontier

unlabeled · c_ee232b625081

103 tests · 68881 LOC · 244 files · introduces 0 tests · 6339 LOC · 23 files

Introduces — evidence that enters the hierarchy at this concept

Code
811 ranges6339 lines · 23 files
Tests
0 tests

Contains — complete concept membership

All code (extent)
4673 ranges68881 lines · 244 files · Browse complete extent
All tests (intent)
103 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.

Showing the top 20 of 23 files by introduced lines: 6274 of 6339 introduced LOC and 802 of 811 ranges. Expand a file to inspect source; the > gutter marks introduced lines.

src/vs/workbench/api/common/extHostTypes.ts 2894 introduced LOC · 270 ranges

Open complete file

1 > /*--------------------------------------------------------------------------------------------- extHostTypes.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 type * as vscode from 'vscode';
7 > import { asArray } from '../../../base/common/arrays.js';
8 > import { encodeBase64, VSBuffer } from '../../../base/common/buffer.js';
9 > import { illegalArgument, SerializedError } from '../../../base/common/errors.js';
10 > import { IRelativePattern } from '../../../base/common/glob.js';
11 > import { MarshalledId } from '../../../base/common/marshallingIds.js';
12 > import { Mimes } from '../../../base/common/mime.js';
13 > import { nextCharLength } from '../../../base/common/strings.js';
14 > import { isNumber, isObject, isString, isStringArray } from '../../../base/common/types.js';
15 > import { isUriComponents, URI } from '../../../base/common/uri.js';
16 > import { generateUuid } from '../../../base/common/uuid.js';
17 > import { TextEditorSelectionSource } from '../../../platform/editor/common/editor.js';
18 > import { ExtensionIdentifier, IExtensionDescription } from '../../../platform/extensions/common/extensions.js';
19 > import { FileSystemProviderErrorCode, markAsFileSystemProviderError } from '../../../platform/files/common/files.js';
20 > import { RemoteAuthorityResolverErrorCode } from '../../../platform/remote/common/remoteAuthorityResolver.js';
21 > import { IRelativePatternDto } from './extHost.protocol.js';
22 > import { CodeActionKind } from './extHostTypes/codeActionKind.js';
23 > import { Diagnostic } from './extHostTypes/diagnostic.js';
24 > import { es5ClassCompat } from './extHostTypes/es5ClassCompat.js';
25 > import { Location } from './extHostTypes/location.js';
26 > import { MarkdownString } from './extHostTypes/markdownString.js';
27 > import { Position } from './extHostTypes/position.js';
28 > import { Range } from './extHostTypes/range.js';
29 > import { SnippetString } from './extHostTypes/snippetString.js';
30 > import { SymbolKind, SymbolTag } from './extHostTypes/symbolInformation.js';
31 > import { TextEdit } from './extHostTypes/textEdit.js';
32 > import { WorkspaceEdit } from './extHostTypes/workspaceEdit.js';
33 > import { HookTypeValue } from '../../contrib/chat/common/promptSyntax/hookTypes.js';
34 >
35 > export { CodeActionKind } from './extHostTypes/codeActionKind.js';
36 > export {
37 > Diagnostic, DiagnosticRelatedInformation,
38 > DiagnosticSeverity, DiagnosticTag
39 > } from './extHostTypes/diagnostic.js';
40 > export { Location } from './extHostTypes/location.js';
41 > export { MarkdownString } from './extHostTypes/markdownString.js';
42 > export { NotebookCellData, NotebookCellKind, NotebookCellOutput, NotebookCellOutputItem, NotebookData, NotebookEdit, NotebookRange } from './extHostTypes/notebooks.js';
43 > export { Position } from './extHostTypes/position.js';
44 > export { Range } from './extHostTypes/range.js';
45 > export { Selection } from './extHostTypes/selection.js';
46 > export { SnippetString } from './extHostTypes/snippetString.js';
47 > export { SnippetTextEdit } from './extHostTypes/snippetTextEdit.js';
48 > export { SymbolInformation, SymbolKind, SymbolTag } from './extHostTypes/symbolInformation.js';
49 > export { EndOfLine, TextEdit } from './extHostTypes/textEdit.js';
50 > export { FileEditType, WorkspaceEdit } from './extHostTypes/workspaceEdit.js';
51 >
52 > export enum TerminalOutputAnchor {
53 > Top = 0,
54 > Bottom = 1
55 > }
56 >
57 > export enum TerminalQuickFixType {
58 > TerminalCommand = 0,
59 > Opener = 1,
60 > Command = 3
61 > }
62 >
63 > @es5ClassCompat
64 > export class Disposable {
65 >
66 > static from(...inDisposables: { dispose(): any }[]): Disposable {
67 > let disposables: ReadonlyArray<{ dispose(): any }> | undefined = inDisposables;
68 > return new Disposable(function () {
69 > if (disposables) {
70 > for (const disposable of disposables) {
71 > if (disposable && typeof disposable.dispose === 'function') {
72 > disposable.dispose();
73 > }
74 > }
75 > disposables = undefined;
76 > }
77 > });
78 > }
79 >
80 > #callOnDispose?: () => any;
81 >
82 > constructor(callOnDispose: () => any) {
83 this.#callOnDispose = callOnDispose;
84 }
86 > dispose(): any {
87 if (typeof this.#callOnDispose === 'function') {
88 this.#callOnDispose();
90 }
91 }
93 >
94 > const validateConnectionToken = (connectionToken: string) => {
95 if (typeof connectionToken !== 'string' || connectionToken.length === 0 || !/^[0-9A-Za-z_\-]+$/.test(connectionToken)) {
96 throw illegalArgument('connectionToken');
97 }
98 };
100 >
101 > export class ResolvedAuthority {
102 > public static isResolvedAuthority(resolvedAuthority: any): resolvedAuthority is ResolvedAuthority {
103 return resolvedAuthority
104 && typeof resolvedAuthority === 'object'
107 && (resolvedAuthority.connectionToken === undefined || typeof resolvedAuthority.connectionToken === 'string');
108 }
110 > readonly host: string;
111 > readonly port: number;
112 > readonly connectionToken: string | undefined;
113 >
114 > constructor(host: string, port: number, connectionToken?: string) {
115 if (typeof host !== 'string' || host.length === 0) {
116 throw illegalArgument('host');
126 this.connectionToken = connectionToken;
127 }
128 > } extHostTypes.ts
129 >
130 >
131 > export class ManagedResolvedAuthority {
132 >
133 > public static isManagedResolvedAuthority(resolvedAuthority: any): resolvedAuthority is ManagedResolvedAuthority {
134 > return resolvedAuthority
135 > && typeof resolvedAuthority === 'object'
136 > && typeof resolvedAuthority.makeConnection === 'function'
137 > && (resolvedAuthority.connectionToken === undefined || typeof resolvedAuthority.connectionToken === 'string');
138 > }
139 >
140 > constructor(public readonly makeConnection: () => Thenable<vscode.ManagedMessagePassing>, public readonly connectionToken?: string) {
141 if (typeof connectionToken !== 'undefined') {
142 validateConnectionToken(connectionToken);
143 }
144 }
145 > } extHostTypes.ts
146 >
147 > export class RemoteAuthorityResolverError extends Error {
148 >
149 > static NotAvailable(message?: string, handled?: boolean): RemoteAuthorityResolverError {
150 return new RemoteAuthorityResolverError(message, RemoteAuthorityResolverErrorCode.NotAvailable, handled);
151 }
153 > static TemporarilyNotAvailable(message?: string): RemoteAuthorityResolverError {
154 return new RemoteAuthorityResolverError(message, RemoteAuthorityResolverErrorCode.TemporarilyNotAvailable);
155 }
157 > public readonly _message: string | undefined;
158 > public readonly _code: RemoteAuthorityResolverErrorCode;
159 > public readonly _detail: unknown;
160 >
161 > constructor(message?: string, code: RemoteAuthorityResolverErrorCode = RemoteAuthorityResolverErrorCode.Unknown, detail?: unknown) {
162 super(message);
163
170 Object.setPrototypeOf(this, RemoteAuthorityResolverError.prototype);
171 }
172 > } extHostTypes.ts
173 >
174 > export enum EnvironmentVariableMutatorType {
175 > Replace = 1,
176 > Append = 2,
177 > Prepend = 3
178 > }
179 >
180 > @es5ClassCompat
181 > export class Hover {
182 >
183 > public contents: (vscode.MarkdownString | vscode.MarkedString)[];
184 > public range: Range | undefined;
185 >
186 > constructor(
187 contents: vscode.MarkdownString | vscode.MarkedString | (vscode.MarkdownString | vscode.MarkedString)[],
188 range?: Range
198 this.range = range;
199 }
200 > } extHostTypes.ts
201 >
202 > @es5ClassCompat
203 > export class VerboseHover extends Hover {
204 >
205 > public canIncreaseVerbosity: boolean | undefined;
206 > public canDecreaseVerbosity: boolean | undefined;
207 >
208 > constructor(
209 contents: vscode.MarkdownString | vscode.MarkedString | (vscode.MarkdownString | vscode.MarkedString)[],
210 range?: Range,
216 this.canDecreaseVerbosity = canDecreaseVerbosity;
217 }
218 > } extHostTypes.ts
219 >
220 > export enum HoverVerbosityAction {
221 > Increase = 0,
222 > Decrease = 1
223 > }
224 >
225 > export enum DocumentHighlightKind {
226 > Text = 0,
227 > Read = 1,
228 > Write = 2
229 > }
230 >
231 > @es5ClassCompat
232 > export class DocumentHighlight {
233 >
234 > range: Range;
235 > kind: DocumentHighlightKind;
236 >
237 > constructor(range: Range, kind: DocumentHighlightKind = DocumentHighlightKind.Text) {
238 this.range = range;
239 this.kind = kind;
240 }
242 > toJSON(): any {
243 return {
244 range: this.range,
246 };
247 }
248 > } extHostTypes.ts
249 >
250 > @es5ClassCompat
251 > export class MultiDocumentHighlight {
252 >
253 > uri: URI;
254 > highlights: DocumentHighlight[];
255 >
256 > constructor(uri: URI, highlights: DocumentHighlight[]) {
257 this.uri = uri;
258 this.highlights = highlights;
259 }
261 > toJSON(): any {
262 return {
263 uri: this.uri,
265 };
266 }
267 > } extHostTypes.ts
268 >
269 > @es5ClassCompat
270 > export class DocumentSymbol {
271 >
272 > static validate(candidate: DocumentSymbol): void {
273 if (!candidate.name) {
274 throw new Error('name must not be falsy');
279 candidate.children?.forEach(DocumentSymbol.validate);
280 }
282 > name: string;
283 > detail: string;
284 > kind: SymbolKind;
285 > tags?: SymbolTag[];
286 > range: Range;
287 > selectionRange: Range;
288 > children: DocumentSymbol[];
289 >
290 > constructor(name: string, detail: string, kind: SymbolKind, range: Range, selectionRange: Range) {
291 this.name = name;
292 this.detail = detail;
298 DocumentSymbol.validate(this);
299 }
300 > } extHostTypes.ts
301 >
302 >
303 > export enum CodeActionTriggerKind {
304 > Invoke = 1,
305 > Automatic = 2,
306 > }
307 >
308 > @es5ClassCompat
309 > export class CodeAction {
310 > title: string;
311 >
312 > command?: vscode.Command;
313 >
314 > edit?: WorkspaceEdit;
315 >
316 > diagnostics?: Diagnostic[];
317 >
318 > kind?: CodeActionKind;
319 >
320 > isPreferred?: boolean;
321 >
322 > constructor(title: string, kind?: CodeActionKind) {
323 this.title = title;
324 this.kind = kind;
325 }
326 > } extHostTypes.ts
327 >
328 > @es5ClassCompat
329 > export class SelectionRange {
330 >
331 > range: Range;
332 > parent?: SelectionRange;
333 >
334 > constructor(range: Range, parent?: SelectionRange) {
335 this.range = range;
336 this.parent = parent;
340 }
341 }
342 > } extHostTypes.ts
343 >
344 > export class CallHierarchyItem {
345 >
346 > _sessionId?: string;
347 > _itemId?: string;
348 >
349 > kind: SymbolKind;
350 > tags?: SymbolTag[];
351 > name: string;
352 > detail?: string;
353 > uri: URI;
354 > range: Range;
355 > selectionRange: Range;
356 >
357 > constructor(kind: SymbolKind, name: string, detail: string, uri: URI, range: Range, selectionRange: Range) {
358 this.kind = kind;
359 this.name = name;
363 this.selectionRange = selectionRange;
364 }
365 > } extHostTypes.ts
366 >
367 > export class CallHierarchyIncomingCall {
368 >
369 > from: vscode.CallHierarchyItem;
370 > fromRanges: vscode.Range[];
371 >
372 > constructor(item: vscode.CallHierarchyItem, fromRanges: vscode.Range[]) {
373 this.fromRanges = fromRanges;
374 this.from = item;
375 }
376 > } extHostTypes.ts
377 > export class CallHierarchyOutgoingCall {
378 >
379 > to: vscode.CallHierarchyItem;
380 > fromRanges: vscode.Range[];
381 >
382 > constructor(item: vscode.CallHierarchyItem, fromRanges: vscode.Range[]) {
383 this.fromRanges = fromRanges;
384 this.to = item;
385 }
386 > } extHostTypes.ts
387 >
388 > export enum LanguageStatusSeverity {
389 > Information = 0,
390 > Warning = 1,
391 > Error = 2
392 > }
393 >
394 >
395 > @es5ClassCompat
396 > export class CodeLens {
397 >
398 > range: Range;
399 >
400 > command: vscode.Command | undefined;
401 >
402 > constructor(range: Range, command?: vscode.Command) {
403 this.range = range;
404 this.command = command;
405 }
407 > get isResolved(): boolean {
408 return !!this.command;
409 }
410 > } extHostTypes.ts
411 >
412 > @es5ClassCompat
413 > export class ParameterInformation {
414 >
415 > label: string | [number, number];
416 > documentation?: string | vscode.MarkdownString;
417 >
418 > constructor(label: string | [number, number], documentation?: string | vscode.MarkdownString) {
419 this.label = label;
420 this.documentation = documentation;
421 }
422 > } extHostTypes.ts
423 >
424 > @es5ClassCompat
425 > export class SignatureInformation {
426 >
427 > label: string;
428 > documentation?: string | vscode.MarkdownString;
429 > parameters: ParameterInformation[];
430 > activeParameter?: number;
431 >
432 > constructor(label: string, documentation?: string | vscode.MarkdownString) {
433 this.label = label;
434 this.documentation = documentation;
435 this.parameters = [];
436 }
437 > } extHostTypes.ts
438 >
439 > @es5ClassCompat
440 > export class SignatureHelp {
441 >
442 > signatures: SignatureInformation[];
443 > activeSignature: number = 0;
444 > activeParameter: number = 0;
445 >
446 > constructor() {
447 this.signatures = [];
448 }
449 > } extHostTypes.ts
450 >
451 > export enum SignatureHelpTriggerKind {
452 > Invoke = 1,
453 > TriggerCharacter = 2,
454 > ContentChange = 3,
455 > }
456 >
457 >
458 > export enum InlayHintKind {
459 > Type = 1,
460 > Parameter = 2,
461 > }
462 >
463 > @es5ClassCompat
464 > export class InlayHintLabelPart {
465 >
466 > value: string;
467 > tooltip?: string | vscode.MarkdownString;
468 > location?: Location;
469 > command?: vscode.Command;
470 >
471 > constructor(value: string) {
472 this.value = value;
473 }
474 > } extHostTypes.ts
475 >
476 > @es5ClassCompat
477 > export class InlayHint implements vscode.InlayHint {
478 >
479 > label: string | InlayHintLabelPart[];
480 > tooltip?: string | vscode.MarkdownString;
481 > position: Position;
482 > textEdits?: TextEdit[];
483 > kind?: vscode.InlayHintKind;
484 > paddingLeft?: boolean;
485 > paddingRight?: boolean;
486 >
487 > constructor(position: Position, label: string | InlayHintLabelPart[], kind?: vscode.InlayHintKind) {
488 this.position = position;
489 this.label = label;
490 this.kind = kind;
491 }
492 > } extHostTypes.ts
493 >
494 > export enum CompletionTriggerKind {
495 > Invoke = 0,
496 > TriggerCharacter = 1,
497 > TriggerForIncompleteCompletions = 2
498 > }
499 >
500 > export interface CompletionContext {
501 > readonly triggerKind: CompletionTriggerKind;
502 > readonly triggerCharacter: string | undefined;
503 > }
504 >
505 > export enum CompletionItemKind {
506 > Text = 0,
507 > Method = 1,
508 > Function = 2,
509 > Constructor = 3,
510 > Field = 4,
511 > Variable = 5,
512 > Class = 6,
513 > Interface = 7,
514 > Module = 8,
515 > Property = 9,
516 > Unit = 10,
517 > Value = 11,
518 > Enum = 12,
519 > Keyword = 13,
520 > Snippet = 14,
521 > Color = 15,
522 > File = 16,
523 > Reference = 17,
524 > Folder = 18,
525 > EnumMember = 19,
526 > Constant = 20,
527 > Struct = 21,
528 > Event = 22,
529 > Operator = 23,
530 > TypeParameter = 24,
531 > User = 25,
532 > Issue = 26
533 > }
534 >
535 > export enum CompletionItemTag {
536 > Deprecated = 1,
537 > }
538 >
539 > export interface CompletionItemLabel {
540 > label: string;
541 > detail?: string;
542 > description?: string;
543 > }
544 >
545 > @es5ClassCompat
546 > export class CompletionItem implements vscode.CompletionItem {
547 >
548 > label: string | CompletionItemLabel;
549 > kind?: CompletionItemKind;
550 > tags?: CompletionItemTag[];
551 > detail?: string;
552 > documentation?: string | vscode.MarkdownString;
553 > sortText?: string;
554 > filterText?: string;
555 > preselect?: boolean;
556 > insertText?: string | SnippetString;
557 > keepWhitespace?: boolean;
558 > range?: Range | { inserting: Range; replacing: Range };
559 > commitCharacters?: string[];
560 > textEdit?: TextEdit;
561 > additionalTextEdits?: TextEdit[];
562 > command?: vscode.Command;
563 >
564 > constructor(label: string | CompletionItemLabel, kind?: CompletionItemKind) {
565 this.label = label;
566 this.kind = kind;
567 }
569 > toJSON(): any {
570 return {
571 label: this.label,
580 };
581 }
582 > } extHostTypes.ts
583 >
584 > @es5ClassCompat
585 > export class CompletionList {
586 >
587 > isIncomplete?: boolean;
588 > items: vscode.CompletionItem[];
589 >
590 > constructor(items: vscode.CompletionItem[] = [], isIncomplete: boolean = false) {
591 this.items = items;
592 this.isIncomplete = isIncomplete;
593 }
594 > } extHostTypes.ts
595 >
596 > @es5ClassCompat
597 > export class InlineSuggestion implements vscode.InlineCompletionItem {
598 >
599 > filterText?: string;
600 > insertText: string;
601 > range?: Range;
602 > command?: vscode.Command;
603 >
604 > constructor(insertText: string, range?: Range, command?: vscode.Command) {
605 this.insertText = insertText;
606 this.range = range;
607 this.command = command;
608 }
609 > } extHostTypes.ts
610 >
611 > @es5ClassCompat
612 > export class InlineSuggestionList implements vscode.InlineCompletionList {
613 > items: vscode.InlineCompletionItem[];
614 >
615 > commands: (vscode.Command | { command: vscode.Command; icon: vscode.ThemeIcon })[] | undefined = undefined;
616 >
617 > suppressSuggestions: boolean | undefined = undefined;
618 >
619 > constructor(items: vscode.InlineCompletionItem[]) {
620 this.items = items;
621 }
622 > } extHostTypes.ts
623 >
624 > export interface PartialAcceptInfo {
625 > kind: PartialAcceptTriggerKind;
626 > acceptedLength: number;
627 > }
628 >
629 > export enum PartialAcceptTriggerKind {
630 > Unknown = 0,
631 > Word = 1,
632 > Line = 2,
633 > Suggest = 3,
634 > }
635 >
636 > export enum InlineCompletionEndOfLifeReasonKind {
637 > Accepted = 0,
638 > Rejected = 1,
639 > Ignored = 2,
640 > }
641 >
642 > export enum InlineCompletionDisplayLocationKind {
643 > Code = 1,
644 > Label = 2
645 > }
646 >
647 > export enum ViewColumn {
648 > Active = -1,
649 > Beside = -2,
650 > One = 1,
651 > Two = 2,
652 > Three = 3,
653 > Four = 4,
654 > Five = 5,
655 > Six = 6,
656 > Seven = 7,
657 > Eight = 8,
658 > Nine = 9
659 > }
660 >
661 > export enum StatusBarAlignment {
662 > Left = 1,
663 > Right = 2
664 > }
665 >
666 > export function asStatusBarItemIdentifier(extension: ExtensionIdentifier, id: string): string {
667 return `${ExtensionIdentifier.toKey(extension)}.${id}`;
668 }
670 > export enum TextEditorLineNumbersStyle {
671 > Off = 0,
672 > On = 1,
673 > Relative = 2,
674 > Interval = 3
675 > }
676 >
677 > export enum TextDocumentSaveReason {
678 > Manual = 1,
679 > AfterDelay = 2,
680 > FocusOut = 3
681 > }
682 >
683 > export enum TextEditorRevealType {
684 > Default = 0,
685 > InCenter = 1,
686 > InCenterIfOutsideViewport = 2,
687 > AtTop = 3
688 > }
689 >
690 > export enum TextEditorSelectionChangeKind {
691 > Keyboard = 1,
692 > Mouse = 2,
693 > Command = 3
694 > }
695 >
696 > export enum TextEditorChangeKind {
697 > Addition = 1,
698 > Deletion = 2,
699 > Modification = 3
700 > }
701 >
702 > export enum TextDocumentChangeReason {
703 > Undo = 1,
704 > Redo = 2,
705 > }
706 >
707 > /**
708 > * These values match very carefully the values of `TrackedRangeStickiness`
709 > */
710 > export enum DecorationRangeBehavior {
711 > /**
712 > * TrackedRangeStickiness.AlwaysGrowsWhenTypingAtEdges
713 > */
714 > OpenOpen = 0,
715 > /**
716 > * TrackedRangeStickiness.NeverGrowsWhenTypingAtEdges
717 > */
718 > ClosedClosed = 1,
719 > /**
720 > * TrackedRangeStickiness.GrowsOnlyWhenTypingBefore
721 > */
722 > OpenClosed = 2,
723 > /**
724 > * TrackedRangeStickiness.GrowsOnlyWhenTypingAfter
725 > */
726 > ClosedOpen = 3
727 > }
728 >
729 > export namespace TextEditorSelectionChangeKind {
730 > export function fromValue(s: TextEditorSelectionSource | string | undefined) {
731 switch (s) {
732 case 'keyboard': return TextEditorSelectionChangeKind.Keyboard;
739 return undefined;
740 }
741 > } extHostTypes.ts
742 >
743 > export enum SyntaxTokenType {
744 > Other = 0,
745 > Comment = 1,
746 > String = 2,
747 > RegEx = 3
748 > }
749 > export namespace SyntaxTokenType {
750 > export function toString(v: SyntaxTokenType | unknown): 'other' | 'comment' | 'string' | 'regex' {
751 switch (v) {
752 case SyntaxTokenType.Other: return 'other';
757 return 'other';
758 }
759 > } extHostTypes.ts
760 >
761 > @es5ClassCompat
762 > export class DocumentLink {
763 >
764 > range: Range;
765 >
766 > target?: URI;
767 >
768 > tooltip?: string;
769 >
770 > constructor(range: Range, target: URI | undefined) {
771 if (target && !(URI.isUri(target))) {
772 throw illegalArgument('target');
778 this.target = target;
779 }
780 > } extHostTypes.ts
781 >
782 > @es5ClassCompat
783 > export class Color {
784 > readonly red: number;
785 > readonly green: number;
786 > readonly blue: number;
787 > readonly alpha: number;
788 >
789 > constructor(red: number, green: number, blue: number, alpha: number) {
790 this.red = red;
791 this.green = green;
793 this.alpha = alpha;
794 }
795 > } extHostTypes.ts
796 >
797 > export type IColorFormat = string | { opaque: string; transparent: string };
798 >
799 > @es5ClassCompat
800 > export class ColorInformation {
801 > range: Range;
802 >
803 > color: Color;
804 >
805 > constructor(range: Range, color: Color) {
806 if (color && !(color instanceof Color)) {
807 throw illegalArgument('color');
813 this.color = color;
814 }
815 > } extHostTypes.ts
816 >
817 > @es5ClassCompat
818 > export class ColorPresentation {
819 > label: string;
820 > textEdit?: TextEdit;
821 > additionalTextEdits?: TextEdit[];
822 >
823 > constructor(label: string) {
824 if (!label || typeof label !== 'string') {
825 throw illegalArgument('label');
827 this.label = label;
828 }
829 > } extHostTypes.ts
830 >
831 > export enum ColorFormat {
832 > RGB = 0,
833 > HEX = 1,
834 > HSL = 2
835 > }
836 >
837 > export enum SourceControlInputBoxValidationType {
838 > Error = 0,
839 > Warning = 1,
840 > Information = 2
841 > }
842 >
843 > export enum TerminalExitReason {
844 > Unknown = 0,
845 > Shutdown = 1,
846 > Process = 2,
847 > User = 3,
848 > Extension = 4
849 > }
850 >
851 > export enum TerminalShellExecutionCommandLineConfidence {
852 > Low = 0,
853 > Medium = 1,
854 > High = 2
855 > }
856 >
857 > export enum TerminalShellType {
858 > Sh = 1,
859 > Bash = 2,
860 > Fish = 3,
861 > Csh = 4,
862 > Ksh = 5,
863 > Zsh = 6,
864 > CommandPrompt = 7,
865 > GitBash = 8,
866 > PowerShell = 9,
867 > Python = 10,
868 > Julia = 11,
869 > NuShell = 12,
870 > Node = 13,
871 > Xonsh = 14
872 > }
873 >
874 > export class TerminalLink implements vscode.TerminalLink {
875 > constructor(
876 public startIndex: number,
877 public length: number,
888 }
889 }
890 > } extHostTypes.ts
891 >
892 > export class TerminalQuickFixOpener {
893 > uri: vscode.Uri;
894 > constructor(uri: vscode.Uri) {
895 this.uri = uri;
896 }
897 > } extHostTypes.ts
898 >
899 > export class TerminalQuickFixCommand {
900 > terminalCommand: string;
901 > constructor(terminalCommand: string) {
902 this.terminalCommand = terminalCommand;
903 }
904 > } extHostTypes.ts
905 >
906 > export enum TerminalLocation {
907 > Panel = 1,
908 > Editor = 2,
909 > }
910 >
911 > export class TerminalProfile implements vscode.TerminalProfile {
912 > constructor(
913 public options: vscode.TerminalOptions | vscode.ExtensionTerminalOptions
914 ) {
917 }
918 }
919 > } extHostTypes.ts
920 >
921 > export enum TerminalCompletionItemKind {
922 > File = 0,
923 > Folder = 1,
924 > Method = 2,
925 > Alias = 3,
926 > Argument = 4,
927 > Option = 5,
928 > OptionValue = 6,
929 > Flag = 7,
930 > SymbolicLinkFile = 8,
931 > SymbolicLinkFolder = 9,
932 > ScmCommit = 10,
933 > ScmBranch = 11,
934 > ScmTag = 12,
935 > ScmStash = 13,
936 > ScmRemote = 14,
937 > PullRequest = 15,
938 > PullRequestDone = 16,
939 > }
940 >
941 > export class TerminalCompletionItem implements vscode.TerminalCompletionItem {
942 > label: string | CompletionItemLabel;
943 > replacementRange: readonly [number, number];
944 > detail?: string | undefined;
945 > documentation?: string | vscode.MarkdownString | undefined;
946 > kind?: TerminalCompletionItemKind | undefined;
947 > isFile?: boolean | undefined;
948 > isDirectory?: boolean | undefined;
949 > isKeyword?: boolean | undefined;
950 >
951 > constructor(label: string | CompletionItemLabel, replacementRange: readonly [number, number], kind?: TerminalCompletionItemKind, detail?: string, documentation?: string | vscode.MarkdownString, isFile?: boolean, isDirectory?: boolean, isKeyword?: boolean) {
952 this.label = label;
953 this.replacementRange = replacementRange;
959 this.isKeyword = isKeyword;
960 }
961 > } extHostTypes.ts
962 >
963 > /**
964 > * Represents a collection of {@link CompletionItem completion items} to be presented
965 > * in the editor.
966 > */
967 > export class TerminalCompletionList<T extends TerminalCompletionItem = TerminalCompletionItem> {
968 >
969 > /**
970 > * Resources should be shown in the completions list
971 > */
972 > resourceOptions?: TerminalCompletionResourceOptions;
973 >
974 > /**
975 > * The completion items.
976 > */
977 > items: T[];
978 >
979 > /**
980 > * Creates a new completion list.
981 > *
982 > * @param items The completion items.
983 > * @param isIncomplete The list is not complete.
984 > */
985 > constructor(items?: T[], resourceOptions?: TerminalCompletionResourceOptions) {
986 this.items = items ?? [];
987 this.resourceOptions = resourceOptions;
988 }
989 > } extHostTypes.ts
990 >
991 > export interface TerminalCompletionResourceOptions {
992 > showFiles?: boolean;
993 > showDirectories?: boolean;
994 > fileExtensions?: string[];
995 > cwd?: vscode.Uri;
996 > }
997 >
998 > export enum TaskRevealKind {
999 > Always = 1,
1000 >
1001 > Silent = 2,
1002 >
1003 > Never = 3
1004 > }
1005 >
1006 > export enum TaskEventKind {
1007 > /** Indicates a task's properties or configuration have changed */
1008 > Changed = 'changed',
1009 >
1010 > /** Indicates a task has begun executing */
1011 > ProcessStarted = 'processStarted',
1012 >
1013 > /** Indicates a task process has completed */
1014 > ProcessEnded = 'processEnded',
1015 >
1016 > /** Indicates a task was terminated, either by user action or by the system */
1017 > Terminated = 'terminated',
1018 >
1019 > /** Indicates a task has started running */
1020 > Start = 'start',
1021 >
1022 > /** Indicates a task has acquired all needed input/variables to execute */
1023 > AcquiredInput = 'acquiredInput',
1024 >
1025 > /** Indicates a dependent task has started */
1026 > DependsOnStarted = 'dependsOnStarted',
1027 >
1028 > /** Indicates a task is actively running/processing */
1029 > Active = 'active',
1030 >
1031 > /** Indicates a task is paused/waiting but not complete */
1032 > Inactive = 'inactive',
1033 >
1034 > /** Indicates a task has completed fully */
1035 > End = 'end',
1036 >
1037 > /** Indicates the task's problem matcher has started */
1038 > ProblemMatcherStarted = 'problemMatcherStarted',
1039 >
1040 > /** Indicates the task's problem matcher has ended without errors */
1041 > ProblemMatcherEnded = 'problemMatcherEnded',
1042 >
1043 > /** Indicates the task's problem matcher has ended with errors */
1044 > ProblemMatcherFoundErrors = 'problemMatcherFoundErrors'
1045 > }
1046 >
1047 >
1048 > export enum TaskPanelKind {
1049 > Shared = 1,
1050 >
1051 > Dedicated = 2,
1052 >
1053 > New = 3
1054 > }
1055 >
1056 > @es5ClassCompat
1057 > export class TaskGroup implements vscode.TaskGroup {
1058 >
1059 > isDefault: boolean | undefined;
1060 > private _id: string;
1061 >
1062 > public static Clean: TaskGroup = new TaskGroup('clean', 'Clean');
1063 >
1064 > public static Build: TaskGroup = new TaskGroup('build', 'Build');
1065 >
1066 > public static Rebuild: TaskGroup = new TaskGroup('rebuild', 'Rebuild');
1067 >
1068 > public static Test: TaskGroup = new TaskGroup('test', 'Test');
1069 >
1070 > public static from(value: string) {
1071 > switch (value) {
1072 > case 'clean':
1073 > return TaskGroup.Clean;
1074 > case 'build':
1075 > return TaskGroup.Build;
1076 > case 'rebuild':
1077 > return TaskGroup.Rebuild;
1078 > case 'test':
1079 > return TaskGroup.Test;
1080 > default:
1081 > return undefined;
1082 > }
1083 > }
1084 >
1085 > constructor(id: string, public readonly label: string) {
1086 > if (typeof id !== 'string') {
1087 throw illegalArgument('name');
1088 }
1089 > if (typeof label !== 'string') { extHostTypes.ts
1090 throw illegalArgument('name');
1091 }
1092 > this._id = id; extHostTypes.ts
1093 > }
1094 >
1095 > get id(): string {
1096 return this._id;
1097 }
1098 > } extHostTypes.ts
1099 >
1100 function computeTaskExecutionId(values: string[]): string {
1101 let id: string = '';
1105 return id;
1106 }
1108 > @es5ClassCompat
1109 > export class ProcessExecution implements vscode.ProcessExecution {
1110 >
1111 > private _process: string;
1112 > private _args: string[];
1113 > private _options: vscode.ProcessExecutionOptions | undefined;
1114 >
1115 > constructor(process: string, options?: vscode.ProcessExecutionOptions);
1116 > constructor(process: string, args: string[], options?: vscode.ProcessExecutionOptions);
1117 > constructor(process: string, varg1?: string[] | vscode.ProcessExecutionOptions, varg2?: vscode.ProcessExecutionOptions) {
1118 if (typeof process !== 'string') {
1119 throw illegalArgument('process');
1130 }
1131 }
1133 >
1134 > get process(): string {
1135 return this._process;
1136 }
1138 > set process(value: string) {
1139 if (typeof value !== 'string') {
1140 throw illegalArgument('process');
1142 this._process = value;
1143 }
1145 > get args(): string[] {
1146 return this._args;
1147 }
1149 > set args(value: string[]) {
1150 if (!Array.isArray(value)) {
1151 value = [];
1153 this._args = value;
1154 }
1156 > get options(): vscode.ProcessExecutionOptions | undefined {
1157 return this._options;
1158 }
1160 > set options(value: vscode.ProcessExecutionOptions | undefined) {
1161 this._options = value;
1162 }
1164 > public computeId(): string {
1165 const props: string[] = [];
1166 props.push('process');
1175 return computeTaskExecutionId(props);
1176 }
1177 > } extHostTypes.ts
1178 >
1179 > @es5ClassCompat
1180 > export class ShellExecution implements vscode.ShellExecution {
1181 >
1182 > private _commandLine: string | undefined;
1183 > private _command: string | vscode.ShellQuotedString | undefined;
1184 > private _args: (string | vscode.ShellQuotedString)[] = [];
1185 > private _options: vscode.ShellExecutionOptions | undefined;
1186 >
1187 > constructor(commandLine: string, options?: vscode.ShellExecutionOptions);
1188 > constructor(command: string | vscode.ShellQuotedString, args: (string | vscode.ShellQuotedString)[], options?: vscode.ShellExecutionOptions);
1189 > constructor(arg0: string | vscode.ShellQuotedString, arg1?: vscode.ShellExecutionOptions | (string | vscode.ShellQuotedString)[], arg2?: vscode.ShellExecutionOptions) {
1190 if (Array.isArray(arg1)) {
1191 if (!arg0) {
1208 }
1209 }
1211 > get commandLine(): string | undefined {
1212 return this._commandLine;
1213 }
1215 > set commandLine(value: string | undefined) {
1216 if (typeof value !== 'string') {
1217 throw illegalArgument('commandLine');
1219 this._commandLine = value;
1220 }
1222 > get command(): string | vscode.ShellQuotedString {
1223 return this._command ? this._command : '';
1224 }
1226 > set command(value: string | vscode.ShellQuotedString) {
1227 if (typeof value !== 'string' && typeof value.value !== 'string') {
1228 throw illegalArgument('command');
1230 this._command = value;
1231 }
1233 > get args(): (string | vscode.ShellQuotedString)[] {
1234 return this._args;
1235 }
1237 > set args(value: (string | vscode.ShellQuotedString)[] | undefined) {
1238 this._args = value || [];
1239 }
1241 > get options(): vscode.ShellExecutionOptions | undefined {
1242 return this._options;
1243 }
1245 > set options(value: vscode.ShellExecutionOptions | undefined) {
1246 this._options = value;
1247 }
1249 > public computeId(): string {
1250 const props: string[] = [];
1251 props.push('shell');
1263 return computeTaskExecutionId(props);
1264 }
1265 > } extHostTypes.ts
1266 >
1267 > export enum ShellQuoting {
1268 > Escape = 1,
1269 > Strong = 2,
1270 > Weak = 3
1271 > }
1272 >
1273 > export enum TaskScope {
1274 > Global = 1,
1275 > Workspace = 2
1276 > }
1277 >
1278 > export enum TaskRunOn {
1279 > Default = 1,
1280 > FolderOpen = 2,
1281 > WorktreeCreated = 3,
1282 > }
1283 >
1284 > export class CustomExecution implements vscode.CustomExecution {
1285 > private _callback: (resolvedDefinition: vscode.TaskDefinition) => Thenable<vscode.Pseudoterminal>;
1286 > constructor(callback: (resolvedDefinition: vscode.TaskDefinition) => Thenable<vscode.Pseudoterminal>) {
1287 this._callback = callback;
1288 }
1289 > public computeId(): string { extHostTypes.ts
1290 return 'customExecution' + generateUuid();
1291 }
1293 > public set callback(value: (resolvedDefinition: vscode.TaskDefinition) => Thenable<vscode.Pseudoterminal>) {
1294 this._callback = value;
1295 }
1297 > public get callback(): ((resolvedDefinition: vscode.TaskDefinition) => Thenable<vscode.Pseudoterminal>) {
1298 return this._callback;
1299 }
1300 > } extHostTypes.ts
1301 >
1302 > @es5ClassCompat
1303 > export class Task implements vscode.Task {
1304 >
1305 > private static ExtensionCallbackType: string = 'customExecution';
1306 > private static ProcessType: string = 'process';
1307 > private static ShellType: string = 'shell';
1308 > private static EmptyType: string = '$empty';
1309 >
1310 > private __id: string | undefined;
1311 > private __deprecated: boolean = false;
1312 >
1313 > private _definition: vscode.TaskDefinition;
1314 > private _scope: vscode.TaskScope.Global | vscode.TaskScope.Workspace | vscode.WorkspaceFolder | undefined;
1315 > private _name: string;
1316 > private _execution: ProcessExecution | ShellExecution | CustomExecution | undefined;
1317 > private _problemMatchers: string[];
1318 > private _hasDefinedMatchers: boolean;
1319 > private _isBackground: boolean;
1320 > private _source: string;
1321 > private _group: TaskGroup | undefined;
1322 > private _presentationOptions: vscode.TaskPresentationOptions;
1323 > private _runOptions: vscode.RunOptions;
1324 > private _detail: string | undefined;
1325 >
1326 > constructor(definition: vscode.TaskDefinition, name: string, source: string, execution?: ProcessExecution | ShellExecution | CustomExecution, problemMatchers?: string | string[]);
1327 > constructor(definition: vscode.TaskDefinition, scope: vscode.TaskScope.Global | vscode.TaskScope.Workspace | vscode.WorkspaceFolder, name: string, source: string, execution?: ProcessExecution | ShellExecution | CustomExecution, problemMatchers?: string | string[]);
1328 > constructor(definition: vscode.TaskDefinition, arg2: string | (vscode.TaskScope.Global | vscode.TaskScope.Workspace) | vscode.WorkspaceFolder, arg3: any, arg4?: any, arg5?: any, arg6?: any) {
1329 this._definition = this.definition = definition;
1330 let problemMatchers: string | string[];
1362 this._runOptions = Object.create(null);
1363 }
1365 > get _id(): string | undefined {
1366 return this.__id;
1367 }
1369 > set _id(value: string | undefined) {
1370 this.__id = value;
1371 }
1373 > get _deprecated(): boolean {
1374 return this.__deprecated;
1375 }
1377 > private clear(): void {
1378 if (this.__id === undefined) {
1379 return;
1383 this.computeDefinitionBasedOnExecution();
1384 }
1386 > private computeDefinitionBasedOnExecution(): void {
1387 if (this._execution instanceof ProcessExecution) {
1388 this._definition = {
1407 }
1408 }
1410 > get definition(): vscode.TaskDefinition {
1411 return this._definition;
1412 }
1414 > set definition(value: vscode.TaskDefinition) {
1415 if (value === undefined || value === null) {
1416 throw illegalArgument('Kind can\'t be undefined or null');
1419 this._definition = value;
1420 }
1422 > get scope(): vscode.TaskScope.Global | vscode.TaskScope.Workspace | vscode.WorkspaceFolder | undefined {
1423 return this._scope;
1424 }
1426 > set target(value: vscode.TaskScope.Global | vscode.TaskScope.Workspace | vscode.WorkspaceFolder) {
1427 this.clear();
1428 this._scope = value;
1429 }
1431 > get name(): string {
1432 return this._name;
1433 }
1435 > set name(value: string) {
1436 if (typeof value !== 'string') {
1437 throw illegalArgument('name');
1440 this._name = value;
1441 }
1443 > get execution(): ProcessExecution | ShellExecution | CustomExecution | undefined {
1444 return this._execution;
1445 }
1447 > set execution(value: ProcessExecution | ShellExecution | CustomExecution | undefined) {
1448 if (value === null) {
1449 value = undefined;
1456 }
1457 }
1459 > get problemMatchers(): string[] {
1460 return this._problemMatchers;
1461 }
1463 > set problemMatchers(value: string[]) {
1464 if (!Array.isArray(value)) {
1465 this.clear();
1473 }
1474 }
1476 > get hasDefinedMatchers(): boolean {
1477 return this._hasDefinedMatchers;
1478 }
1480 > get isBackground(): boolean {
1481 return this._isBackground;
1482 }
1484 > set isBackground(value: boolean) {
1485 if (value !== true && value !== false) {
1486 value = false;
1489 this._isBackground = value;
1490 }
1492 > get source(): string {
1493 return this._source;
1494 }
1496 > set source(value: string) {
1497 if (typeof value !== 'string' || value.length === 0) {
1498 throw illegalArgument('source must be a string of length > 0');
1501 this._source = value;
1502 }
1504 > get group(): TaskGroup | undefined {
1505 return this._group;
1506 }
1508 > set group(value: TaskGroup | undefined) {
1509 if (value === null) {
1510 value = undefined;
1513 this._group = value;
1514 }
1516 > get detail(): string | undefined {
1517 return this._detail;
1518 }
1520 > set detail(value: string | undefined) {
1521 if (value === null) {
1522 value = undefined;
1524 this._detail = value;
1525 }
1527 > get presentationOptions(): vscode.TaskPresentationOptions {
1528 return this._presentationOptions;
1529 }
1531 > set presentationOptions(value: vscode.TaskPresentationOptions) {
1532 if (value === null || value === undefined) {
1533 value = Object.create(null);
1536 this._presentationOptions = value;
1537 }
1539 > get runOptions(): vscode.RunOptions {
1540 return this._runOptions;
1541 }
1543 > set runOptions(value: vscode.RunOptions) {
1544 if (value === null || value === undefined) {
1545 value = Object.create(null);
1548 this._runOptions = value;
1549 }
1550 > } extHostTypes.ts
1551 >
1552 >
1553 > export enum ProgressLocation {
1554 > SourceControl = 1,
1555 > Window = 10,
1556 > Notification = 15
1557 > }
1558 >
1559 > export namespace ViewBadge {
1560 > export function isViewBadge(thing: any): thing is vscode.ViewBadge {
1561 const viewBadgeThing = thing as vscode.ViewBadge;
1562
1571 return true;
1572 }
1573 > } extHostTypes.ts
1574 >
1575 > @es5ClassCompat
1576 > export class TreeItem {
1577 >
1578 > label?: string | vscode.TreeItemLabel;
1579 > resourceUri?: URI;
1580 > iconPath?: string | URI | { light: string | URI; dark: string | URI } | ThemeIcon;
1581 > command?: vscode.Command;
1582 > contextValue?: string;
1583 > tooltip?: string | vscode.MarkdownString;
1584 > checkboxState?: vscode.TreeItemCheckboxState;
1585 >
1586 > static isTreeItem(thing: any, extension: IExtensionDescription): thing is TreeItem {
1587 > const treeItemThing = thing as vscode.TreeItem;
1588 >
1589 > if (treeItemThing.checkboxState !== undefined) {
1590 > const checkbox = isNumber(treeItemThing.checkboxState) ? treeItemThing.checkboxState :
1591 > isObject(treeItemThing.checkboxState) && isNumber(treeItemThing.checkboxState.state) ? treeItemThing.checkboxState.state : undefined;
1592 > const tooltip = !isNumber(treeItemThing.checkboxState) && isObject(treeItemThing.checkboxState) ? treeItemThing.checkboxState.tooltip : undefined;
1593 > if (checkbox === undefined || (checkbox !== TreeItemCheckboxState.Checked && checkbox !== TreeItemCheckboxState.Unchecked) || (tooltip !== undefined && !isString(tooltip))) {
1594 > console.log('INVALID tree item, invalid checkboxState', treeItemThing.checkboxState);
1595 > return false;
1596 > }
1597 > }
1598 >
1599 > if (thing instanceof TreeItem) {
1600 > return true;
1601 > }
1602 >
1603 > if (treeItemThing.label !== undefined && !isString(treeItemThing.label) && !(treeItemThing.label?.label)) {
1604 > console.log('INVALID tree item, invalid label', treeItemThing.label);
1605 > return false;
1606 > }
1607 > if ((treeItemThing.id !== undefined) && !isString(treeItemThing.id)) {
1608 > console.log('INVALID tree item, invalid id', treeItemThing.id);
1609 > return false;
1610 > }
1611 > if ((treeItemThing.iconPath !== undefined) && !isString(treeItemThing.iconPath) && !URI.isUri(treeItemThing.iconPath) && (!treeItemThing.iconPath || !isString((treeItemThing.iconPath as vscode.ThemeIcon).id))) {
1612 > const asLightAndDarkThing = treeItemThing.iconPath as { light: string | URI; dark: string | URI } | null;
1613 > if (!asLightAndDarkThing || (!isString(asLightAndDarkThing.light) && !URI.isUri(asLightAndDarkThing.light) && !isString(asLightAndDarkThing.dark) && !URI.isUri(asLightAndDarkThing.dark))) {
1614 > console.log('INVALID tree item, invalid iconPath', treeItemThing.iconPath);
1615 > return false;
1616 > }
1617 > }
1618 > if ((treeItemThing.description !== undefined) && !isString(treeItemThing.description) && (typeof treeItemThing.description !== 'boolean')) {
1619 > console.log('INVALID tree item, invalid description', treeItemThing.description);
1620 > return false;
1621 > }
1622 > if ((treeItemThing.resourceUri !== undefined) && !URI.isUri(treeItemThing.resourceUri)) {
1623 > console.log('INVALID tree item, invalid resourceUri', treeItemThing.resourceUri);
1624 > return false;
1625 > }
1626 > if ((treeItemThing.tooltip !== undefined) && !isString(treeItemThing.tooltip) && !(treeItemThing.tooltip instanceof MarkdownString)) {
1627 > console.log('INVALID tree item, invalid tooltip', treeItemThing.tooltip);
1628 > return false;
1629 > }
1630 > if ((treeItemThing.command !== undefined) && !treeItemThing.command.command) {
1631 > console.log('INVALID tree item, invalid command', treeItemThing.command);
1632 > return false;
1633 > }
1634 > if ((treeItemThing.collapsibleState !== undefined) && (treeItemThing.collapsibleState < TreeItemCollapsibleState.None) && (treeItemThing.collapsibleState > TreeItemCollapsibleState.Expanded)) {
1635 > console.log('INVALID tree item, invalid collapsibleState', treeItemThing.collapsibleState);
1636 > return false;
1637 > }
1638 > if ((treeItemThing.contextValue !== undefined) && !isString(treeItemThing.contextValue)) {
1639 > console.log('INVALID tree item, invalid contextValue', treeItemThing.contextValue);
1640 > return false;
1641 > }
1642 > if ((treeItemThing.accessibilityInformation !== undefined) && !treeItemThing.accessibilityInformation?.label) {
1643 > console.log('INVALID tree item, invalid accessibilityInformation', treeItemThing.accessibilityInformation);
1644 > return false;
1645 > }
1646 >
1647 > return true;
1648 > }
1649 >
1650 > constructor(label: string | vscode.TreeItemLabel, collapsibleState?: vscode.TreeItemCollapsibleState);
1651 > constructor(resourceUri: URI, collapsibleState?: vscode.TreeItemCollapsibleState);
1652 > constructor(arg1: string | vscode.TreeItemLabel | URI, public collapsibleState: vscode.TreeItemCollapsibleState = TreeItemCollapsibleState.None) {
1653 if (URI.isUri(arg1)) {
1654 this.resourceUri = arg1;
1657 }
1658 }
1660 > }
1661 >
1662 > export enum TreeItemCollapsibleState {
1663 > None = 0,
1664 > Collapsed = 1,
1665 > Expanded = 2
1666 > }
1667 >
1668 > export enum TreeItemCheckboxState {
1669 > Unchecked = 0,
1670 > Checked = 1
1671 > }
1672 >
1673 > @es5ClassCompat
1674 > export class DataTransferItem implements vscode.DataTransferItem {
1675 >
1676 > async asString(): Promise<string> {
1677 > return typeof this.value === 'string' ? this.value : JSON.stringify(this.value);
1678 > }
1679 >
1680 > asFile(): undefined | vscode.DataTransferFile {
1681 return undefined;
1682 }
1684 > constructor(
1685 public readonly value: any,
1686 ) { }
1687 > } extHostTypes.ts
1688 >
1689 > /**
1690 > * A data transfer item that has been created by VS Code instead of by a extension.
1691 > *
1692 > * Intentionally not exported to extensions.
1693 > */
1694 > export class InternalDataTransferItem extends DataTransferItem { }
1695 >
1696 > /**
1697 > * A data transfer item for a file.
1698 > *
1699 > * Intentionally not exported to extensions as only we can create these.
1700 > */
1701 > export class InternalFileDataTransferItem extends InternalDataTransferItem {
1702 >
1703 > readonly #file: vscode.DataTransferFile;
1704 >
1705 > constructor(file: vscode.DataTransferFile) {
1706 super('');
1707 this.#file = file;
1708 }
1710 > override asFile() {
1711 return this.#file;
1712 }
1713 > } extHostTypes.ts
1714 >
1715 > /**
1716 > * Intentionally not exported to extensions
1717 > */
1718 > export class DataTransferFile implements vscode.DataTransferFile {
1719 >
1720 > public readonly name: string;
1721 > public readonly uri: vscode.Uri | undefined;
1722 >
1723 > public readonly _itemId: string;
1724 > private readonly _getData: () => Promise<Uint8Array>;
1725 >
1726 > constructor(name: string, uri: vscode.Uri | undefined, itemId: string, getData: () => Promise<Uint8Array>) {
1727 this.name = name;
1728 this.uri = uri;
1730 this._getData = getData;
1731 }
1733 > data(): Promise<Uint8Array> {
1734 return this._getData();
1735 }
1736 > } extHostTypes.ts
1737 >
1738 > @es5ClassCompat
1739 > export class DataTransfer implements vscode.DataTransfer {
1740 > #items = new Map<string, vscode.DataTransferItem[]>();
1741 >
1742 > constructor(init?: Iterable<readonly [string, vscode.DataTransferItem]>) {
1743 for (const [mime, item] of init ?? []) {
1744 const existing = this.#items.get(this.#normalizeMime(mime));
1750 }
1751 }
1753 > get(mimeType: string): vscode.DataTransferItem | undefined {
1754 return this.#items.get(this.#normalizeMime(mimeType))?.[0];
1755 }
1757 > set(mimeType: string, value: vscode.DataTransferItem): void {
1758 // This intentionally overwrites all entries for a given mimetype.
1759 // This is similar to how the DOM DataTransfer type works
1760 this.#items.set(this.#normalizeMime(mimeType), [value]);
1761 }
1763 > forEach(callbackfn: (value: vscode.DataTransferItem, key: string, dataTransfer: DataTransfer) => void, thisArg?: unknown): void {
1764 for (const [mime, items] of this.#items) {
1765 for (const item of items) {
1768 }
1769 }
1771 > *[Symbol.iterator](): IterableIterator<[mimeType: string, item: vscode.DataTransferItem]> {
1772 for (const [mime, items] of this.#items) {
1773 for (const item of items) {
1776 }
1777 }
1779 > #normalizeMime(mimeType: string): string {
1780 return mimeType.toLowerCase();
1781 }
1782 > } extHostTypes.ts
1783 >
1784 > @es5ClassCompat
1785 > export class DocumentDropEdit {
1786 > title?: string;
1787 >
1788 > id: string | undefined;
1789 >
1790 > insertText: string | SnippetString;
1791 >
1792 > additionalEdit?: WorkspaceEdit;
1793 >
1794 > kind?: DocumentDropOrPasteEditKind;
1795 >
1796 > constructor(insertText: string | SnippetString, title?: string, kind?: DocumentDropOrPasteEditKind) {
1797 this.insertText = insertText;
1798 this.title = title;
1799 this.kind = kind;
1800 }
1801 > } extHostTypes.ts
1802 >
1803 > export enum DocumentPasteTriggerKind {
1804 > Automatic = 0,
1805 > PasteAs = 1,
1806 > }
1807 >
1808 > export class DocumentDropOrPasteEditKind {
1809 > static Empty: DocumentDropOrPasteEditKind;
1810 > static Text: DocumentDropOrPasteEditKind;
1811 > static TextUpdateImports: DocumentDropOrPasteEditKind;
1812 >
1813 > private static sep = '.';
1814 >
1815 > constructor(
1816 > public readonly value: string
1817 > ) { }
1818 >
1819 > public append(...parts: string[]): DocumentDropOrPasteEditKind {
1820 > return new DocumentDropOrPasteEditKind((this.value ? [this.value, ...parts] : parts).join(DocumentDropOrPasteEditKind.sep));
1821 > }
1822 >
1823 > public intersects(other: DocumentDropOrPasteEditKind): boolean {
1824 return this.contains(other) || other.contains(this);
1825 }
1827 > public contains(other: DocumentDropOrPasteEditKind): boolean {
1828 return this.value === other.value || other.value.startsWith(this.value + DocumentDropOrPasteEditKind.sep);
1829 }
1830 > } extHostTypes.ts
1831 > DocumentDropOrPasteEditKind.Empty = new DocumentDropOrPasteEditKind('');
1832 > DocumentDropOrPasteEditKind.Text = new DocumentDropOrPasteEditKind('text');
1833 > DocumentDropOrPasteEditKind.TextUpdateImports = DocumentDropOrPasteEditKind.Text.append('updateImports');
1834 >
1835 > export class DocumentPasteEdit {
1836 >
1837 > title: string;
1838 > insertText: string | SnippetString;
1839 > additionalEdit?: WorkspaceEdit;
1840 > kind: DocumentDropOrPasteEditKind;
1841 >
1842 > constructor(insertText: string | SnippetString, title: string, kind: DocumentDropOrPasteEditKind) {
1843 this.title = title;
1844 this.insertText = insertText;
1845 this.kind = kind;
1846 }
1847 > } extHostTypes.ts
1848 >
1849 > @es5ClassCompat
1850 > export class ThemeIcon {
1851 >
1852 > static File: ThemeIcon;
1853 > static Folder: ThemeIcon;
1854 >
1855 > readonly id: string;
1856 > readonly color?: ThemeColor;
1857 >
1858 > constructor(id: string, color?: ThemeColor) {
1859 > this.id = id;
1860 > this.color = color;
1861 > }
1862 >
1863 > static isThemeIcon(thing: any) {
1864 if (typeof thing.id !== 'string') {
1865 console.log('INVALID ThemeIcon, invalid id', thing.id);
1868 return true;
1869 }
1870 > } extHostTypes.ts
1871 > ThemeIcon.File = new ThemeIcon('file');
1872 > ThemeIcon.Folder = new ThemeIcon('folder');
1873 >
1874 >
1875 > @es5ClassCompat
1876 > export class ThemeColor {
1877 > id: string;
1878 > constructor(id: string) {
1879 this.id = id;
1880 }
1881 > } extHostTypes.ts
1882 >
1883 > export enum ConfigurationTarget {
1884 > Global = 1,
1885 >
1886 > Workspace = 2,
1887 >
1888 > WorkspaceFolder = 3
1889 > }
1890 >
1891 > @es5ClassCompat
1892 > export class RelativePattern implements IRelativePattern {
1893 >
1894 > pattern: string;
1895 >
1896 > private _base!: string;
1897 > get base(): string {
1898 return this._base;
1899 }
1900 > set base(base: string) { extHostTypes.ts
1901 this._base = base;
1902 this._baseUri = URI.file(base);
1903 }
1905 > private _baseUri!: URI;
1906 > get baseUri(): URI {
1907 return this._baseUri;
1908 }
1909 > set baseUri(baseUri: URI) { extHostTypes.ts
1910 this._baseUri = baseUri;
1911 this._base = baseUri.fsPath;
1912 }
1914 > constructor(base: vscode.WorkspaceFolder | URI | string, pattern: string) {
1915 if (typeof base !== 'string') {
1916 if (!base || !URI.isUri(base) && !URI.isUri(base.uri)) {
1933 this.pattern = pattern;
1934 }
1936 > toJSON(): IRelativePatternDto {
1937 return {
1938 pattern: this.pattern,
1941 };
1942 }
1943 > } extHostTypes.ts
1944 >
1945 > const breakpointIds = new WeakMap<Breakpoint, string>();
1946 >
1947 > /**
1948 > * We want to be able to construct Breakpoints internally that have a particular id, but we don't want extensions to be
1949 > * able to do this with the exposed Breakpoint classes in extension API.
1950 > * We also want "instanceof" to work with debug.breakpoints and the exposed breakpoint classes.
1951 > * And private members will be renamed in the built js, so casting to any and setting a private member is not safe.
1952 > * So, we store internal breakpoint IDs in a WeakMap. This function must be called after constructing a Breakpoint
1953 > * with a known id.
1954 > */
1955 > export function setBreakpointId(bp: Breakpoint, id: string) {
1956 breakpointIds.set(bp, id);
1957 }
1959 > @es5ClassCompat
1960 > export class Breakpoint {
1961 >
1962 > private _id: string | undefined;
1963 >
1964 > readonly enabled: boolean;
1965 > readonly condition?: string;
1966 > readonly hitCondition?: string;
1967 > readonly logMessage?: string;
1968 > readonly mode?: string;
1969 >
1970 > protected constructor(enabled?: boolean, condition?: string, hitCondition?: string, logMessage?: string, mode?: string) {
1971 this.enabled = typeof enabled === 'boolean' ? enabled : true;
1972 if (typeof condition === 'string') {
1983 }
1984 }
1986 > get id(): string {
1987 if (!this._id) {
1988 this._id = breakpointIds.get(this) ?? generateUuid();
1990 return this._id;
1991 }
1992 > } extHostTypes.ts
1993 >
1994 > @es5ClassCompat
1995 > export class SourceBreakpoint extends Breakpoint {
1996 > readonly location: Location;
1997 >
1998 > constructor(location: Location, enabled?: boolean, condition?: string, hitCondition?: string, logMessage?: string, mode?: string) {
1999 super(enabled, condition, hitCondition, logMessage, mode);
2000 if (location === null) {
2003 this.location = location;
2004 }
2005 > } extHostTypes.ts
2006 >
2007 > @es5ClassCompat
2008 > export class FunctionBreakpoint extends Breakpoint {
2009 > readonly functionName: string;
2010 >
2011 > constructor(functionName: string, enabled?: boolean, condition?: string, hitCondition?: string, logMessage?: string, mode?: string) {
2012 super(enabled, condition, hitCondition, logMessage, mode);
2013 this.functionName = functionName;
2014 }
2015 > } extHostTypes.ts
2016 >
2017 > @es5ClassCompat
2018 > export class DataBreakpoint extends Breakpoint {
2019 > readonly label: string;
2020 > readonly dataId: string;
2021 > readonly canPersist: boolean;
2022 >
2023 > constructor(label: string, dataId: string, canPersist: boolean, enabled?: boolean, condition?: string, hitCondition?: string, logMessage?: string, mode?: string) {
2024 super(enabled, condition, hitCondition, logMessage, mode);
2025 if (!dataId) {
2030 this.canPersist = canPersist;
2031 }
2032 > } extHostTypes.ts
2033 >
2034 > @es5ClassCompat
2035 > export class DebugAdapterExecutable implements vscode.DebugAdapterExecutable {
2036 > readonly command: string;
2037 > readonly args: string[];
2038 > readonly options?: vscode.DebugAdapterExecutableOptions;
2039 >
2040 > constructor(command: string, args: string[], options?: vscode.DebugAdapterExecutableOptions) {
2041 this.command = command;
2042 this.args = args || [];
2043 this.options = options;
2044 }
2045 > } extHostTypes.ts
2046 >
2047 > @es5ClassCompat
2048 > export class DebugAdapterServer implements vscode.DebugAdapterServer {
2049 > readonly port: number;
2050 > readonly host?: string;
2051 >
2052 > constructor(port: number, host?: string) {
2053 this.port = port;
2054 this.host = host;
2055 }
2056 > } extHostTypes.ts
2057 >
2058 > @es5ClassCompat
2059 > export class DebugAdapterNamedPipeServer implements vscode.DebugAdapterNamedPipeServer {
2060 > constructor(public readonly path: string) {
2061 }
2062 > } extHostTypes.ts
2063 >
2064 > @es5ClassCompat
2065 > export class DebugAdapterInlineImplementation implements vscode.DebugAdapterInlineImplementation {
2066 > readonly implementation: vscode.DebugAdapter;
2067 >
2068 > constructor(impl: vscode.DebugAdapter) {
2069 this.implementation = impl;
2070 }
2071 > } extHostTypes.ts
2072 >
2073 >
2074 > export class DebugStackFrame implements vscode.DebugStackFrame {
2075 > constructor(
2076 public readonly session: vscode.DebugSession,
2077 readonly threadId: number,
2078 readonly frameId: number) { }
2079 > } extHostTypes.ts
2080 >
2081 > export class DebugThread implements vscode.DebugThread {
2082 > constructor(
2083 public readonly session: vscode.DebugSession,
2084 readonly threadId: number) { }
2085 > } extHostTypes.ts
2086 >
2087 >
2088 > @es5ClassCompat
2089 > export class EvaluatableExpression implements vscode.EvaluatableExpression {
2090 > readonly range: vscode.Range;
2091 > readonly expression?: string;
2092 >
2093 > constructor(range: vscode.Range, expression?: string) {
2094 this.range = range;
2095 this.expression = expression;
2096 }
2097 > } extHostTypes.ts
2098 >
2099 > export enum InlineCompletionTriggerKind {
2100 > Invoke = 0,
2101 > Automatic = 1,
2102 > }
2103 >
2104 > export enum InlineCompletionsDisposeReasonKind {
2105 > Other = 0,
2106 > Empty = 1,
2107 > TokenCancellation = 2,
2108 > LostRace = 3,
2109 > NotTaken = 4,
2110 > }
2111 >
2112 > @es5ClassCompat
2113 > export class InlineValueText implements vscode.InlineValueText {
2114 > readonly range: Range;
2115 > readonly text: string;
2116 >
2117 > constructor(range: Range, text: string) {
2118 this.range = range;
2119 this.text = text;
2120 }
2121 > } extHostTypes.ts
2122 >
2123 > @es5ClassCompat
2124 > export class InlineValueVariableLookup implements vscode.InlineValueVariableLookup {
2125 > readonly range: Range;
2126 > readonly variableName?: string;
2127 > readonly caseSensitiveLookup: boolean;
2128 >
2129 > constructor(range: Range, variableName?: string, caseSensitiveLookup: boolean = true) {
2130 this.range = range;
2131 this.variableName = variableName;
2132 this.caseSensitiveLookup = caseSensitiveLookup;
2133 }
2134 > } extHostTypes.ts
2135 >
2136 > @es5ClassCompat
2137 > export class InlineValueEvaluatableExpression implements vscode.InlineValueEvaluatableExpression {
2138 > readonly range: Range;
2139 > readonly expression?: string;
2140 >
2141 > constructor(range: Range, expression?: string) {
2142 this.range = range;
2143 this.expression = expression;
2144 }
2145 > } extHostTypes.ts
2146 >
2147 > @es5ClassCompat
2148 > export class InlineValueContext implements vscode.InlineValueContext {
2149 >
2150 > readonly frameId: number;
2151 > readonly stoppedLocation: vscode.Range;
2152 >
2153 > constructor(frameId: number, range: vscode.Range) {
2154 this.frameId = frameId;
2155 this.stoppedLocation = range;
2156 }
2157 > } extHostTypes.ts
2158 >
2159 > export enum NewSymbolNameTag {
2160 > AIGenerated = 1
2161 > }
2162 >
2163 > export enum NewSymbolNameTriggerKind {
2164 > Invoke = 0,
2165 > Automatic = 1,
2166 > }
2167 >
2168 > export class NewSymbolName implements vscode.NewSymbolName {
2169 > readonly newSymbolName: string;
2170 > readonly tags?: readonly vscode.NewSymbolNameTag[] | undefined;
2171 >
2172 > constructor(
2173 newSymbolName: string,
2174 tags?: readonly NewSymbolNameTag[]
2177 this.tags = tags;
2178 }
2179 > } extHostTypes.ts
2180 >
2181 > //#region file api
2182 >
2183 > export enum FileChangeType {
2184 > Changed = 1,
2185 > Created = 2,
2186 > Deleted = 3,
2187 > }
2188 >
2189 > @es5ClassCompat
2190 > export class FileSystemError extends Error {
2191 >
2192 > static FileExists(messageOrUri?: string | URI): FileSystemError {
2193 return new FileSystemError(messageOrUri, FileSystemProviderErrorCode.FileExists, FileSystemError.FileExists);
2194 }
2195 > static FileNotFound(messageOrUri?: string | URI): FileSystemError { extHostTypes.ts
2196 return new FileSystemError(messageOrUri, FileSystemProviderErrorCode.FileNotFound, FileSystemError.FileNotFound);
2197 }
2198 > static FileNotADirectory(messageOrUri?: string | URI): FileSystemError { extHostTypes.ts
2199 return new FileSystemError(messageOrUri, FileSystemProviderErrorCode.FileNotADirectory, FileSystemError.FileNotADirectory);
2200 }
2201 > static FileIsADirectory(messageOrUri?: string | URI): FileSystemError { extHostTypes.ts
2202 return new FileSystemError(messageOrUri, FileSystemProviderErrorCode.FileIsADirectory, FileSystemError.FileIsADirectory);
2203 }
2204 > static NoPermissions(messageOrUri?: string | URI): FileSystemError { extHostTypes.ts
2205 return new FileSystemError(messageOrUri, FileSystemProviderErrorCode.NoPermissions, FileSystemError.NoPermissions);
2206 }
2207 > static Unavailable(messageOrUri?: string | URI): FileSystemError { extHostTypes.ts
2208 return new FileSystemError(messageOrUri, FileSystemProviderErrorCode.Unavailable, FileSystemError.Unavailable);
2209 }
2211 > readonly code: string;
2212 >
2213 > constructor(uriOrMessage?: string | URI, code: FileSystemProviderErrorCode = FileSystemProviderErrorCode.Unknown, terminator?: Function) {
2214 super(URI.isUri(uriOrMessage) ? uriOrMessage.toString(true) : uriOrMessage);
2215
2229 }
2230 }
2231 > } extHostTypes.ts
2232 >
2233 > //#endregion
2234 >
2235 > //#region folding api
2236 >
2237 > @es5ClassCompat
2238 > export class FoldingRange {
2239 >
2240 > start: number;
2241 >
2242 > end: number;
2243 >
2244 > kind?: FoldingRangeKind;
2245 >
2246 > constructor(start: number, end: number, kind?: FoldingRangeKind) {
2247 this.start = start;
2248 this.end = end;
2249 this.kind = kind;
2250 }
2251 > } extHostTypes.ts
2252 >
2253 > export enum FoldingRangeKind {
2254 > Comment = 1,
2255 > Imports = 2,
2256 > Region = 3
2257 > }
2258 >
2259 > //#endregion
2260 >
2261 > //#region Comment
2262 > export enum CommentThreadCollapsibleState {
2263 > /**
2264 > * Determines an item is collapsed
2265 > */
2266 > Collapsed = 0,
2267 > /**
2268 > * Determines an item is expanded
2269 > */
2270 > Expanded = 1
2271 > }
2272 >
2273 > export enum CommentMode {
2274 > Editing = 0,
2275 > Preview = 1
2276 > }
2277 >
2278 > export enum CommentState {
2279 > Published = 0,
2280 > Draft = 1
2281 > }
2282 >
2283 > export enum CommentThreadState {
2284 > Unresolved = 0,
2285 > Resolved = 1
2286 > }
2287 >
2288 > export enum CommentThreadApplicability {
2289 > Current = 0,
2290 > Outdated = 1
2291 > }
2292 >
2293 > export enum CommentThreadFocus {
2294 > Reply = 1,
2295 > Comment = 2
2296 > }
2297 >
2298 > //#endregion
2299 >
2300 > //#region Semantic Coloring
2301 >
2302 > export class SemanticTokensLegend {
2303 > public readonly tokenTypes: string[];
2304 > public readonly tokenModifiers: string[];
2305 >
2306 > constructor(tokenTypes: string[], tokenModifiers: string[] = []) {
2307 this.tokenTypes = tokenTypes;
2308 this.tokenModifiers = tokenModifiers;
2309 }
2310 > } extHostTypes.ts
2311 >
2312 function isStrArrayOrUndefined(arg: any): arg is string[] | undefined {
2313 return ((typeof arg === 'undefined') || isStringArray(arg));
2314 }
2316 > export class SemanticTokensBuilder {
2317 >
2318 > private _prevLine: number;
2319 > private _prevChar: number;
2320 > private _dataIsSortedAndDeltaEncoded: boolean;
2321 > private _data: number[];
2322 > private _dataLen: number;
2323 > private _tokenTypeStrToInt: Map<string, number>;
2324 > private _tokenModifierStrToInt: Map<string, number>;
2325 > private _hasLegend: boolean;
2326 >
2327 > constructor(legend?: vscode.SemanticTokensLegend) {
2328 this._prevLine = 0;
2329 this._prevChar = 0;
2344 }
2345 }
2347 > public push(line: number, char: number, length: number, tokenType: number, tokenModifiers?: number): void;
2348 > public push(range: Range, tokenType: string, tokenModifiers?: string[]): void;
2349 > public push(arg0: any, arg1: any, arg2: any, arg3?: any, arg4?: any): void {
2350 if (typeof arg0 === 'number' && typeof arg1 === 'number' && typeof arg2 === 'number' && typeof arg3 === 'number' && (typeof arg4 === 'number' || typeof arg4 === 'undefined')) {
2351 if (typeof arg4 === 'undefined') {
2361 throw illegalArgument();
2362 }
2364 > private _push(range: vscode.Range, tokenType: string, tokenModifiers?: string[]): void {
2365 if (!this._hasLegend) {
2366 throw new Error('Legend must be provided in constructor');
2388 this._pushEncoded(line, char, length, nTokenType, nTokenModifiers);
2389 }
2391 > private _pushEncoded(line: number, char: number, length: number, tokenType: number, tokenModifiers: number): void {
2392 if (this._dataIsSortedAndDeltaEncoded && (line < this._prevLine || (line === this._prevLine && char < this._prevChar))) {
2393 // push calls were ordered and are no longer ordered
2437 this._prevChar = char;
2438 }
2440 > private static _sortAndDeltaEncode(data: number[]): Uint32Array {
2441 const pos: number[] = [];
2442 const tokenCount = (data.length / 5) | 0;
2481 return result;
2482 }
2484 > public build(resultId?: string): SemanticTokens {
2485 if (!this._dataIsSortedAndDeltaEncoded) {
2486 return new SemanticTokens(SemanticTokensBuilder._sortAndDeltaEncode(this._data), resultId);
2488 return new SemanticTokens(new Uint32Array(this._data), resultId);
2489 }
2490 > } extHostTypes.ts
2491 >
2492 > export class SemanticTokens {
2493 > readonly resultId: string | undefined;
2494 > readonly data: Uint32Array;
2495 >
2496 > constructor(data: Uint32Array, resultId?: string) {
2497 this.resultId = resultId;
2498 this.data = data;
2499 }
2500 > } extHostTypes.ts
2501 >
2502 > export class SemanticTokensEdit {
2503 > readonly start: number;
2504 > readonly deleteCount: number;
2505 > readonly data: Uint32Array | undefined;
2506 >
2507 > constructor(start: number, deleteCount: number, data?: Uint32Array) {
2508 this.start = start;
2509 this.deleteCount = deleteCount;
2510 this.data = data;
2511 }
2512 > } extHostTypes.ts
2513 >
2514 > export class SemanticTokensEdits {
2515 > readonly resultId: string | undefined;
2516 > readonly edits: SemanticTokensEdit[];
2517 >
2518 > constructor(edits: SemanticTokensEdit[], resultId?: string) {
2519 this.resultId = resultId;
2520 this.edits = edits;
2521 }
2522 > } extHostTypes.ts
2523 >
2524 > //#endregion
2525 >
2526 > //#region debug
2527 > export enum DebugConsoleMode {
2528 > /**
2529 > * Debug session should have a separate debug console.
2530 > */
2531 > Separate = 0,
2532 >
2533 > /**
2534 > * Debug session should share debug console with its parent session.
2535 > * This value has no effect for sessions which do not have a parent session.
2536 > */
2537 > MergeWithParent = 1
2538 > }
2539 >
2540 > export class DebugVisualization {
2541 > iconPath?: URI | { light: URI; dark: URI } | ThemeIcon;
2542 > visualization?: vscode.Command | vscode.TreeDataProvider<unknown>;
2543 >
2544 > constructor(public name: string) { }
2545 > }
2546 >
2547 > //#endregion
2548 >
2549 > export enum QuickInputButtonLocation {
2550 > Title = 1,
2551 > Inline = 2,
2552 > Input = 3
2553 > }
2554 >
2555 > @es5ClassCompat
2556 > export class QuickInputButtons {
2557 >
2558 > static readonly Back: vscode.QuickInputButton = { iconPath: new ThemeIcon('arrow-left') };
2559 >
2560 > private constructor() { }
2561 > }
2562 >
2563 > export enum QuickPickItemKind {
2564 > Separator = -1,
2565 > Default = 0,
2566 > }
2567 >
2568 > export enum InputBoxValidationSeverity {
2569 > Info = 1,
2570 > Warning = 2,
2571 > Error = 3
2572 > }
2573 >
2574 > export enum ExtensionKind {
2575 > UI = 1,
2576 > Workspace = 2
2577 > }
2578 >
2579 > export class FileDecoration {
2580 >
2581 > static validate(d: FileDecoration): boolean {
2582 if (typeof d.badge === 'string') {
2583 let len = nextCharLength(d.badge, 0);
2598 return true;
2599 }
2601 > badge?: string | vscode.ThemeIcon;
2602 > tooltip?: string;
2603 > color?: vscode.ThemeColor;
2604 > propagate?: boolean;
2605 >
2606 > constructor(badge?: string | ThemeIcon, tooltip?: string, color?: ThemeColor) {
2607 this.badge = badge;
2608 this.tooltip = tooltip;
2609 this.color = color;
2610 }
2611 > } extHostTypes.ts
2612 >
2613 > //#region Theming
2614 >
2615 > @es5ClassCompat
2616 > export class ColorTheme implements vscode.ColorTheme {
2617 > constructor(public readonly kind: ColorThemeKind) {
2618 }
2619 > } extHostTypes.ts
2620 >
2621 > export enum ColorThemeKind {
2622 > Light = 1,
2623 > Dark = 2,
2624 > HighContrast = 3,
2625 > HighContrastLight = 4
2626 > }
2627 >
2628 > //#endregion Theming
2629 > //#region Notebook
2630 >
2631 > export class CellErrorStackFrame {
2632 > /**
2633 > * @param label The name of the stack frame
2634 > * @param file The file URI of the stack frame
2635 > * @param position The position of the stack frame within the file
2636 > */
2637 > constructor(
2638 public label: string,
2639 public uri?: vscode.Uri,
2640 public position?: Position,
2641 ) { }
2642 > } extHostTypes.ts
2643 >
2644 > export enum NotebookCellExecutionState {
2645 > Idle = 1,
2646 > Pending = 2,
2647 > Executing = 3,
2648 > }
2649 >
2650 > export enum NotebookCellStatusBarAlignment {
2651 > Left = 1,
2652 > Right = 2
2653 > }
2654 >
2655 > export enum NotebookEditorRevealType {
2656 > Default = 0,
2657 > InCenter = 1,
2658 > InCenterIfOutsideViewport = 2,
2659 > AtTop = 3
2660 > }
2661 >
2662 > export class NotebookCellStatusBarItem {
2663 > constructor(
2664 public text: string,
2665 public alignment: NotebookCellStatusBarAlignment) { }
2666 > } extHostTypes.ts
2667 >
2668 >
2669 > export enum NotebookControllerAffinity {
2670 > Default = 1,
2671 > Preferred = 2
2672 > }
2673 >
2674 > export enum NotebookControllerAffinity2 {
2675 > Default = 1,
2676 > Preferred = 2,
2677 > Hidden = -1
2678 > }
2679 >
2680 > export class NotebookRendererScript {
2681 >
2682 > public provides: readonly string[];
2683 >
2684 > constructor(
2685 public uri: vscode.Uri,
2686 provides: string | readonly string[] = []
2688 this.provides = asArray(provides);
2689 }
2690 > } extHostTypes.ts
2691 >
2692 > export class NotebookKernelSourceAction {
2693 > description?: string;
2694 > detail?: string;
2695 > command?: vscode.Command;
2696 > constructor(
2697 public label: string
2698 ) { }
2699 > } extHostTypes.ts
2700 >
2701 > export enum NotebookVariablesRequestKind {
2702 > Named = 1,
2703 > Indexed = 2
2704 > }
2705 >
2706 > //#endregion
2707 >
2708 > //#region Timeline
2709 >
2710 > @es5ClassCompat
2711 > export class TimelineItem implements vscode.TimelineItem {
2712 > constructor(public label: string, public timestamp: number) { }
2713 > }
2714 >
2715 > //#endregion Timeline
2716 >
2717 > //#region ExtensionContext
2718 >
2719 > export enum ExtensionMode {
2720 > /**
2721 > * The extension is installed normally (for example, from the marketplace
2722 > * or VSIX) in VS Code.
2723 > */
2724 > Production = 1,
2725 >
2726 > /**
2727 > * The extension is running from an `--extensionDevelopmentPath` provided
2728 > * when launching VS Code.
2729 > */
2730 > Development = 2,
2731 >
2732 > /**
2733 > * The extension is running from an `--extensionDevelopmentPath` and
2734 > * the extension host is running unit tests.
2735 > */
2736 > Test = 3,
2737 > }
2738 >
2739 > export enum ExtensionRuntime {
2740 > /**
2741 > * The extension is running in a NodeJS extension host. Runtime access to NodeJS APIs is available.
2742 > */
2743 > Node = 1,
2744 > /**
2745 > * The extension is running in a Webworker extension host. Runtime access is limited to Webworker APIs.
2746 > */
2747 > Webworker = 2
2748 > }
2749 >
2750 > //#endregion ExtensionContext
2751 >
2752 > export enum StandardTokenType {
2753 > Other = 0,
2754 > Comment = 1,
2755 > String = 2,
2756 > RegEx = 3
2757 > }
2758 >
2759 > export enum SyntaxHighlightingTokenFontStyle {
2760 > None = 0,
2761 > Italic = 1,
2762 > Bold = 2,
2763 > Underline = 4,
2764 > Strikethrough = 8,
2765 > }
2766 >
2767 >
2768 > export class LinkedEditingRanges {
2769 > constructor(public readonly ranges: Range[], public readonly wordPattern?: RegExp) {
2770 }
2771 > } extHostTypes.ts
2772 >
2773 > //#region ports
2774 > export class PortAttributes {
2775 > private _autoForwardAction: PortAutoForwardAction;
2776 >
2777 > constructor(autoForwardAction: PortAutoForwardAction) {
2778 this._autoForwardAction = autoForwardAction;
2779 }
2781 > get autoForwardAction(): PortAutoForwardAction {
2782 return this._autoForwardAction;
2783 }
2784 > } extHostTypes.ts
2785 > //#endregion ports
2786 >
2787 > //#region Testing
2788 > export enum TestResultState {
2789 > Queued = 1,
2790 > Running = 2,
2791 > Passed = 3,
2792 > Failed = 4,
2793 > Skipped = 5,
2794 > Errored = 6
2795 > }
2796 >
2797 > export enum TestRunProfileKind {
2798 > Run = 1,
2799 > Debug = 2,
2800 > Coverage = 3,
2801 > }
2802 >
2803 > export class TestRunProfileBase {
2804 > constructor(
2805 public readonly controllerId: string,
2806 public readonly profileId: number,
2807 public readonly kind: vscode.TestRunProfileKind,
2808 ) { }
2809 > } extHostTypes.ts
2810 >
2811 > @es5ClassCompat
2812 > export class TestRunRequest implements vscode.TestRunRequest {
2813 > constructor(
2814 public readonly include: vscode.TestItem[] | undefined = undefined,
2815 public readonly exclude: vscode.TestItem[] | undefined = undefined,
2818 public readonly preserveFocus = true,
2819 ) { }
2820 > } extHostTypes.ts
2821 >
2822 > @es5ClassCompat
2823 > export class TestMessage implements vscode.TestMessage {
2824 > public expectedOutput?: string;
2825 > public actualOutput?: string;
2826 > public location?: vscode.Location;
2827 > public contextValue?: string;
2828 >
2829 > /** proposed: */
2830 > public stackTrace?: TestMessageStackFrame[];
2831 >
2832 > public static diff(message: string | vscode.MarkdownString, expected: string, actual: string) {
2833 > const msg = new TestMessage(message);
2834 > msg.expectedOutput = expected;
2835 > msg.actualOutput = actual;
2836 > return msg;
2837 > }
2838 >
2839 > constructor(public message: string | vscode.MarkdownString) { }
2840 > }
2841 >
2842 > @es5ClassCompat
2843 > export class TestTag implements vscode.TestTag {
2844 > constructor(public readonly id: string) { }
2845 > }
2846 >
2847 > export class TestMessageStackFrame {
2848 > /**
2849 > * @param label The name of the stack frame
2850 > * @param file The file URI of the stack frame
2851 > * @param position The position of the stack frame within the file
2852 > */
2853 > constructor(
2854 public label: string,
2855 public uri?: vscode.Uri,
2856 public position?: Position,
2857 ) { }
2858 > } extHostTypes.ts
2859 >
2860 > //#endregion
2861 >
2862 > //#region Test Coverage
2863 > export class TestCoverageCount implements vscode.TestCoverageCount {
2864 > constructor(public covered: number, public total: number) {
2865 validateTestCoverageCount(this);
2866 }
2867 > } extHostTypes.ts
2868 >
2869 > export function validateTestCoverageCount(cc?: vscode.TestCoverageCount) {
2870 if (!cc) {
2871 return;
2880 }
2881 }
2883 > export class FileCoverage implements vscode.FileCoverage {
2884 > public static fromDetails(uri: vscode.Uri, details: vscode.FileCoverageDetail[]): vscode.FileCoverage {
2885 > const statements = new TestCoverageCount(0, 0);
2886 > const branches = new TestCoverageCount(0, 0);
2887 > const decl = new TestCoverageCount(0, 0);
2888 >
2889 > for (const detail of details) {
2890 > if ('branches' in detail) {
2891 > statements.total += 1;
2892 > statements.covered += detail.executed ? 1 : 0;
2893 >
2894 > for (const branch of detail.branches) {
2895 > branches.total += 1;
2896 > branches.covered += branch.executed ? 1 : 0;
2897 > }
2898 > } else {
2899 > decl.total += 1;
2900 > decl.covered += detail.executed ? 1 : 0;
2901 > }
2902 > }
2903 >
2904 > const coverage = new FileCoverage(
2905 > uri,
2906 > statements,
2907 > branches.total > 0 ? branches : undefined,
2908 > decl.total > 0 ? decl : undefined,
2909 > );
2910 >
2911 > coverage.detailedCoverage = details;
2912 >
2913 > return coverage;
2914 > }
2915 >
2916 > detailedCoverage?: vscode.FileCoverageDetail[];
2917 >
2918 > constructor(
2919 public readonly uri: vscode.Uri,
2920 public statementCoverage: vscode.TestCoverageCount,
2924 ) {
2925 }
2926 > } extHostTypes.ts
2927 >
2928 > export class StatementCoverage implements vscode.StatementCoverage {
2929 > // back compat until finalization:
2930 > get executionCount() { return +this.executed; }
2931 > set executionCount(n: number) { this.executed = n; }
2932 >
2933 > constructor(
2934 public executed: number | boolean,
2935 public location: Position | Range,
2936 public branches: vscode.BranchCoverage[] = [],
2937 ) { }
2938 > } extHostTypes.ts
2939 >
2940 > export class BranchCoverage implements vscode.BranchCoverage {
2941 > // back compat until finalization:
2942 > get executionCount() { return +this.executed; }
2943 > set executionCount(n: number) { this.executed = n; }
2944 >
2945 > constructor(
2946 public executed: number | boolean,
2947 public location: Position | Range,
2948 public label?: string,
2949 ) { }
2950 > } extHostTypes.ts
2951 >
2952 > export class DeclarationCoverage implements vscode.DeclarationCoverage {
2953 > // back compat until finalization:
2954 > get executionCount() { return +this.executed; }
2955 > set executionCount(n: number) { this.executed = n; }
2956 >
2957 > constructor(
2958 public readonly name: string,
2959 public executed: number | boolean,
2960 public location: Position | Range,
2961 ) { }
2962 > } extHostTypes.ts
2963 > //#endregion
2964 >
2965 > export enum ExternalUriOpenerPriority {
2966 > None = 0,
2967 > Option = 1,
2968 > Default = 2,
2969 > Preferred = 3,
2970 > }
2971 >
2972 > export enum WorkspaceTrustState {
2973 > Untrusted = 0,
2974 > Trusted = 1,
2975 > Unspecified = 2
2976 > }
2977 >
2978 > export enum PortAutoForwardAction {
2979 > Notify = 1,
2980 > OpenBrowser = 2,
2981 > OpenPreview = 3,
2982 > Silent = 4,
2983 > Ignore = 5,
2984 > OpenBrowserOnce = 6
2985 > }
2986 >
2987 > export class TypeHierarchyItem {
2988 > _sessionId?: string;
2989 > _itemId?: string;
2990 >
2991 > kind: SymbolKind;
2992 > tags?: SymbolTag[];
2993 > name: string;
2994 > detail?: string;
2995 > uri: URI;
2996 > range: Range;
2997 > selectionRange: Range;
2998 >
2999 > constructor(kind: SymbolKind, name: string, detail: string, uri: URI, range: Range, selectionRange: Range) {
3000 this.kind = kind;
3001 this.name = name;
3005 this.selectionRange = selectionRange;
3006 }
3007 > } extHostTypes.ts
3008 >
3009 > //#region Tab Inputs
3010 >
3011 > export class TextTabInput {
3012 > constructor(readonly uri: URI) { }
3013 > }
3014 >
3015 > export class TextDiffTabInput {
3016 > constructor(readonly original: URI, readonly modified: URI) { }
3017 > }
3018 >
3019 > export class TextMergeTabInput {
3020 > constructor(readonly base: URI, readonly input1: URI, readonly input2: URI, readonly result: URI) { }
3021 > }
3022 >
3023 > export class CustomEditorTabInput {
3024 > constructor(readonly uri: URI, readonly viewType: string) { }
3025 > }
3026 >
3027 > export class WebviewEditorTabInput {
3028 > constructor(readonly viewType: string) { }
3029 > }
3030 >
3031 > export class NotebookEditorTabInput {
3032 > constructor(readonly uri: URI, readonly notebookType: string) { }
3033 > }
3034 >
3035 > export class NotebookDiffEditorTabInput {
3036 > constructor(readonly original: URI, readonly modified: URI, readonly notebookType: string) { }
3037 > }
3038 >
3039 > export class TerminalEditorTabInput {
3040 > constructor() { }
3041 > }
3042 > export class InteractiveWindowInput {
3043 > constructor(readonly uri: URI, readonly inputBoxUri: URI) { }
3044 > }
3045 >
3046 > export class ChatEditorTabInput {
3047 > constructor() { }
3048 > }
3049 >
3050 > export class TextMultiDiffTabInput {
3051 > constructor(readonly textDiffs: TextDiffTabInput[]) { }
3052 > }
3053 > //#endregion
3054 >
3055 > //#region Chat
3056 >
3057 > export enum InteractiveSessionVoteDirection {
3058 > Down = 0,
3059 > Up = 1
3060 > }
3061 >
3062 > export enum ChatCopyKind {
3063 > Action = 1,
3064 > Toolbar = 2
3065 > }
3066 >
3067 > export enum ChatVariableLevel {
3068 > Short = 1,
3069 > Medium = 2,
3070 > Full = 3
3071 > }
3072 >
3073 > export class ChatCompletionItem implements vscode.ChatCompletionItem {
3074 > id: string;
3075 > label: string | CompletionItemLabel;
3076 > fullName?: string | undefined;
3077 > icon?: vscode.ThemeIcon;
3078 > insertText?: string;
3079 > values: vscode.ChatVariableValue[];
3080 > detail?: string;
3081 > documentation?: string | MarkdownString;
3082 > command?: vscode.Command;
3083 >
3084 > constructor(id: string, label: string | CompletionItemLabel, values: vscode.ChatVariableValue[]) {
3085 this.id = id;
3086 this.label = label;
3087 this.values = values;
3088 }
3089 > } extHostTypes.ts
3090 >
3091 > export enum ChatEditingSessionActionOutcome {
3092 > Accepted = 1,
3093 > Rejected = 2,
3094 > Saved = 3
3095 > }
3096 >
3097 > export enum ChatRequestEditedFileEventKind {
3098 > Keep = 1,
3099 > Undo = 2,
3100 > UserModification = 3,
3101 > }
3102 >
3103 > //#endregion
3104 >
3105 > //#region Interactive Editor
3106 >
3107 > export enum InteractiveEditorResponseFeedbackKind {
3108 > Unhelpful = 0,
3109 > Helpful = 1,
3110 > Undone = 2,
3111 > Accepted = 3,
3112 > Bug = 4
3113 > }
3114 >
3115 > export enum ChatResultFeedbackKind {
3116 > Unhelpful = 0,
3117 > Helpful = 1,
3118 > }
3119 >
3120 > export class ChatResponseMarkdownPart {
3121 > value: vscode.MarkdownString;
3122 > constructor(value: string | vscode.MarkdownString) {
3123 if (typeof value !== 'string' && value.isTrusted === true) {
3124 throw new Error('The boolean form of MarkdownString.isTrusted is NOT supported for chat participants.');
3127 this.value = typeof value === 'string' ? new MarkdownString(value) : value;
3128 }
3129 > } extHostTypes.ts
3130 >
3131 > /**
3132 > * TODO if 'vulnerabilities' is finalized, this should be merged with the base ChatResponseMarkdownPart. I just don't see how to do that while keeping
3133 > * vulnerabilities in a seperate API proposal in a clean way.
3134 > */
3135 > export class ChatResponseMarkdownWithVulnerabilitiesPart {
3136 > value: vscode.MarkdownString;
3137 > vulnerabilities: vscode.ChatVulnerability[];
3138 > constructor(value: string | vscode.MarkdownString, vulnerabilities: vscode.ChatVulnerability[]) {
3139 if (typeof value !== 'string' && value.isTrusted === true) {
3140 throw new Error('The boolean form of MarkdownString.isTrusted is NOT supported for chat participants.');
3144 this.vulnerabilities = vulnerabilities;
3145 }
3146 > } extHostTypes.ts
3147 >
3148 > export class ChatResponseConfirmationPart {
3149 > title: string;
3150 > message: string | vscode.MarkdownString;
3151 > data: any;
3152 > buttons?: string[];
3153 >
3154 > constructor(title: string, message: string | vscode.MarkdownString, data: any, buttons?: string[]) {
3155 this.title = title;
3156 this.message = message;
3158 this.buttons = buttons;
3159 }
3160 > } extHostTypes.ts
3161 >
3162 > export class ChatResponseFileTreePart {
3163 > value: vscode.ChatResponseFileTree[];
3164 > baseUri: vscode.Uri;
3165 > constructor(value: vscode.ChatResponseFileTree[], baseUri: vscode.Uri) {
3166 this.value = value;
3167 this.baseUri = baseUri;
3168 }
3169 > } extHostTypes.ts
3170 >
3171 > export class ChatResponseMultiDiffPart {
3172 > value: vscode.ChatResponseDiffEntry[];
3173 > title: string;
3174 > readOnly?: boolean;
3175 > constructor(value: vscode.ChatResponseDiffEntry[], title: string, readOnly?: boolean) {
3176 this.value = value;
3177 this.title = title;
3178 this.readOnly = readOnly;
3179 }
3180 > } extHostTypes.ts
3181 >
3182 > export class McpToolInvocationContentData {
3183 > mimeType: string;
3184 > data: Uint8Array;
3185 > constructor(data: Uint8Array, mimeType: string) {
3186 this.data = data;
3187 this.mimeType = mimeType;
3188 }
3189 > } extHostTypes.ts
3190 >
3191 > export class ChatSubagentToolInvocationData {
3192 > description?: string;
3193 > agentName?: string;
3194 > prompt?: string;
3195 > result?: string;
3196 > modelName?: string;
3197 > constructor(description?: string, agentName?: string, prompt?: string, result?: string) {
3198 this.description = description;
3199 this.agentName = agentName;
3201 this.result = result;
3202 }
3203 > } extHostTypes.ts
3204 >
3205 > export class ChatResponseExternalEditPart {
3206 > applied: Thenable<string>;
3207 > didGetApplied!: (value: string) => void;
3208 >
3209 > constructor(
3210 public uris: vscode.Uri[],
3211 public callback: () => Thenable<unknown>,
3215 });
3216 }
3217 > } extHostTypes.ts
3218 >
3219 > export class ChatResponseAnchorPart implements vscode.ChatResponseAnchorPart {
3220 > value: vscode.Uri | vscode.Location;
3221 > title?: string;
3222 >
3223 > value2: vscode.Uri | vscode.Location | vscode.SymbolInformation;
3224 > resolve?(token: vscode.CancellationToken): Thenable<void>;
3225 >
3226 > constructor(value: vscode.Uri | vscode.Location | vscode.SymbolInformation, title?: string) {
3227 // eslint-disable-next-line local/code-no-any-casts
3228 this.value = value as any;
3230 this.title = title;
3231 }
3232 > } extHostTypes.ts
3233 >
3234 > export class ChatResponseProgressPart {
3235 > value: string;
3236 > constructor(value: string) {
3237 this.value = value;
3238 }
3239 > } extHostTypes.ts
3240 >
3241 > export class ChatResponseProgressPart2 {
3242 > value: string;
3243 > task?: (progress: vscode.Progress<vscode.ChatResponseWarningPart>) => Thenable<string | void>;
3244 > constructor(value: string, task?: (progress: vscode.Progress<vscode.ChatResponseWarningPart>) => Thenable<string | void>) {
3245 this.value = value;
3246 this.task = task;
3247 }
3248 > } extHostTypes.ts
3249 >
3250 > export class ChatResponseThinkingProgressPart {
3251 > value: string | string[];
3252 > id?: string;
3253 > metadata?: { readonly [key: string]: any };
3254 > constructor(value: string | string[], id?: string, metadata?: { readonly [key: string]: any }) {
3255 this.value = value;
3256 this.id = id;
3257 this.metadata = metadata;
3258 }
3259 > } extHostTypes.ts
3260 >
3261 > export class ChatResponseHookPart {
3262 > hookType: HookTypeValue;
3263 > stopReason?: string;
3264 > systemMessage?: string;
3265 > metadata?: { readonly [key: string]: unknown };
3266 > constructor(hookType: HookTypeValue, stopReason?: string, systemMessage?: string, metadata?: { readonly [key: string]: unknown }) {
3267 this.hookType = hookType;
3268 this.stopReason = stopReason;
3270 this.metadata = metadata;
3271 }
3272 > } extHostTypes.ts
3273 >
3274 > export class ChatResponseAutoModeResolutionPart {
3275 > resolvedModel: string;
3276 > resolvedModelName: string;
3277 > predictedLabel: string;
3278 > confidence: number;
3279 > constructor(resolvedModel: string, resolvedModelName: string, predictedLabel: string, confidence: number) {
3280 this.resolvedModel = resolvedModel;
3281 this.resolvedModelName = resolvedModelName;
3283 this.confidence = confidence;
3284 }
3285 > } extHostTypes.ts
3286 >
3287 > export class ChatResponseWarningPart {
3288 > value: vscode.MarkdownString;
3289 > constructor(value: string | vscode.MarkdownString) {
3290 if (typeof value !== 'string' && value.isTrusted === true) {
3291 throw new Error('The boolean form of MarkdownString.isTrusted is NOT supported for chat participants.');
3294 this.value = typeof value === 'string' ? new MarkdownString(value) : value;
3295 }
3296 > } extHostTypes.ts
3297 >
3298 > export class ChatResponseInfoPart {
3299 > value: vscode.MarkdownString;
3300 > constructor(value: string | vscode.MarkdownString) {
3301 if (typeof value !== 'string' && value.isTrusted === true) {
3302 throw new Error('The boolean form of MarkdownString.isTrusted is NOT supported for chat participants.');
3305 this.value = typeof value === 'string' ? new MarkdownString(value) : value;
3306 }
3307 > } extHostTypes.ts
3308 >
3309 > export class ChatResponseCommandButtonPart {
3310 > value: vscode.Command;
3311 > constructor(value: vscode.Command) {
3312 this.value = value;
3313 }
3314 > } extHostTypes.ts
3315 >
3316 > export class ChatResponseReferencePart {
3317 > value: vscode.Uri | vscode.Location | { variableName: string; value?: vscode.Uri | vscode.Location } | string;
3318 > iconPath?: vscode.Uri | vscode.ThemeIcon | { light: vscode.Uri; dark: vscode.Uri };
3319 > options?: { status?: { description: string; kind: vscode.ChatResponseReferencePartStatusKind }; diffMeta?: { added: number; removed: number } };
3320 > constructor(value: vscode.Uri | vscode.Location | { variableName: string; value?: vscode.Uri | vscode.Location } | string, iconPath?: vscode.Uri | vscode.ThemeIcon | { light: vscode.Uri; dark: vscode.Uri }, options?: { status?: { description: string; kind: vscode.ChatResponseReferencePartStatusKind } }) {
3321 this.value = value;
3322 this.iconPath = iconPath;
3323 this.options = options;
3324 }
3325 > } extHostTypes.ts
3326 >
3327 > export class ChatResponseCodeblockUriPart {
3328 > isEdit?: boolean;
3329 > undoStopId?: string;
3330 > value: vscode.Uri;
3331 > constructor(value: vscode.Uri, isEdit?: boolean, undoStopId?: string) {
3332 this.value = value;
3333 this.isEdit = isEdit;
3334 this.undoStopId = undoStopId;
3335 }
3336 > } extHostTypes.ts
3337 >
3338 > export class ChatResponseCodeCitationPart {
3339 > value: vscode.Uri;
3340 > license: string;
3341 > snippet: string;
3342 > constructor(value: vscode.Uri, license: string, snippet: string) {
3343 this.value = value;
3344 this.license = license;
3345 this.snippet = snippet;
3346 }
3347 > } extHostTypes.ts
3348 >
3349 > export class ChatResponseMovePart {
3350 > constructor(
3351 public readonly uri: vscode.Uri,
3352 public readonly range: vscode.Range,
3353 ) {
3354 }
3355 > } extHostTypes.ts
3356 >
3357 > export class ChatResponseExtensionsPart {
3358 > constructor(
3359 public readonly extensions: string[],
3360 ) {
3361 }
3362 > } extHostTypes.ts
3363 >
3364 > export class ChatResponsePullRequestPart {
3365 > public readonly uri?: vscode.Uri;
3366 > public readonly command: vscode.Command;
3367 >
3368 > constructor(
3369 uriOrCommand: vscode.Uri | vscode.Command,
3370 public readonly title: string,
3384 }
3385 }
3387 > toJSON() {
3388 return {
3389 $mid: MarshalledId.ChatResponsePullRequestPart,
3394 };
3395 }
3396 > } extHostTypes.ts
3397 >
3398 > /**
3399 > * The type of question for a chat question carousel.
3400 > */
3401 > export enum ChatQuestionType {
3402 > /**
3403 > * A free-form text input question.
3404 > */
3405 > Text = 1,
3406 > /**
3407 > * A single-select question with radio buttons.
3408 > */
3409 > SingleSelect = 2,
3410 > /**
3411 > * A multi-select question with checkboxes.
3412 > */
3413 > MultiSelect = 3
3414 > }
3415 >
3416 > /**
3417 > * Represents a question to be displayed in a chat question carousel.
3418 > * Questions can be of type 'text' for free-form input, 'singleSelect' for radio buttons,
3419 > * or 'multiSelect' for checkboxes.
3420 > */
3421 > export class ChatQuestion {
3422 > /** Unique identifier for the question. */
3423 > id: string;
3424 > /** The type of question: Text for free-form input, SingleSelect for radio buttons, MultiSelect for checkboxes. */
3425 > type: ChatQuestionType;
3426 > /** The title/header of the question. */
3427 > title: string;
3428 > /** Optional detailed message or description for the question. */
3429 > message?: string | vscode.MarkdownString;
3430 > /** Options for singleSelect or multiSelect questions. */
3431 > options?: { id: string; label: string; value: unknown }[];
3432 > /** The id(s) of the default selected option(s). */
3433 > defaultValue?: string | string[];
3434 > /** Whether to allow free-form text input in addition to predefined options. */
3435 > allowFreeformInput?: boolean;
3436 >
3437 > constructor(
3438 id: string,
3439 type: ChatQuestionType,
3454 this.allowFreeformInput = options?.allowFreeformInput;
3455 }
3456 > } extHostTypes.ts
3457 >
3458 > /**
3459 > * A carousel view for presenting multiple questions inline in the chat response.
3460 > * Users can navigate between questions and submit their answers.
3461 > */
3462 > export class ChatResponseQuestionCarouselPart {
3463 > /** The questions to display in the carousel. */
3464 > questions: ChatQuestion[];
3465 > /** Whether users can skip answering the questions. */
3466 > allowSkip: boolean;
3467 >
3468 > constructor(questions: ChatQuestion[], allowSkip: boolean = true) {
3469 this.questions = questions;
3470 this.allowSkip = allowSkip;
3471 }
3472 > } extHostTypes.ts
3473 >
3474 > export class ChatResponseTextEditPart implements vscode.ChatResponseTextEditPart {
3475 > uri: vscode.Uri;
3476 > edits: vscode.TextEdit[];
3477 > isDone?: boolean;
3478 > constructor(uri: vscode.Uri, editsOrDone: vscode.TextEdit | vscode.TextEdit[] | true) {
3479 this.uri = uri;
3480 if (editsOrDone === true) {
3485 }
3486 }
3487 > } extHostTypes.ts
3488 >
3489 > export class ChatResponseNotebookEditPart implements vscode.ChatResponseNotebookEditPart {
3490 > uri: vscode.Uri;
3491 > edits: vscode.NotebookEdit[];
3492 > isDone?: boolean;
3493 > constructor(uri: vscode.Uri, editsOrDone: vscode.NotebookEdit | vscode.NotebookEdit[] | true) {
3494 this.uri = uri;
3495 if (editsOrDone === true) {
3501 }
3502 }
3503 > } extHostTypes.ts
3504 >
3505 > export class ChatResponseWorkspaceEditPart implements vscode.ChatResponseWorkspaceEditPart {
3506 > edits: vscode.ChatWorkspaceFileEdit[];
3507 > constructor(edits: vscode.ChatWorkspaceFileEdit[]) {
3508 this.edits = edits;
3509 }
3510 > } extHostTypes.ts
3511 >
3512 > export interface ChatTerminalToolInvocationData2 {
3513 > commandLine: {
3514 > original: string;
3515 > userEdited?: string;
3516 > toolEdited?: string;
3517 > };
3518 > language: string;
3519 > }
3520 >
3521 > export enum ChatTodoStatus {
3522 > NotStarted = 1,
3523 > InProgress = 2,
3524 > Completed = 3
3525 > }
3526 >
3527 > export enum ChatDebugSubagentStatus {
3528 > Running = 0,
3529 > Completed = 1,
3530 > Failed = 2
3531 > }
3532 >
3533 > export class ChatToolInvocationPart {
3534 > toolName: string;
3535 > toolCallId: string;
3536 > errorMessage?: string;
3537 > invocationMessage?: string | vscode.MarkdownString;
3538 > originMessage?: string | vscode.MarkdownString;
3539 > pastTenseMessage?: string | vscode.MarkdownString;
3540 > isConfirmed?: boolean;
3541 > isComplete?: boolean;
3542 > toolSpecificData?: ChatTerminalToolInvocationData2;
3543 > subAgentInvocationId?: string;
3544 > subAgentName?: string;
3545 > presentation?: 'hidden' | 'hiddenAfterComplete' | undefined;
3546 >
3547 > constructor(toolName: string,
3548 toolCallId: string,
3549 errorMessage?: string) {
3552 this.errorMessage = errorMessage;
3553 }
3554 > } extHostTypes.ts
3555 >
3556 > export class ChatRequestTurn implements vscode.ChatRequestTurn2 {
3557 > constructor(
3558 readonly prompt: string,
3559 readonly command: string | undefined,
3566 readonly modeInstructions2?: vscode.ChatRequestModeInstructions,
3567 ) { }
3568 > } extHostTypes.ts
3569 >
3570 > export class ChatResponseTurn implements vscode.ChatResponseTurn {
3571 >
3572 > constructor(
3573 readonly response: ReadonlyArray<ChatResponseMarkdownPart | ChatResponseFileTreePart | ChatResponseAnchorPart | ChatResponseCommandButtonPart>,
3574 readonly result: vscode.ChatResult,
3576 readonly command?: string
3577 ) { }
3578 > } extHostTypes.ts
3579 >
3580 > export class ChatResponseTurn2 implements vscode.ChatResponseTurn2 {
3581 >
3582 > constructor(
3583 readonly response: ReadonlyArray<ChatResponseMarkdownPart | ChatResponseFileTreePart | ChatResponseAnchorPart | ChatResponseCommandButtonPart | ChatResponseExtensionsPart | ChatToolInvocationPart>,
3584 readonly result: vscode.ChatResult,
3586 readonly command?: string
3587 ) { }
3588 > } extHostTypes.ts
3589 >
3590 > export enum ChatLocation {
3591 > Panel = 1,
3592 > Terminal = 2,
3593 > Notebook = 3,
3594 > Editor = 4,
3595 > }
3596 >
3597 > export enum ChatSessionStatus {
3598 > Failed = 0,
3599 > Completed = 1,
3600 > InProgress = 2,
3601 > NeedsInput = 3
3602 > }
3603 >
3604 > export class ChatSessionCustomizationType {
3605 > static readonly Agent = new ChatSessionCustomizationType('agent');
3606 > static readonly Skill = new ChatSessionCustomizationType('skill');
3607 > static readonly Instructions = new ChatSessionCustomizationType('instructions');
3608 > static readonly Prompt = new ChatSessionCustomizationType('prompt');
3609 > static readonly Hook = new ChatSessionCustomizationType('hook');
3610 > static readonly Plugins = new ChatSessionCustomizationType('plugins');
3611 >
3612 > constructor(public readonly id: string) { }
3613 > }
3614 >
3615 > export enum ChatDebugLogLevel {
3616 > Trace = 0,
3617 > Info = 1,
3618 > Warning = 2,
3619 > Error = 3
3620 > }
3621 >
3622 > export enum ChatDebugToolCallResult {
3623 > Success = 0,
3624 > Error = 1
3625 > }
3626 >
3627 > export enum ChatDebugHookResult {
3628 > Success = 0,
3629 > Error = 1,
3630 > NonBlockingError = 2
3631 > }
3632 >
3633 > export class ChatDebugToolCallEvent {
3634 > readonly _kind = 'toolCall';
3635 > id?: string;
3636 > sessionResource?: vscode.Uri;
3637 > created: Date;
3638 > parentEventId?: string;
3639 > toolName: string;
3640 > toolCallId?: string;
3641 > input?: string;
3642 > output?: string;
3643 > result?: ChatDebugToolCallResult;
3644 > durationInMillis?: number;
3645 >
3646 > constructor(toolName: string, created: Date) {
3647 this.toolName = toolName;
3648 this.created = created;
3649 }
3650 > } extHostTypes.ts
3651 >
3652 > export class ChatDebugModelTurnEvent {
3653 > readonly _kind = 'modelTurn';
3654 > id?: string;
3655 > sessionResource?: vscode.Uri;
3656 > created: Date;
3657 > parentEventId?: string;
3658 > model?: string;
3659 > requestName?: string;
3660 > inputTokens?: number;
3661 > outputTokens?: number;
3662 > cachedTokens?: number;
3663 > totalTokens?: number;
3664 > cost?: number;
3665 > copilotUsageNanoAiu?: number;
3666 > durationInMillis?: number;
3667 >
3668 > constructor(created: Date) {
3669 this.created = created;
3670 }
3671 > } extHostTypes.ts
3672 >
3673 > export class ChatDebugGenericEvent {
3674 > readonly _kind = 'generic';
3675 > id?: string;
3676 > sessionResource?: vscode.Uri;
3677 > created: Date;
3678 > parentEventId?: string;
3679 > name: string;
3680 > details?: string;
3681 > level: ChatDebugLogLevel;
3682 > category?: string;
3683 >
3684 > constructor(name: string, level: ChatDebugLogLevel, created: Date) {
3685 this.name = name;
3686 this.level = level;
3687 this.created = created;
3688 }
3689 > } extHostTypes.ts
3690 >
3691 > export class ChatDebugSubagentInvocationEvent {
3692 > readonly _kind = 'subagentInvocation';
3693 > id?: string;
3694 > sessionResource?: vscode.Uri;
3695 > created: Date;
3696 > parentEventId?: string;
3697 > agentName: string;
3698 > description?: string;
3699 > status?: ChatDebugSubagentStatus;
3700 > durationInMillis?: number;
3701 > toolCallCount?: number;
3702 > modelTurnCount?: number;
3703 >
3704 > constructor(agentName: string, created: Date) {
3705 this.agentName = agentName;
3706 this.created = created;
3707 }
3708 > } extHostTypes.ts
3709 >
3710 > export class ChatDebugMessageSection {
3711 > name: string;
3712 > content: string;
3713 >
3714 > constructor(name: string, content: string) {
3715 this.name = name;
3716 this.content = content;
3717 }
3718 > } extHostTypes.ts
3719 >
3720 > export class ChatDebugUserMessageEvent {
3721 > readonly _kind = 'userMessage';
3722 > id?: string;
3723 > sessionResource?: vscode.Uri;
3724 > created: Date;
3725 > parentEventId?: string;
3726 > message: string;
3727 > sections: ChatDebugMessageSection[];
3728 >
3729 > constructor(message: string, created: Date) {
3730 this.message = message;
3731 this.created = created;
3732 this.sections = [];
3733 }
3734 > } extHostTypes.ts
3735 >
3736 > export class ChatDebugAgentResponseEvent {
3737 > readonly _kind = 'agentResponse';
3738 > id?: string;
3739 > sessionResource?: vscode.Uri;
3740 > created: Date;
3741 > parentEventId?: string;
3742 > message: string;
3743 > sections: ChatDebugMessageSection[];
3744 >
3745 > constructor(message: string, created: Date) {
3746 this.message = message;
3747 this.created = created;
3748 this.sections = [];
3749 }
3750 > } extHostTypes.ts
3751 >
3752 > export class ChatDebugEventTextContent {
3753 > readonly _kind = 'text';
3754 > value: string;
3755 >
3756 > constructor(value: string) {
3757 this.value = value;
3758 }
3759 > } extHostTypes.ts
3760 >
3761 > export enum ChatDebugMessageContentType {
3762 > User = 0,
3763 > Agent = 1
3764 > }
3765 >
3766 > export class ChatDebugEventMessageContent {
3767 > readonly _kind = 'messageContent';
3768 > type: ChatDebugMessageContentType;
3769 > message: string;
3770 > sections: ChatDebugMessageSection[];
3771 >
3772 > constructor(type: ChatDebugMessageContentType, message: string, sections: ChatDebugMessageSection[]) {
3773 this.type = type;
3774 this.message = message;
3775 this.sections = sections;
3776 }
3777 > } extHostTypes.ts
3778 >
3779 > export class ChatDebugEventToolCallContent {
3780 > readonly _kind = 'toolCallContent';
3781 > toolName: string;
3782 > result?: ChatDebugToolCallResult;
3783 > durationInMillis?: number;
3784 > input?: string;
3785 > output?: string;
3786 >
3787 > constructor(toolName: string) {
3788 this.toolName = toolName;
3789 }
3790 > } extHostTypes.ts
3791 >
3792 > export class ChatDebugEventModelTurnContent {
3793 > readonly _kind = 'modelTurnContent';
3794 > requestName: string;
3795 > model?: string;
3796 > status?: string;
3797 > durationInMillis?: number;
3798 > timeToFirstTokenInMillis?: number;
3799 > requestId?: string;
3800 > maxInputTokens?: number;
3801 > maxOutputTokens?: number;
3802 > inputTokens?: number;
3803 > outputTokens?: number;
3804 > cachedTokens?: number;
3805 > totalTokens?: number;
3806 > requestOptions?: string;
3807 > errorMessage?: string;
3808 > sections?: ChatDebugMessageSection[];
3809 >
3810 > constructor(requestName: string) {
3811 this.requestName = requestName;
3812 }
3813 > } extHostTypes.ts
3814 >
3815 > export class ChatDebugEventHookContent {
3816 > readonly _kind = 'hookContent';
3817 > hookType: string;
3818 > command?: string;
3819 > result?: ChatDebugHookResult;
3820 > durationInMillis?: number;
3821 > input?: string;
3822 > output?: string;
3823 > exitCode?: number;
3824 > errorMessage?: string;
3825 >
3826 > constructor(hookType: string) {
3827 this.hookType = hookType;
3828 }
3829 > } extHostTypes.ts
3830 >
3831 > export class ChatSessionChangedFile {
3832 > constructor(public readonly uri: vscode.Uri, public readonly originalUri: vscode.Uri | undefined, public readonly modifiedUri: vscode.Uri | undefined, public readonly insertions: number, public readonly deletions: number) { }
3833 > }
3834 >
3835 > export enum ChatResponseReferencePartStatusKind {
3836 > Complete = 1,
3837 > Partial = 2,
3838 > Omitted = 3
3839 > }
3840 >
3841 > export enum ChatResponseClearToPreviousToolInvocationReason {
3842 > NoReason = 0,
3843 > FilteredContentRetry = 1,
3844 > CopyrightContentRetry = 2,
3845 > }
3846 >
3847 > export class ChatRequestEditorData implements vscode.ChatRequestEditorData {
3848 > constructor(
3849 readonly editor: vscode.TextEditor,
3850 readonly document: vscode.TextDocument,
3852 readonly wholeRange: vscode.Range,
3853 ) { }
3854 > } extHostTypes.ts
3855 >
3856 > export class ChatRequestNotebookData implements vscode.ChatRequestNotebookData {
3857 > constructor(
3858 readonly cell: vscode.TextDocument
3859 ) { }
3860 > } extHostTypes.ts
3861 >
3862 > export class ChatReferenceBinaryData implements vscode.ChatReferenceBinaryData {
3863 > mimeType: string;
3864 > data: () => Thenable<Uint8Array>;
3865 > reference?: vscode.Uri;
3866 > isPasted?: boolean;
3867 > isURL?: boolean;
3868 > constructor(mimeType: string, data: () => Thenable<Uint8Array>, reference?: vscode.Uri, isPasted?: boolean, isURL?: boolean) {
3869 this.mimeType = mimeType;
3870 this.data = data;
3873 this.isURL = isURL;
3874 }
3875 > } extHostTypes.ts
3876 >
3877 > export class ChatReferenceDiagnostic implements vscode.ChatReferenceDiagnostic {
3878 > constructor(public readonly diagnostics: [vscode.Uri, vscode.Diagnostic[]][]) { }
3879 > }
3880 >
3881 > export enum LanguageModelChatMessageRole {
3882 > User = 1,
3883 > Assistant = 2,
3884 > System = 3
3885 > }
3886 >
3887 > export class LanguageModelToolResultPart implements vscode.LanguageModelToolResultPart {
3888 >
3889 > callId: string;
3890 > content: (LanguageModelTextPart | LanguageModelPromptTsxPart | unknown)[];
3891 > isError: boolean;
3892 >
3893 > constructor(callId: string, content: (LanguageModelTextPart | LanguageModelPromptTsxPart | unknown)[], isError?: boolean) {
3894 this.callId = callId;
3895 this.content = content;
3896 this.isError = isError ?? false;
3897 }
3898 > } extHostTypes.ts
3899 >
3900 >
3901 > export enum ChatErrorLevel {
3902 > Info = 0,
3903 > Warning = 1,
3904 > Error = 2
3905 > }
3906 >
3907 > export enum ChatInputNotificationSeverity {
3908 > Info = 0,
3909 > Warning = 1,
3910 > Error = 2,
3911 > }
3912 >
3913 > export class LanguageModelChatMessage implements vscode.LanguageModelChatMessage {
3914 >
3915 > static User(content: string | (LanguageModelTextPart | LanguageModelToolResultPart | LanguageModelToolCallPart | LanguageModelDataPart)[], name?: string): LanguageModelChatMessage {
3916 > return new LanguageModelChatMessage(LanguageModelChatMessageRole.User, content, name);
3917 > }
3918 >
3919 > static Assistant(content: string | (LanguageModelTextPart | LanguageModelToolResultPart | LanguageModelToolCallPart | LanguageModelDataPart)[], name?: string): LanguageModelChatMessage {
3920 return new LanguageModelChatMessage(LanguageModelChatMessageRole.Assistant, content, name);
3921 }
3923 > role: vscode.LanguageModelChatMessageRole;
3924 >
3925 > private _content: (LanguageModelTextPart | LanguageModelToolResultPart | LanguageModelToolCallPart | LanguageModelDataPart)[] = [];
3926 >
3927 > set content(value: string | (LanguageModelTextPart | LanguageModelToolResultPart | LanguageModelToolCallPart | LanguageModelDataPart)[]) {
3928 if (typeof value === 'string') {
3929 // we changed this and still support setting content with a string property. this keep the API runtime stable
3934 }
3935 }
3937 > get content(): (LanguageModelTextPart | LanguageModelToolResultPart | LanguageModelToolCallPart | LanguageModelDataPart)[] {
3938 return this._content;
3939 }
3941 > name: string | undefined;
3942 >
3943 > constructor(role: vscode.LanguageModelChatMessageRole, content: string | (LanguageModelTextPart | LanguageModelToolResultPart | LanguageModelToolCallPart | LanguageModelDataPart)[], name?: string) {
3944 this.role = role;
3945 this.content = content;
3946 this.name = name;
3947 }
3948 > } extHostTypes.ts
3949 >
3950 > export class LanguageModelChatMessage2 implements vscode.LanguageModelChatMessage2 {
3951 >
3952 > static User(content: string | (LanguageModelTextPart | LanguageModelToolResultPart | LanguageModelToolCallPart | LanguageModelDataPart)[], name?: string): LanguageModelChatMessage2 {
3953 > return new LanguageModelChatMessage2(LanguageModelChatMessageRole.User, content, name);
3954 > }
3955 >
3956 > static Assistant(content: string | (LanguageModelTextPart | LanguageModelToolResultPart | LanguageModelToolCallPart | LanguageModelDataPart)[], name?: string): LanguageModelChatMessage2 {
3957 return new LanguageModelChatMessage2(LanguageModelChatMessageRole.Assistant, content, name);
3958 }
3960 > role: vscode.LanguageModelChatMessageRole;
3961 >
3962 > private _content: (LanguageModelTextPart | LanguageModelToolResultPart | LanguageModelToolCallPart | LanguageModelDataPart | LanguageModelThinkingPart)[] = [];
3963 >
3964 > set content(value: string | (LanguageModelTextPart | LanguageModelToolResultPart | LanguageModelToolCallPart | LanguageModelDataPart | LanguageModelThinkingPart)[]) {
3965 if (typeof value === 'string') {
3966 // we changed this and still support setting content with a string property. this keep the API runtime stable
3971 }
3972 }
3974 > get content(): (LanguageModelTextPart | LanguageModelToolResultPart | LanguageModelToolCallPart | LanguageModelDataPart | LanguageModelThinkingPart)[] {
3975 return this._content;
3976 }
3978 > // Temp to avoid breaking changes
3979 > set content2(value: (string | LanguageModelToolResultPart | LanguageModelToolCallPart | LanguageModelDataPart)[] | undefined) {
3980 if (value) {
3981 this.content = value.map(part => {
3987 }
3988 }
3990 > get content2(): (string | LanguageModelToolResultPart | LanguageModelToolCallPart | LanguageModelDataPart | LanguageModelThinkingPart)[] | undefined {
3991 return this.content.map(part => {
3992 if (part instanceof LanguageModelTextPart) {
3996 });
3997 }
3999 > name: string | undefined;
4000 >
4001 > constructor(role: vscode.LanguageModelChatMessageRole, content: string | (LanguageModelTextPart | LanguageModelToolResultPart | LanguageModelToolCallPart | LanguageModelDataPart | LanguageModelThinkingPart)[], name?: string) {
4002 this.role = role;
4003 this.content = content;
4004 this.name = name;
4005 }
4006 > } extHostTypes.ts
4007 >
4008 >
4009 > export class LanguageModelToolCallPart implements vscode.LanguageModelToolCallPart {
4010 > callId: string;
4011 > name: string;
4012 > input: any;
4013 >
4014 > constructor(callId: string, name: string, input: any) {
4015 this.callId = callId;
4016 this.name = name;
4018 this.input = input;
4019 }
4020 > } extHostTypes.ts
4021 >
4022 > export enum LanguageModelPartAudience {
4023 > Assistant = 0,
4024 > User = 1,
4025 > Extension = 2,
4026 > }
4027 >
4028 > export class LanguageModelTextPart implements vscode.LanguageModelTextPart2 {
4029 > value: string;
4030 > audience: vscode.LanguageModelPartAudience[] | undefined;
4031 >
4032 > constructor(value: string, audience?: vscode.LanguageModelPartAudience[]) {
4033 this.value = value;
4034 audience = audience;
4035 }
4037 > toJSON() {
4038 return {
4039 $mid: MarshalledId.LanguageModelTextPart,
4042 };
4043 }
4044 > } extHostTypes.ts
4045 >
4046 > export class LanguageModelDataPart implements vscode.LanguageModelDataPart2 {
4047 > mimeType: string;
4048 > data: Uint8Array<ArrayBufferLike>;
4049 > audience: vscode.LanguageModelPartAudience[] | undefined;
4050 >
4051 > constructor(data: Uint8Array<ArrayBufferLike>, mimeType: string, audience?: vscode.LanguageModelPartAudience[]) {
4052 this.mimeType = mimeType;
4053 this.data = data;
4054 this.audience = audience;
4055 }
4057 > static image(data: Uint8Array<ArrayBufferLike>, mimeType: string): vscode.LanguageModelDataPart {
4058 return new LanguageModelDataPart(data, mimeType);
4059 }
4061 > static json(value: object, mime: string = 'text/x-json'): vscode.LanguageModelDataPart {
4062 const rawStr = JSON.stringify(value, undefined, '\t');
4063 return new LanguageModelDataPart(VSBuffer.fromString(rawStr).buffer, mime);
4064 }
4066 > static text(value: string, mime: string = Mimes.text): vscode.LanguageModelDataPart {
4067 return new LanguageModelDataPart(VSBuffer.fromString(value).buffer, mime);
4068 }
4070 > toJSON() {
4071 return {
4072 $mid: MarshalledId.LanguageModelDataPart,
4076 };
4077 }
4078 > } extHostTypes.ts
4079 >
4080 > export enum ChatImageMimeType {
4081 > PNG = 'image/png',
4082 > JPEG = 'image/jpeg',
4083 > GIF = 'image/gif',
4084 > WEBP = 'image/webp',
4085 > BMP = 'image/bmp',
4086 > }
4087 >
4088 > export class LanguageModelThinkingPart implements vscode.LanguageModelThinkingPart {
4089 > value: string | string[];
4090 > id?: string;
4091 > metadata?: { readonly [key: string]: any };
4092 >
4093 > constructor(value: string | string[], id?: string, metadata?: { readonly [key: string]: any }) {
4094 this.value = value;
4095 this.id = id;
4096 this.metadata = metadata;
4097 }
4099 > toJSON() {
4100 return {
4101 $mid: MarshalledId.LanguageModelThinkingPart,
4105 };
4106 }
4107 > } extHostTypes.ts
4108 >
4109 >
4110 >
4111 > export class LanguageModelPromptTsxPart {
4112 > value: unknown;
4113 >
4114 > constructor(value: unknown) {
4115 this.value = value;
4116 }
4118 > toJSON() {
4119 return {
4120 $mid: MarshalledId.LanguageModelPromptTsxPart,
4122 };
4123 }
4124 > } extHostTypes.ts
4125 >
4126 > /**
4127 > * @deprecated
4128 > */
4129 > export class LanguageModelChatSystemMessage {
4130 > content: string;
4131 > constructor(content: string) {
4132 this.content = content;
4133 }
4134 > } extHostTypes.ts
4135 >
4136 >
4137 > /**
4138 > * @deprecated
4139 > */
4140 > export class LanguageModelChatUserMessage {
4141 > content: string;
4142 > name: string | undefined;
4143 >
4144 > constructor(content: string, name?: string) {
4145 this.content = content;
4146 this.name = name;
4147 }
4148 > } extHostTypes.ts
4149 >
4150 > /**
4151 > * @deprecated
4152 > */
4153 > export class LanguageModelChatAssistantMessage {
4154 > content: string;
4155 > name?: string;
4156 >
4157 > constructor(content: string, name?: string) {
4158 this.content = content;
4159 this.name = name;
4160 }
4161 > } extHostTypes.ts
4162 >
4163 > export class LanguageModelError extends Error {
4164 >
4165 > static readonly #name = 'LanguageModelError';
4166 >
4167 > static NotFound(message?: string): LanguageModelError {
4168 return new LanguageModelError(message, LanguageModelError.NotFound.name);
4169 }
4171 > static NoPermissions(message?: string): LanguageModelError {
4172 return new LanguageModelError(message, LanguageModelError.NoPermissions.name);
4173 }
4175 > static Blocked(message?: string): LanguageModelError {
4176 return new LanguageModelError(message, LanguageModelError.Blocked.name);
4177 }
4179 > static tryDeserialize(data: SerializedError): LanguageModelError | undefined {
4180 if (data.name !== LanguageModelError.#name) {
4181 return undefined;
4183 return new LanguageModelError(data.message, data.code, data.cause);
4184 }
4186 > readonly code: string;
4187 >
4188 > constructor(message?: string, code?: string, cause?: Error) {
4189 super(message, { cause });
4190 this.name = LanguageModelError.#name;
4191 this.code = code ?? '';
4192 }
4194 > }
4195 >
4196 > export class LanguageModelToolResult {
4197 > constructor(public content: (LanguageModelTextPart | LanguageModelPromptTsxPart | LanguageModelDataPart)[]) { }
4198 >
4199 > toJSON() {
4200 return {
4201 $mid: MarshalledId.LanguageModelToolResult,
4203 };
4204 }
4205 > } extHostTypes.ts
4206 >
4207 > export class LanguageModelToolResult2 {
4208 > constructor(public content: (LanguageModelTextPart | LanguageModelPromptTsxPart | LanguageModelDataPart)[]) { }
4209 >
4210 > toJSON() {
4211 return {
4212 $mid: MarshalledId.LanguageModelToolResult,
4214 };
4215 }
4216 > } extHostTypes.ts
4217 >
4218 > export class ExtendedLanguageModelToolResult extends LanguageModelToolResult {
4219 > toolResultMessage?: string | MarkdownString;
4220 > toolResultDetails?: Array<URI | Location>;
4221 > toolMetadata?: unknown;
4222 > hasError?: boolean;
4223 > }
4224 >
4225 > export enum LanguageModelChatToolMode {
4226 > Auto = 1,
4227 > Required = 2
4228 > }
4229 >
4230 > export class LanguageModelToolExtensionSource implements vscode.LanguageModelToolExtensionSource {
4231 > constructor(public readonly id: string, public readonly label: string) { }
4232 > }
4233 >
4234 > export class LanguageModelToolMCPSource implements vscode.LanguageModelToolMCPSource {
4235 > constructor(public readonly label: string, public readonly name: string, public readonly instructions: string | undefined) { }
4236 > }
4237 >
4238 > //#endregion
4239 >
4240 > //#region ai
4241 >
4242 > export enum RelatedInformationType {
4243 > SymbolInformation = 1,
4244 > CommandInformation = 2,
4245 > SearchInformation = 3,
4246 > SettingInformation = 4
4247 > }
4248 >
4249 > export enum SettingsSearchResultKind {
4250 > EMBEDDED = 1,
4251 > LLM_RANKED = 2,
4252 > CANCELED = 3,
4253 > }
4254 >
4255 > //#endregion
4256 >
4257 > //#region Speech
4258 >
4259 > export enum SpeechToTextStatus {
4260 > Started = 1,
4261 > Recognizing = 2,
4262 > Recognized = 3,
4263 > Stopped = 4,
4264 > Error = 5
4265 > }
4266 >
4267 > export enum TextToSpeechStatus {
4268 > Started = 1,
4269 > Stopped = 2,
4270 > Error = 3
4271 > }
4272 >
4273 > export enum KeywordRecognitionStatus {
4274 > Recognized = 1,
4275 > Stopped = 2
4276 > }
4277 >
4278 > //#endregion
4279 >
4280 > //#region MCP
4281 > export enum McpToolAvailability {
4282 > Initial = 0,
4283 > Dynamic = 1,
4284 > }
4285 >
4286 > export class McpStdioServerDefinition implements vscode.McpStdioServerDefinition {
4287 > cwd?: URI;
4288 >
4289 > constructor(
4290 public label: string,
4291 public command: string,
4295 public metadata?: vscode.McpServerMetadata,
4296 ) { }
4297 > } extHostTypes.ts
4298 >
4299 > export class McpHttpServerDefinition implements vscode.McpHttpServerDefinition {
4300 > constructor(
4301 public label: string,
4302 public uri: URI,
4306 public authentication?: { providerId: string; scopes: string[] },
4307 ) { }
4308 > } extHostTypes.ts
4309 > //#endregion
4310 >
4311 > //#region Chat Prompt Files
4312 > //#endregion
src/vs/workbench/api/common/extHostTypeConverters.ts 1080 introduced LOC · 268 ranges

Open complete file

1 > /*--------------------------------------------------------------------------------------------- extHostTypeConverters.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 type * as vscode from 'vscode';
7 > import { asArray, coalesce, isNonEmptyArray } from '../../../base/common/arrays.js';
8 > import { VSBuffer, decodeBase64, encodeBase64 } from '../../../base/common/buffer.js';
9 > import { IStringDictionary } from '../../../base/common/collections.js';
10 > import { IDataTransferFile, IDataTransferItem, UriList } from '../../../base/common/dataTransfer.js';
11 > import { createSingleCallFunction } from '../../../base/common/functional.js';
12 > import * as htmlContent from '../../../base/common/htmlContent.js';
13 > import { DisposableStore } from '../../../base/common/lifecycle.js';
14 > import { ResourceMap, ResourceSet } from '../../../base/common/map.js';
15 > import * as marked from '../../../base/common/marked/marked.js';
16 > import { parse, revive } from '../../../base/common/marshalling.js';
17 > import { MarshalledId } from '../../../base/common/marshallingIds.js';
18 > import { Mimes } from '../../../base/common/mime.js';
19 > import { cloneAndChange } from '../../../base/common/objects.js';
20 > import { OS } from '../../../base/common/platform.js';
21 > import { IPrefixTreeNode, WellDefinedPrefixTree } from '../../../base/common/prefixTree.js';
22 > import { basename } from '../../../base/common/resources.js';
23 > import { ThemeIcon } from '../../../base/common/themables.js';
24 > import { isDefined, isEmptyObject, isNumber, isString, isUndefinedOrNull } from '../../../base/common/types.js';
25 > import { URI, UriComponents, isUriComponents } from '../../../base/common/uri.js';
26 > import { IURITransformer } from '../../../base/common/uriIpc.js';
27 > import { generateUuid } from '../../../base/common/uuid.js';
28 > import { RenderLineNumbersType } from '../../../editor/common/config/editorOptions.js';
29 > import { IPosition } from '../../../editor/common/core/position.js';
30 > import * as editorRange from '../../../editor/common/core/range.js';
31 > import { ISelection } from '../../../editor/common/core/selection.js';
32 > import { IContentDecorationRenderOptions, IDecorationOptions, IDecorationRenderOptions, IThemeDecorationRenderOptions } from '../../../editor/common/editorCommon.js';
33 > import * as encodedTokenAttributes from '../../../editor/common/encodedTokenAttributes.js';
34 > import * as languageSelector from '../../../editor/common/languageSelector.js';
35 > import * as languages from '../../../editor/common/languages.js';
36 > import { EndOfLineSequence, TrackedRangeStickiness } from '../../../editor/common/model.js';
37 > import { ITextEditorOptions } from '../../../platform/editor/common/editor.js';
38 > import { IExtensionDescription, IRelaxedExtensionDescription } from '../../../platform/extensions/common/extensions.js';
39 > import { ILogService } from '../../../platform/log/common/log.js';
40 > import { IMarkerData, IRelatedInformation, MarkerSeverity, MarkerTag } from '../../../platform/markers/common/markers.js';
41 > import { ProgressLocation as MainProgressLocation } from '../../../platform/progress/common/progress.js';
42 > import { DEFAULT_EDITOR_ASSOCIATION, SaveReason } from '../../common/editor.js';
43 > import { IViewBadge } from '../../common/views.js';
44 > import { IChatAgentRequest, IChatAgentResult } from '../../contrib/chat/common/participants/chatAgents.js';
45 > import { IChatRequestModeInstructions } from '../../contrib/chat/common/model/chatModel.js';
46 > import { IChatAgentMarkdownContentWithVulnerability, IChatAutoModeResolutionPart, IChatCodeCitation, IChatCommandButton, IChatConfirmation, IChatContentInlineReference, IChatContentReference, IChatExtensionsContent, IChatExternalToolInvocationUpdate, IChatFollowup, IChatHookPart, IChatMarkdownContent, IChatMoveMessage, IChatMultiDiffDataSerialized, IChatProgressMessage, IChatPullRequestContent, IChatQuestionCarousel, IChatResponseCodeblockUriPart, IChatTaskDto, IChatTaskResult, IChatTerminalToolInvocationData, IChatTextEdit, IChatThinkingPart, IChatToolInvocationSerialized, IChatTreeData, IChatUserActionEvent, IChatWarningMessage, IChatInfoMessage, IChatWorkspaceEdit } from '../../contrib/chat/common/chatService/chatService.js';
47 > import { LocalChatSessionUri } from '../../contrib/chat/common/model/chatUri.js';
48 > import { ChatRequestToolReferenceEntry, IChatRequestVariableEntry, isImageVariableEntry, isPromptFileVariableEntry, isPromptTextVariableEntry } from '../../contrib/chat/common/attachments/chatVariableEntries.js';
49 > import { ChatSessionStatus, IChatSessionItem } from '../../contrib/chat/common/chatSessionsService.js';
50 > import { ChatAgentLocation } from '../../contrib/chat/common/constants.js';
51 > import { ChatRequestHooks, resolveEffectiveCommand } from '../../contrib/chat/common/promptSyntax/hookSchema.js';
52 > import { type IParsedHookCommand } from '../../../platform/agentPlugins/common/pluginParsers.js';
53 > import { IToolInvocationContext, IToolResult, IToolResultInputOutputDetails, IToolResultOutputDetails, ToolDataSource, ToolInvocationPresentation } from '../../contrib/chat/common/tools/languageModelToolsService.js';
54 > import * as chatProvider from '../../contrib/chat/common/languageModels.js';
55 > import { IChatMessageDataPart, IChatResponseDataPart, IChatResponsePromptTsxPart, IChatResponseTextPart } from '../../contrib/chat/common/languageModels.js';
56 > import { DebugTreeItemCollapsibleState, IDebugVisualizationTreeItem } from '../../contrib/debug/common/debug.js';
57 > import { McpServerDefinition as McpServerDefinitionType, McpServerLaunch, McpServerTransportType } from '../../contrib/mcp/common/mcpTypes.js';
58 > import * as notebooks from '../../contrib/notebook/common/notebookCommon.js';
59 > import { CellEditType } from '../../contrib/notebook/common/notebookCommon.js';
60 > import { ICellRange } from '../../contrib/notebook/common/notebookRange.js';
61 > import { InputValidationType } from '../../contrib/scm/common/scm.js';
62 > import * as search from '../../contrib/search/common/search.js';
63 > import { TestId } from '../../contrib/testing/common/testId.js';
64 > import { CoverageDetails, DetailType, ICoverageCount, IFileCoverage, ISerializedTestResults, ITestErrorMessage, ITestItem, ITestRunProfileReference, ITestTag, TestMessageType, TestResultItem, TestRunProfileBitset, denamespaceTestTag, namespaceTestTag } from '../../contrib/testing/common/testTypes.js';
65 > import { AiSettingsSearchResult, AiSettingsSearchResultKind } from '../../services/aiSettingsSearch/common/aiSettingsSearch.js';
66 > import { EditorGroupColumn } from '../../services/editor/common/editorGroupColumn.js';
67 > import { ACTIVE_GROUP, SIDE_GROUP } from '../../services/editor/common/editorService.js';
68 > import { checkProposedApiEnabled, isProposedApiEnabled } from '../../services/extensions/common/extensions.js';
69 > import { Dto, SerializableObjectWithBuffers } from '../../services/extensions/common/proxyIdentifier.js';
70 > import * as extHostProtocol from './extHost.protocol.js';
71 > import { CommandsConverter } from './extHostCommands.js';
72 > import { getPrivateApiFor } from './extHostTestingPrivateApi.js';
73 > import * as types from './extHostTypes.js';
74 > import { LanguageModelDataPart, LanguageModelPromptTsxPart, LanguageModelTextPart } from './extHostTypes.js';
75 >
76 > export namespace Command {
77 >
78 > export interface ICommandsConverter {
79 > fromInternal(command: extHostProtocol.ICommandDto): vscode.Command | undefined;
80 > toInternal(command: vscode.Command | undefined, disposables: DisposableStore): extHostProtocol.ICommandDto | undefined;
81 > }
82 > }
83 >
84 > export interface PositionLike {
85 > line: number;
86 > character: number;
87 > }
88 >
89 > export interface RangeLike {
90 > start: PositionLike;
91 > end: PositionLike;
92 > }
93 >
94 > export interface SelectionLike extends RangeLike {
95 > anchor: PositionLike;
96 > active: PositionLike;
97 > }
98 > export namespace Selection {
99 >
100 > export function to(selection: ISelection): types.Selection {
101 const { selectionStartLineNumber, selectionStartColumn, positionLineNumber, positionColumn } = selection;
102 const start = new types.Position(selectionStartLineNumber - 1, selectionStartColumn - 1);
104 return new types.Selection(start, end);
105 }
107 > export function from(selection: SelectionLike): ISelection {
108 const { anchor, active } = selection;
109 return {
114 };
115 }
117 > export namespace Range {
118 >
119 > export function from(range: undefined): undefined;
120 > export function from(range: RangeLike): editorRange.IRange;
121 > export function from(range: RangeLike | undefined): editorRange.IRange | undefined;
122 > export function from(range: RangeLike | undefined): editorRange.IRange | undefined {
123 if (!range) {
124 return undefined;
132 };
133 }
135 > export function to(range: undefined): types.Range;
136 > export function to(range: editorRange.IRange): types.Range;
137 > export function to(range: editorRange.IRange | undefined): types.Range | undefined;
138 > export function to(range: editorRange.IRange | undefined): types.Range | undefined {
139 if (!range) {
140 return undefined;
143 return new types.Range(startLineNumber - 1, startColumn - 1, endLineNumber - 1, endColumn - 1);
144 }
146 >
147 > export namespace Location {
148 >
149 > export function from(location: vscode.Location): Dto<languages.Location> {
150 return {
151 uri: location.uri,
153 };
154 }
156 > export function to(location: Dto<languages.Location>): vscode.Location {
157 return new types.Location(URI.revive(location.uri), Range.to(location.range));
158 }
160 >
161 > export namespace TokenType {
162 > export function to(type: encodedTokenAttributes.StandardTokenType): types.StandardTokenType {
163 switch (type) {
164 case encodedTokenAttributes.StandardTokenType.Comment: return types.StandardTokenType.Comment;
168 }
169 }
171 >
172 > export namespace Position {
173 > export function to(position: IPosition): types.Position {
174 return new types.Position(position.lineNumber - 1, position.column - 1);
175 }
176 > export function from(position: types.Position | vscode.Position): IPosition { extHostTypeConverters.ts
177 return { lineNumber: position.line + 1, column: position.character + 1 };
178 }
180 >
181 > export namespace DocumentSelector {
182 >
183 > export function from(value: vscode.DocumentSelector, uriTransformer?: IURITransformer, extension?: IExtensionDescription): extHostProtocol.IDocumentFilterDto[] {
184 return coalesce(asArray(value).map(sel => _doTransformDocumentSelector(sel, uriTransformer, extension)));
185 }
187 > function _doTransformDocumentSelector(selector: string | vscode.DocumentFilter, uriTransformer: IURITransformer | undefined, extension: IExtensionDescription | undefined): extHostProtocol.IDocumentFilterDto | undefined {
188 if (typeof selector === 'string') {
189 return {
208 return undefined;
209 }
211 > function _transformScheme(scheme: string | undefined, uriTransformer: IURITransformer | undefined): string | undefined {
212 if (uriTransformer && typeof scheme === 'string') {
213 return uriTransformer.transformOutgoingScheme(scheme);
215 return scheme;
216 }
218 >
219 > export namespace TabSelector {
220 >
221 > function isViewTypeSelector(value: vscode.TabSelector): value is { viewType: string } {
222 return (value as { viewType?: string }).viewType !== undefined;
223 }
225 > export function from(value: vscode.TabSelector, uriTransformer?: IURITransformer, extension?: IExtensionDescription): extHostProtocol.ITabSelectorDto {
226 if (isViewTypeSelector(value)) {
227 return { viewType: value.viewType };
229 return { uri: DocumentSelector.from(value.uri, uriTransformer, extension) };
230 }
232 >
233 > export namespace DiagnosticTag {
234 > export function from(value: vscode.DiagnosticTag): MarkerTag | undefined {
235 switch (value) {
236 case types.DiagnosticTag.Unnecessary:
241 return undefined;
242 }
243 > export function to(value: MarkerTag): vscode.DiagnosticTag | undefined { extHostTypeConverters.ts
244 switch (value) {
245 case MarkerTag.Unnecessary:
251 }
252 }
254 >
255 > export namespace Diagnostic {
256 > export function from(value: vscode.Diagnostic): IMarkerData {
257 let code: string | { value: string; target: URI } | undefined;
258
278 };
279 }
281 > export function to(value: IMarkerData): vscode.Diagnostic {
282 const res = new types.Diagnostic(Range.to(value), value.message, DiagnosticSeverity.to(value.severity));
283 res.source = value.source;
287 return res;
288 }
290 >
291 > export namespace DiagnosticRelatedInformation {
292 > export function from(value: vscode.DiagnosticRelatedInformation): IRelatedInformation {
293 return {
294 ...Range.from(value.location.range),
297 };
298 }
299 > export function to(value: IRelatedInformation): types.DiagnosticRelatedInformation { extHostTypeConverters.ts
300 return new types.DiagnosticRelatedInformation(new types.Location(value.resource, Range.to(value)), value.message);
301 }
303 > export namespace DiagnosticSeverity {
304 >
305 > export function from(value: number): MarkerSeverity {
306 switch (value) {
307 case types.DiagnosticSeverity.Error:
316 return MarkerSeverity.Error;
317 }
319 > export function to(value: MarkerSeverity): types.DiagnosticSeverity {
320 switch (value) {
321 case MarkerSeverity.Info:
331 }
332 }
334 >
335 > export namespace ViewColumn {
336 > export function from(column?: vscode.ViewColumn): EditorGroupColumn {
337 if (typeof column === 'number' && column >= types.ViewColumn.One) {
338 return column - 1; // adjust zero index (ViewColumn.ONE => 0)
345 return ACTIVE_GROUP; // default is always the active group
346 }
348 > export function to(position: EditorGroupColumn): vscode.ViewColumn {
349 if (typeof position === 'number' && position >= 0) {
350 return position + 1; // adjust to index (ViewColumn.ONE => 1)
353 throw new Error(`invalid 'EditorGroupColumn'`);
354 }
356 >
357 function isDecorationOptions(something: any): something is vscode.DecorationOptions {
358 return (typeof something.range !== 'undefined');
359 }
361 > export function isDecorationOptionsArr(something: vscode.Range[] | vscode.DecorationOptions[]): something is vscode.DecorationOptions[] {
362 if (something.length === 0) {
363 return true;
365 return isDecorationOptions(something[0]) ? true : false;
366 }
368 > export namespace MarkdownString {
369 >
370 > export function fromMany(markup: (vscode.MarkdownString | vscode.MarkedString)[]): htmlContent.IMarkdownString[] {
371 return markup.map(MarkdownString.from);
372 }
374 > interface Codeblock {
375 > language: string;
376 > value: string;
377 > }
378 >
379 > function isCodeblock(thing: any): thing is Codeblock {
380 return thing && typeof thing === 'object'
381 && typeof (<Codeblock>thing).language === 'string'
382 && typeof (<Codeblock>thing).value === 'string';
383 }
385 > export function from(markup: vscode.MarkdownString | vscode.MarkedString): htmlContent.IMarkdownString {
386 let res: htmlContent.IMarkdownString;
387 if (isCodeblock(markup)) {
423 return res;
424 }
426 > function _uriMassage(part: string, bucket: { [n: string]: UriComponents }): string {
427 if (!part) {
428 return part;
455 return JSON.stringify(data);
456 }
458 > export function to(value: htmlContent.IMarkdownString): vscode.MarkdownString {
459 const result = new types.MarkdownString(value.value, value.supportThemeIcons);
460 result.isTrusted = value.isTrusted;
464 return result;
465 }
467 > export function fromStrict(value: string | vscode.MarkdownString | undefined | null): undefined | string | htmlContent.IMarkdownString {
468 if (!value) {
469 return undefined;
471 return typeof value === 'string' ? value : MarkdownString.from(value);
472 }
474 >
475 > export function fromRangeOrRangeWithMessage(ranges: vscode.Range[] | vscode.DecorationOptions[]): IDecorationOptions[] {
476 if (isDecorationOptionsArr(ranges)) {
477 return ranges.map((r): IDecorationOptions => {
493 }
494 }
496 > export function pathOrURIToURI(value: string | URI): URI {
497 if (typeof value === 'undefined') {
498 return value;
504 }
505 }
507 > export namespace ThemableDecorationAttachmentRenderOptions {
508 > export function from(options: vscode.ThemableDecorationAttachmentRenderOptions): IContentDecorationRenderOptions {
509 if (typeof options === 'undefined') {
510 return options;
525 };
526 }
528 >
529 > export namespace ThemableDecorationRenderOptions {
530 > export function from(options: vscode.ThemableDecorationRenderOptions): IThemeDecorationRenderOptions {
531 if (typeof options === 'undefined') {
532 return options;
558 };
559 }
561 >
562 > export namespace DecorationRangeBehavior {
563 > export function from(value: types.DecorationRangeBehavior): TrackedRangeStickiness {
564 if (typeof value === 'undefined') {
565 return value;
576 }
577 }
579 >
580 > export namespace DecorationRenderOptions {
581 > export function from(options: vscode.DecorationRenderOptions): IDecorationRenderOptions {
582 return {
583 isWholeLine: options.isWholeLine,
612 };
613 }
615 >
616 > export namespace TextEdit {
617 >
618 > export function from(edit: vscode.TextEdit): languages.TextEdit {
619 return {
620 text: edit.newText,
623 };
624 }
626 > export function to(edit: languages.TextEdit): types.TextEdit {
627 const result = new types.TextEdit(Range.to(edit.range), edit.text);
628 result.newEol = (typeof edit.eol === 'undefined' ? undefined : EndOfLine.to(edit.eol))!;
629 return result;
630 }
632 >
633 > export namespace WorkspaceEdit {
634 >
635 > export interface IVersionInformationProvider {
636 > getTextDocumentVersion(uri: URI): number | undefined;
637 > getNotebookDocumentVersion(uri: URI): number | undefined;
638 > }
639 >
640 > export function from(value: vscode.WorkspaceEdit, versionInfo?: IVersionInformationProvider): extHostProtocol.IWorkspaceEditDto {
641 const result: extHostProtocol.IWorkspaceEditDto = {
642 edits: []
722 return result;
723 }
725 > export function to(value: extHostProtocol.IWorkspaceEditDto) {
726 const result = new types.WorkspaceEdit();
727 const edits = new ResourceMap<(types.TextEdit | types.SnippetTextEdit)[]>();
763 return result;
764 }
766 >
767 >
768 > export namespace SymbolKind {
769 >
770 > const _fromMapping: { [kind: number]: languages.SymbolKind } = Object.create(null);
771 > _fromMapping[types.SymbolKind.File] = languages.SymbolKind.File;
772 > _fromMapping[types.SymbolKind.Module] = languages.SymbolKind.Module;
773 > _fromMapping[types.SymbolKind.Namespace] = languages.SymbolKind.Namespace;
774 > _fromMapping[types.SymbolKind.Package] = languages.SymbolKind.Package;
775 > _fromMapping[types.SymbolKind.Class] = languages.SymbolKind.Class;
776 > _fromMapping[types.SymbolKind.Method] = languages.SymbolKind.Method;
777 > _fromMapping[types.SymbolKind.Property] = languages.SymbolKind.Property;
778 > _fromMapping[types.SymbolKind.Field] = languages.SymbolKind.Field;
779 > _fromMapping[types.SymbolKind.Constructor] = languages.SymbolKind.Constructor;
780 > _fromMapping[types.SymbolKind.Enum] = languages.SymbolKind.Enum;
781 > _fromMapping[types.SymbolKind.Interface] = languages.SymbolKind.Interface;
782 > _fromMapping[types.SymbolKind.Function] = languages.SymbolKind.Function;
783 > _fromMapping[types.SymbolKind.Variable] = languages.SymbolKind.Variable;
784 > _fromMapping[types.SymbolKind.Constant] = languages.SymbolKind.Constant;
785 > _fromMapping[types.SymbolKind.String] = languages.SymbolKind.String;
786 > _fromMapping[types.SymbolKind.Number] = languages.SymbolKind.Number;
787 > _fromMapping[types.SymbolKind.Boolean] = languages.SymbolKind.Boolean;
788 > _fromMapping[types.SymbolKind.Array] = languages.SymbolKind.Array;
789 > _fromMapping[types.SymbolKind.Object] = languages.SymbolKind.Object;
790 > _fromMapping[types.SymbolKind.Key] = languages.SymbolKind.Key;
791 > _fromMapping[types.SymbolKind.Null] = languages.SymbolKind.Null;
792 > _fromMapping[types.SymbolKind.EnumMember] = languages.SymbolKind.EnumMember;
793 > _fromMapping[types.SymbolKind.Struct] = languages.SymbolKind.Struct;
794 > _fromMapping[types.SymbolKind.Event] = languages.SymbolKind.Event;
795 > _fromMapping[types.SymbolKind.Operator] = languages.SymbolKind.Operator;
796 > _fromMapping[types.SymbolKind.TypeParameter] = languages.SymbolKind.TypeParameter;
797 >
798 > export function from(kind: vscode.SymbolKind): languages.SymbolKind {
799 return typeof _fromMapping[kind] === 'number' ? _fromMapping[kind] : languages.SymbolKind.Property;
800 }
802 > export function to(kind: languages.SymbolKind): vscode.SymbolKind {
803 for (const k in _fromMapping) {
804 if (_fromMapping[k] === kind) {
808 return types.SymbolKind.Property;
809 }
811 >
812 > export namespace SymbolTag {
813 >
814 > export function from(kind: types.SymbolTag): languages.SymbolTag {
815 switch (kind) {
816 case types.SymbolTag.Deprecated: return languages.SymbolTag.Deprecated;
817 }
818 }
820 > export function to(kind: languages.SymbolTag): types.SymbolTag {
821 switch (kind) {
822 case languages.SymbolTag.Deprecated: return types.SymbolTag.Deprecated;
823 }
824 }
826 >
827 > export namespace WorkspaceSymbol {
828 > export function from(info: vscode.SymbolInformation): search.IWorkspaceSymbol {
829 return {
830 name: info.name,
835 };
836 }
837 > export function to(info: search.IWorkspaceSymbol): types.SymbolInformation { extHostTypeConverters.ts
838 const result = new types.SymbolInformation(
839 info.name,
845 return result;
846 }
848 >
849 > export namespace DocumentSymbol {
850 > export function from(info: vscode.DocumentSymbol): languages.DocumentSymbol {
851 const result: languages.DocumentSymbol = {
852 name: info.name || '!!MISSING: name!!',
862 return result;
863 }
864 > export function to(info: languages.DocumentSymbol): vscode.DocumentSymbol { extHostTypeConverters.ts
865 const result = new types.DocumentSymbol(
866 info.name,
879 return result;
880 }
882 >
883 > export namespace CallHierarchyItem {
884 >
885 > export function to(item: extHostProtocol.ICallHierarchyItemDto): types.CallHierarchyItem {
886 const result = new types.CallHierarchyItem(
887 SymbolKind.to(item.kind),
898 return result;
899 }
901 > export function from(item: vscode.CallHierarchyItem, sessionId?: string, itemId?: string): extHostProtocol.ICallHierarchyItemDto {
902
903 sessionId = sessionId ?? (<types.CallHierarchyItem>item)._sessionId;
920 };
921 }
923 >
924 > export namespace CallHierarchyIncomingCall {
925 >
926 > export function to(item: extHostProtocol.IIncomingCallDto): types.CallHierarchyIncomingCall {
927 return new types.CallHierarchyIncomingCall(
928 CallHierarchyItem.to(item.from),
930 );
931 }
933 >
934 > export namespace CallHierarchyOutgoingCall {
935 >
936 > export function to(item: extHostProtocol.IOutgoingCallDto): types.CallHierarchyOutgoingCall {
937 return new types.CallHierarchyOutgoingCall(
938 CallHierarchyItem.to(item.to),
940 );
941 }
943 >
944 >
945 > export namespace location {
946 > export function from(value: vscode.Location): languages.Location {
947 return {
948 range: value.range && Range.from(value.range),
950 };
951 }
953 > export function to(value: extHostProtocol.ILocationDto): types.Location {
954 return new types.Location(URI.revive(value.uri), Range.to(value.range));
955 }
957 >
958 > export namespace DefinitionLink {
959 > export function from(value: vscode.Location | vscode.DefinitionLink): languages.LocationLink {
960 const definitionLink = <vscode.DefinitionLink>value;
961 const location = <vscode.Location>value;
971 };
972 }
973 > export function to(value: extHostProtocol.ILocationLinkDto): vscode.LocationLink { extHostTypeConverters.ts
974 return {
975 targetUri: URI.revive(value.uri),
983 };
984 }
986 >
987 > export namespace Hover {
988 > export function from(hover: vscode.VerboseHover): languages.Hover {
989 const convertedHover: languages.Hover = {
990 range: Range.from(hover.range),
995 return convertedHover;
996 }
998 > export function to(info: languages.Hover): types.VerboseHover {
999 const contents = info.contents.map(MarkdownString.to);
1000 const range = Range.to(info.range);
1003 return new types.VerboseHover(contents, range, canIncreaseVerbosity, canDecreaseVerbosity);
1004 }
1006 >
1007 > export namespace EvaluatableExpression {
1008 > export function from(expression: vscode.EvaluatableExpression): languages.EvaluatableExpression {
1009 return {
1010 range: Range.from(expression.range),
1012 };
1013 }
1015 > export function to(info: languages.EvaluatableExpression): types.EvaluatableExpression {
1016 return new types.EvaluatableExpression(Range.to(info.range), info.expression);
1017 }
1019 >
1020 > export namespace InlineValue {
1021 > export function from(inlineValue: vscode.InlineValue): languages.InlineValue {
1022 if (inlineValue instanceof types.InlineValueText) {
1023 return {
1043 }
1044 }
1046 > export function to(inlineValue: languages.InlineValue): vscode.InlineValue {
1047 switch (inlineValue.type) {
1048 case 'text':
1064 }
1065 }
1067 >
1068 > export namespace InlineValueContext {
1069 > export function from(inlineValueContext: vscode.InlineValueContext): extHostProtocol.IInlineValueContextDto {
1070 return {
1071 frameId: inlineValueContext.frameId,
1073 };
1074 }
1076 > export function to(inlineValueContext: extHostProtocol.IInlineValueContextDto): types.InlineValueContext {
1077 return new types.InlineValueContext(inlineValueContext.frameId, Range.to(inlineValueContext.stoppedLocation));
1078 }
1080 >
1081 > export namespace DocumentHighlight {
1082 > export function from(documentHighlight: vscode.DocumentHighlight): languages.DocumentHighlight {
1083 return {
1084 range: Range.from(documentHighlight.range),
1086 };
1087 }
1088 > export function to(occurrence: languages.DocumentHighlight): types.DocumentHighlight { extHostTypeConverters.ts
1089 return new types.DocumentHighlight(Range.to(occurrence.range), occurrence.kind);
1090 }
1092 >
1093 > export namespace MultiDocumentHighlight {
1094 > export function from(multiDocumentHighlight: vscode.MultiDocumentHighlight): languages.MultiDocumentHighlight {
1095 return {
1096 uri: multiDocumentHighlight.uri,
1098 };
1099 }
1101 > export function to(multiDocumentHighlight: languages.MultiDocumentHighlight): types.MultiDocumentHighlight {
1102 return new types.MultiDocumentHighlight(URI.revive(multiDocumentHighlight.uri), multiDocumentHighlight.highlights.map(DocumentHighlight.to));
1103 }
1105 >
1106 > export namespace CompletionTriggerKind {
1107 > export function to(kind: languages.CompletionTriggerKind) {
1108 switch (kind) {
1109 case languages.CompletionTriggerKind.TriggerCharacter:
1116 }
1117 }
1119 >
1120 > export namespace CompletionContext {
1121 > export function to(context: languages.CompletionContext): types.CompletionContext {
1122 return {
1123 triggerKind: CompletionTriggerKind.to(context.triggerKind),
1125 };
1126 }
1128 >
1129 > export namespace CompletionItemTag {
1130 >
1131 > export function from(kind: types.CompletionItemTag): languages.CompletionItemTag {
1132 switch (kind) {
1133 case types.CompletionItemTag.Deprecated: return languages.CompletionItemTag.Deprecated;
1134 }
1135 }
1137 > export function to(kind: languages.CompletionItemTag): types.CompletionItemTag {
1138 switch (kind) {
1139 case languages.CompletionItemTag.Deprecated: return types.CompletionItemTag.Deprecated;
1140 }
1141 }
1143 >
1144 > export namespace CompletionCommand {
1145 > export function from(c: vscode.Command | { command: vscode.Command; icon: vscode.ThemeIcon }, converter: CommandsConverter, disposables: DisposableStore): { command: extHostProtocol.ICommandDto; icon?: languages.IconPath } {
1146 if ('icon' in c && 'command' in c) {
1147 return {
1152 return { command: converter.toInternal(c, disposables) };
1153 }
1155 >
1156 > export namespace CompletionItemKind {
1157 >
1158 > const _from = new Map<types.CompletionItemKind, languages.CompletionItemKind>([
1159 > [types.CompletionItemKind.Method, languages.CompletionItemKind.Method],
1160 > [types.CompletionItemKind.Function, languages.CompletionItemKind.Function],
1161 > [types.CompletionItemKind.Constructor, languages.CompletionItemKind.Constructor],
1162 > [types.CompletionItemKind.Field, languages.CompletionItemKind.Field],
1163 > [types.CompletionItemKind.Variable, languages.CompletionItemKind.Variable],
1164 > [types.CompletionItemKind.Class, languages.CompletionItemKind.Class],
1165 > [types.CompletionItemKind.Interface, languages.CompletionItemKind.Interface],
1166 > [types.CompletionItemKind.Struct, languages.CompletionItemKind.Struct],
1167 > [types.CompletionItemKind.Module, languages.CompletionItemKind.Module],
1168 > [types.CompletionItemKind.Property, languages.CompletionItemKind.Property],
1169 > [types.CompletionItemKind.Unit, languages.CompletionItemKind.Unit],
1170 > [types.CompletionItemKind.Value, languages.CompletionItemKind.Value],
1171 > [types.CompletionItemKind.Constant, languages.CompletionItemKind.Constant],
1172 > [types.CompletionItemKind.Enum, languages.CompletionItemKind.Enum],
1173 > [types.CompletionItemKind.EnumMember, languages.CompletionItemKind.EnumMember],
1174 > [types.CompletionItemKind.Keyword, languages.CompletionItemKind.Keyword],
1175 > [types.CompletionItemKind.Snippet, languages.CompletionItemKind.Snippet],
1176 > [types.CompletionItemKind.Text, languages.CompletionItemKind.Text],
1177 > [types.CompletionItemKind.Color, languages.CompletionItemKind.Color],
1178 > [types.CompletionItemKind.File, languages.CompletionItemKind.File],
1179 > [types.CompletionItemKind.Reference, languages.CompletionItemKind.Reference],
1180 > [types.CompletionItemKind.Folder, languages.CompletionItemKind.Folder],
1181 > [types.CompletionItemKind.Event, languages.CompletionItemKind.Event],
1182 > [types.CompletionItemKind.Operator, languages.CompletionItemKind.Operator],
1183 > [types.CompletionItemKind.TypeParameter, languages.CompletionItemKind.TypeParameter],
1184 > [types.CompletionItemKind.Issue, languages.CompletionItemKind.Issue],
1185 > [types.CompletionItemKind.User, languages.CompletionItemKind.User],
1186 > ]);
1187 >
1188 > export function from(kind: types.CompletionItemKind): languages.CompletionItemKind {
1189 return _from.get(kind) ?? languages.CompletionItemKind.Property;
1190 }
1192 > const _to = new Map<languages.CompletionItemKind, types.CompletionItemKind>([
1193 > [languages.CompletionItemKind.Method, types.CompletionItemKind.Method],
1194 > [languages.CompletionItemKind.Function, types.CompletionItemKind.Function],
1195 > [languages.CompletionItemKind.Constructor, types.CompletionItemKind.Constructor],
1196 > [languages.CompletionItemKind.Field, types.CompletionItemKind.Field],
1197 > [languages.CompletionItemKind.Variable, types.CompletionItemKind.Variable],
1198 > [languages.CompletionItemKind.Class, types.CompletionItemKind.Class],
1199 > [languages.CompletionItemKind.Interface, types.CompletionItemKind.Interface],
1200 > [languages.CompletionItemKind.Struct, types.CompletionItemKind.Struct],
1201 > [languages.CompletionItemKind.Module, types.CompletionItemKind.Module],
1202 > [languages.CompletionItemKind.Property, types.CompletionItemKind.Property],
1203 > [languages.CompletionItemKind.Unit, types.CompletionItemKind.Unit],
1204 > [languages.CompletionItemKind.Value, types.CompletionItemKind.Value],
1205 > [languages.CompletionItemKind.Constant, types.CompletionItemKind.Constant],
1206 > [languages.CompletionItemKind.Enum, types.CompletionItemKind.Enum],
1207 > [languages.CompletionItemKind.EnumMember, types.CompletionItemKind.EnumMember],
1208 > [languages.CompletionItemKind.Keyword, types.CompletionItemKind.Keyword],
1209 > [languages.CompletionItemKind.Snippet, types.CompletionItemKind.Snippet],
1210 > [languages.CompletionItemKind.Text, types.CompletionItemKind.Text],
1211 > [languages.CompletionItemKind.Color, types.CompletionItemKind.Color],
1212 > [languages.CompletionItemKind.File, types.CompletionItemKind.File],
1213 > [languages.CompletionItemKind.Reference, types.CompletionItemKind.Reference],
1214 > [languages.CompletionItemKind.Folder, types.CompletionItemKind.Folder],
1215 > [languages.CompletionItemKind.Event, types.CompletionItemKind.Event],
1216 > [languages.CompletionItemKind.Operator, types.CompletionItemKind.Operator],
1217 > [languages.CompletionItemKind.TypeParameter, types.CompletionItemKind.TypeParameter],
1218 > [languages.CompletionItemKind.User, types.CompletionItemKind.User],
1219 > [languages.CompletionItemKind.Issue, types.CompletionItemKind.Issue],
1220 > ]);
1221 >
1222 > export function to(kind: languages.CompletionItemKind): types.CompletionItemKind {
1223 return _to.get(kind) ?? types.CompletionItemKind.Property;
1224 }
1226 >
1227 > export namespace CompletionItem {
1228 >
1229 > export function to(suggestion: languages.CompletionItem, converter?: Command.ICommandsConverter): types.CompletionItem {
1230
1231 const result = new types.CompletionItem(suggestion.label);
1262 return result;
1263 }
1265 >
1266 > export namespace ParameterInformation {
1267 > export function from(info: types.ParameterInformation): languages.ParameterInformation {
1268 if (typeof info.label !== 'string' && !Array.isArray(info.label)) {
1269 throw new TypeError('Invalid label');
1275 };
1276 }
1277 > export function to(info: languages.ParameterInformation): types.ParameterInformation { extHostTypeConverters.ts
1278 return {
1279 label: info.label,
1281 };
1282 }
1284 >
1285 > export namespace SignatureInformation {
1286 >
1287 > export function from(info: types.SignatureInformation): languages.SignatureInformation {
1288 return {
1289 label: info.label,
1293 };
1294 }
1296 > export function to(info: languages.SignatureInformation): types.SignatureInformation {
1297 return {
1298 label: info.label,
1302 };
1303 }
1305 >
1306 > export namespace SignatureHelp {
1307 >
1308 > export function from(help: types.SignatureHelp): languages.SignatureHelp {
1309 return {
1310 activeSignature: help.activeSignature,
1313 };
1314 }
1316 > export function to(help: languages.SignatureHelp): types.SignatureHelp {
1317 return {
1318 activeSignature: help.activeSignature,
1321 };
1322 }
1324 >
1325 > export namespace InlayHint {
1326 >
1327 > export function to(converter: Command.ICommandsConverter, hint: languages.InlayHint): vscode.InlayHint {
1328 const res = new types.InlayHint(
1329 Position.to(hint.position),
1337 return res;
1338 }
1340 >
1341 > export namespace InlayHintLabelPart {
1342 >
1343 > export function to(converter: Command.ICommandsConverter, part: languages.InlayHintLabelPart): types.InlayHintLabelPart {
1344 const result = new types.InlayHintLabelPart(part.label);
1345 result.tooltip = htmlContent.isMarkdownString(part.tooltip)
1354 return result;
1355 }
1357 >
1358 > export namespace InlayHintKind {
1359 > export function from(kind: vscode.InlayHintKind): languages.InlayHintKind {
1360 return kind;
1361 }
1362 > export function to(kind: languages.InlayHintKind): vscode.InlayHintKind { extHostTypeConverters.ts
1363 return kind;
1364 }
1366 >
1367 > export namespace DocumentLink {
1368 >
1369 > export function from(link: vscode.DocumentLink): languages.ILink {
1370 return {
1371 range: Range.from(link.range),
1374 };
1375 }
1377 > export function to(link: languages.ILink): vscode.DocumentLink {
1378 let target: URI | undefined = undefined;
1379 if (link.url) {
1388 return result;
1389 }
1391 >
1392 > export namespace ColorPresentation {
1393 > export function to(colorPresentation: languages.IColorPresentation): types.ColorPresentation {
1394 const cp = new types.ColorPresentation(colorPresentation.label);
1395 if (colorPresentation.textEdit) {
1401 return cp;
1402 }
1404 > export function from(colorPresentation: vscode.ColorPresentation): languages.IColorPresentation {
1405 return {
1406 label: colorPresentation.label,
1409 };
1410 }
1412 >
1413 > export namespace Color {
1414 > export function to(c: [number, number, number, number]): types.Color {
1415 return new types.Color(c[0], c[1], c[2], c[3]);
1416 }
1417 > export function from(color: types.Color): [number, number, number, number] { extHostTypeConverters.ts
1418 return [color.red, color.green, color.blue, color.alpha];
1419 }
1421 >
1422 >
1423 > export namespace SelectionRange {
1424 > export function from(obj: vscode.SelectionRange): languages.SelectionRange {
1425 return { range: Range.from(obj.range) };
1426 }
1428 > export function to(obj: languages.SelectionRange): vscode.SelectionRange {
1429 return new types.SelectionRange(Range.to(obj.range));
1430 }
1432 >
1433 > export namespace TextDocumentSaveReason {
1434 >
1435 > export function to(reason: SaveReason): vscode.TextDocumentSaveReason {
1436 switch (reason) {
1437 case SaveReason.AUTO:
1444 }
1445 }
1447 >
1448 > export namespace TextEditorLineNumbersStyle {
1449 > export function from(style: vscode.TextEditorLineNumbersStyle): RenderLineNumbersType {
1450 switch (style) {
1451 case types.TextEditorLineNumbersStyle.Off:
1460 }
1461 }
1462 > export function to(style: RenderLineNumbersType): vscode.TextEditorLineNumbersStyle { extHostTypeConverters.ts
1463 switch (style) {
1464 case RenderLineNumbersType.Off:
1473 }
1474 }
1476 >
1477 > export namespace EndOfLine {
1478 >
1479 > export function from(eol: vscode.EndOfLine): EndOfLineSequence | undefined {
1480 if (eol === types.EndOfLine.CRLF) {
1481 return EndOfLineSequence.CRLF;
1485 return undefined;
1486 }
1488 > export function to(eol: EndOfLineSequence): vscode.EndOfLine | undefined {
1489 if (eol === EndOfLineSequence.CRLF) {
1490 return types.EndOfLine.CRLF;
1494 return undefined;
1495 }
1497 >
1498 > export namespace ProgressLocation {
1499 > export function from(loc: vscode.ProgressLocation | { viewId: string }): MainProgressLocation | string {
1500 if (typeof loc === 'object') {
1501 return loc.viewId;
1509 throw new Error(`Unknown 'ProgressLocation'`);
1510 }
1512 >
1513 > export namespace FoldingRange {
1514 > export function from(r: vscode.FoldingRange): languages.FoldingRange {
1515 const range: languages.FoldingRange = { start: r.start + 1, end: r.end + 1 };
1516 if (r.kind) {
1519 return range;
1520 }
1521 > export function to(r: languages.FoldingRange): vscode.FoldingRange { extHostTypeConverters.ts
1522 const range: vscode.FoldingRange = { start: r.start - 1, end: r.end - 1 };
1523 if (r.kind) {
1526 return range;
1527 }
1529 >
1530 > export namespace FoldingRangeKind {
1531 > export function from(kind: vscode.FoldingRangeKind | undefined): languages.FoldingRangeKind | undefined {
1532 if (kind) {
1533 switch (kind) {
1542 return undefined;
1543 }
1544 > export function to(kind: languages.FoldingRangeKind | undefined): vscode.FoldingRangeKind | undefined { extHostTypeConverters.ts
1545 if (kind) {
1546 switch (kind.value) {
1555 return undefined;
1556 }
1558 >
1559 > export interface TextEditorOpenOptions extends vscode.TextDocumentShowOptions {
1560 > background?: boolean;
1561 > override?: boolean;
1562 > }
1563 >
1564 > export namespace TextEditorOpenOptions {
1565 >
1566 > export function from(options?: TextEditorOpenOptions): ITextEditorOptions | undefined {
1567 if (options) {
1568 return {
1577 return undefined;
1578 }
1580 > }
1581 >
1582 > export namespace GlobPattern {
1583 >
1584 > export function from(pattern: vscode.GlobPattern): string | extHostProtocol.IRelativePatternDto;
1585 > export function from(pattern: undefined): undefined;
1586 > export function from(pattern: null): null;
1587 > export function from(pattern: vscode.GlobPattern | undefined | null): string | extHostProtocol.IRelativePatternDto | undefined | null;
1588 > export function from(pattern: vscode.GlobPattern | undefined | null): string | extHostProtocol.IRelativePatternDto | undefined | null {
1589 if (pattern instanceof types.RelativePattern) {
1590 return pattern.toJSON();
1606 return pattern; // preserve `undefined` and `null`
1607 }
1609 > function isRelativePatternShape(obj: unknown): obj is { base: string; baseUri: URI; pattern: string } {
1610 const rp = obj as { base: string; baseUri: URI; pattern: string } | undefined | null;
1611 if (!rp) {
1615 return URI.isUri(rp.baseUri) && typeof rp.pattern === 'string';
1616 }
1618 > function isLegacyRelativePatternShape(obj: unknown): obj is { base: string; pattern: string } {
1619
1620 // Before 1.64.x, `RelativePattern` did not have any `baseUri: Uri`
1629 return typeof rp.base === 'string' && typeof rp.pattern === 'string';
1630 }
1632 > export function to(pattern: string | extHostProtocol.IRelativePatternDto): vscode.GlobPattern {
1633 if (typeof pattern === 'string') {
1634 return pattern;
1637 return new types.RelativePattern(URI.revive(pattern.baseUri), pattern.pattern);
1638 }
1640 >
1641 > export namespace LanguageSelector {
1642 >
1643 > export function from(selector: undefined): undefined;
1644 > export function from(selector: vscode.DocumentSelector): languageSelector.LanguageSelector;
1645 > export function from(selector: vscode.DocumentSelector | undefined): languageSelector.LanguageSelector | undefined;
1646 > export function from(selector: vscode.DocumentSelector | undefined): languageSelector.LanguageSelector | undefined {
1647 if (!selector) {
1648 return undefined;
1662 }
1663 }
1665 >
1666 > export namespace NotebookRange {
1667 >
1668 > export function from(range: vscode.NotebookRange): ICellRange {
1669 return { start: range.start, end: range.end };
1670 }
1672 > export function to(range: ICellRange): types.NotebookRange {
1673 return new types.NotebookRange(range.start, range.end);
1674 }
1676 >
1677 > export namespace NotebookCellExecutionSummary {
1678 > export function to(data: notebooks.NotebookCellInternalMetadata): vscode.NotebookCellExecutionSummary {
1679 return {
1680 timing: typeof data.runStartTime === 'number' && typeof data.runEndTime === 'number' ? { startTime: data.runStartTime, endTime: data.runEndTime } : undefined,
1683 };
1684 }
1686 > export function from(data: vscode.NotebookCellExecutionSummary): Partial<notebooks.NotebookCellInternalMetadata> {
1687 return {
1688 lastRunSuccess: data.success,
1692 };
1693 }
1695 >
1696 > export namespace NotebookCellKind {
1697 > export function from(data: vscode.NotebookCellKind): notebooks.CellKind {
1698 switch (data) {
1699 case types.NotebookCellKind.Markup:
1704 }
1705 }
1707 > export function to(data: notebooks.CellKind): vscode.NotebookCellKind {
1708 switch (data) {
1709 case notebooks.CellKind.Markup:
1714 }
1715 }
1717 >
1718 > export namespace NotebookData {
1719 >
1720 > export function from(data: vscode.NotebookData): extHostProtocol.NotebookDataDto {
1721 const res: extHostProtocol.NotebookDataDto = {
1722 metadata: data.metadata ?? Object.create(null),
1729 return res;
1730 }
1732 > export function to(data: extHostProtocol.NotebookDataDto): vscode.NotebookData {
1733 const res = new types.NotebookData(
1734 data.cells.map(NotebookCellData.to),
1739 return res;
1740 }
1742 >
1743 > export namespace NotebookCellData {
1744 >
1745 > export function from(data: vscode.NotebookCellData): extHostProtocol.NotebookCellDataDto {
1746 return {
1747 cellKind: NotebookCellKind.from(data.kind),
1754 };
1755 }
1757 > export function to(data: extHostProtocol.NotebookCellDataDto): vscode.NotebookCellData {
1758 return new types.NotebookCellData(
1759 NotebookCellKind.to(data.cellKind),
1766 );
1767 }
1769 >
1770 > export namespace NotebookCellOutputItem {
1771 > export function from(item: types.NotebookCellOutputItem): extHostProtocol.NotebookOutputItemDto {
1772 return {
1773 mime: item.mime,
1775 };
1776 }
1778 > export function to(item: extHostProtocol.NotebookOutputItemDto): types.NotebookCellOutputItem {
1779 return new types.NotebookCellOutputItem(item.valueBytes.buffer, item.mime);
1780 }
1782 >
1783 > export namespace NotebookCellOutput {
1784 > export function from(output: vscode.NotebookCellOutput): extHostProtocol.NotebookOutputDto {
1785 return {
1786 outputId: output.id,
1789 };
1790 }
1792 > export function to(output: extHostProtocol.NotebookOutputDto): vscode.NotebookCellOutput {
1793 const items = output.items.map(NotebookCellOutputItem.to);
1794 return new types.NotebookCellOutput(items, output.outputId, output.metadata);
1795 }
1797 >
1798 >
1799 > export namespace NotebookExclusiveDocumentPattern {
1800 > export function from(pattern: { include: vscode.GlobPattern | undefined; exclude: vscode.GlobPattern | undefined }): { include: string | extHostProtocol.IRelativePatternDto | undefined; exclude: string | extHostProtocol.IRelativePatternDto | undefined };
1801 > export function from(pattern: vscode.GlobPattern): string | extHostProtocol.IRelativePatternDto;
1802 > export function from(pattern: undefined): undefined;
1803 > export function from(pattern: { include: vscode.GlobPattern | undefined | null; exclude: vscode.GlobPattern | undefined } | vscode.GlobPattern | undefined): string | extHostProtocol.IRelativePatternDto | { include: string | extHostProtocol.IRelativePatternDto | undefined; exclude: string | extHostProtocol.IRelativePatternDto | undefined } | undefined;
1804 > export function from(pattern: { include: vscode.GlobPattern | undefined | null; exclude: vscode.GlobPattern | undefined } | vscode.GlobPattern | undefined): string | extHostProtocol.IRelativePatternDto | { include: string | extHostProtocol.IRelativePatternDto | undefined; exclude: string | extHostProtocol.IRelativePatternDto | undefined } | undefined {
1805 if (isExclusivePattern(pattern)) {
1806 return {
1812 return GlobPattern.from(pattern) ?? undefined;
1813 }
1815 > export function to(pattern: string | extHostProtocol.IRelativePatternDto | { include: string | extHostProtocol.IRelativePatternDto; exclude: string | extHostProtocol.IRelativePatternDto }): { include: vscode.GlobPattern; exclude: vscode.GlobPattern } | vscode.GlobPattern {
1816 if (isExclusivePattern(pattern)) {
1817 return {
1823 return GlobPattern.to(pattern);
1824 }
1826 > function isExclusivePattern<T>(obj: any): obj is { include?: T; exclude?: T } {
1827 const ep = obj as { include?: T; exclude?: T } | undefined | null;
1828 if (!ep) {
1831 return !isUndefinedOrNull(ep.include) && !isUndefinedOrNull(ep.exclude);
1832 }
1834 >
1835 > export namespace NotebookStatusBarItem {
1836 > export function from(item: vscode.NotebookCellStatusBarItem, commandsConverter: Command.ICommandsConverter, disposables: DisposableStore): notebooks.INotebookCellStatusBarItem {
1837 const command = typeof item.command === 'string' ? { title: '', command: item.command } : item.command;
1838 return {
1845 };
1846 }
1848 >
1849 > export namespace NotebookKernelSourceAction {
1850 > export function from(item: vscode.NotebookKernelSourceAction, commandsConverter: Command.ICommandsConverter, disposables: DisposableStore): notebooks.INotebookKernelSourceAction {
1851 const command = typeof item.command === 'string' ? { title: '', command: item.command } : item.command;
1852
1859 };
1860 }
1862 >
1863 > export namespace NotebookDocumentContentOptions {
1864 > export function from(options: vscode.NotebookDocumentContentOptions | undefined): notebooks.TransientOptions {
1865 return {
1866 transientOutputs: options?.transientOutputs ?? false,
1870 };
1871 }
1873 >
1874 > export namespace NotebookRendererScript {
1875 > export function from(preload: vscode.NotebookRendererScript): { uri: UriComponents; provides: readonly string[] } {
1876 return {
1877 uri: preload.uri,
1879 };
1880 }
1882 > export function to(preload: { uri: UriComponents; provides: readonly string[] }): vscode.NotebookRendererScript {
1883 return new types.NotebookRendererScript(URI.revive(preload.uri), preload.provides);
1884 }
1886 >
1887 > export namespace TestMessage {
1888 > export function from(message: vscode.TestMessage): ITestErrorMessage.Serialized {
1889 return {
1890 message: MarkdownString.fromStrict(message.message) || '',
1901 };
1902 }
1904 > export function to(item: ITestErrorMessage.Serialized): vscode.TestMessage {
1905 const message = new types.TestMessage(typeof item.message === 'string' ? item.message : MarkdownString.to(item.message));
1906 message.actualOutput = item.actual;
1910 return message;
1911 }
1913 >
1914 > export namespace TestTag {
1915 > export const namespace = namespaceTestTag;
1916 >
1917 > export const denamespace = denamespaceTestTag;
1918 > }
1919 >
1920 > export namespace TestRunProfile {
1921 > export function from(item: types.TestRunProfileBase): ITestRunProfileReference {
1922 return {
1923 controllerId: item.controllerId,
1926 };
1927 }
1929 >
1930 > export namespace TestRunProfileKind {
1931 > const profileGroupToBitset: { [K in vscode.TestRunProfileKind]: TestRunProfileBitset } = {
1932 > [types.TestRunProfileKind.Coverage]: TestRunProfileBitset.Coverage,
1933 > [types.TestRunProfileKind.Debug]: TestRunProfileBitset.Debug,
1934 > [types.TestRunProfileKind.Run]: TestRunProfileBitset.Run,
1935 > };
1936 >
1937 > export function from(kind: types.TestRunProfileKind): TestRunProfileBitset {
1938 return profileGroupToBitset.hasOwnProperty(kind) ? profileGroupToBitset[kind] : TestRunProfileBitset.Run;
1939 }
1941 >
1942 > export namespace TestItem {
1943 > export type Raw = vscode.TestItem;
1944 >
1945 > export function from(item: vscode.TestItem): ITestItem {
1946 const ctrlId = getPrivateApiFor(item).controllerId;
1947 return {
1957 };
1958 }
1960 > export function toPlain(item: ITestItem.Serialized): vscode.TestItem {
1961 return {
1962 parent: undefined,
1985 };
1986 }
1988 >
1989 > export namespace TestTag {
1990 > export function from(tag: vscode.TestTag): ITestTag {
1991 return { id: tag.id };
1992 }
1994 > export function to(tag: ITestTag): vscode.TestTag {
1995 return new types.TestTag(tag.id);
1996 }
1998 >
1999 > export namespace TestResults {
2000 > const convertTestResultItem = (node: IPrefixTreeNode<TestResultItem.Serialized>, parent?: vscode.TestResultSnapshot): vscode.TestResultSnapshot | undefined => {
2001 const item = node.value;
2002 if (!item) {
2028 return snapshot;
2029 };
2031 > export function to(serialized: ISerializedTestResults): vscode.TestRunResult {
2032 const tree = new WellDefinedPrefixTree<TestResultItem.Serialized>();
2033 for (const item of serialized.items) {
2053 };
2054 }
2056 >
2057 > export namespace TestCoverage {
2058 > function fromCoverageCount(count: vscode.TestCoverageCount): ICoverageCount {
2059 return { covered: count.covered, total: count.total };
2060 }
2062 > function fromLocation(location: vscode.Range | vscode.Position) {
2063 return 'line' in location ? Position.from(location) : Range.from(location);
2064 }
2066 > function toLocation(location: IPosition | editorRange.IRange): types.Position | types.Range;
2067 > function toLocation(location: IPosition | editorRange.IRange | undefined): types.Position | types.Range | undefined;
2068 > function toLocation(location: IPosition | editorRange.IRange | undefined): types.Position | types.Range | undefined {
2069 if (!location) { return undefined; }
2070 return 'endLineNumber' in location ? Range.to(location) : Position.to(location);
2071 }
2073 > export function to(serialized: CoverageDetails.Serialized): vscode.FileCoverageDetail {
2074 if (serialized.type === DetailType.Statement) {
2075 const branches: vscode.BranchCoverage[] = [];
2100 }
2101 }
2103 > export function fromDetails(coverage: vscode.FileCoverageDetail): CoverageDetails.Serialized {
2104 if (typeof coverage.executed === 'number' && coverage.executed < 0) {
2105 throw new Error(`Invalid coverage count ${coverage.executed}`);
2124 }
2125 }
2127 > export function fromFile(controllerId: string, id: string, coverage: vscode.FileCoverage): IFileCoverage.Serialized {
2128 types.validateTestCoverageCount(coverage.statementCoverage);
2129 types.validateTestCoverageCount(coverage.branchCoverage);
2140 };
2141 }
2143 >
2144 > export namespace CodeActionTriggerKind {
2145 >
2146 > export function to(value: languages.CodeActionTriggerType): types.CodeActionTriggerKind {
2147 switch (value) {
2148 case languages.CodeActionTriggerType.Invoke:
2153 }
2154 }
2156 >
2157 > export namespace TypeHierarchyItem {
2158 >
2159 > export function to(item: extHostProtocol.ITypeHierarchyItemDto): types.TypeHierarchyItem {
2160 const result = new types.TypeHierarchyItem(
2161 SymbolKind.to(item.kind),
2172 return result;
2173 }
2175 > export function from(item: vscode.TypeHierarchyItem, sessionId?: string, itemId?: string): extHostProtocol.ITypeHierarchyItemDto {
2176
2177 sessionId = sessionId ?? (<types.TypeHierarchyItem>item)._sessionId;
2194 };
2195 }
2197 >
2198 > export namespace ViewBadge {
2199 > export function from(badge: vscode.ViewBadge | undefined): IViewBadge | undefined {
2200 if (!badge) {
2201 return undefined;
2207 };
2208 }
2210 >
2211 > export namespace DataTransferItem {
2212 > export function to(mime: string, item: extHostProtocol.DataTransferItemDTO, resolveFileData: (id: string) => Promise<Uint8Array>): types.DataTransferItem {
2213 const file = item.fileData;
2214 if (file) {
2223 return new types.InternalDataTransferItem(item.asString);
2224 }
2226 > export async function from(mime: string, item: vscode.DataTransferItem | IDataTransferItem, id: string = generateUuid()): Promise<extHostProtocol.DataTransferItemDTO> {
2227 const stringValue = await item.asString();
2228
2247 };
2248 }
2250 > function serializeUriList(stringValue: string): ReadonlyArray<string | URI> {
2251 return UriList.split(stringValue).map(part => {
2252 if (part.startsWith('#')) {
2263 });
2264 }
2266 > function reviveUriList(parts: ReadonlyArray<string | UriComponents>): string {
2267 return UriList.create(parts.map(part => {
2268 return typeof part === 'string' ? part : URI.revive(part);
2269 }));
2270 }
2272 >
2273 > export namespace DataTransfer {
2274 > export function toDataTransfer(value: extHostProtocol.DataTransferDTO, resolveFileData: (itemId: string) => Promise<Uint8Array>): types.DataTransfer {
2275 const init = value.items.map(([type, item]) => {
2276 return [type, DataTransferItem.to(type, item, resolveFileData)] as const;
2278 return new types.DataTransfer(init);
2279 }
2281 > export async function from(dataTransfer: vscode.DataTransfer): Promise<extHostProtocol.DataTransferDTO> {
2282 const items = await Promise.all(Array.from(dataTransfer, async ([mime, value]) => {
2283 return [mime, await DataTransferItem.from(mime, value)] as const;
2286 return { items };
2287 }
2289 > export async function fromList(dataTransfer: Iterable<readonly [string, IDataTransferItem]>): Promise<extHostProtocol.DataTransferDTO> {
2290 const items = await Promise.all(Array.from(dataTransfer, async ([mime, value]) => {
2291 return [mime, await DataTransferItem.from(mime, value, value.id)] as const;
2294 return { items };
2295 }
2297 >
2298 > export namespace ChatFollowup {
2299 > export function from(followup: vscode.ChatFollowup, request: IChatAgentRequest | undefined): IChatFollowup {
2300 return {
2301 kind: 'reply',
2306 };
2307 }
2309 > export function to(followup: IChatFollowup): vscode.ChatFollowup {
2310 return {
2311 prompt: followup.message,
2315 };
2316 }
2318 >
2319 > export namespace LanguageModelChatMessageRole {
2320 > export function to(role: chatProvider.ChatMessageRole): vscode.LanguageModelChatMessageRole {
2321 switch (role) {
2322 case chatProvider.ChatMessageRole.System: return types.LanguageModelChatMessageRole.System;
2325 }
2326 }
2328 > export function from(role: vscode.LanguageModelChatMessageRole): chatProvider.ChatMessageRole {
2329 switch (role) {
2330 case types.LanguageModelChatMessageRole.System: return chatProvider.ChatMessageRole.System;
2334 return chatProvider.ChatMessageRole.User;
2335 }
2337 >
2338 > export namespace LanguageModelChatMessage {
2339 >
2340 > export function to(message: chatProvider.IChatMessage): vscode.LanguageModelChatMessage {
2341 const content = message.content.map(c => {
2342 if (c.type === 'text') {
2370 return result;
2371 }
2373 > export function from(message: vscode.LanguageModelChatMessage): chatProvider.IChatMessage {
2374
2375 const role = LanguageModelChatMessageRole.from(message.role);
2461 };
2462 }
2464 >
2465 > export namespace LanguageModelChatMessage2 {
2466 >
2467 > export function to(message: chatProvider.IChatMessage): vscode.LanguageModelChatMessage2 {
2468 const content = message.content.map(c => {
2469 if (c.type === 'text') {
2494 return result;
2495 }
2497 > export function from(message: vscode.LanguageModelChatMessage2): chatProvider.IChatMessage {
2498
2499 const role = LanguageModelChatMessageRole.from(message.role);
2593 };
2594 }
2596 >
2597 function isImageDataPart(part: types.LanguageModelDataPart): boolean {
2598 const mime = typeof part.mimeType === 'string' ? part.mimeType.toLowerCase() : '';
2609 }
2610 }
2612 > export namespace ChatResponseMarkdownPart {
2613 > export function from(part: vscode.ChatResponseMarkdownPart): Dto<IChatMarkdownContent> {
2614 return {
2615 kind: 'markdownContent',
2617 };
2618 }
2619 > export function to(part: Dto<IChatMarkdownContent>): vscode.ChatResponseMarkdownPart { extHostTypeConverters.ts
2620 return new types.ChatResponseMarkdownPart(MarkdownString.to(part.content));
2621 }
2623 >
2624 > export namespace ChatResponseCodeblockUriPart {
2625 > export function from(part: vscode.ChatResponseCodeblockUriPart): Dto<IChatResponseCodeblockUriPart> {
2626 return {
2627 kind: 'codeblockUri',
2631 };
2632 }
2633 > export function to(part: Dto<IChatResponseCodeblockUriPart>): vscode.ChatResponseCodeblockUriPart { extHostTypeConverters.ts
2634 return new types.ChatResponseCodeblockUriPart(URI.revive(part.uri), part.isEdit, part.undoStopId);
2635 }
2637 >
2638 > export namespace ChatResponseMarkdownWithVulnerabilitiesPart {
2639 > export function from(part: vscode.ChatResponseMarkdownWithVulnerabilitiesPart): Dto<IChatAgentMarkdownContentWithVulnerability> {
2640 return {
2641 kind: 'markdownVuln',
2644 };
2645 }
2646 > export function to(part: Dto<IChatAgentMarkdownContentWithVulnerability>): vscode.ChatResponseMarkdownWithVulnerabilitiesPart { extHostTypeConverters.ts
2647 return new types.ChatResponseMarkdownWithVulnerabilitiesPart(MarkdownString.to(part.content), part.vulnerabilities);
2648 }
2650 >
2651 > export namespace ChatResponseConfirmationPart {
2652 > export function from(part: vscode.ChatResponseConfirmationPart): Dto<IChatConfirmation> {
2653 return {
2654 kind: 'confirmation',
2659 };
2660 }
2662 >
2663 > export namespace ChatResponseQuestionCarouselPart {
2664 > function questionTypeToString(type: vscode.ChatQuestionType): 'text' | 'singleSelect' | 'multiSelect' {
2665 switch (type) {
2666 case types.ChatQuestionType.Text: return 'text';
2670 }
2671 }
2673 > function stringToQuestionType(type: 'text' | 'singleSelect' | 'multiSelect'): vscode.ChatQuestionType {
2674 switch (type) {
2675 case 'text': return types.ChatQuestionType.Text;
2679 }
2680 }
2682 > export function from(part: vscode.ChatResponseQuestionCarouselPart): Dto<IChatQuestionCarousel> {
2683 return {
2684 kind: 'questionCarousel',
2695 };
2696 }
2698 > export function to(part: Dto<IChatQuestionCarousel>): vscode.ChatResponseQuestionCarouselPart {
2699 const questions = part.questions.map(q => new types.ChatQuestion(
2700 q.id,
2714 return new types.ChatResponseQuestionCarouselPart(questions, part.allowSkip);
2715 }
2717 >
2718 > export namespace ChatResponseFilesPart {
2719 > export function from(part: vscode.ChatResponseFileTreePart): IChatTreeData {
2720 const { value, baseUri } = part;
2721 function convert(items: vscode.ChatResponseFileTree[], baseUri: URI): extHostProtocol.IChatResponseProgressFileTreeData[] {
2738 };
2739 }
2740 > export function to(part: Dto<IChatTreeData>): vscode.ChatResponseFileTreePart { extHostTypeConverters.ts
2741 const treeData = revive<extHostProtocol.IChatResponseProgressFileTreeData>(part.treeData);
2742 function convert(items: extHostProtocol.IChatResponseProgressFileTreeData[]): vscode.ChatResponseFileTree[] {
2753 return new types.ChatResponseFileTreePart(items, baseUri);
2754 }
2756 >
2757 > export namespace ChatResponseMultiDiffPart {
2758 > export function from(part: vscode.ChatResponseMultiDiffPart): IChatMultiDiffDataSerialized {
2759 return {
2760 kind: 'multiDiffData',
2772 };
2773 }
2774 > export function to(part: IChatMultiDiffDataSerialized): vscode.ChatResponseMultiDiffPart { extHostTypeConverters.ts
2775 const resources = part.multiDiffData.resources.map(resource => ({
2776 originalUri: resource.originalUri ? URI.revive(resource.originalUri) : undefined,
2782 return new types.ChatResponseMultiDiffPart(resources, part.multiDiffData.title, part.readOnly);
2783 }
2785 >
2786 > export namespace ChatResponseAnchorPart {
2787 > export function from(part: vscode.ChatResponseAnchorPart): Dto<IChatContentInlineReference> {
2788 // Work around type-narrowing confusion between vscode.Uri and URI
2789 const isUri = (thing: unknown): thing is vscode.Uri => URI.isUri(thing);
2800 };
2801 }
2803 > export function to(part: Dto<IChatContentInlineReference>): vscode.ChatResponseAnchorPart {
2804 const value = revive<IChatContentInlineReference>(part);
2805 return new types.ChatResponseAnchorPart(
2812 );
2813 }
2815 >
2816 > export namespace ChatResponseProgressPart {
2817 > export function from(part: vscode.ChatResponseProgressPart): Dto<IChatProgressMessage> {
2818 return {
2819 kind: 'progressMessage',
2821 };
2822 }
2823 > export function to(part: Dto<IChatProgressMessage>): vscode.ChatResponseProgressPart { extHostTypeConverters.ts
2824 return new types.ChatResponseProgressPart(part.content.value);
2825 }
2827 >
2828 > export namespace ChatResponseThinkingProgressPart {
2829 > export function from(part: vscode.ChatResponseThinkingProgressPart): Dto<IChatThinkingPart> {
2830 return {
2831 kind: 'thinking',
2835 };
2836 }
2837 > export function to(part: Dto<IChatThinkingPart>): vscode.ChatResponseThinkingProgressPart { extHostTypeConverters.ts
2838 return new types.ChatResponseThinkingProgressPart(part.value ?? '', part.id, part.metadata);
2839 }
2841 >
2842 > export namespace ChatResponseHookPart {
2843 > export function from(part: vscode.ChatResponseHookPart): Dto<IChatHookPart> {
2844 return {
2845 kind: 'hook',
2850 };
2851 }
2852 > export function to(part: Dto<IChatHookPart>): vscode.ChatResponseHookPart { extHostTypeConverters.ts
2853 return new types.ChatResponseHookPart(part.hookType, part.stopReason, part.systemMessage, part.metadata);
2854 }
2856 >
2857 > export namespace ChatResponseAutoModeResolutionPart {
2858 > const validLabels = new Set<IChatAutoModeResolutionPart['predictedLabel']>(['needs_reasoning', 'no_reasoning', 'fallback']);
2859 >
2860 > export function from(part: vscode.ChatResponseAutoModeResolutionPart): Dto<IChatAutoModeResolutionPart> {
2861 const label = validLabels.has(part.predictedLabel as IChatAutoModeResolutionPart['predictedLabel'])
2862 ? part.predictedLabel as IChatAutoModeResolutionPart['predictedLabel']
2870 };
2871 }
2872 > export function to(part: Dto<IChatAutoModeResolutionPart>): vscode.ChatResponseAutoModeResolutionPart { extHostTypeConverters.ts
2873 return new types.ChatResponseAutoModeResolutionPart(part.resolvedModel, part.resolvedModelName, part.predictedLabel, part.confidence);
2874 }
2876 >
2877 > export namespace ChatResponseWarningPart {
2878 > export function from(part: vscode.ChatResponseWarningPart): Dto<IChatWarningMessage> {
2879 return {
2880 kind: 'warning',
2882 };
2883 }
2884 > export function to(part: Dto<IChatWarningMessage>): vscode.ChatResponseWarningPart { extHostTypeConverters.ts
2885 return new types.ChatResponseWarningPart(part.content.value);
2886 }
2888 >
2889 > export namespace ChatResponseInfoPart {
2890 > export function from(part: vscode.ChatResponseInfoPart): Dto<IChatInfoMessage> {
2891 return {
2892 kind: 'info',
2894 };
2895 }
2896 > export function to(part: Dto<IChatInfoMessage>): vscode.ChatResponseInfoPart { extHostTypeConverters.ts
2897 return new types.ChatResponseInfoPart(part.content.value);
2898 }
2900 >
2901 > export namespace ChatResponseExtensionsPart {
2902 > export function from(part: vscode.ChatResponseExtensionsPart): Dto<IChatExtensionsContent> {
2903 return {
2904 kind: 'extensions',
2906 };
2907 }
2909 >
2910 > export namespace ChatResponsePullRequestPart {
2911 > export function from(part: Omit<vscode.ChatResponsePullRequestPart, 'command'> & { command?: vscode.Command }, commandsConverter: CommandsConverter, commandDisposables: DisposableStore): Dto<IChatPullRequestContent> {
2912 // If the command isn't in the converter, then this session may have been restored, and the command args don't exist anymore
2913 let command: extHostProtocol.ICommandDto;
2934 };
2935 }
2937 >
2938 > export namespace ChatResponseMovePart {
2939 > export function from(part: vscode.ChatResponseMovePart): Dto<IChatMoveMessage> {
2940 return {
2941 kind: 'move',
2944 };
2945 }
2946 > export function to(part: Dto<IChatMoveMessage>): vscode.ChatResponseMovePart { extHostTypeConverters.ts
2947 return new types.ChatResponseMovePart(URI.revive(part.uri), Range.to(part.range));
2948 }
2950 >
2951 > export namespace ChatToolInvocationPart {
2952 > export function from(part: vscode.ChatToolInvocationPart): IChatToolInvocationSerialized | IChatExternalToolInvocationUpdate {
2953 // Check if toolSpecificData is ChatMcpToolInvocationData (has input and output)
2954 // If so, convert to resultDetails for rendering via ChatInputOutputMarkdownProgressPart
3005 };
3006 }
3008 > function isChatMcpToolInvocationData(data: any): data is vscode.ChatMcpToolInvocationData {
3009 return data !== null && typeof data === 'object' &&
3010 'input' in data && typeof data.input === 'string' &&
3011 'output' in data && Array.isArray(data.output);
3012 }
3014 > function convertMcpToResultDetails(data: vscode.ChatMcpToolInvocationData, isError?: boolean): IToolResultInputOutputDetails {
3015 return {
3016 input: data.input,
3027 };
3028 }
3030 > function convertToolSpecificData(data: any): any {
3031 // Convert extension API terminal tool data to internal format
3032 if ('command' in data && 'language' in data) {
3098 return data;
3099 }
3101 > function todoStatusEnumToString(status: types.ChatTodoStatus | string): string {
3102 // Handle enum values
3103 switch (status) {
3112 }
3113 }
3115 > function todoStatusStringToEnum(status: string): types.ChatTodoStatus {
3116 switch (status) {
3117 case 'not-started':
3125 }
3126 }
3128 > export function to(part: any): vscode.ChatToolInvocationPart {
3129 const toolInvocation = new types.ChatToolInvocationPart(
3130 part.toolId || part.toolName,
3156 return toolInvocation;
3157 }
3159 > function convertFromInternalToolSpecificData(data: any): any {
3160 // Convert internal terminal tool data to extension API format
3161 if (data.kind === 'terminal') {
3213 return data;
3214 }
3216 >
3217 > export namespace ChatTask {
3218 > export function from(part: vscode.ChatResponseProgressPart2): IChatTaskDto {
3219 return {
3220 kind: 'progressTask',
3222 };
3223 }
3225 >
3226 > export namespace ChatTaskResult {
3227 > export function from(part: string | void): Dto<IChatTaskResult> {
3228 return {
3229 kind: 'progressTaskResult',
3231 };
3232 }
3234 >
3235 > export namespace ChatResponseCommandButtonPart {
3236 > export function from(part: vscode.ChatResponseCommandButtonPart, commandsConverter: CommandsConverter, commandDisposables: DisposableStore): Dto<IChatCommandButton> {
3237 // If the command isn't in the converter, then this session may have been restored, and the command args don't exist anymore
3238 const command = commandsConverter.toInternal(part.value, commandDisposables) ?? { command: part.value.command, title: part.value.title };
3242 };
3243 }
3244 > export function to(part: Dto<IChatCommandButton>, commandsConverter: CommandsConverter): vscode.ChatResponseCommandButtonPart { extHostTypeConverters.ts
3245 // If the command isn't in the converter, then this session may have been restored, and the command args don't exist anymore
3246 return new types.ChatResponseCommandButtonPart(commandsConverter.fromInternal(part.command) ?? { command: part.command.id, title: part.command.title });
3247 }
3249 >
3250 > export namespace ChatResponseTextEditPart {
3251 > export function from(part: vscode.ChatResponseTextEditPart): Dto<IChatTextEdit> {
3252 return {
3253 kind: 'textEdit',
3257 };
3258 }
3259 > export function to(part: Dto<IChatTextEdit>): vscode.ChatResponseTextEditPart { extHostTypeConverters.ts
3260 const result = new types.ChatResponseTextEditPart(URI.revive(part.uri), part.edits.map(e => TextEdit.to(e)));
3261 result.isDone = part.done;
3262 return result;
3263 }
3265 > }
3266 >
3267 > export namespace NotebookEdit {
3268 > export function from(edit: vscode.NotebookEdit): extHostProtocol.ICellEditOperationDto {
3269 if (edit.newCellMetadata) {
3270 return {
3287 }
3288 }
3290 >
3291 >
3292 > export namespace ChatResponseNotebookEditPart {
3293 > export function from(part: vscode.ChatResponseNotebookEditPart): extHostProtocol.IChatNotebookEditDto {
3294 return {
3295 kind: 'notebookEdit',
3299 };
3300 }
3302 >
3303 > export namespace ChatResponseWorkspaceEditPart {
3304 > export function from(part: vscode.ChatResponseWorkspaceEditPart): IChatWorkspaceEdit {
3305 return {
3306 kind: 'workspaceEdit',
3311 };
3312 }
3314 >
3315 > export namespace ChatResponseReferencePart {
3316 > export function from(part: types.ChatResponseReferencePart): Dto<IChatContentReference> {
3317 const iconPath = ThemeIcon.isThemeIcon(part.iconPath) ? part.iconPath
3318 : URI.isUri(part.iconPath) ? { light: URI.revive(part.iconPath) }
3343 };
3344 }
3345 > export function to(part: Dto<IChatContentReference>): vscode.ChatResponseReferencePart { extHostTypeConverters.ts
3346 const value = revive<IChatContentReference>(part);
3347
3358 ) as vscode.ChatResponseReferencePart; // 'value' is extended with variableName
3359 }
3361 >
3362 > export namespace ChatResponseCodeCitationPart {
3363 > export function from(part: vscode.ChatResponseCodeCitationPart): Dto<IChatCodeCitation> {
3364 return {
3365 kind: 'codeCitation',
3369 };
3370 }
3372 >
3373 > export namespace ChatResponsePart {
3374 >
3375 > export function from(part: vscode.ExtendedChatResponsePart, commandsConverter: CommandsConverter, commandDisposables: DisposableStore): extHostProtocol.IChatProgressDto {
3376 if (part instanceof types.ChatResponseMarkdownPart) {
3377 return ChatResponseMarkdownPart.from(part);
3429 };
3430 }
3432 > export function to(part: extHostProtocol.IChatProgressDto, commandsConverter: CommandsConverter): vscode.ChatResponsePart | undefined {
3433 switch (part.kind) {
3434 case 'reference': return ChatResponseReferencePart.to(part);
3442 return undefined;
3443 }
3445 > export function toContent(part: extHostProtocol.IChatContentProgressDto, commandsConverter: CommandsConverter): vscode.ChatResponseMarkdownPart | vscode.ChatResponseFileTreePart | vscode.ChatResponseAnchorPart | vscode.ChatResponseCommandButtonPart | undefined {
3446 switch (part.kind) {
3447 case 'markdownContent': return ChatResponseMarkdownPart.to(part);
3454 return undefined;
3455 }
3457 >
3458 > export namespace ChatAgentRequest {
3459 > export function to(request: IChatAgentRequest, location2: vscode.ChatRequestEditorData | vscode.ChatRequestNotebookData | undefined, model: vscode.LanguageModelChat, modelConfiguration: IStringDictionary<unknown> | undefined, diagnostics: readonly [vscode.Uri, readonly vscode.Diagnostic[]][], tools: Map<vscode.LanguageModelToolInformation, boolean>, extension: IRelaxedExtensionDescription, logService: ILogService): vscode.ChatRequest {
3460
3461 const toolReferences: IChatRequestVariableEntry[] = [];
3544 return requestWithAllProps;
3545 }
3547 >
3548 > export namespace ChatLocation {
3549 > export function to(loc: ChatAgentLocation): types.ChatLocation {
3550 switch (loc) {
3551 case ChatAgentLocation.Notebook: return types.ChatLocation.Notebook;
3555 }
3556 }
3558 > export function from(loc: types.ChatLocation): ChatAgentLocation {
3559 switch (loc) {
3560 case types.ChatLocation.Notebook: return ChatAgentLocation.Notebook;
3564 }
3565 }
3567 >
3568 > export namespace ChatSessionCustomizationType {
3569 > export function from(type: types.ChatSessionCustomizationType): string {
3570 return type.id;
3571 }
3573 > export function to(id: string): types.ChatSessionCustomizationType {
3574 switch (id) {
3575 case 'agent': return types.ChatSessionCustomizationType.Agent;
3582 }
3583 }
3585 >
3586 > export namespace ChatPromptReference {
3587 > export function to(variable: IChatRequestVariableEntry, diagnostics: readonly [vscode.Uri, readonly vscode.Diagnostic[]][], logService: ILogService): vscode.ChatPromptReference | undefined {
3588 let value: vscode.ChatPromptReference['value'] = variable.value;
3589 if (!value) {
3648 };
3649 }
3651 >
3652 > export namespace ChatLanguageModelToolReference {
3653 > export function to(variable: IChatRequestVariableEntry): vscode.ChatLanguageModelToolReference {
3654 const value = variable.value;
3655 if (value) {
3662 };
3663 }
3665 >
3666 > namespace ChatLanguageModelToolReferences {
3667 > export function to(variables: readonly ChatRequestToolReferenceEntry[]): vscode.ChatLanguageModelToolReference[] {
3668 const toolReferences = [];
3669 for (const v of variables) {
3678 return toolReferences;
3679 }
3681 >
3682 > export namespace ChatRequestModeInstructions {
3683 > export function to(mode: IChatRequestModeInstructions | Dto<IChatRequestModeInstructions> | undefined): vscode.ChatRequestModeInstructions | undefined {
3684 if (mode) {
3685 return {
3695 return undefined;
3696 }
3698 > export function from(mode: vscode.ChatRequestModeInstructions | undefined): IChatRequestModeInstructions | undefined {
3699 if (mode) {
3700 return {
3716 return undefined;
3717 }
3719 >
3720 > export namespace ChatAgentCompletionItem {
3721 > export function from(item: vscode.ChatCompletionItem, commandsConverter: CommandsConverter, disposables: DisposableStore): extHostProtocol.IChatAgentCompletionItem {
3722 return {
3723 id: item.id,
3732 };
3733 }
3735 >
3736 > export namespace ChatAgentResult {
3737 > export function to(result: IChatAgentResult): vscode.ChatResult {
3738 return {
3739 errorDetails: result.errorDetails,
3743 };
3744 }
3745 > export function from(result: vscode.ChatResult): Dto<IChatAgentResult> { extHostTypeConverters.ts
3746 return {
3747 errorDetails: result.errorDetails,
3751 };
3752 }
3754 > function reviveMetadata(metadata: IChatAgentResult['metadata']) {
3755 return cloneAndChange(metadata, value => {
3756 if (value.$mid === MarshalledId.LanguageModelToolResult) {
3783 });
3784 }
3786 >
3787 > export namespace ChatAgentUserActionEvent {
3788 > export function to(result: IChatAgentResult, event: IChatUserActionEvent, commandsConverter: CommandsConverter): vscode.ChatUserActionEvent | undefined {
3789 if (event.action.kind === 'vote') {
3790 // Is the "feedback" type
3842 }
3843 }
3845 >
3846 > export namespace TerminalQuickFix {
3847 > export function from(quickFix: vscode.TerminalQuickFixTerminalCommand | vscode.TerminalQuickFixOpener | vscode.Command, converter: Command.ICommandsConverter, disposables: DisposableStore): extHostProtocol.ITerminalQuickFixTerminalCommandDto | extHostProtocol.ITerminalQuickFixOpenerDto | extHostProtocol.ICommandDto | undefined {
3848 if ('terminalCommand' in quickFix) {
3849 return { terminalCommand: quickFix.terminalCommand, shouldExecute: quickFix.shouldExecute };
3854 return converter.toInternal(quickFix, disposables);
3855 }
3857 > export namespace TerminalCompletionItemDto {
3858 > export function from(item: vscode.TerminalCompletionItem): extHostProtocol.ITerminalCompletionItemDto {
3859 return {
3860 ...item,
3862 };
3863 }
3865 >
3866 > export namespace TerminalCompletionList {
3867 > export function from(completions: vscode.TerminalCompletionList | vscode.TerminalCompletionItem[], pathSeparator: string): extHostProtocol.TerminalCompletionListDto {
3868 if (Array.isArray(completions)) {
3869 return {
3876 };
3877 }
3879 >
3880 > export namespace TerminalCompletionResourceOptions {
3881 > export function from(resourceOptions: vscode.TerminalCompletionResourceOptions, pathSeparator: string): extHostProtocol.TerminalCompletionResourceOptionsDto {
3882 return {
3883 ...resourceOptions,
3887 };
3888 }
3890 >
3891 > export namespace PartialAcceptInfo {
3892 > export function to(info: languages.PartialAcceptInfo): types.PartialAcceptInfo {
3893 return {
3894 kind: PartialAcceptTriggerKind.to(info.kind),
3896 };
3897 }
3899 >
3900 > export namespace PartialAcceptTriggerKind {
3901 > export function to(kind: languages.PartialAcceptTriggerKind): types.PartialAcceptTriggerKind {
3902 switch (kind) {
3903 case languages.PartialAcceptTriggerKind.Word:
3911 }
3912 }
3914 >
3915 > export namespace InlineCompletionEndOfLifeReason {
3916 > export function to<T>(reason: languages.InlineCompletionEndOfLifeReason<T>, convertFn: (item: T) => vscode.InlineCompletionItem | undefined): vscode.InlineCompletionEndOfLifeReason {
3917 if (reason.kind === languages.InlineCompletionEndOfLifeReasonKind.Ignored) {
3918 const supersededBy = reason.supersededBy ? convertFn(reason.supersededBy) : undefined;
3931 };
3932 }
3934 >
3935 > export namespace InlineCompletionHintStyle {
3936 > export function from(value: vscode.InlineCompletionDisplayLocationKind): languages.InlineCompletionHintStyle {
3937 if (value === types.InlineCompletionDisplayLocationKind.Label) {
3938 return languages.InlineCompletionHintStyle.Label;
3941 }
3942 }
3944 > export function to(kind: languages.InlineCompletionHintStyle): types.InlineCompletionDisplayLocationKind {
3945 switch (kind) {
3946 case languages.InlineCompletionHintStyle.Label:
3950 }
3951 }
3953 >
3954 > export namespace DebugTreeItem {
3955 > export function from(item: vscode.DebugTreeItem, id: number): IDebugVisualizationTreeItem {
3956 return {
3957 id,
3963 };
3964 }
3966 >
3967 > export namespace LanguageModelToolSource {
3968 > export function to(source: Dto<ToolDataSource>): vscode.LanguageModelToolInformation['source'] {
3969 if (source.type === 'mcp') {
3970 return new types.LanguageModelToolMCPSource(source.label, source.serverLabel || source.label, source.instructions);
3975 }
3976 }
3978 >
3979 > export namespace LanguageModelToolResult {
3980 > export function to(result: IToolResult): vscode.ExtendedLanguageModelToolResult {
3981 const toolResult = new types.LanguageModelToolResult(result.content.map(item => {
3982 if (item.kind === 'text') {
3996 return toolResult;
3997 }
3999 > export function from(result: vscode.ExtendedLanguageModelToolResult2, extension: IExtensionDescription): Dto<IToolResult> | SerializableObjectWithBuffers<Dto<IToolResult>> {
4000 if (result.toolResultMessage) {
4001 checkProposedApiEnabled(extension, 'chatParticipantPrivate');
4064 return hasBuffers ? new SerializableObjectWithBuffers(dto) : dto;
4065 }
4067 >
4068 > export namespace IconPath {
4069 > export function fromThemeIcon(iconPath: vscode.ThemeIcon): languages.IconPath {
4070 return iconPath;
4071 }
4073 > /**
4074 > * Converts a {@link vscode.IconPath} to an {@link extHostProtocol.IconPathDto}.
4075 > * @note This function will tolerate strings specified instead of URIs in IconPath for historical reasons.
4076 > * Such strings are treated as file paths and converted using {@link URI.file} function, not {@link URI.from}.
4077 > * See https://github.com/microsoft/vscode/issues/110432#issuecomment-726144556 for context.
4078 > */
4079 > export function from(value: undefined): undefined;
4080 > export function from(value: vscode.IconPath): extHostProtocol.IconPathDto;
4081 > export function from(value: vscode.IconPath | undefined): extHostProtocol.IconPathDto | undefined;
4082 > export function from(value: vscode.IconPath | undefined): extHostProtocol.IconPathDto | undefined {
4083 if (!value) {
4084 return undefined;
4097 }
4098 }
4100 > /**
4101 > * Converts a {@link extHostProtocol.IconPathDto} to a {@link vscode.IconPath}.
4102 > * @note This is a strict conversion and we assume types are correct in this case.
4103 > */
4104 > export function to(value: undefined): undefined;
4105 > export function to(value: extHostProtocol.IconPathDto): vscode.IconPath;
4106 > export function to(value: extHostProtocol.IconPathDto | undefined): vscode.IconPath | undefined;
4107 > export function to(value: extHostProtocol.IconPathDto | undefined): vscode.IconPath | undefined {
4108 if (!value) {
4109 return undefined;
4120 }
4121 }
4123 >
4124 > export namespace AiSettingsSearch {
4125 > export function fromSettingsSearchResult(result: vscode.SettingsSearchResult): AiSettingsSearchResult {
4126 return {
4127 query: result.query,
4130 };
4131 }
4133 > function fromSettingsSearchResultKind(kind: number): AiSettingsSearchResultKind {
4134 switch (kind) {
4135 case AiSettingsSearchResultKind.EMBEDDED:
4143 }
4144 }
4146 >
4147 > export namespace McpServerDefinition {
4148 > function isHttpConfig(candidate: vscode.McpServerDefinition): candidate is vscode.McpHttpServerDefinition {
4149 return !!(candidate as vscode.McpHttpServerDefinition).uri;
4150 }
4152 > export function from(item: vscode.McpServerDefinition): McpServerLaunch.Serialized {
4153 return McpServerLaunch.toSerialized(
4154 isHttpConfig(item)
4173 );
4174 }
4176 > /** Converts from the IPC DTO to the API type. */
4177 > export function to(dto: McpServerDefinitionType.Serialized): vscode.McpServerDefinition {
4178 const launch = McpServerLaunch.fromSerialized(dto.launch);
4179 if (launch.type === McpServerTransportType.HTTP) {
4198 }
4199 }
4201 >
4202 > export namespace SourceControlInputBoxValidationType {
4203 > export function from(type: number): InputValidationType {
4204 switch (type) {
4205 case types.SourceControlInputBoxValidationType.Error:
4213 }
4214 }
4216 >
4217 > export namespace ChatRequestHooksConverter {
4218 > export function to(hooks: ChatRequestHooks): vscode.ChatRequestHooks {
4219 const result: Record<string, vscode.ChatHookCommand[]> = {};
4220 for (const [hookType, commands] of Object.entries(hooks)) {
4235 return result;
4236 }
4238 >
4239 > export namespace ChatHookCommand {
4240 > export function to(hook: IParsedHookCommand): vscode.ChatHookCommand | undefined {
4241 const command = resolveEffectiveCommand(hook, OS);
4242 if (!command) {
4250 };
4251 }
4253 >
4254 > export namespace ChatSessionItem {
4255 >
4256 > function convertStatus(status: vscode.ChatSessionStatus | undefined): ChatSessionStatus | undefined {
4257 if (status === undefined) {
4258 return undefined;
4272 }
4273 }
4275 > export function from(sessionContent: vscode.ChatSessionItem): Dto<IChatSessionItem> {
4276 // Support both new (created, lastRequestStarted, lastRequestEnded) and old (startTime, endTime) timing properties
4277 const timing = sessionContent.timing;
src/vs/workbench/contrib/testing/common/testTypes.ts 755 introduced LOC · 45 ranges

Open complete file

1 > /*--------------------------------------------------------------------------------------------- testTypes.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 { IMarkdownString } from '../../../../base/common/htmlContent.js';
7 > import { MarshalledId } from '../../../../base/common/marshallingIds.js';
8 > import { URI, UriComponents } from '../../../../base/common/uri.js';
9 > import { IPosition, Position } from '../../../../editor/common/core/position.js';
10 > import { IRange, Range } from '../../../../editor/common/core/range.js';
11 > import { localize } from '../../../../nls.js';
12 > import { TestId } from './testId.js';
13 >
14 > export const enum TestResultState {
15 > Unset = 0,
16 > Queued = 1,
17 > Running = 2,
18 > Passed = 3,
19 > Failed = 4,
20 > Skipped = 5,
21 > Errored = 6
22 > }
23 >
24 > export const testResultStateToContextValues: { [K in TestResultState]: string } = {
25 > [TestResultState.Unset]: 'unset',
26 > [TestResultState.Queued]: 'queued',
27 > [TestResultState.Running]: 'running',
28 > [TestResultState.Passed]: 'passed',
29 > [TestResultState.Failed]: 'failed',
30 > [TestResultState.Skipped]: 'skipped',
31 > [TestResultState.Errored]: 'errored',
32 > };
33 >
34 > /** note: keep in sync with TestRunProfileKind in vscode.d.ts */
35 > export const enum ExtTestRunProfileKind {
36 > Run = 1,
37 > Debug = 2,
38 > Coverage = 3,
39 > }
40 >
41 > export const enum TestControllerCapability {
42 > Refresh = 1 << 1,
43 > CodeRelatedToTest = 1 << 2,
44 > TestRelatedToCode = 1 << 3,
45 > }
46 >
47 > export const enum TestRunProfileBitset {
48 > Run = 1 << 1,
49 > Debug = 1 << 2,
50 > Coverage = 1 << 3,
51 > HasNonDefaultProfile = 1 << 4,
52 > HasConfigurable = 1 << 5,
53 > SupportsContinuousRun = 1 << 6,
54 > }
55 >
56 > export const testProfileBitset = {
57 > [TestRunProfileBitset.Run]: localize('testing.runProfileBitset.run', 'Run'),
58 > [TestRunProfileBitset.Debug]: localize('testing.runProfileBitset.debug', 'Debug'),
59 > [TestRunProfileBitset.Coverage]: localize('testing.runProfileBitset.coverage', 'Coverage'),
60 > };
61 >
62 > /**
63 > * List of all test run profile bitset values.
64 > */
65 > export const testRunProfileBitsetList = [
66 > TestRunProfileBitset.Run,
67 > TestRunProfileBitset.Debug,
68 > TestRunProfileBitset.Coverage,
69 > TestRunProfileBitset.HasNonDefaultProfile,
70 > TestRunProfileBitset.HasConfigurable,
71 > TestRunProfileBitset.SupportsContinuousRun,
72 > ];
73 >
74 > /**
75 > * DTO for a controller's run profiles.
76 > */
77 > export interface ITestRunProfile {
78 > controllerId: string;
79 > profileId: number;
80 > label: string;
81 > group: TestRunProfileBitset;
82 > isDefault: boolean;
83 > tag: string | null;
84 > hasConfigurationHandler: boolean;
85 > supportsContinuousRun: boolean;
86 > }
87 >
88 > export interface ITestRunProfileReference {
89 > controllerId: string;
90 > profileId: number;
91 > group: TestRunProfileBitset;
92 > }
93 >
94 > /**
95 > * A fully-resolved request to run tests, passsed between the main thread
96 > * and extension host.
97 > */
98 > export interface ResolvedTestRunRequest {
99 > group: TestRunProfileBitset;
100 > targets: {
101 > testIds: string[];
102 > controllerId: string;
103 > profileId: number;
104 > }[];
105 > exclude?: string[];
106 > /** Whether this is a continuous test run */
107 > continuous?: boolean;
108 > /** Whether this was trigged by a user action in UI. Default=true */
109 > preserveFocus?: boolean;
110 > }
111 >
112 > /**
113 > * Request to the main thread to run a set of tests.
114 > */
115 > export interface ExtensionRunTestsRequest {
116 > id: string;
117 > include: string[];
118 > exclude: string[];
119 > controllerId: string;
120 > profile?: { group: TestRunProfileBitset; id: number };
121 > persist: boolean;
122 > preserveFocus: boolean;
123 > /** Whether this is a result of a continuous test run request */
124 > continuous: boolean;
125 > }
126 >
127 > /**
128 > * Request parameters a controller run handler. This is different than
129 > * {@link IStartControllerTests}. The latter is used to ask for one or more test
130 > * runs tracked directly by the renderer.
131 > *
132 > * This alone can be used to start an autorun, without a specific associated runId.
133 > */
134 > export interface ICallProfileRunHandler {
135 > controllerId: string;
136 > profileId: number;
137 > excludeExtIds: string[];
138 > testIds: string[];
139 > }
140 >
141 > export const isStartControllerTests = (t: ICallProfileRunHandler | IStartControllerTests): t is IStartControllerTests => ('runId' as keyof IStartControllerTests) in t;
142 >
143 > /**
144 > * Request from the main thread to run tests for a single controller.
145 > */
146 > export interface IStartControllerTests extends ICallProfileRunHandler {
147 > runId: string;
148 > }
149 >
150 > export interface IStartControllerTestsResult {
151 > error?: string;
152 > }
153 >
154 > /**
155 > * Location with a fully-instantiated Range and URI.
156 > */
157 > export interface IRichLocation {
158 > range: Range;
159 > uri: URI;
160 > }
161 >
162 > /** Subset of the IUriIdentityService */
163 > export interface ITestUriCanonicalizer {
164 > /** @link import('vs/platform/uriIdentity/common/uriIdentity').IUriIdentityService */
165 > asCanonicalUri(uri: URI): URI;
166 > }
167 >
168 > export namespace IRichLocation {
169 > export interface Serialize {
170 > range: IRange;
171 > uri: UriComponents;
172 > }
173 >
174 > export const serialize = (location: Readonly<IRichLocation>): Serialize => ({
175 range: location.range.toJSON(),
176 uri: location.uri.toJSON(),
177 });
178 > testTypes.ts
179 > export const deserialize = (uriIdentity: ITestUriCanonicalizer, location: Serialize): IRichLocation => ({
180 range: Range.lift(location.range),
181 uri: uriIdentity.asCanonicalUri(URI.revive(location.uri)),
182 });
183 > } testTypes.ts
184 >
185 > export const enum TestMessageType {
186 > Error,
187 > Output
188 > }
189 >
190 > export interface ITestMessageStackFrame {
191 > label: string;
192 > uri: URI | undefined;
193 > position: Position | undefined;
194 > }
195 >
196 > export namespace ITestMessageStackFrame {
197 > export interface Serialized {
198 > label: string;
199 > uri: UriComponents | undefined;
200 > position: IPosition | undefined;
201 > }
202 >
203 > export const serialize = (stack: Readonly<ITestMessageStackFrame>): Serialized => ({
204 label: stack.label,
205 uri: stack.uri?.toJSON(),
206 position: stack.position?.toJSON(),
207 });
208 > testTypes.ts
209 > export const deserialize = (uriIdentity: ITestUriCanonicalizer, stack: Serialized): ITestMessageStackFrame => ({
210 label: stack.label,
211 uri: stack.uri ? uriIdentity.asCanonicalUri(URI.revive(stack.uri)) : undefined,
212 position: stack.position ? Position.lift(stack.position) : undefined,
213 });
214 > } testTypes.ts
215 >
216 > export interface ITestErrorMessage {
217 > message: string | IMarkdownString;
218 > type: TestMessageType.Error;
219 > expected: string | undefined;
220 > actual: string | undefined;
221 > contextValue: string | undefined;
222 > location: IRichLocation | undefined;
223 > stackTrace: undefined | ITestMessageStackFrame[];
224 > }
225 >
226 > export namespace ITestErrorMessage {
227 > export interface Serialized {
228 > message: string | IMarkdownString;
229 > type: TestMessageType.Error;
230 > expected: string | undefined;
231 > actual: string | undefined;
232 > contextValue: string | undefined;
233 > location: IRichLocation.Serialize | undefined;
234 > stackTrace: undefined | ITestMessageStackFrame.Serialized[];
235 > }
236 >
237 > export const serialize = (message: Readonly<ITestErrorMessage>): Serialized => ({
238 message: message.message,
239 type: TestMessageType.Error,
244 stackTrace: message.stackTrace?.map(ITestMessageStackFrame.serialize),
245 });
246 > testTypes.ts
247 > export const deserialize = (uriIdentity: ITestUriCanonicalizer, message: Serialized): ITestErrorMessage => ({
248 message: message.message,
249 type: TestMessageType.Error,
254 stackTrace: message.stackTrace && message.stackTrace.map(s => ITestMessageStackFrame.deserialize(uriIdentity, s)),
255 });
256 > } testTypes.ts
257 >
258 > export interface ITestOutputMessage {
259 > message: string;
260 > type: TestMessageType.Output;
261 > offset: number;
262 > length: number;
263 > marker?: number;
264 > location: IRichLocation | undefined;
265 > }
266 >
267 > /**
268 > * Gets the TTY marker ID for either starting or ending
269 > * an ITestOutputMessage.marker of the given ID.
270 > */
271 > export const getMarkId = (marker: number, start: boolean) => `${start ? 's' : 'e'}${marker}`;
272 >
273 > export namespace ITestOutputMessage {
274 > export interface Serialized {
275 > message: string;
276 > offset: number;
277 > length: number;
278 > type: TestMessageType.Output;
279 > location: IRichLocation.Serialize | undefined;
280 > }
281 >
282 > export const serialize = (message: Readonly<ITestOutputMessage>): Serialized => ({
283 message: message.message,
284 type: TestMessageType.Output,
287 location: message.location && IRichLocation.serialize(message.location),
288 });
289 > testTypes.ts
290 > export const deserialize = (uriIdentity: ITestUriCanonicalizer, message: Serialized): ITestOutputMessage => ({
291 message: message.message,
292 type: TestMessageType.Output,
295 location: message.location && IRichLocation.deserialize(uriIdentity, message.location),
296 });
297 > } testTypes.ts
298 >
299 > export type ITestMessage = ITestErrorMessage | ITestOutputMessage;
300 >
301 > export namespace ITestMessage {
302 > export type Serialized = ITestErrorMessage.Serialized | ITestOutputMessage.Serialized;
303 >
304 > export const serialize = (message: Readonly<ITestMessage>): Serialized =>
305 message.type === TestMessageType.Error ? ITestErrorMessage.serialize(message) : ITestOutputMessage.serialize(message);
306 > testTypes.ts
307 > export const deserialize = (uriIdentity: ITestUriCanonicalizer, message: Serialized): ITestMessage =>
308 message.type === TestMessageType.Error ? ITestErrorMessage.deserialize(uriIdentity, message) : ITestOutputMessage.deserialize(uriIdentity, message);
309 > testTypes.ts
310 > export const isDiffable = (message: ITestMessage): message is ITestErrorMessage & { actual: string; expected: string } =>
311 message.type === TestMessageType.Error && message.actual !== undefined && message.expected !== undefined;
312 > } testTypes.ts
313 >
314 > export interface ITestTaskState {
315 > state: TestResultState;
316 > duration: number | undefined;
317 > messages: ITestMessage[];
318 > }
319 >
320 > export namespace ITestTaskState {
321 > export interface Serialized {
322 > state: TestResultState;
323 > duration: number | undefined;
324 > messages: ITestMessage.Serialized[];
325 > }
326 >
327 > export const serializeWithoutMessages = (state: ITestTaskState): Serialized => ({
328 state: state.state,
329 duration: state.duration,
330 messages: [],
331 });
332 > testTypes.ts
333 > export const serialize = (state: Readonly<ITestTaskState>): Serialized => ({
334 state: state.state,
335 duration: state.duration,
336 messages: state.messages.map(ITestMessage.serialize),
337 });
338 > testTypes.ts
339 > export const deserialize = (uriIdentity: ITestUriCanonicalizer, state: Serialized): ITestTaskState => ({
340 state: state.state,
341 duration: state.duration,
342 messages: state.messages.map(m => ITestMessage.deserialize(uriIdentity, m)),
343 });
344 > } testTypes.ts
345 >
346 > export interface ITestRunTask {
347 > id: string;
348 > name: string;
349 > running: boolean;
350 > ctrlId: string;
351 > }
352 >
353 > export interface ITestTag {
354 > readonly id: string;
355 > }
356 >
357 > const testTagDelimiter = '\0';
358 >
359 > export const namespaceTestTag =
360 > (ctrlId: string, tagId: string) => ctrlId + testTagDelimiter + tagId;
361 >
362 > export const denamespaceTestTag = (namespaced: string) => {
363 const index = namespaced.indexOf(testTagDelimiter);
364 return { ctrlId: namespaced.slice(0, index), tagId: namespaced.slice(index + 1) };
365 };
366 > testTypes.ts
367 > export interface ITestTagDisplayInfo {
368 > id: string;
369 > }
370 >
371 > /**
372 > * The TestItem from .d.ts, as a plain object without children.
373 > */
374 > export interface ITestItem {
375 > /** ID of the test given by the test controller */
376 > extId: string;
377 > label: string;
378 > tags: string[];
379 > busy: boolean;
380 > children?: never;
381 > uri: URI | undefined;
382 > range: Range | null;
383 > description: string | null;
384 > error: string | IMarkdownString | null;
385 > sortText: string | null;
386 > }
387 >
388 > export namespace ITestItem {
389 > export interface Serialized {
390 > extId: string;
391 > label: string;
392 > tags: string[];
393 > busy: boolean;
394 > children?: never;
395 > uri: UriComponents | undefined;
396 > range: IRange | null;
397 > description: string | null;
398 > error: string | IMarkdownString | null;
399 > sortText: string | null;
400 > }
401 >
402 > export const serialize = (item: Readonly<ITestItem>): Serialized => ({
403 extId: item.extId,
404 label: item.label,
412 sortText: item.sortText
413 });
414 > testTypes.ts
415 > export const deserialize = (uriIdentity: ITestUriCanonicalizer, serialized: Serialized): ITestItem => ({
416 extId: serialized.extId,
417 label: serialized.label,
425 sortText: serialized.sortText
426 });
427 > } testTypes.ts
428 >
429 > export const enum TestItemExpandState {
430 > NotExpandable,
431 > Expandable,
432 > BusyExpanding,
433 > Expanded,
434 > }
435 >
436 > /**
437 > * TestItem-like shape, but with an ID and children as strings.
438 > */
439 > export interface InternalTestItem {
440 > /** Controller ID from whence this test came */
441 > controllerId: string;
442 > /** Expandability state */
443 > expand: TestItemExpandState;
444 > /** Raw test item properties */
445 > item: ITestItem;
446 > }
447 >
448 > export namespace InternalTestItem {
449 > export interface Serialized {
450 > expand: TestItemExpandState;
451 > item: ITestItem.Serialized;
452 > }
453 >
454 > export const serialize = (item: Readonly<InternalTestItem>): Serialized => ({
455 expand: item.expand,
456 item: ITestItem.serialize(item.item)
457 });
458 > testTypes.ts
459 > export const deserialize = (uriIdentity: ITestUriCanonicalizer, serialized: Serialized): InternalTestItem => ({
460 // the `controllerId` is derived from the test.item.extId. It's redundant
461 // in the non-serialized InternalTestItem too, but there just because it's
465 item: ITestItem.deserialize(uriIdentity, serialized.item)
466 });
467 > } testTypes.ts
468 >
469 > /**
470 > * A partial update made to an existing InternalTestItem.
471 > */
472 > export interface ITestItemUpdate {
473 > extId: string;
474 > expand?: TestItemExpandState;
475 > item?: Partial<ITestItem>;
476 > }
477 >
478 > export namespace ITestItemUpdate {
479 > export interface Serialized {
480 > extId: string;
481 > expand?: TestItemExpandState;
482 > item?: Partial<ITestItem.Serialized>;
483 > }
484 >
485 > export const serialize = (u: Readonly<ITestItemUpdate>): Serialized => {
486 let item: Partial<ITestItem.Serialized> | undefined;
487 if (u.item) {
499 return { extId: u.extId, expand: u.expand, item };
500 };
501 > testTypes.ts
502 > export const deserialize = (u: Serialized): ITestItemUpdate => {
503 let item: Partial<ITestItem> | undefined;
504 if (u.item) {
515 return { extId: u.extId, expand: u.expand, item };
516 };
517 > testTypes.ts
518 > }
519 >
520 > export const applyTestItemUpdate = (internal: InternalTestItem | ITestItemUpdate, patch: ITestItemUpdate) => {
521 if (patch.expand !== undefined) {
522 internal.expand = patch.expand;
526 }
527 };
528 > testTypes.ts
529 > /** Request to an ext host to get followup messages for a test failure. */
530 > export interface TestMessageFollowupRequest {
531 > resultId: string;
532 > extId: string;
533 > taskIndex: number;
534 > messageIndex: number;
535 > }
536 >
537 > /** Request to an ext host to get followup messages for a test failure. */
538 > export interface TestMessageFollowupResponse {
539 > id: number;
540 > title: string;
541 > }
542 >
543 > /**
544 > * Test result item used in the main thread.
545 > */
546 > export interface TestResultItem extends InternalTestItem {
547 > /** State of this test in various tasks */
548 > tasks: ITestTaskState[];
549 > /** State of this test as a computation of its tasks */
550 > ownComputedState: TestResultState;
551 > /** Computed state based on children */
552 > computedState: TestResultState;
553 > /** Max duration of the item's tasks (if run directly) */
554 > ownDuration?: number;
555 > /** Whether this test item is outdated */
556 > retired?: boolean;
557 > }
558 >
559 > export namespace TestResultItem {
560 > /**
561 > * Serialized version of the TestResultItem. Note that 'retired' is not
562 > * included since all hydrated items are automatically retired.
563 > */
564 > export interface Serialized extends InternalTestItem.Serialized {
565 > tasks: ITestTaskState.Serialized[];
566 > ownComputedState: TestResultState;
567 > computedState: TestResultState;
568 > }
569 >
570 > export const serializeWithoutMessages = (original: TestResultItem): Serialized => ({
571 ...InternalTestItem.serialize(original),
572 ownComputedState: original.ownComputedState,
574 tasks: original.tasks.map(ITestTaskState.serializeWithoutMessages),
575 });
576 > testTypes.ts
577 > export const serialize = (original: Readonly<TestResultItem>): Serialized => ({
578 ...InternalTestItem.serialize(original),
579 ownComputedState: original.ownComputedState,
581 tasks: original.tasks.map(ITestTaskState.serialize),
582 });
583 > testTypes.ts
584 > export const deserialize = (uriIdentity: ITestUriCanonicalizer, serialized: Serialized): TestResultItem => ({
585 ...InternalTestItem.deserialize(uriIdentity, serialized),
586 ownComputedState: serialized.ownComputedState,
589 retired: true,
590 });
591 > } testTypes.ts
592 >
593 > export interface ISerializedTestResults {
594 > /** ID of these test results */
595 > id: string;
596 > /** Time the results were compelted */
597 > completedAt: number;
598 > /** Subset of test result items */
599 > items: TestResultItem.Serialized[];
600 > /** Tasks involved in the run. */
601 > tasks: { id: string; name: string | undefined; ctrlId: string; hasCoverage: boolean }[];
602 > /** Human-readable name of the test run. */
603 > name: string;
604 > /** Test trigger informaton */
605 > request: ResolvedTestRunRequest;
606 > }
607 >
608 > export interface ITestCoverage {
609 > files: IFileCoverage[];
610 > }
611 >
612 > export interface ICoverageCount {
613 > covered: number;
614 > total: number;
615 > }
616 >
617 > export namespace ICoverageCount {
618 > export const empty = (): ICoverageCount => ({ covered: 0, total: 0 });
619 > export const sum = (target: ICoverageCount, src: Readonly<ICoverageCount>) => {
620 target.covered += src.covered;
621 target.total += src.total;
622 };
623 > } testTypes.ts
624 >
625 > export interface IFileCoverage {
626 > id: string;
627 > uri: URI;
628 > testIds?: string[];
629 > statement: ICoverageCount;
630 > branch?: ICoverageCount;
631 > declaration?: ICoverageCount;
632 > }
633 >
634 > export namespace IFileCoverage {
635 > export interface Serialized {
636 > id: string;
637 > uri: UriComponents;
638 > testIds: string[] | undefined;
639 > statement: ICoverageCount;
640 > branch?: ICoverageCount;
641 > declaration?: ICoverageCount;
642 > }
643 >
644 > export const serialize = (original: Readonly<IFileCoverage>): Serialized => ({
645 id: original.id,
646 statement: original.statement,
650 uri: original.uri.toJSON(),
651 });
652 > testTypes.ts
653 > export const deserialize = (uriIdentity: ITestUriCanonicalizer, serialized: Serialized): IFileCoverage => ({
654 id: serialized.id,
655 statement: serialized.statement,
659 uri: uriIdentity.asCanonicalUri(URI.revive(serialized.uri)),
660 });
661 > testTypes.ts
662 > export const empty = (id: string, uri: URI): IFileCoverage => ({
663 id,
664 uri,
665 statement: ICoverageCount.empty(),
666 });
667 > } testTypes.ts
668 >
669 function serializeThingWithLocation<T extends { location?: Range | Position }>(serialized: T): T & { location?: IRange | IPosition } {
670 return {
673 };
674 }
675 > testTypes.ts
676 function deserializeThingWithLocation<T extends { location?: IRange | IPosition }>(serialized: T): T & { location?: Range | Position } {
677 serialized.location = serialized.location ? (Position.isIPosition(serialized.location) ? Position.lift(serialized.location) : Range.lift(serialized.location)) : undefined;
678 return serialized as T & { location?: Range | Position };
679 }
680 > testTypes.ts
681 > /** Number of recent runs in which coverage reports should be retained. */
682 > export const KEEP_N_LAST_COVERAGE_REPORTS = 3;
683 >
684 > export const enum DetailType {
685 > Declaration,
686 > Statement,
687 > Branch,
688 > }
689 >
690 > export type CoverageDetails = IDeclarationCoverage | IStatementCoverage;
691 >
692 > export namespace CoverageDetails {
693 > export type Serialized = IDeclarationCoverage.Serialized | IStatementCoverage.Serialized;
694 >
695 > export const serialize = (original: Readonly<CoverageDetails>): Serialized =>
696 original.type === DetailType.Declaration ? IDeclarationCoverage.serialize(original) : IStatementCoverage.serialize(original);
697 > testTypes.ts
698 > export const deserialize = (serialized: Serialized): CoverageDetails =>
699 serialized.type === DetailType.Declaration ? IDeclarationCoverage.deserialize(serialized) : IStatementCoverage.deserialize(serialized);
700 > } testTypes.ts
701 >
702 > export interface IBranchCoverage {
703 > count: number | boolean;
704 > label?: string;
705 > location?: Range | Position;
706 > }
707 >
708 > export namespace IBranchCoverage {
709 > export interface Serialized {
710 > count: number | boolean;
711 > label?: string;
712 > location?: IRange | IPosition;
713 > }
714 >
715 > export const serialize: (original: IBranchCoverage) => Serialized = serializeThingWithLocation;
716 > export const deserialize: (original: Serialized) => IBranchCoverage = deserializeThingWithLocation;
717 > }
718 >
719 > export interface IDeclarationCoverage {
720 > type: DetailType.Declaration;
721 > name: string;
722 > count: number | boolean;
723 > location: Range | Position;
724 > }
725 >
726 > export namespace IDeclarationCoverage {
727 > export interface Serialized {
728 > type: DetailType.Declaration;
729 > name: string;
730 > count: number | boolean;
731 > location: IRange | IPosition;
732 > }
733 >
734 > export const serialize: (original: IDeclarationCoverage) => Serialized = serializeThingWithLocation;
735 > export const deserialize: (original: Serialized) => IDeclarationCoverage = deserializeThingWithLocation;
736 > }
737 >
738 > export interface IStatementCoverage {
739 > type: DetailType.Statement;
740 > count: number | boolean;
741 > location: Range | Position;
742 > branches?: IBranchCoverage[];
743 > }
744 >
745 > export namespace IStatementCoverage {
746 > export interface Serialized {
747 > type: DetailType.Statement;
748 > count: number | boolean;
749 > location: IRange | IPosition;
750 > branches?: IBranchCoverage.Serialized[];
751 > }
752 >
753 > export const serialize = (original: Readonly<IStatementCoverage>): Serialized => ({
754 ...serializeThingWithLocation(original),
755 branches: original.branches?.map(IBranchCoverage.serialize),
756 });
757 > testTypes.ts
758 > export const deserialize = (serialized: Serialized): IStatementCoverage => ({
759 ...deserializeThingWithLocation(serialized),
760 branches: serialized.branches?.map(IBranchCoverage.deserialize),
761 });
762 > } testTypes.ts
763 >
764 > export const enum TestDiffOpType {
765 > /** Adds a new test (with children) */
766 > Add,
767 > /** Shallow-updates an existing test */
768 > Update,
769 > /** Ranges of some tests in a document were synced, so it should be considered up-to-date */
770 > DocumentSynced,
771 > /** Removes a test (and all its children) */
772 > Remove,
773 > /** Changes the number of controllers who are yet to publish their collection roots. */
774 > IncrementPendingExtHosts,
775 > /** Retires a test/result */
776 > Retire,
777 > /** Add a new test tag */
778 > AddTag,
779 > /** Remove a test tag */
780 > RemoveTag,
781 > }
782 >
783 > export type TestsDiffOp =
784 > | { op: TestDiffOpType.Add; item: InternalTestItem }
785 > | { op: TestDiffOpType.Update; item: ITestItemUpdate }
786 > | { op: TestDiffOpType.Remove; itemId: string }
787 > | { op: TestDiffOpType.Retire; itemId: string }
788 > | { op: TestDiffOpType.IncrementPendingExtHosts; amount: number }
789 > | { op: TestDiffOpType.AddTag; tag: ITestTagDisplayInfo }
790 > | { op: TestDiffOpType.RemoveTag; id: string }
791 > | { op: TestDiffOpType.DocumentSynced; uri: URI; docv?: number };
792 >
793 > export namespace TestsDiffOp {
794 > export type Serialized =
795 > | { op: TestDiffOpType.Add; item: InternalTestItem.Serialized }
796 > | { op: TestDiffOpType.Update; item: ITestItemUpdate.Serialized }
797 > | { op: TestDiffOpType.Remove; itemId: string }
798 > | { op: TestDiffOpType.Retire; itemId: string }
799 > | { op: TestDiffOpType.IncrementPendingExtHosts; amount: number }
800 > | { op: TestDiffOpType.AddTag; tag: ITestTagDisplayInfo }
801 > | { op: TestDiffOpType.RemoveTag; id: string }
802 > | { op: TestDiffOpType.DocumentSynced; uri: UriComponents; docv?: number };
803 >
804 > export const deserialize = (uriIdentity: ITestUriCanonicalizer, u: Serialized): TestsDiffOp => {
805 if (u.op === TestDiffOpType.Add) {
806 return { op: u.op, item: InternalTestItem.deserialize(uriIdentity, u.item) };
813 }
814 };
815 > testTypes.ts
816 > export const serialize = (u: Readonly<TestsDiffOp>): Serialized => {
817 if (u.op === TestDiffOpType.Add) {
818 return { op: u.op, item: InternalTestItem.serialize(u.item) };
823 }
824 };
825 > } testTypes.ts
826 >
827 > /**
828 > * Context for actions taken in the test explorer view.
829 > */
830 > export interface ITestItemContext {
831 > /** Marshalling marker */
832 > $mid: MarshalledId.TestItemContext;
833 > /** Tests and parents from the root to the current items */
834 > tests: InternalTestItem.Serialized[];
835 > }
836 >
837 > /**
838 > * Context for actions taken in the test explorer view.
839 > */
840 > export interface ITestMessageMenuArgs {
841 > /** Marshalling marker */
842 > $mid: MarshalledId.TestMessageMenuArgs;
843 > /** Tests ext ID */
844 > test: InternalTestItem.Serialized;
845 > /** Serialized test message */
846 > message: ITestMessage.Serialized;
847 > }
848 >
849 > /**
850 > * Request from the ext host or main thread to indicate that tests have
851 > * changed. It's assumed that any item upserted *must* have its children
852 > * previously also upserted, or upserted as part of the same operation.
853 > * Children that no longer exist in an upserted item will be removed.
854 > */
855 > export type TestsDiff = TestsDiffOp[];
856 >
857 > /**
858 > * @private
859 > */
860 > export interface IncrementalTestCollectionItem extends InternalTestItem {
861 > children: Set<string>;
862 > }
863 >
864 > /**
865 > * The IncrementalChangeCollector is used in the IncrementalTestCollection
866 > * and called with diff changes as they're applied. This is used in the
867 > * ext host to create a cohesive change event from a diff.
868 > */
869 > export interface IncrementalChangeCollector<T> {
870 > /**
871 > * A node was added.
872 > */
873 > add?(node: T): void;
874 >
875 > /**
876 > * A node in the collection was updated.
877 > */
878 > update?(node: T): void;
879 >
880 > /**
881 > * A node was removed.
882 > */
883 > remove?(node: T, isNestedOperation: boolean): void;
884 >
885 > /**
886 > * Called when the diff has been applied.
887 > */
888 > complete?(): void;
889 > }
890 >
891 > /**
892 > * Maintains tests in this extension host sent from the main thread.
893 > */
894 > export abstract class AbstractIncrementalTestCollection<T extends IncrementalTestCollectionItem> {
895 > private readonly _tags = new Map<string, ITestTagDisplayInfo>();
896 >
897 > /**
898 > * Map of item IDs to test item objects.
899 > */
900 > protected readonly items = new Map<string, T>();
901 >
902 > /**
903 > * ID of test root items.
904 > */
905 > protected readonly roots = new Set<T>();
906 >
907 > /**
908 > * Number of 'busy' controllers.
909 > */
910 > protected busyControllerCount = 0;
911 >
912 > /**
913 > * Number of pending roots.
914 > */
915 > protected pendingRootCount = 0;
916 >
917 > /**
918 > * Known test tags.
919 > */
920 > public readonly tags: ReadonlyMap<string, ITestTagDisplayInfo> = this._tags;
921 >
922 > constructor(private readonly uriIdentity: ITestUriCanonicalizer) { }
923 >
924 > /**
925 > * Applies the diff to the collection.
926 > */
927 > public apply(diff: TestsDiff) {
928 const changes = this.createChangeCollector();
929
962 changes.complete?.();
963 }
964 > testTypes.ts
965 > protected add(item: InternalTestItem, changes: IncrementalChangeCollector<T>
966 ) {
967 const parentId = TestId.parentId(item.item.extId)?.toString();
988 return created;
989 }
990 > testTypes.ts
991 > protected update(patch: ITestItemUpdate, changes: IncrementalChangeCollector<T>
992 ) {
993 const existing = this.items.get(patch.extId);
1009 return existing;
1010 }
1011 > testTypes.ts
1012 > protected remove(itemId: string, changes: IncrementalChangeCollector<T>) {
1013 const toRemove = this.items.get(itemId);
1014 if (!toRemove) {
1040 }
1041 }
1042 > testTypes.ts
1043 > /**
1044 > * Called when the extension signals a test result should be retired.
1045 > */
1046 > protected retireTest(testId: string) {
1047 // no-op
1048 }
1049 > testTypes.ts
1050 > /**
1051 > * Updates the number of test root sources who are yet to report. When
1052 > * the total pending test roots reaches 0, the roots for all controllers
1053 > * will exist in the collection.
1054 > */
1055 > public updatePendingRoots(delta: number) {
1056 this.pendingRootCount += delta;
1057 }
1058 > testTypes.ts
1059 > /**
1060 > * Called before a diff is applied to create a new change collector.
1061 > */
1062 > protected createChangeCollector(): IncrementalChangeCollector<T> {
1063 return {};
1064 }
1065 > testTypes.ts
1066 > /**
1067 > * Creates a new item for the collection from the internal test item.
1068 > */
1069 > protected abstract createItem(internal: InternalTestItem, parent?: T): T;
1070 > }
src/vs/workbench/contrib/scm/common/scm.ts 266 introduced LOC · 1 range

Open complete file

1 > /*--------------------------------------------------------------------------------------------- scm.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 { URI } from '../../../../base/common/uri.js';
7 > import { createDecorator } from '../../../../platform/instantiation/common/instantiation.js';
8 > import { Event } from '../../../../base/common/event.js';
9 > import { IDisposable } from '../../../../base/common/lifecycle.js';
10 > import { Command } from '../../../../editor/common/languages.js';
11 > import { IAction } from '../../../../base/common/actions.js';
12 > import { IMenu } from '../../../../platform/actions/common/actions.js';
13 > import { ThemeIcon } from '../../../../base/common/themables.js';
14 > import { IMarkdownString } from '../../../../base/common/htmlContent.js';
15 > import { ResourceTree } from '../../../../base/common/resourceTree.js';
16 > import { ISCMHistoryProvider } from './history.js';
17 > import { ITextModel } from '../../../../editor/common/model.js';
18 > import { IObservable } from '../../../../base/common/observable.js';
19 > import { ISCMArtifact, ISCMArtifactGroup, ISCMArtifactProvider } from './artifact.js';
20 >
21 > export const VIEWLET_ID = 'workbench.view.scm';
22 > export const VIEW_PANE_ID = 'workbench.scm';
23 > export const REPOSITORIES_VIEW_PANE_ID = 'workbench.scm.repositories';
24 > export const HISTORY_VIEW_PANE_ID = 'workbench.scm.history';
25 >
26 > export const enum ViewMode {
27 > List = 'list',
28 > Tree = 'tree'
29 > }
30 >
31 > export interface IBaselineResourceProvider {
32 > getBaselineResource(resource: URI): Promise<URI>;
33 > }
34 >
35 > export const ISCMService = createDecorator<ISCMService>('scm');
36 >
37 > export interface ISCMResourceDecorations {
38 > icon?: URI | ThemeIcon;
39 > iconDark?: URI | ThemeIcon;
40 > tooltip?: string;
41 > strikeThrough?: boolean;
42 > faded?: boolean;
43 > }
44 >
45 > export interface ISCMResource {
46 > readonly resourceGroup: ISCMResourceGroup;
47 > readonly sourceUri: URI;
48 > readonly decorations: ISCMResourceDecorations;
49 > readonly contextValue: string | undefined;
50 > readonly command: Command | undefined;
51 > readonly multiDiffEditorOriginalUri: URI | undefined;
52 > readonly multiDiffEditorModifiedUri: URI | undefined;
53 > open(preserveFocus: boolean): Promise<void>;
54 > }
55 >
56 > export interface ISCMResourceGroup {
57 > readonly id: string;
58 > readonly provider: ISCMProvider;
59 >
60 > readonly resources: readonly ISCMResource[];
61 > readonly resourceTree: ResourceTree<ISCMResource, ISCMResourceGroup>;
62 > readonly onDidChangeResources: Event<void>;
63 >
64 > readonly label: string;
65 > contextValue: string | undefined;
66 > readonly hideWhenEmpty: boolean;
67 > readonly onDidChange: Event<void>;
68 >
69 > readonly multiDiffEditorEnableViewChanges: boolean;
70 > }
71 >
72 > export interface ISCMProvider extends IDisposable {
73 > readonly id: string;
74 > readonly parentId?: string;
75 > readonly providerId: string;
76 > readonly label: string;
77 > readonly name: string;
78 >
79 > readonly groups: readonly ISCMResourceGroup[];
80 > readonly onDidChangeResourceGroups: Event<void>;
81 > readonly onDidChangeResources: Event<void>;
82 >
83 > readonly rootUri?: URI;
84 > readonly iconPath?: URI | { light: URI; dark: URI } | ThemeIcon;
85 > readonly isHidden?: boolean;
86 > readonly inputBoxTextModel: ITextModel;
87 > readonly contextValue: IObservable<string | undefined>;
88 > readonly count: IObservable<number | undefined>;
89 > readonly commitTemplate: IObservable<string>;
90 > readonly artifactProvider: IObservable<ISCMArtifactProvider | undefined>;
91 > readonly historyProvider: IObservable<ISCMHistoryProvider | undefined>;
92 > readonly acceptInputCommand?: Command;
93 > readonly actionButton: IObservable<ISCMActionButtonDescriptor | undefined>;
94 > readonly statusBarCommands: IObservable<readonly Command[] | undefined>;
95 >
96 > getOriginalResource(uri: URI): Promise<URI | null>;
97 > }
98 >
99 > export interface ISCMInputValueProviderContext {
100 > readonly resourceGroupId: string;
101 > readonly resources: readonly URI[];
102 > }
103 >
104 > export const enum InputValidationType {
105 > Error = 0,
106 > Warning = 1,
107 > Information = 2
108 > }
109 >
110 > export interface IInputValidation {
111 > message: string | IMarkdownString;
112 > type: InputValidationType;
113 > }
114 >
115 > export interface IInputValidator {
116 > (value: string, cursorPosition: number): Promise<IInputValidation | undefined>;
117 > }
118 >
119 > export enum SCMInputChangeReason {
120 > HistoryPrevious,
121 > HistoryNext
122 > }
123 >
124 > export interface ISCMInputChangeEvent {
125 > readonly value: string;
126 > readonly reason?: SCMInputChangeReason;
127 > }
128 >
129 > export interface ISCMActionButtonDescriptor {
130 > command: Command & { shortTitle?: string };
131 > secondaryCommands?: Command[][];
132 > enabled: boolean;
133 > }
134 >
135 > export interface ISCMActionButton {
136 > readonly type: 'actionButton';
137 > readonly repository: ISCMRepository;
138 > readonly button: ISCMActionButtonDescriptor;
139 > }
140 >
141 > export interface ISCMInput {
142 > readonly repository: ISCMRepository;
143 >
144 > readonly value: string;
145 > setValue(value: string, fromKeyboard: boolean): void;
146 > readonly onDidChange: Event<ISCMInputChangeEvent>;
147 >
148 > placeholder: string;
149 > readonly onDidChangePlaceholder: Event<string>;
150 >
151 > validateInput: IInputValidator;
152 > readonly onDidChangeValidateInput: Event<void>;
153 >
154 > enabled: boolean;
155 > readonly onDidChangeEnablement: Event<boolean>;
156 >
157 > visible: boolean;
158 > readonly onDidChangeVisibility: Event<boolean>;
159 >
160 > setFocus(): void;
161 > readonly onDidChangeFocus: Event<void>;
162 >
163 > showValidationMessage(message: string | IMarkdownString, type: InputValidationType): void;
164 > readonly onDidChangeValidationMessage: Event<IInputValidation>;
165 >
166 > clearValidation(): void;
167 > readonly onDidClearValidation: Event<void>;
168 >
169 > showNextHistoryValue(): void;
170 > showPreviousHistoryValue(): void;
171 > }
172 >
173 > export interface ISCMRepository extends IDisposable {
174 > readonly id: string;
175 > readonly provider: ISCMProvider;
176 > readonly input: ISCMInput;
177 > }
178 >
179 > export interface ISCMService {
180 >
181 > readonly _serviceBrand: undefined;
182 > readonly onDidAddRepository: Event<ISCMRepository>;
183 > readonly onDidRemoveRepository: Event<ISCMRepository>;
184 > readonly repositories: Iterable<ISCMRepository>;
185 > readonly repositoryCount: number;
186 >
187 > registerSCMProvider(provider: ISCMProvider): ISCMRepository;
188 >
189 > getRepository(id: string): ISCMRepository | undefined;
190 > getRepository(resource: URI): ISCMRepository | undefined;
191 > }
192 >
193 > export interface ISCMTitleMenu {
194 > readonly actions: IAction[];
195 > readonly secondaryActions: IAction[];
196 > readonly onDidChangeTitle: Event<void>;
197 > readonly menu: IMenu;
198 > }
199 >
200 > export interface ISCMRepositoryMenus {
201 > readonly titleMenu: ISCMTitleMenu;
202 > getRepositoryMenu(repository: ISCMRepository): IMenu;
203 > getRepositoryContextMenu(repository: ISCMRepository): IMenu;
204 > getResourceGroupMenu(group: ISCMResourceGroup): IMenu;
205 > getResourceMenu(resource: ISCMResource): IMenu;
206 > getResourceFolderMenu(group: ISCMResourceGroup): IMenu;
207 > getArtifactGroupMenu(artifactGroup: ISCMArtifactGroup): IMenu;
208 > getArtifactMenu(artifactGroup: ISCMArtifactGroup, artifact: ISCMArtifact): IMenu;
209 > }
210 >
211 > export interface ISCMMenus {
212 > getRepositoryMenus(provider: ISCMProvider): ISCMRepositoryMenus;
213 > }
214 >
215 > export const enum ISCMRepositorySortKey {
216 > DiscoveryTime = 'discoveryTime',
217 > Name = 'name',
218 > Path = 'path'
219 > }
220 >
221 > export const enum ISCMRepositorySelectionMode {
222 > Single = 'single',
223 > Multiple = 'multiple'
224 > }
225 >
226 > export const ISCMViewService = createDecorator<ISCMViewService>('scmView');
227 >
228 > export interface ISCMViewVisibleRepositoryChangeEvent {
229 > readonly added: Iterable<ISCMRepository>;
230 > readonly removed: Iterable<ISCMRepository>;
231 > }
232 >
233 > export interface ISCMViewService {
234 > readonly _serviceBrand: undefined;
235 >
236 > readonly menus: ISCMMenus;
237 > readonly selectionModeConfig: IObservable<ISCMRepositorySelectionMode>;
238 > readonly explorerEnabledConfig: IObservable<boolean>;
239 > readonly graphShowIncomingChangesConfig: IObservable<boolean>;
240 > readonly graphShowOutgoingChangesConfig: IObservable<boolean>;
241 >
242 > repositories: ISCMRepository[];
243 > readonly onDidChangeRepositories: Event<ISCMViewVisibleRepositoryChangeEvent>;
244 > readonly didFinishLoadingRepositories: IObservable<boolean>;
245 >
246 > visibleRepositories: readonly ISCMRepository[];
247 > readonly onDidChangeVisibleRepositories: Event<ISCMViewVisibleRepositoryChangeEvent>;
248 >
249 > isVisible(repository: ISCMRepository): boolean;
250 > toggleVisibility(repository: ISCMRepository, visible?: boolean): void;
251 >
252 > toggleSortKey(sortKey: ISCMRepositorySortKey): void;
253 > toggleSelectionMode(selectionMode: ISCMRepositorySelectionMode): void;
254 >
255 > readonly focusedRepository: ISCMRepository | undefined;
256 > readonly onDidFocusRepository: Event<ISCMRepository | undefined>;
257 > focus(repository: ISCMRepository): void;
258 >
259 > /**
260 > * The active repository is the repository selected in the Source Control Repositories view
261 > * or the repository associated with the active editor. The active repository is shown in the
262 > * Source Control Repository status bar item.
263 > */
264 > readonly activeRepository: IObservable<{ repository: ISCMRepository; pinned: boolean } | undefined>;
265 > pinActiveRepository(repository: ISCMRepository | undefined): void;
266 > }
src/vs/workbench/contrib/testing/common/testItemCollection.ts 255 introduced LOC · 29 ranges

Open complete file

1 > /*--------------------------------------------------------------------------------------------- testItemCollection.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 { Barrier, isThenable, RunOnceScheduler } from '../../../../base/common/async.js';
7 > import { Emitter } from '../../../../base/common/event.js';
8 > import { Disposable } from '../../../../base/common/lifecycle.js';
9 > import { assertNever } from '../../../../base/common/assert.js';
10 > import { applyTestItemUpdate, ITestItem, ITestTag, namespaceTestTag, TestDiffOpType, TestItemExpandState, TestsDiff, TestsDiffOp } from './testTypes.js';
11 > import { TestId } from './testId.js';
12 > import { URI } from '../../../../base/common/uri.js';
13 >
14 > /**
15 > * @private
16 > */
17 > interface CollectionItem<T> {
18 > readonly fullId: TestId;
19 > actual: T;
20 > expand: TestItemExpandState;
21 > /**
22 > * Number of levels of items below this one that are expanded. May be infinite.
23 > */
24 > expandLevels?: number;
25 > resolveBarrier?: Barrier;
26 > }
27 >
28 > export const enum TestItemEventOp {
29 > Upsert,
30 > SetTags,
31 > UpdateCanResolveChildren,
32 > RemoveChild,
33 > SetProp,
34 > Bulk,
35 > DocumentSynced,
36 > }
37 >
38 > export interface ITestItemUpsertChild {
39 > op: TestItemEventOp.Upsert;
40 > item: ITestItemLike;
41 > }
42 >
43 > export interface ITestItemUpdateCanResolveChildren {
44 > op: TestItemEventOp.UpdateCanResolveChildren;
45 > state: boolean;
46 > }
47 >
48 > export interface ITestItemSetTags {
49 > op: TestItemEventOp.SetTags;
50 > new: ITestTag[];
51 > old: ITestTag[];
52 > }
53 >
54 > export interface ITestItemRemoveChild {
55 > op: TestItemEventOp.RemoveChild;
56 > id: string;
57 > }
58 >
59 > export interface ITestItemSetProp {
60 > op: TestItemEventOp.SetProp;
61 > update: Partial<ITestItem>;
62 > }
63 > export interface ITestItemBulkReplace {
64 > op: TestItemEventOp.Bulk;
65 > ops: (ITestItemUpsertChild | ITestItemRemoveChild)[];
66 > }
67 >
68 > export interface ITestItemDocumentSynced {
69 > op: TestItemEventOp.DocumentSynced;
70 > }
71 >
72 > export type ExtHostTestItemEvent =
73 > | ITestItemSetTags
74 > | ITestItemUpsertChild
75 > | ITestItemRemoveChild
76 > | ITestItemUpdateCanResolveChildren
77 > | ITestItemSetProp
78 > | ITestItemBulkReplace
79 > | ITestItemDocumentSynced;
80 >
81 > export interface ITestItemApi<T> {
82 > controllerId: string;
83 > parent?: T;
84 > listener?: (evt: ExtHostTestItemEvent) => void;
85 > }
86 >
87 > export interface ITestItemCollectionOptions<T> {
88 > /** Controller ID to use to prefix these test items. */
89 > controllerId: string;
90 >
91 > /** Gets the document version at the given URI, if it's open */
92 > getDocumentVersion(uri: URI | undefined): number | undefined;
93 >
94 > /** Gets API for the given test item, used to listen for events and set parents. */
95 > getApiFor(item: T): ITestItemApi<T>;
96 >
97 > /** Converts the full test item to the common interface. */
98 > toITestItem(item: T): ITestItem;
99 >
100 > /** Gets children for the item. */
101 > getChildren(item: T): ITestChildrenLike<T>;
102 >
103 > /** Root to use for the new test collection. */
104 > root: T;
105 > }
106 >
107 > const strictEqualComparator = <T>(a: T, b: T) => a === b;
108 > const diffableProps: { [K in keyof ITestItem]?: (a: ITestItem[K], b: ITestItem[K]) => boolean } = {
109 > range: (a, b) => {
110 if (a === b) { return true; }
111 if (!a || !b) { return false; }
112 return a.equalsRange(b);
113 },
114 > busy: strictEqualComparator, testItemCollection.ts
115 > label: strictEqualComparator,
116 > description: strictEqualComparator,
117 > error: strictEqualComparator,
118 > sortText: strictEqualComparator,
119 > tags: (a, b) => {
120 if (a.length !== b.length) {
121 return false;
128 return true;
129 },
131 >
132 > const diffableEntries = Object.entries(diffableProps) as readonly [keyof ITestItem, (a: unknown, b: unknown) => boolean][];
133 >
134 > const diffTestItems = (a: ITestItem, b: ITestItem) => {
135 let output: Record<string, unknown> | undefined;
136 for (const [key, cmp] of diffableEntries) {
146 return output as Partial<ITestItem> | undefined;
147 };
149 > export interface ITestChildrenLike<T> extends Iterable<[string, T]> {
150 > get(id: string): T | undefined;
151 > delete(id: string): void;
152 > }
153 >
154 > export interface ITestItemLike {
155 > id: string;
156 > tags: readonly ITestTag[];
157 > uri?: URI;
158 > canResolveChildren: boolean;
159 > }
160 >
161 > /**
162 > * Maintains a collection of test items for a single controller.
163 > */
164 > export class TestItemCollection<T extends ITestItemLike> extends Disposable {
165 > private readonly debounceSendDiff = this._register(new RunOnceScheduler(() => this.flushDiff(), 200));
166 > private readonly diffOpEmitter = this._register(new Emitter<TestsDiff>());
167 > private _resolveHandler?: (item: T | undefined) => Promise<void> | void;
168 >
169 > public get root() {
170 > return this.options.root;
171 > }
172 >
173 > public readonly tree = new Map</* full test id */string, CollectionItem<T>>();
174 > private readonly tags = new Map<string, { label?: string; refCount: number }>();
175 >
176 > protected diff: TestsDiff = [];
177 >
178 > constructor(private readonly options: ITestItemCollectionOptions<T>) {
179 super();
180 this.root.canResolveChildren = true;
181 this.upsertItem(this.root, undefined);
182 }
184 > /**
185 > * Handler used for expanding test items.
186 > */
187 > public set resolveHandler(handler: undefined | ((item: T | undefined) => void)) {
188 this._resolveHandler = handler;
189 for (const test of this.tree.values()) {
191 }
192 }
194 > public get resolveHandler() {
195 return this._resolveHandler;
196 }
198 > /**
199 > * Fires when an operation happens that should result in a diff.
200 > */
201 > public readonly onDidGenerateDiff = this.diffOpEmitter.event;
202 >
203 > /**
204 > * Gets a diff of all changes that have been made, and clears the diff queue.
205 > */
206 > public collectDiff() {
207 const diff = this.diff;
208 this.diff = [];
209 return diff;
210 }
212 > /**
213 > * Pushes a new diff entry onto the collected diff list.
214 > */
215 > public pushDiff(diff: TestsDiffOp) {
216 switch (diff.op) {
217 case TestDiffOpType.DocumentSynced: {
249 }
250 }
252 > /**
253 > * Expands the test and the given number of `levels` of children. If levels
254 > * is < 0, then all children will be expanded. If it's 0, then only this
255 > * item will be expanded.
256 > */
257 > public expand(testId: string, levels: number): Promise<void> | void {
258 const internal = this.tree.get(testId);
259 if (!internal) {
278 }
279 }
281 > public override dispose() {
282 for (const item of this.tree.values()) {
283 this.options.getApiFor(item.actual).listener = undefined;
288 super.dispose();
289 }
291 > private onTestItemEvent(internal: CollectionItem<T>, evt: ExtHostTestItemEvent) {
292 switch (evt.op) {
293 case TestItemEventOp.RemoveChild:
331 }
332 }
334 > private documentSynced(uri: URI | undefined) {
335 if (uri) {
336 this.pushDiff({
341 }
342 }
344 > private upsertItem(actual: T, parent: CollectionItem<T> | undefined): void {
345 const fullId = TestId.fromExtHostTestItem(actual, this.root.id, parent?.actual);
346
434 this.documentSynced(internal.actual.uri);
435 }
437 > private diffTagRefs(newTags: readonly ITestTag[], oldTags: readonly ITestTag[], extId: string) {
438 const toDelete = new Set(oldTags.map(t => t.id));
439 for (const tag of newTags) {
450 toDelete.forEach(this.decrementTagRefs, this);
451 }
453 > private incrementTagRefs(tag: ITestTag) {
454 const existing = this.tags.get(tag.id);
455 if (existing) {
464 }
465 }
467 > private decrementTagRefs(tagId: string) {
468 const existing = this.tags.get(tagId);
469 if (existing && !--existing.refCount) {
472 }
473 }
475 > private setItemParent(actual: T, parent: CollectionItem<T> | undefined) {
476 this.options.getApiFor(actual).parent = parent && parent.actual !== this.root ? parent.actual : undefined;
477 }
479 > private connectItem(actual: T, internal: CollectionItem<T>, parent: CollectionItem<T> | undefined) {
480 this.setItemParent(actual, parent);
481 const api = this.options.getApiFor(actual);
484 this.updateExpandability(internal);
485 }
487 > private connectItemAndChildren(actual: T, internal: CollectionItem<T>, parent: CollectionItem<T> | undefined) {
488 this.connectItem(actual, internal, parent);
489
493 }
494 }
496 > /**
497 > * Updates the `expand` state of the item. Should be called whenever the
498 > * resolved state of the item changes. Can automatically expand the item
499 > * if requested by a consumer.
500 > */
501 > private updateExpandability(internal: CollectionItem<T>) {
502 let newState: TestItemExpandState;
503 if (!this._resolveHandler) {
524 }
525 }
527 > /**
528 > * Expands all children of the item, "levels" deep. If levels is 0, only
529 > * the children will be expanded. If it's 1, the children and their children
530 > * will be expanded. If it's <0, it's a no-op.
531 > */
532 > private expandChildren(internal: CollectionItem<T>, levels: number): Promise<void> | void {
533 if (levels < 0) {
534 return;
547 }
548 }
550 > /**
551 > * Calls `discoverChildren` on the item, refreshing all its tests.
552 > */
553 > private resolveChildren(internal: CollectionItem<T>) {
554 if (internal.resolveBarrier) {
555 return internal.resolveBarrier;
589 return internal.resolveBarrier;
590 }
592 > private pushExpandStateUpdate(internal: CollectionItem<T>) {
593 this.pushDiff({ op: TestDiffOpType.Update, item: { extId: internal.fullId.toString(), expand: internal.expand } });
594 }
596 > private removeItem(childId: string) {
597 const childItem = this.tree.get(childId);
598 if (!childItem) {
621 }
622 }
624 > /**
625 > * Immediately emits any pending diffs on the collection.
626 > */
627 > public flushDiff() {
628 const diff = this.collectDiff();
629 if (diff.length) {
631 }
632 }
634 >
635 > /** Implementation of vscode.TestItemCollection */
636 > export interface ITestItemChildren<T extends ITestItemLike> extends Iterable<[string, T]> {
637 > readonly size: number;
638 > replace(items: readonly T[]): void;
639 > forEach(callback: (item: T, collection: this) => unknown, thisArg?: unknown): void;
640 > add(item: T): void;
641 > delete(itemId: string): void;
642 > get(itemId: string): T | undefined;
643 >
644 > toJSON(): readonly T[];
645 > }
646 >
647 > export class DuplicateTestItemError extends Error {
648 > constructor(id: string) {
649 super(`Attempted to insert a duplicate test item ID ${id}`);
650 }
652 >
653 > export class InvalidTestItemError extends Error {
654 > constructor(id: string) {
655 super(`TestItem with ID "${id}" is invalid. Make sure to create it from the createTestItem method.`);
656 }
658 >
659 > export class MixedTestItemController extends Error {
660 > constructor(id: string, ctrlA: string, ctrlB: string) {
661 super(`TestItem with ID "${id}" is from controller "${ctrlA}" and cannot be added as a child of an item from controller "${ctrlB}".`);
662 }
664 >
665 > export const createTestItemChildren = <T extends ITestItemLike>(api: ITestItemApi<T>, getApi: (item: T) => ITestItemApi<T>, checkCtor: Function): ITestItemChildren<T> => {
666 let mapped = new Map<string, T>();
667
src/vs/workbench/contrib/testing/common/testId.ts 158 introduced LOC · 23 ranges

Open complete file

1 > /*--------------------------------------------------------------------------------------------- testId.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 > export const enum TestIdPathParts {
7 > /** Delimiter for path parts in test IDs */
8 > Delimiter = '\0',
9 > }
10 >
11 > /**
12 > * Enum for describing relative positions of tests. Similar to
13 > * `node.compareDocumentPosition` in the DOM.
14 > */
15 > export const enum TestPosition {
16 > /** a === b */
17 > IsSame,
18 > /** Neither a nor b are a child of one another. They may share a common parent, though. */
19 > Disconnected,
20 > /** b is a child of a */
21 > IsChild,
22 > /** b is a parent of a */
23 > IsParent,
24 > }
25 >
26 > type TestItemLike = { id: string; parent?: TestItemLike; _isRoot?: boolean };
27 >
28 > /**
29 > * The test ID is a stringifiable client that
30 > */
31 > export class TestId {
32 > private stringifed?: string;
33 >
34 > /**
35 > * Creates a test ID from an ext host test item.
36 > */
37 > public static fromExtHostTestItem(item: TestItemLike, rootId: string, parent = item.parent) {
38 > if (item._isRoot) {
39 > return new TestId([rootId]);
40 > }
41 >
42 > const path = [item.id];
43 > for (let i = parent; i && i.id !== rootId; i = i.parent) {
44 > path.push(i.id);
45 > }
46 > path.push(rootId);
47 >
48 > return new TestId(path.reverse());
49 > }
50 >
51 > /**
52 > * Cheaply ets whether the ID refers to the root .
53 > */
54 > public static isRoot(idString: string) {
55 return !idString.includes(TestIdPathParts.Delimiter);
56 }
57 > testId.ts
58 > /**
59 > * Cheaply gets whether the ID refers to the root .
60 > */
61 > public static root(idString: string) {
62 const idx = idString.indexOf(TestIdPathParts.Delimiter);
63 return idx === -1 ? idString : idString.slice(0, idx);
64 }
65 > testId.ts
66 > /**
67 > * Creates a test ID from a serialized TestId instance.
68 > */
69 > public static fromString(idString: string) {
70 return new TestId(idString.split(TestIdPathParts.Delimiter));
71 }
72 > testId.ts
73 > /**
74 > * Gets the ID resulting from adding b to the base ID.
75 > */
76 > public static join(base: TestId, b: string) {
77 return new TestId([...base.path, b]);
78 }
79 > testId.ts
80 > /**
81 > * Splits a test ID into its parts.
82 > */
83 > public static split(idString: string) {
84 return idString.split(TestIdPathParts.Delimiter);
85 }
86 > testId.ts
87 > /**
88 > * Gets the string ID resulting from adding b to the base ID.
89 > */
90 > public static joinToString(base: string | TestId, b: string) {
91 return base.toString() + TestIdPathParts.Delimiter + b;
92 }
93 > testId.ts
94 > /**
95 > * Cheaply gets the parent ID of a test identified with the string.
96 > */
97 > public static parentId(idString: string) {
98 const idx = idString.lastIndexOf(TestIdPathParts.Delimiter);
99 return idx === -1 ? undefined : idString.slice(0, idx);
100 }
101 > testId.ts
102 > /**
103 > * Cheaply gets the local ID of a test identified with the string.
104 > */
105 > public static localId(idString: string) {
106 const idx = idString.lastIndexOf(TestIdPathParts.Delimiter);
107 return idx === -1 ? idString : idString.slice(idx + TestIdPathParts.Delimiter.length);
108 }
109 > testId.ts
110 > /**
111 > * Gets whether maybeChild is a child of maybeParent.
112 > * todo@connor4312: review usages of this to see if using the WellDefinedPrefixTree is better
113 > */
114 > public static isChild(maybeParent: string, maybeChild: string) {
115 return maybeChild[maybeParent.length] === TestIdPathParts.Delimiter && maybeChild.startsWith(maybeParent);
116 }
117 > testId.ts
118 > /**
119 > * Compares the position of the two ID strings.
120 > * todo@connor4312: review usages of this to see if using the WellDefinedPrefixTree is better
121 > */
122 > public static compare(a: string, b: string) {
123 if (a === b) {
124 return TestPosition.IsSame;
135 return TestPosition.Disconnected;
136 }
137 > testId.ts
138 > public static getLengthOfCommonPrefix(length: number, getId: (i: number) => TestId): number {
139 if (length === 0) {
140 return 0;
156 return commonPrefix;
157 }
158 > testId.ts
159 > constructor(
160 public readonly path: readonly string[],
161 private readonly viewEnd = path.length,
165 }
166 }
167 > testId.ts
168 > /**
169 > * Gets the ID of the parent test.
170 > */
171 > public get rootId(): TestId {
172 return new TestId(this.path, 1);
173 }
174 > testId.ts
175 > /**
176 > * Gets the ID of the parent test.
177 > */
178 > public get parentId(): TestId | undefined {
179 return this.viewEnd > 1 ? new TestId(this.path, this.viewEnd - 1) : undefined;
180 }
181 > testId.ts
182 > /**
183 > * Gets the local ID of the current full test ID.
184 > */
185 > public get localId() {
186 return this.path[this.viewEnd - 1];
187 }
188 > testId.ts
189 > /**
190 > * Gets whether this ID refers to the root.
191 > */
192 > public get controllerId() {
193 return this.path[0];
194 }
195 > testId.ts
196 > /**
197 > * Gets whether this ID refers to the root.
198 > */
199 > public get isRoot() {
200 return this.viewEnd === 1;
201 }
202 > testId.ts
203 > /**
204 > * Returns an iterable that yields IDs of all parent items down to and
205 > * including the current item.
206 > */
207 > public *idsFromRoot() {
208 for (let i = 1; i <= this.viewEnd; i++) {
209 yield new TestId(this.path, i);
210 }
211 }
212 > testId.ts
213 > /**
214 > * Returns an iterable that yields IDs of the current item up to the root
215 > * item.
216 > */
217 > public *idsToRoot() {
218 for (let i = this.viewEnd; i > 0; i--) {
219 yield new TestId(this.path, i);
220 }
221 }
222 > testId.ts
223 > /**
224 > * Compares the other test ID with this one.
225 > */
226 > public compare(other: TestId | string) {
227 if (typeof other === 'string') {
228 return TestId.compare(this.toString(), other);
245 return TestPosition.IsSame;
246 }
247 > testId.ts
248 > /**
249 > * Serializes the ID.
250 > */
251 > public toJSON() {
252 return this.toString();
253 }
254 > testId.ts
255 > /**
256 > * Serializes the ID to a string.
257 > */
258 > public toString() {
259 if (!this.stringifed) {
260 this.stringifed = this.path[0];
267 return this.stringifed;
268 }
269 > } testId.ts
src/vs/workbench/api/common/extHostTypes/notebooks.ts 125 introduced LOC · 29 ranges

Open complete file

1 > /*--------------------------------------------------------------------------------------------- notebooks.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 type * as vscode from 'vscode';
7 > import { es5ClassCompat } from './es5ClassCompat.js';
8 > import { illegalArgument } from '../../../../base/common/errors.js';
9 > import { Mimes, normalizeMimeType, isTextStreamMime } from '../../../../base/common/mime.js';
10 > import { generateUuid } from '../../../../base/common/uuid.js';
11 >
12 > export enum NotebookCellKind {
13 > Markup = 1,
14 > Code = 2
15 > }
16 >
17 > export class NotebookRange {
18 > static isNotebookRange(thing: unknown): thing is vscode.NotebookRange {
19 if (thing instanceof NotebookRange) {
20 return true;
26 && typeof (<NotebookRange>thing).end === 'number';
27 }
29 > private _start: number;
30 > private _end: number;
31 >
32 > get start() {
33 return this._start;
34 }
36 > get end() {
37 return this._end;
38 }
40 > get isEmpty(): boolean {
41 return this._start === this._end;
42 }
44 > constructor(start: number, end: number) {
45 if (start < 0) {
46 throw illegalArgument('start must be positive');
57 }
58 }
60 > with(change: { start?: number; end?: number }): NotebookRange {
61 let start = this._start;
62 let end = this._end;
73 return new NotebookRange(start, end);
74 }
75 > } notebooks.ts
76 >
77 > export class NotebookCellData {
78 >
79 > static validate(data: NotebookCellData): void {
80 if (typeof data.kind !== 'number') {
81 throw new Error('NotebookCellData MUST have \'kind\' property');
88 }
89 }
91 > static isNotebookCellDataArray(value: unknown): value is vscode.NotebookCellData[] {
92 return Array.isArray(value) && (<unknown[]>value).every(elem => NotebookCellData.isNotebookCellData(elem));
93 }
95 > static isNotebookCellData(value: unknown): value is vscode.NotebookCellData {
96 // return value instanceof NotebookCellData;
97 return true;
98 }
100 > kind: NotebookCellKind;
101 > value: string;
102 > languageId: string;
103 > mime?: string;
104 > outputs?: vscode.NotebookCellOutput[];
105 > metadata?: Record<string, unknown>;
106 > executionSummary?: vscode.NotebookCellExecutionSummary;
107 >
108 > constructor(kind: NotebookCellKind, value: string, languageId: string, mime?: string, outputs?: vscode.NotebookCellOutput[], metadata?: Record<string, unknown>, executionSummary?: vscode.NotebookCellExecutionSummary) {
109 this.kind = kind;
110 this.value = value;
117 NotebookCellData.validate(this);
118 }
119 > } notebooks.ts
120 >
121 > export class NotebookData {
122 >
123 > cells: NotebookCellData[];
124 > metadata?: { [key: string]: unknown };
125 >
126 > constructor(cells: NotebookCellData[]) {
127 this.cells = cells;
128 }
129 > } notebooks.ts
130 >
131 > @es5ClassCompat
132 > export class NotebookEdit implements vscode.NotebookEdit {
133 >
134 > static isNotebookCellEdit(thing: unknown): thing is NotebookEdit {
135 if (thing instanceof NotebookEdit) {
136 return true;
142 && Array.isArray((<NotebookEdit>thing).newCells);
143 }
144 > notebooks.ts
145 > static replaceCells(range: NotebookRange, newCells: NotebookCellData[]): NotebookEdit {
146 return new NotebookEdit(range, newCells);
147 }
148 > notebooks.ts
149 > static insertCells(index: number, newCells: vscode.NotebookCellData[]): vscode.NotebookEdit {
150 return new NotebookEdit(new NotebookRange(index, index), newCells);
151 }
152 > notebooks.ts
153 > static deleteCells(range: NotebookRange): NotebookEdit {
154 return new NotebookEdit(range, []);
155 }
156 > notebooks.ts
157 > static updateCellMetadata(index: number, newMetadata: { [key: string]: unknown }): NotebookEdit {
158 const edit = new NotebookEdit(new NotebookRange(index, index), []);
159 edit.newCellMetadata = newMetadata;
160 return edit;
161 }
162 > notebooks.ts
163 > static updateNotebookMetadata(newMetadata: { [key: string]: unknown }): NotebookEdit {
164 const edit = new NotebookEdit(new NotebookRange(0, 0), []);
165 edit.newNotebookMetadata = newMetadata;
166 return edit;
167 }
168 > notebooks.ts
169 > range: NotebookRange;
170 > newCells: NotebookCellData[];
171 > newCellMetadata?: { [key: string]: unknown };
172 > newNotebookMetadata?: { [key: string]: unknown };
173 >
174 > constructor(range: NotebookRange, newCells: NotebookCellData[]) {
175 this.range = range;
176 this.newCells = newCells;
177 }
178 > } notebooks.ts
179 >
180 > export class NotebookCellOutputItem {
181 >
182 > static isNotebookCellOutputItem(obj: unknown): obj is vscode.NotebookCellOutputItem {
183 > if (obj instanceof NotebookCellOutputItem) {
184 > return true;
185 > }
186 > if (!obj) {
187 > return false;
188 > }
189 > return typeof (<vscode.NotebookCellOutputItem>obj).mime === 'string'
190 > && (<vscode.NotebookCellOutputItem>obj).data instanceof Uint8Array;
191 > }
192 >
193 > static error(err: Error | { name: string; message?: string; stack?: string }): NotebookCellOutputItem {
194 const obj = {
195 name: err.name,
199 return NotebookCellOutputItem.json(obj, 'application/vnd.code.notebook.error');
200 }
201 > notebooks.ts
202 > static stdout(value: string): NotebookCellOutputItem {
203 return NotebookCellOutputItem.text(value, 'application/vnd.code.notebook.stdout');
204 }
205 > notebooks.ts
206 > static stderr(value: string): NotebookCellOutputItem {
207 return NotebookCellOutputItem.text(value, 'application/vnd.code.notebook.stderr');
208 }
209 > notebooks.ts
210 > static bytes(value: Uint8Array, mime: string = 'application/octet-stream'): NotebookCellOutputItem {
211 return new NotebookCellOutputItem(value, mime);
212 }
213 > notebooks.ts
214 > static #encoder = new TextEncoder();
215 >
216 > static text(value: string, mime: string = Mimes.text): NotebookCellOutputItem {
217 const bytes = NotebookCellOutputItem.#encoder.encode(String(value));
218 return new NotebookCellOutputItem(bytes, mime);
219 }
220 > notebooks.ts
221 > static json(value: unknown, mime: string = 'text/x-json'): NotebookCellOutputItem {
222 const rawStr = JSON.stringify(value, undefined, '\t');
223 return NotebookCellOutputItem.text(rawStr, mime);
224 }
225 > notebooks.ts
226 > constructor(
227 public data: Uint8Array,
228 public mime: string
234 this.mime = mimeNormalized;
235 }
236 > } notebooks.ts
237 >
238 > export class NotebookCellOutput {
239 >
240 > static isNotebookCellOutput(candidate: unknown): candidate is vscode.NotebookCellOutput {
241 if (candidate instanceof NotebookCellOutput) {
242 return true;
247 return typeof (<NotebookCellOutput>candidate).id === 'string' && Array.isArray((<NotebookCellOutput>candidate).items);
248 }
249 > notebooks.ts
250 > static ensureUniqueMimeTypes(items: NotebookCellOutputItem[], warn: boolean = false): NotebookCellOutputItem[] {
251 const seen = new Set<string>();
252 const removeIdx = new Set<number>();
270 return items.filter((_item, index) => !removeIdx.has(index));
271 }
272 > notebooks.ts
273 > id: string;
274 > items: NotebookCellOutputItem[];
275 > metadata?: Record<string, unknown>;
276 >
277 > constructor(
278 items: NotebookCellOutputItem[],
279 idOrMetadata?: string | Record<string, unknown>,
src/vs/workbench/api/common/extHostTypes/workspaceEdit.ts 120 introduced LOC · 18 ranges

Open complete file

1 > /*--------------------------------------------------------------------------------------------- workspaceEdit.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 type * as vscode from 'vscode';
7 > import { coalesceInPlace } from '../../../../base/common/arrays.js';
8 > import { ResourceMap } from '../../../../base/common/map.js';
9 > import { URI } from '../../../../base/common/uri.js';
10 > import { CellEditType, ICellMetadataEdit, IDocumentMetadataEdit } from '../../../contrib/notebook/common/notebookCommon.js';
11 > import { NotebookEdit } from './notebooks.js';
12 > import { SnippetTextEdit } from './snippetTextEdit.js';
13 > import { es5ClassCompat } from './es5ClassCompat.js';
14 > import { Position } from './position.js';
15 > import { Range } from './range.js';
16 > import { TextEdit } from './textEdit.js';
17 >
18 > export interface IFileOperationOptions {
19 > readonly overwrite?: boolean;
20 > readonly ignoreIfExists?: boolean;
21 > readonly ignoreIfNotExists?: boolean;
22 > readonly recursive?: boolean;
23 > readonly contents?: Uint8Array | vscode.DataTransferFile;
24 > }
25 >
26 > export const enum FileEditType {
27 > File = 1,
28 > Text = 2,
29 > Cell = 3,
30 > CellReplace = 5,
31 > Snippet = 6,
32 > }
33 >
34 > export interface IFileOperation {
35 > readonly _type: FileEditType.File;
36 > readonly from?: URI;
37 > readonly to?: URI;
38 > readonly options?: IFileOperationOptions;
39 > readonly metadata?: vscode.WorkspaceEditEntryMetadata;
40 > }
41 >
42 > export interface IFileTextEdit {
43 > readonly _type: FileEditType.Text;
44 > readonly uri: URI;
45 > readonly edit: TextEdit;
46 > readonly metadata?: vscode.WorkspaceEditEntryMetadata;
47 > }
48 >
49 > export interface IFileSnippetTextEdit {
50 > readonly _type: FileEditType.Snippet;
51 > readonly uri: URI;
52 > readonly range: vscode.Range;
53 > readonly edit: vscode.SnippetString;
54 > readonly metadata?: vscode.WorkspaceEditEntryMetadata;
55 > readonly keepWhitespace?: boolean;
56 > }
57 >
58 > export interface IFileCellEdit {
59 > readonly _type: FileEditType.Cell;
60 > readonly uri: URI;
61 > readonly edit?: ICellMetadataEdit | IDocumentMetadataEdit;
62 > readonly metadata?: vscode.WorkspaceEditEntryMetadata;
63 > }
64 >
65 > export interface ICellEdit {
66 > readonly _type: FileEditType.CellReplace;
67 > readonly metadata?: vscode.WorkspaceEditEntryMetadata;
68 > readonly uri: URI;
69 > readonly index: number;
70 > readonly count: number;
71 > readonly cells: vscode.NotebookCellData[];
72 > }
73 >
74 > export type WorkspaceEditEntry = IFileOperation | IFileTextEdit | IFileSnippetTextEdit | IFileCellEdit | ICellEdit;
75 >
76 > @es5ClassCompat
77 > export class WorkspaceEdit implements vscode.WorkspaceEdit {
78
79 private readonly _edits: WorkspaceEditEntry[] = [];
81 >
82 > _allEntries(): ReadonlyArray<WorkspaceEditEntry> {
83 return this._edits;
84 }
86 > // --- file
87 > renameFile(from: vscode.Uri, to: vscode.Uri, options?: { readonly overwrite?: boolean; readonly ignoreIfExists?: boolean }, metadata?: vscode.WorkspaceEditEntryMetadata): void {
88 this._edits.push({ _type: FileEditType.File, from, to, options, metadata });
89 }
91 > createFile(uri: vscode.Uri, options?: { readonly overwrite?: boolean; readonly ignoreIfExists?: boolean; readonly contents?: Uint8Array | vscode.DataTransferFile }, metadata?: vscode.WorkspaceEditEntryMetadata): void {
92 this._edits.push({ _type: FileEditType.File, from: undefined, to: uri, options, metadata });
93 }
95 > deleteFile(uri: vscode.Uri, options?: { readonly recursive?: boolean; readonly ignoreIfNotExists?: boolean }, metadata?: vscode.WorkspaceEditEntryMetadata): void {
96 this._edits.push({ _type: FileEditType.File, from: uri, to: undefined, options, metadata });
97 }
99 > // --- notebook
100 > private replaceNotebookMetadata(uri: URI, value: Record<string, unknown>, metadata?: vscode.WorkspaceEditEntryMetadata): void {
101 this._edits.push({ _type: FileEditType.Cell, metadata, uri, edit: { editType: CellEditType.DocumentMetadata, metadata: value } });
102 }
104 > private replaceNotebookCells(uri: URI, startOrRange: vscode.NotebookRange, cellData: vscode.NotebookCellData[], metadata?: vscode.WorkspaceEditEntryMetadata): void {
105 const start = startOrRange.start;
106 const end = startOrRange.end;
110 }
111 }
113 > private replaceNotebookCellMetadata(uri: URI, index: number, cellMetadata: Record<string, unknown>, metadata?: vscode.WorkspaceEditEntryMetadata): void {
114 this._edits.push({ _type: FileEditType.Cell, metadata, uri, edit: { editType: CellEditType.Metadata, index, metadata: cellMetadata } });
115 }
117 > // --- text
118 > replace(uri: URI, range: Range, newText: string, metadata?: vscode.WorkspaceEditEntryMetadata): void {
119 this._edits.push({ _type: FileEditType.Text, uri, edit: new TextEdit(range, newText), metadata });
120 }
122 > insert(resource: URI, position: Position, newText: string, metadata?: vscode.WorkspaceEditEntryMetadata): void {
123 this.replace(resource, new Range(position, position), newText, metadata);
124 }
126 > delete(resource: URI, range: Range, metadata?: vscode.WorkspaceEditEntryMetadata): void {
127 this.replace(resource, range, '', metadata);
128 }
130 > // --- text (Maplike)
131 > has(uri: URI): boolean {
132 return this._edits.some(edit => edit._type === FileEditType.Text && edit.uri.toString() === uri.toString());
133 }
135 > set(uri: URI, edits: ReadonlyArray<TextEdit | SnippetTextEdit>): void;
136 > set(uri: URI, edits: ReadonlyArray<[TextEdit | SnippetTextEdit, vscode.WorkspaceEditEntryMetadata | undefined]>): void;
137 > set(uri: URI, edits: readonly NotebookEdit[]): void;
138 > set(uri: URI, edits: ReadonlyArray<[NotebookEdit, vscode.WorkspaceEditEntryMetadata | undefined]>): void;
139 >
140 > set(uri: URI, edits: null | undefined | ReadonlyArray<TextEdit | SnippetTextEdit | NotebookEdit | [NotebookEdit, vscode.WorkspaceEditEntryMetadata | undefined] | [TextEdit | SnippetTextEdit, vscode.WorkspaceEditEntryMetadata | undefined]>): void {
141 if (!edits) {
142 // remove all text, snippet, or notebook edits for `uri`
186 }
187 }
189 > get(uri: URI): TextEdit[] {
190 const res: TextEdit[] = [];
191 for (const candidate of this._edits) {
196 return res;
197 }
199 > entries(): [URI, TextEdit[]][] {
200 const textEdits = new ResourceMap<[URI, TextEdit[]]>();
201 for (const candidate of this._edits) {
211 return [...textEdits.values()];
212 }
214 > get size(): number {
215 return this.entries().length;
216 }
218 > toJSON(): [URI, TextEdit[]][] {
219 return this.entries();
220 }
src/vs/base/common/dataTransfer.ts 108 introduced LOC · 19 ranges

Open complete file

1 > /*--------------------------------------------------------------------------------------------- dataTransfer.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 { distinct } from './arrays.js';
7 > import { Iterable } from './iterator.js';
8 > import { URI } from './uri.js';
9 > import { generateUuid } from './uuid.js';
10 >
11 > export interface IDataTransferFile {
12 > readonly id: string;
13 > readonly name: string;
14 > readonly uri?: URI;
15 > data(): Promise<Uint8Array>;
16 > }
17 >
18 > export interface IDataTransferItem {
19 > id?: string;
20 > asString(): Thenable<string>;
21 > asFile(): IDataTransferFile | undefined;
22 > value: unknown;
23 > }
24 >
25 > export function createStringDataTransferItem(stringOrPromise: string | Promise<string>, id?: string): IDataTransferItem {
26 return {
27 id,
31 };
32 }
34 > export function createFileDataTransferItem(fileName: string, uri: URI | undefined, data: () => Promise<Uint8Array>, id?: string): IDataTransferItem {
35 const file = { id: generateUuid(), name: fileName, uri, data };
36 return {
41 };
42 }
44 > export interface IReadonlyVSDataTransfer extends Iterable<readonly [string, IDataTransferItem]> {
45 > /**
46 > * Get the total number of entries in this data transfer.
47 > */
48 > get size(): number;
49 >
50 > /**
51 > * Check if this data transfer contains data for `mimeType`.
52 > *
53 > * This uses exact matching and does not support wildcards.
54 > */
55 > has(mimeType: string): boolean;
56 >
57 > /**
58 > * Check if this data transfer contains data matching `pattern`.
59 > *
60 > * This allows matching for wildcards, such as `image/*`.
61 > *
62 > * Use the special `files` mime type to match any file in the data transfer.
63 > */
64 > matches(pattern: string): boolean;
65 >
66 > /**
67 > * Retrieve the first entry for `mimeType`.
68 > *
69 > * Note that if you want to find all entries for a given mime type, use {@link IReadonlyVSDataTransfer.entries} instead.
70 > */
71 > get(mimeType: string): IDataTransferItem | undefined;
72 > }
73 >
74 > export class VSDataTransfer implements IReadonlyVSDataTransfer {
75
76 private readonly _entries = new Map<string, IDataTransferItem[]>();
78 > public get size(): number {
79 let size = 0;
80 for (const _ of this._entries) {
83 return size;
84 }
86 > public has(mimeType: string): boolean {
87 return this._entries.has(this.toKey(mimeType));
88 }
90 > public matches(pattern: string): boolean {
91 const mimes = [...this._entries.keys()];
92 if (Iterable.some(this, ([_, item]) => item.asFile())) {
96 return matchesMimeType_normalized(normalizeMimeType(pattern), mimes);
97 }
99 > public get(mimeType: string): IDataTransferItem | undefined {
100 return this._entries.get(this.toKey(mimeType))?.[0];
101 }
103 > /**
104 > * Add a new entry to this data transfer.
105 > *
106 > * This does not replace existing entries for `mimeType`.
107 > */
108 > public append(mimeType: string, value: IDataTransferItem): void {
109 const existing = this._entries.get(mimeType);
110 if (existing) {
114 }
115 }
117 > /**
118 > * Set the entry for a given mime type.
119 > *
120 > * This replaces all existing entries for `mimeType`.
121 > */
122 > public replace(mimeType: string, value: IDataTransferItem): void {
123 this._entries.set(this.toKey(mimeType), [value]);
124 }
126 > /**
127 > * Remove all entries for `mimeType`.
128 > */
129 > public delete(mimeType: string) {
130 this._entries.delete(this.toKey(mimeType));
131 }
133 > /**
134 > * Iterate over all `[mime, item]` pairs in this data transfer.
135 > *
136 > * There may be multiple entries for each mime type.
137 > */
138 > public *[Symbol.iterator](): IterableIterator<readonly [string, IDataTransferItem]> {
139 for (const [mine, items] of this._entries) {
140 for (const item of items) {
143 }
144 }
146 > private toKey(mimeType: string): string {
147 return normalizeMimeType(mimeType);
148 }
149 > } dataTransfer.ts
150 >
151 function normalizeMimeType(mimeType: string): string {
152 return mimeType.toLowerCase();
153 }
155 > export function matchesMimeType(pattern: string, mimeTypes: readonly string[]): boolean {
156 return matchesMimeType_normalized(
157 normalizeMimeType(pattern),
158 mimeTypes.map(normalizeMimeType));
159 }
161 function matchesMimeType_normalized(normalizedPattern: string, normalizedMimeTypes: readonly string[]): boolean {
162 // Anything wildcard
183 return false;
184 }
186 >
187 > export const UriList = Object.freeze({
188 > // http://amundsen.com/hypermedia/urilist/
189 > create: (entries: ReadonlyArray<string | URI>): string => {
190 return distinct(entries.map(x => x.toString())).join('\r\n');
191 },
192 > split: (str: string): string[] => { dataTransfer.ts
193 return str.split('\r\n');
194 },
195 > parse: (str: string): string[] => { dataTransfer.ts
196 return UriList.split(str).filter(value => !value.startsWith('#'));
197 }
198 > }); dataTransfer.ts
src/vs/workbench/api/common/extHostTypes/symbolInformation.ts 60 introduced LOC · 4 ranges

Open complete file

1 > /*--------------------------------------------------------------------------------------------- symbolInformation.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 { URI } from '../../../../base/common/uri.js';
7 > import { es5ClassCompat } from './es5ClassCompat.js';
8 > import { Location } from './location.js';
9 > import { Range } from './range.js';
10 >
11 > export enum SymbolKind {
12 > File = 0,
13 > Module = 1,
14 > Namespace = 2,
15 > Package = 3,
16 > Class = 4,
17 > Method = 5,
18 > Property = 6,
19 > Field = 7,
20 > Constructor = 8,
21 > Enum = 9,
22 > Interface = 10,
23 > Function = 11,
24 > Variable = 12,
25 > Constant = 13,
26 > String = 14,
27 > Number = 15,
28 > Boolean = 16,
29 > Array = 17,
30 > Object = 18,
31 > Key = 19,
32 > Null = 20,
33 > EnumMember = 21,
34 > Struct = 22,
35 > Event = 23,
36 > Operator = 24,
37 > TypeParameter = 25
38 > }
39 >
40 > export enum SymbolTag {
41 > Deprecated = 1
42 > }
43 >
44 > @es5ClassCompat
45 > export class SymbolInformation {
46 >
47 > static validate(candidate: SymbolInformation): void {
48 if (!candidate.name) {
49 throw new Error('name must not be falsy');
50 }
51 }
53 > name: string;
54 > location!: Location;
55 > kind: SymbolKind;
56 > tags?: SymbolTag[];
57 > containerName: string | undefined;
58 >
59 > constructor(name: string, kind: SymbolKind, containerName: string | undefined, location: Location);
60 > constructor(name: string, kind: SymbolKind, range: Range, uri?: URI, containerName?: string);
61 > constructor(name: string, kind: SymbolKind, rangeOrContainer: string | undefined | Range, locationOrUri?: Location | URI, containerName?: string) {
62 this.name = name;
63 this.kind = kind;
76 SymbolInformation.validate(this);
77 }
79 > toJSON(): { name: string; kind: string; location: Location; containerName: string | undefined } {
80 return {
81 name: this.name,
src/vs/workbench/api/common/extHostTypes/markdownString.ts 55 introduced LOC · 17 ranges

Open complete file

1 > /*--------------------------------------------------------------------------------------------- markdownString.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 type * as vscode from 'vscode';
7 > import { MarkdownString as BaseMarkdownString, MarkdownStringTrustedOptions } from '../../../../base/common/htmlContent.js';
8 > import { es5ClassCompat } from './es5ClassCompat.js';
9 >
10 > @es5ClassCompat
11 > export class MarkdownString implements vscode.MarkdownString {
12 >
13 > readonly #delegate: BaseMarkdownString;
14 >
15 > static isMarkdownString(thing: unknown): thing is vscode.MarkdownString {
16 > if (thing instanceof MarkdownString) {
17 > return true;
18 > }
19 > if (!thing || typeof thing !== 'object') {
20 > return false;
21 > }
22 > return (thing as vscode.MarkdownString).appendCodeblock && (thing as vscode.MarkdownString).appendMarkdown && (thing as vscode.MarkdownString).appendText && ((thing as vscode.MarkdownString).value !== undefined);
23 > }
24 >
25 > constructor(value?: string, supportThemeIcons: boolean = false) {
26 this.#delegate = new BaseMarkdownString(value, { supportThemeIcons });
27 }
29 > get value(): string {
30 return this.#delegate.value;
31 }
32 > set value(value: string) { markdownString.ts
33 this.#delegate.value = value;
34 }
36 > get isTrusted(): boolean | MarkdownStringTrustedOptions | undefined {
37 return this.#delegate.isTrusted;
38 }
40 > set isTrusted(value: boolean | MarkdownStringTrustedOptions | undefined) {
41 this.#delegate.isTrusted = value;
42 }
44 > get supportThemeIcons(): boolean | undefined {
45 return this.#delegate.supportThemeIcons;
46 }
48 > set supportThemeIcons(value: boolean | undefined) {
49 this.#delegate.supportThemeIcons = value;
50 }
52 > get supportHtml(): boolean | undefined {
53 return this.#delegate.supportHtml;
54 }
56 > set supportHtml(value: boolean | undefined) {
57 this.#delegate.supportHtml = value;
58 }
60 > get supportAlertSyntax(): boolean | undefined {
61 return this.#delegate.supportAlertSyntax;
62 }
64 > set supportAlertSyntax(value: boolean | undefined) {
65 this.#delegate.supportAlertSyntax = value;
66 }
68 > get baseUri(): vscode.Uri | undefined {
69 return this.#delegate.baseUri;
70 }
72 > set baseUri(value: vscode.Uri | undefined) {
73 this.#delegate.baseUri = value;
74 }
76 > appendText(value: string): vscode.MarkdownString {
77 this.#delegate.appendText(value);
78 return this;
79 }
81 > appendMarkdown(value: string): vscode.MarkdownString {
82 this.#delegate.appendMarkdown(value);
83 return this;
84 }
86 > appendCodeblock(value: string, language?: string): vscode.MarkdownString {
87 this.#delegate.appendCodeblock(language ?? '', value);
88 return this;
89 }
src/vs/workbench/api/common/extHostTypes/diagnostic.ts 53 introduced LOC · 7 ranges

Open complete file

1 > /*--------------------------------------------------------------------------------------------- diagnostic.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 { equals } from '../../../../base/common/arrays.js';
7 > import { URI } from '../../../../base/common/uri.js';
8 > import { es5ClassCompat } from './es5ClassCompat.js';
9 > import { Location } from './location.js';
10 > import { Range } from './range.js';
11 >
12 > export enum DiagnosticTag {
13 > Unnecessary = 1,
14 > Deprecated = 2
15 > }
16 >
17 > export enum DiagnosticSeverity {
18 > Hint = 3,
19 > Information = 2,
20 > Warning = 1,
21 > Error = 0
22 > }
23 >
24 > @es5ClassCompat
25 > export class DiagnosticRelatedInformation {
26 >
27 > static is(thing: unknown): thing is DiagnosticRelatedInformation {
28 if (!thing) {
29 return false;
34 && URI.isUri((<DiagnosticRelatedInformation>thing).location.uri);
35 }
37 > location: Location;
38 > message: string;
39 >
40 > constructor(location: Location, message: string) {
41 this.location = location;
42 this.message = message;
43 }
45 > static isEqual(a: DiagnosticRelatedInformation, b: DiagnosticRelatedInformation): boolean {
46 if (a === b) {
47 return true;
54 && a.location.uri.toString() === b.location.uri.toString();
55 }
56 > } diagnostic.ts
57 >
58 > @es5ClassCompat
59 > export class Diagnostic {
60 >
61 > range: Range;
62 > message: string;
63 > severity: DiagnosticSeverity;
64 > source?: string;
65 > code?: string | number;
66 > relatedInformation?: DiagnosticRelatedInformation[];
67 > tags?: DiagnosticTag[];
68 >
69 > constructor(range: Range, message: string, severity: DiagnosticSeverity = DiagnosticSeverity.Error) {
70 if (!Range.isRange(range)) {
71 throw new TypeError('range must be set');
78 this.severity = severity;
79 }
81 > toJSON(): { severity: string; message: string; range: Range; source?: string; code?: string | number } {
82 return {
83 severity: DiagnosticSeverity[this.severity],
88 };
89 }
91 > static isEqual(a: Diagnostic | undefined, b: Diagnostic | undefined): boolean {
92 if (a === b) {
93 return true;
105 && equals(a.relatedInformation, b.relatedInformation, DiagnosticRelatedInformation.isEqual);
106 }
107 > } diagnostic.ts
src/vs/workbench/api/common/extHostTypes/position.ts 53 introduced LOC · 18 ranges

Open complete file

1 > /*--------------------------------------------------------------------------------------------- position.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 type * as vscode from 'vscode';
7 > import { illegalArgument } from '../../../../base/common/errors.js';
8 > import { es5ClassCompat } from './es5ClassCompat.js';
9 >
10 > @es5ClassCompat
11 > export class Position {
12 >
13 > static Min(...positions: Position[]): Position {
14 if (positions.length === 0) {
15 throw new TypeError();
24 return result;
25 }
27 > static Max(...positions: Position[]): Position {
28 if (positions.length === 0) {
29 throw new TypeError();
38 return result;
39 }
41 > static isPosition(other: unknown): other is Position {
42 if (!other) {
43 return false;
52 return false;
53 }
55 > static of(obj: vscode.Position): Position {
56 if (obj instanceof Position) {
57 return obj;
61 throw new Error('Invalid argument, is NOT a position-like object');
62 }
64 > private _line: number;
65 > private _character: number;
66 >
67 > get line(): number {
68 return this._line;
69 }
71 > get character(): number {
72 return this._character;
73 }
75 > constructor(line: number, character: number) {
76 if (line < 0) {
77 throw illegalArgument('line must be non-negative');
83 this._character = character;
84 }
86 > isBefore(other: Position): boolean {
87 if (this._line < other._line) {
88 return true;
93 return this._character < other._character;
94 }
96 > isBeforeOrEqual(other: Position): boolean {
97 if (this._line < other._line) {
98 return true;
103 return this._character <= other._character;
104 }
105 > position.ts
106 > isAfter(other: Position): boolean {
107 return !this.isBeforeOrEqual(other);
108 }
109 > position.ts
110 > isAfterOrEqual(other: Position): boolean {
111 return !this.isBefore(other);
112 }
113 > position.ts
114 > isEqual(other: Position): boolean {
115 return this._line === other._line && this._character === other._character;
116 }
117 > position.ts
118 > compareTo(other: Position): number {
119 if (this._line < other._line) {
120 return -1;
133 }
134 }
135 > position.ts
136 > translate(change: { lineDelta?: number; characterDelta?: number }): Position;
137 > translate(lineDelta?: number, characterDelta?: number): Position;
138 > translate(lineDeltaOrChange: number | undefined | { lineDelta?: number; characterDelta?: number }, characterDelta: number = 0): Position {
139
140 if (lineDeltaOrChange === null || characterDelta === null) {
157 return new Position(this.line + lineDelta, this.character + characterDelta);
158 }
159 > position.ts
160 > with(change: { line?: number; character?: number }): Position;
161 > with(line?: number, character?: number): Position;
162 > with(lineOrChange: number | undefined | { line?: number; character?: number }, character: number = this.character): Position {
163
164 if (lineOrChange === null || character === null) {
183 return new Position(line, character);
184 }
185 > position.ts
186 > toJSON(): { line: number; character: number } {
187 return { line: this.line, character: this.character };
188 }
189 > position.ts
190 > [Symbol.for('debug.description')]() {
191 return `(${this.line}:${this.character})`;
192 }
193 > } position.ts
src/vs/workbench/api/common/extHostTypes/range.ts 51 introduced LOC · 15 ranges

Open complete file

1 > /*--------------------------------------------------------------------------------------------- range.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 type * as vscode from 'vscode';
7 > import { illegalArgument } from '../../../../base/common/errors.js';
8 > import { es5ClassCompat } from './es5ClassCompat.js';
9 > import { Position } from './position.js';
10 >
11 > @es5ClassCompat
12 > export class Range {
13 >
14 > static isRange(thing: unknown): thing is vscode.Range {
15 if (thing instanceof Range) {
16 return true;
22 && Position.isPosition((<Range>thing).end);
23 }
24 > range.ts
25 > static of(obj: vscode.Range): Range {
26 if (obj instanceof Range) {
27 return obj;
32 throw new Error('Invalid argument, is NOT a range-like object');
33 }
34 > range.ts
35 > protected _start: Position;
36 > protected _end: Position;
37 >
38 > get start(): Position {
39 return this._start;
40 }
41 > range.ts
42 > get end(): Position {
43 return this._end;
44 }
45 > range.ts
46 > constructor(start: vscode.Position, end: vscode.Position);
47 > constructor(start: Position, end: Position);
48 > constructor(startLine: number, startColumn: number, endLine: number, endColumn: number);
49 > constructor(startLineOrStart: number | Position | vscode.Position, startColumnOrEnd: number | Position | vscode.Position, endLine?: number, endColumn?: number) {
50 let start: Position | undefined;
51 let end: Position | undefined;
71 }
72 }
73 > range.ts
74 > contains(positionOrRange: Position | Range): boolean {
75 if (Range.isRange(positionOrRange)) {
76 return this.contains(positionOrRange.start)
88 return false;
89 }
90 > range.ts
91 > isEqual(other: Range): boolean {
92 return this._start.isEqual(other._start) && this._end.isEqual(other._end);
93 }
94 > range.ts
95 > intersection(other: Range): Range | undefined {
96 const start = Position.Max(other.start, this._start);
97 const end = Position.Min(other.end, this._end);
104 return new Range(start, end);
105 }
106 > range.ts
107 > union(other: Range): Range {
108 if (this.contains(other)) {
109 return this;
115 return new Range(start, end);
116 }
117 > range.ts
118 > get isEmpty(): boolean {
119 return this._start.isEqual(this._end);
120 }
121 > range.ts
122 > get isSingleLine(): boolean {
123 return this._start.line === this._end.line;
124 }
125 > range.ts
126 > with(change: { start?: Position; end?: Position }): Range;
127 > with(start?: Position, end?: Position): Range;
128 > with(startOrChange: Position | undefined | { start?: Position; end?: Position }, end: Position = this.end): Range {
129
130 if (startOrChange === null || end === null) {
149 return new Range(start, end);
150 }
151 > range.ts
152 > toJSON(): unknown {
153 return [this.start, this.end];
154 }
155 > range.ts
156 > [Symbol.for('debug.description')]() {
157 return getDebugDescriptionOfRange(this);
158 }
159 > } range.ts
160 >
161 > export function getDebugDescriptionOfRange(range: vscode.Range): string {
162 return range.isEmpty
163 ? `[${range.start.line}:${range.start.character})`
src/vs/workbench/api/common/extHostTypes/textEdit.ts 48 introduced LOC · 14 ranges

Open complete file

1 > /*--------------------------------------------------------------------------------------------- textEdit.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 { illegalArgument } from '../../../../base/common/errors.js';
7 > import { es5ClassCompat } from './es5ClassCompat.js';
8 > import { Position } from './position.js';
9 > import { Range } from './range.js';
10 >
11 > export enum EndOfLine {
12 > LF = 1,
13 > CRLF = 2
14 > }
15 >
16 > @es5ClassCompat
17 > export class TextEdit {
18 >
19 > static isTextEdit(thing: unknown): thing is TextEdit {
20 if (thing instanceof TextEdit) {
21 return true;
27 && typeof (<TextEdit>thing).newText === 'string';
28 }
30 > static replace(range: Range, newText: string): TextEdit {
31 return new TextEdit(range, newText);
32 }
34 > static insert(position: Position, newText: string): TextEdit {
35 return TextEdit.replace(new Range(position, position), newText);
36 }
38 > static delete(range: Range): TextEdit {
39 return TextEdit.replace(range, '');
40 }
42 > static setEndOfLine(eol: EndOfLine): TextEdit {
43 const ret = new TextEdit(new Range(new Position(0, 0), new Position(0, 0)), '');
44 ret.newEol = eol;
45 return ret;
46 }
48 > protected _range: Range;
49 > protected _newText: string | null;
50 > protected _newEol?: EndOfLine;
51 >
52 > get range(): Range {
53 return this._range;
54 }
56 > set range(value: Range) {
57 if (value && !Range.isRange(value)) {
58 throw illegalArgument('range');
60 this._range = value;
61 }
63 > get newText(): string {
64 return this._newText || '';
65 }
67 > set newText(value: string) {
68 if (value && typeof value !== 'string') {
69 throw illegalArgument('newText');
71 this._newText = value;
72 }
74 > get newEol(): EndOfLine | undefined {
75 return this._newEol;
76 }
78 > set newEol(value: EndOfLine | undefined) {
79 if (value && typeof value !== 'number') {
80 throw illegalArgument('newEol');
82 this._newEol = value;
83 }
85 > constructor(range: Range, newText: string | null) {
86 this._range = range;
87 this._newText = newText;
88 }
90 > toJSON(): { range: Range; newText: string; newEol: EndOfLine | undefined } {
91 return {
92 range: this.range,
src/vs/workbench/services/aiSettingsSearch/common/aiSettingsSearch.ts 47 introduced LOC · 1 range

Open complete file

1 > /*--------------------------------------------------------------------------------------------- aiSettingsSearch.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 { CancellationToken } from '../../../../base/common/cancellation.js';
7 > import { Event } from '../../../../base/common/event.js';
8 > import { IDisposable } from '../../../../base/common/lifecycle.js';
9 > import { createDecorator } from '../../../../platform/instantiation/common/instantiation.js';
10 >
11 > export const IAiSettingsSearchService = createDecorator<IAiSettingsSearchService>('IAiSettingsSearchService');
12 >
13 > export enum AiSettingsSearchResultKind {
14 > EMBEDDED = 1,
15 > LLM_RANKED = 2,
16 > CANCELED = 3,
17 > }
18 >
19 > export interface AiSettingsSearchResult {
20 > query: string;
21 > kind: AiSettingsSearchResultKind;
22 > settings: string[];
23 > }
24 >
25 > export interface AiSettingsSearchProviderOptions {
26 > limit: number;
27 > embeddingsOnly: boolean;
28 > }
29 >
30 > export interface IAiSettingsSearchService {
31 > readonly _serviceBrand: undefined;
32 > readonly onProviderRegistered: Event<void>;
33 >
34 > // Called from the Settings editor
35 > isEnabled(): boolean;
36 > startSearch(query: string, token: CancellationToken): void;
37 > getEmbeddingsResults(query: string, token: CancellationToken): Promise<string[] | null>;
38 > getLLMRankedResults(query: string, token: CancellationToken): Promise<string[] | null>;
39 >
40 > // Called from the main thread
41 > registerSettingsSearchProvider(provider: IAiSettingsSearchProvider): IDisposable;
42 > handleSearchResult(results: AiSettingsSearchResult): void;
43 > }
44 >
45 > export interface IAiSettingsSearchProvider {
46 > searchSettings(query: string, option: AiSettingsSearchProviderOptions, token: CancellationToken): void;
47 > }
src/vs/workbench/api/common/extHostTypes/codeActionKind.ts 46 introduced LOC · 3 ranges

Open complete file

1 > /*--------------------------------------------------------------------------------------------- codeActionKind.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 { es5ClassCompat } from './es5ClassCompat.js';
7 >
8 > @es5ClassCompat
9 > export class CodeActionKind {
10 > private static readonly sep = '.';
11 >
12 > public static Empty: CodeActionKind;
13 > public static QuickFix: CodeActionKind;
14 > public static Refactor: CodeActionKind;
15 > public static RefactorExtract: CodeActionKind;
16 > public static RefactorInline: CodeActionKind;
17 > public static RefactorMove: CodeActionKind;
18 > public static RefactorRewrite: CodeActionKind;
19 > public static Source: CodeActionKind;
20 > public static SourceOrganizeImports: CodeActionKind;
21 > public static SourceFixAll: CodeActionKind;
22 > public static Notebook: CodeActionKind;
23 >
24 > constructor(
25 > public readonly value: string
26 > ) { }
27 >
28 > public append(parts: string): CodeActionKind {
29 > return new CodeActionKind(this.value ? this.value + CodeActionKind.sep + parts : parts);
30 > }
31 >
32 > public intersects(other: CodeActionKind): boolean {
33 return this.contains(other) || other.contains(this);
34 }
36 > public contains(other: CodeActionKind): boolean {
37 return this.value === other.value || other.value.startsWith(this.value + CodeActionKind.sep);
38 }
40 > CodeActionKind.Empty = new CodeActionKind('');
41 > CodeActionKind.QuickFix = CodeActionKind.Empty.append('quickfix');
42 > CodeActionKind.Refactor = CodeActionKind.Empty.append('refactor');
43 > CodeActionKind.RefactorExtract = CodeActionKind.Refactor.append('extract');
44 > CodeActionKind.RefactorInline = CodeActionKind.Refactor.append('inline');
45 > CodeActionKind.RefactorMove = CodeActionKind.Refactor.append('move');
46 > CodeActionKind.RefactorRewrite = CodeActionKind.Refactor.append('rewrite');
47 > CodeActionKind.Source = CodeActionKind.Empty.append('source');
48 > CodeActionKind.SourceOrganizeImports = CodeActionKind.Source.append('organizeImports');
49 > CodeActionKind.SourceFixAll = CodeActionKind.Source.append('fixAll');
50 > CodeActionKind.Notebook = CodeActionKind.Empty.append('notebook');
src/vs/workbench/api/common/extHostTypes/snippetString.ts 38 introduced LOC · 8 ranges

Open complete file

1 > /*--------------------------------------------------------------------------------------------- snippetString.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 { es5ClassCompat } from './es5ClassCompat.js';
7 >
8 > @es5ClassCompat
9 > export class SnippetString {
10 >
11 > static isSnippetString(thing: unknown): thing is SnippetString {
12 > if (thing instanceof SnippetString) {
13 > return true;
14 > }
15 > if (!thing || typeof thing !== 'object') {
16 > return false;
17 > }
18 > return typeof (<SnippetString>thing).value === 'string';
19 > }
20 >
21 > private static _escape(value: string): string {
22 return value.replace(/\$|}|\\/g, '\\$&');
23 }
25 > private _tabstop: number = 1;
26 >
27 > value: string;
28 >
29 > constructor(value?: string) {
30 this.value = value || '';
31 }
33 > appendText(string: string): SnippetString {
34 this.value += SnippetString._escape(string);
35 return this;
36 }
38 > appendTabstop(number: number = this._tabstop++): SnippetString {
39 this.value += '$';
40 this.value += number;
41 return this;
42 }
44 > appendPlaceholder(value: string | ((snippet: SnippetString) => unknown), number: number = this._tabstop++): SnippetString {
45
46 if (typeof value === 'function') {
62 return this;
63 }
65 > appendChoice(values: string[], number: number = this._tabstop++): SnippetString {
66 const value = values.map(s => s.replaceAll(/[|\\,]/g, '\\$&')).join(',');
67
74 return this;
75 }
77 > appendVariable(name: string, defaultValue?: string | ((snippet: SnippetString) => unknown)): SnippetString {
78
79 if (typeof defaultValue === 'function') {
src/vs/workbench/api/common/extHostTypes/selection.ts 36 introduced LOC · 8 ranges

Open complete file

1 > /*--------------------------------------------------------------------------------------------- selection.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 type * as vscode from 'vscode';
7 > import { es5ClassCompat } from './es5ClassCompat.js';
8 > import { Position } from './position.js';
9 > import { getDebugDescriptionOfRange, Range } from './range.js';
10 >
11 > @es5ClassCompat
12 > export class Selection extends Range {
13 >
14 > static isSelection(thing: unknown): thing is Selection {
15 if (thing instanceof Selection) {
16 return true;
24 && typeof (<Selection>thing).isReversed === 'boolean';
25 }
27 > private _anchor: Position;
28 >
29 > public get anchor(): Position {
30 return this._anchor;
31 }
33 > private _active: Position;
34 >
35 > public get active(): Position {
36 return this._active;
37 }
39 > constructor(anchor: Position, active: Position);
40 > constructor(anchorLine: number, anchorColumn: number, activeLine: number, activeColumn: number);
41 > constructor(anchorLineOrAnchor: number | Position, anchorColumnOrActive: number | Position, activeLine?: number, activeColumn?: number) {
42 let anchor: Position | undefined;
43 let active: Position | undefined;
60 this._active = active;
61 }
63 > get isReversed(): boolean {
64 return this._anchor === this._end;
65 }
67 > override toJSON() {
68 return {
69 start: this.start,
73 };
74 }
76 >
77 > [Symbol.for('debug.description')]() {
78 return getDebugDescriptionOfSelection(this);
79 }
80 > } selection.ts
81 >
82 > export function getDebugDescriptionOfSelection(selection: vscode.Selection): string {
83 let rangeStr = getDebugDescriptionOfRange(selection);
84 if (!selection.isEmpty) {
src/vs/workbench/api/common/extHostTypes/snippetTextEdit.ts 26 introduced LOC · 5 ranges

Open complete file

1 > /*--------------------------------------------------------------------------------------------- snippetTextEdit.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 type * as vscode from 'vscode';
7 > import { SnippetString } from './snippetString.js';
8 > import { Position } from './position.js';
9 > import { Range } from './range.js';
10 >
11 > export class SnippetTextEdit implements vscode.SnippetTextEdit {
12 >
13 > static isSnippetTextEdit(thing: unknown): thing is SnippetTextEdit {
14 if (thing instanceof SnippetTextEdit) {
15 return true;
21 && SnippetString.isSnippetString((<SnippetTextEdit>thing).snippet);
22 }
24 > static replace(range: Range, snippet: SnippetString): SnippetTextEdit {
25 return new SnippetTextEdit(range, snippet);
26 }
28 > static insert(position: Position, snippet: SnippetString): SnippetTextEdit {
29 return SnippetTextEdit.replace(new Range(position, position), snippet);
30 }
32 > range: Range;
33 >
34 > snippet: SnippetString;
35 >
36 > keepWhitespace?: boolean;
37 >
38 > constructor(range: Range, snippet: SnippetString) {
39 this.range = range;
40 this.snippet = snippet;
41 }