@@ -442,3 +442,49 @@ export function asSelectionRange(item: vscode.SelectionRange): monaco.languages.
442
442
range : asRange ( item . range ) ,
443
443
} ;
444
444
}
445
+
446
+ export function asInlayHint ( item : vscode . InlayHint ) : monaco . languages . InlayHint {
447
+ return {
448
+ label : asInlayHintLabel ( item . label ) ,
449
+ tooltip : item . tooltip ,
450
+ command : undefined ,
451
+ position : asPosition ( item . position ) ,
452
+ kind : item . kind ? asInlayHintKind ( item . kind ) : undefined ,
453
+ paddingLeft : item . paddingLeft ,
454
+ paddingRight : item . paddingRight ,
455
+ } ;
456
+ }
457
+
458
+ export function asInlayHintKind ( kind : vscode . InlayHintKind ) : monaco . languages . InlayHintKind {
459
+ switch ( kind ) {
460
+ case vscode . InlayHintKind . Parameter :
461
+ return monaco . languages . InlayHintKind . Parameter ;
462
+ case vscode . InlayHintKind . Type :
463
+ return monaco . languages . InlayHintKind . Type ;
464
+ }
465
+ }
466
+
467
+ export function asInlayHintLabel ( label : vscode . InlayHint [ 'label' ] ) : monaco . languages . InlayHint [ 'label' ] {
468
+ if ( typeof label === 'string' ) {
469
+ return label ;
470
+ }
471
+ else {
472
+ return label . map ( asInlayHintLabelPart ) ;
473
+ }
474
+ }
475
+
476
+ export function asInlayHintLabelPart ( part : vscode . InlayHintLabelPart ) : monaco . languages . InlayHintLabelPart {
477
+ return {
478
+ label : part . value ,
479
+ tooltip : part . tooltip ,
480
+ command : part . command ? asCommand ( part . command ) : undefined ,
481
+ location : part . location ? asLocation ( part . location ) : undefined ,
482
+ } ;
483
+ }
484
+
485
+ export function asPosition ( position : vscode . Position ) : monaco . Position {
486
+ return {
487
+ lineNumber : position . line + 1 ,
488
+ column : position . character + 1 ,
489
+ } as unknown as monaco . Position ;
490
+ }
0 commit comments