@@ -3,6 +3,9 @@ namespace ts.InlineHints {
33 interface HintInfo {
44 text : string ;
55 range : TextSpan ;
6+ triggerPosition : number ;
7+ prefix ?: string ;
8+ postfix ?: string ;
69 whitespaceBefore ?: boolean ;
710 whitespaceAfter ?: boolean ;
811 }
@@ -80,26 +83,32 @@ namespace ts.InlineHints {
8083 return isArrowFunction ( node ) || isFunctionExpression ( node ) || isFunctionDeclaration ( node ) || isMethodDeclaration ( node ) ;
8184 }
8285
83- function addNameHints ( text : string , range : TextSpan ) {
86+ function addNameHints ( node : Node , text : string , range : TextSpan ) {
8487 result . push ( {
85- text : ` ${ truncation ( text , maxHintsLength ) } :` ,
88+ text : truncation ( text , maxHintsLength ) ,
8689 range,
90+ triggerPosition : node . getStart ( ) ,
91+ postfix : ":" ,
8792 whitespaceAfter : true ,
8893 } ) ;
8994 }
9095
91- function addTypeHints ( text : string , range : TextSpan ) {
96+ function addTypeHints ( node : Node , text : string , range : TextSpan ) {
9297 result . push ( {
93- text : `: ${ truncation ( text , maxHintsLength ) } ` ,
98+ text : truncation ( text , maxHintsLength ) ,
9499 range,
100+ triggerPosition : node . getStart ( ) ,
101+ prefix : ":" ,
95102 whitespaceBefore : true ,
96103 } ) ;
97104 }
98105
99- function addEnumMemberValueHints ( text : string , range : TextSpan ) {
106+ function addEnumMemberValueHints ( node : Node , text : string , range : TextSpan ) {
100107 result . push ( {
101- text : `= ${ truncation ( text , maxHintsLength ) } ` ,
108+ text : truncation ( text , maxHintsLength ) ,
102109 range,
110+ triggerPosition : node . getStart ( ) ,
111+ prefix : "= " ,
103112 whitespaceBefore : true ,
104113 } ) ;
105114 }
@@ -121,7 +130,7 @@ namespace ts.InlineHints {
121130 return ;
122131 }
123132
124- addTypeHints ( typeDisplayString , makeEmptyRange ( call . end ) ) ;
133+ addTypeHints ( call , typeDisplayString , makeEmptyRange ( call . end ) ) ;
125134 }
126135
127136 function shouldCallExpressionHint ( call : CallExpression ) {
@@ -151,7 +160,7 @@ namespace ts.InlineHints {
151160
152161 const enumValue = checker . getConstantValue ( member ) ;
153162 if ( enumValue !== undefined ) {
154- addEnumMemberValueHints ( enumValue . toString ( ) , makeEmptyRange ( member . end ) ) ;
163+ addEnumMemberValueHints ( member , enumValue . toString ( ) , makeEmptyRange ( member . end ) ) ;
155164 }
156165 }
157166
@@ -167,7 +176,7 @@ namespace ts.InlineHints {
167176
168177 const typeDisplayString = printTypeInSingleLine ( declarationType ) ;
169178 if ( typeDisplayString ) {
170- addTypeHints ( typeDisplayString , makeEmptyRange ( decl . name . end ) ) ;
179+ addTypeHints ( decl . name , typeDisplayString , makeEmptyRange ( decl . name . end ) ) ;
171180 }
172181 }
173182
@@ -191,7 +200,7 @@ namespace ts.InlineHints {
191200 const parameterName = checker . getParameterIdentifierNameAtPosition ( signature , i ) ;
192201 if ( parameterName ) {
193202 if ( preferences . includeInlineDuplicatedParameterNameHints || ! isIdentifier ( arg ) || arg . text !== parameterName ) {
194- addNameHints ( unescapeLeadingUnderscores ( parameterName ) , makeEmptyRange ( expr . arguments [ i ] . getStart ( ) ) ) ;
203+ addNameHints ( arg , unescapeLeadingUnderscores ( parameterName ) , makeEmptyRange ( expr . arguments [ i ] . getStart ( ) ) ) ;
195204 }
196205 }
197206 }
@@ -219,7 +228,7 @@ namespace ts.InlineHints {
219228 return ;
220229 }
221230
222- addTypeHints ( typeDisplayString , makeEmptyRange ( getTypeAnnotationPosition ( decl ) ) ) ;
231+ addTypeHints ( decl , typeDisplayString , makeEmptyRange ( getTypeAnnotationPosition ( decl ) ) ) ;
223232 }
224233
225234 function getTypeAnnotationPosition ( decl : ArrowFunction | FunctionExpression | MethodDeclaration | FunctionDeclaration ) {
@@ -257,7 +266,7 @@ namespace ts.InlineHints {
257266 continue ;
258267 }
259268
260- addTypeHints ( typeDisplayString , makeEmptyRange ( param . end ) ) ;
269+ addTypeHints ( param , typeDisplayString , makeEmptyRange ( param . end ) ) ;
261270 }
262271 }
263272
0 commit comments