4
4
*--------------------------------------------------------------------------------------------*/
5
5
6
6
import * as vscode from 'vscode' ;
7
- import * as Proto from '../protocol' ;
8
- import { DocumentSelector } from '../utils/documentSelector ' ;
9
- import { ClientCapability , ITypeScriptServiceClient , ServerResponse , ExecConfig } from '../typescriptService ' ;
7
+ import type * as Proto from '../protocol' ;
8
+ import { ClientCapability , ITypeScriptServiceClient } from '../typescriptService ' ;
9
+ import API from '../utils/api ' ;
10
10
import { Condition , conditionalRegistration , requireMinVersion , requireSomeCapability } from '../utils/dependentRegistration' ;
11
+ import { Disposable } from '../utils/dispose' ;
12
+ import { DocumentSelector } from '../utils/documentSelector' ;
11
13
import { Position } from '../utils/typeConverters' ;
12
14
import FileConfigurationManager , { getInlayHintsPreferences , InlayHintSettingNames } from './fileConfigurationManager' ;
13
- import API from '../utils/api' ;
14
- import { Disposable } from '../utils/dispose' ;
15
-
16
- namespace ExperimentalProto {
17
- export const enum CommandTypes {
18
- ProvideInlineHints = 'ProvideInlayHints'
19
- }
20
-
21
- export interface InlayHintsArgs extends Proto . FileRequestArgs {
22
- /**
23
- * Start position of the span.
24
- */
25
- start : number ;
26
- /**
27
- * Length of the span.
28
- */
29
- length : number ;
30
- }
31
-
32
- export interface InlineHintsRequest extends Proto . Request {
33
- command : CommandTypes . ProvideInlineHints ;
34
- arguments : InlayHintsArgs ;
35
- }
36
-
37
- export enum InlayHintKind {
38
- Type = 'Type' ,
39
- Parameter = 'Parameter' ,
40
- Enum = 'Enum'
41
- }
42
-
43
- interface InlayHintItem {
44
- text : string ;
45
- position : Proto . Location ;
46
- kind ?: InlayHintKind ;
47
- whitespaceBefore ?: boolean ;
48
- whitespaceAfter ?: boolean ;
49
- }
50
-
51
- export interface InlayHintsResponse extends Proto . Response {
52
- body ?: InlayHintItem [ ] ;
53
- }
54
-
55
- export interface IExtendedTypeScriptServiceClient {
56
- execute < K extends keyof ExtendedTsServerRequests > (
57
- command : K ,
58
- args : ExtendedTsServerRequests [ K ] [ 0 ] ,
59
- token : vscode . CancellationToken ,
60
- config ?: ExecConfig
61
- ) : Promise < ServerResponse . Response < ExtendedTsServerRequests [ K ] [ 1 ] > > ;
62
- }
63
15
64
- export interface ExtendedTsServerRequests {
65
- 'provideInlayHints' : [ InlayHintsArgs , InlayHintsResponse ] ;
66
- }
67
-
68
- export namespace InlayHintKind {
69
- export function fromProtocolInlayHintKind ( kind : InlayHintKind ) : vscode . InlayHintKind {
70
- switch ( kind ) {
71
- case InlayHintKind . Parameter :
72
- return vscode . InlayHintKind . Parameter ;
73
- case InlayHintKind . Type :
74
- return vscode . InlayHintKind . Type ;
75
- case InlayHintKind . Enum :
76
- return vscode . InlayHintKind . Other ;
77
- default :
78
- return vscode . InlayHintKind . Other ;
79
- }
80
- }
81
- }
82
- }
83
16
84
17
const inlayHintSettingNames = [
85
18
InlayHintSettingNames . parameterNamesSuppressWhenArgumentMatchesName ,
@@ -122,7 +55,7 @@ class TypeScriptInlayHintsProvider extends Disposable implements vscode.InlayHin
122
55
123
56
await this . fileConfigurationManager . ensureConfigurationForDocument ( model , token ) ;
124
57
125
- const response = await ( this . client as ExperimentalProto . IExtendedTypeScriptServiceClient ) . execute ( 'provideInlayHints' , { file : filepath , start, length } , token ) ;
58
+ const response = await this . client . execute ( 'provideInlayHints' , { file : filepath , start, length } , token ) ;
126
59
if ( response . type !== 'response' || ! response . success || ! response . body ) {
127
60
return [ ] ;
128
61
}
@@ -131,7 +64,7 @@ class TypeScriptInlayHintsProvider extends Disposable implements vscode.InlayHin
131
64
const result = new vscode . InlayHint (
132
65
hint . text ,
133
66
Position . fromLocation ( hint . position ) ,
134
- hint . kind && ExperimentalProto . InlayHintKind . fromProtocolInlayHintKind ( hint . kind )
67
+ hint . kind && fromProtocolInlayHintKind ( hint . kind )
135
68
) ;
136
69
result . whitespaceBefore = hint . whitespaceBefore ;
137
70
result . whitespaceAfter = hint . whitespaceAfter ;
@@ -140,6 +73,16 @@ class TypeScriptInlayHintsProvider extends Disposable implements vscode.InlayHin
140
73
}
141
74
}
142
75
76
+
77
+ function fromProtocolInlayHintKind ( kind : Proto . InlayHintKind ) : vscode . InlayHintKind {
78
+ switch ( kind ) {
79
+ case 'Parameter' : return vscode . InlayHintKind . Parameter ;
80
+ case 'Type' : return vscode . InlayHintKind . Type ;
81
+ case 'Enum' : return vscode . InlayHintKind . Other ;
82
+ default : return vscode . InlayHintKind . Other ;
83
+ }
84
+ }
85
+
143
86
export function requireInlayHintsConfiguration (
144
87
language : string
145
88
) {
0 commit comments