Skip to content

Commit 1a0ec81

Browse files
author
Andy
authored
quickInfo: Display info for signature on a separate line from variable info (microsoft#18698)
1 parent ef6f935 commit 1a0ec81

6 files changed

Lines changed: 66 additions & 41 deletions

File tree

src/services/symbolDisplay.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -191,13 +191,14 @@ namespace ts.SymbolDisplay {
191191
// If it is call or construct signature of lambda's write type name
192192
displayParts.push(punctuationPart(SyntaxKind.ColonToken));
193193
displayParts.push(spacePart());
194+
if (!(type.flags & TypeFlags.Object && (<ObjectType>type).objectFlags & ObjectFlags.Anonymous) && type.symbol) {
195+
addRange(displayParts, symbolToDisplayParts(typeChecker, type.symbol, enclosingDeclaration, /*meaning*/ undefined, SymbolFormatFlags.WriteTypeParametersOrArguments));
196+
displayParts.push(lineBreakPart());
197+
}
194198
if (useConstructSignatures) {
195199
displayParts.push(keywordPart(SyntaxKind.NewKeyword));
196200
displayParts.push(spacePart());
197201
}
198-
if (!(type.flags & TypeFlags.Object && (<ObjectType>type).objectFlags & ObjectFlags.Anonymous) && type.symbol) {
199-
addRange(displayParts, symbolToDisplayParts(typeChecker, type.symbol, enclosingDeclaration, /*meaning*/ undefined, SymbolFormatFlags.WriteTypeParametersOrArguments));
200-
}
201202
addSignatureDisplayParts(signature, allSignatures, TypeFormatFlags.WriteArrowStyleSignature);
202203
break;
203204

tests/baselines/reference/quickInfoDisplayPartsInterfaceMembers.baseline

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -368,6 +368,10 @@
368368
"text": "I",
369369
"kind": "interfaceName"
370370
},
371+
{
372+
"text": "\n",
373+
"kind": "lineBreak"
374+
},
371375
{
372376
"text": "(",
373377
"kind": "punctuation"
@@ -472,6 +476,14 @@
472476
"text": " ",
473477
"kind": "space"
474478
},
479+
{
480+
"text": "I",
481+
"kind": "interfaceName"
482+
},
483+
{
484+
"text": "\n",
485+
"kind": "lineBreak"
486+
},
475487
{
476488
"text": "new",
477489
"kind": "keyword"
@@ -480,10 +492,6 @@
480492
"text": " ",
481493
"kind": "space"
482494
},
483-
{
484-
"text": "I",
485-
"kind": "interfaceName"
486-
},
487495
{
488496
"text": "(",
489497
"kind": "punctuation"

tests/baselines/reference/quickInfoDisplayPartsTypeParameterInInterface.baseline

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2058,6 +2058,14 @@
20582058
"text": " ",
20592059
"kind": "space"
20602060
},
2061+
{
2062+
"text": "I",
2063+
"kind": "interfaceName"
2064+
},
2065+
{
2066+
"text": "\n",
2067+
"kind": "lineBreak"
2068+
},
20612069
{
20622070
"text": "new",
20632071
"kind": "keyword"
@@ -2066,10 +2074,6 @@
20662074
"text": " ",
20672075
"kind": "space"
20682076
},
2069-
{
2070-
"text": "I",
2071-
"kind": "interfaceName"
2072-
},
20732077
{
20742078
"text": "<",
20752079
"kind": "punctuation"
@@ -2188,6 +2192,10 @@
21882192
"text": "I",
21892193
"kind": "interfaceName"
21902194
},
2195+
{
2196+
"text": "\n",
2197+
"kind": "lineBreak"
2198+
},
21912199
{
21922200
"text": "<",
21932201
"kind": "punctuation"
@@ -5462,6 +5470,14 @@
54625470
"text": " ",
54635471
"kind": "space"
54645472
},
5473+
{
5474+
"text": "I1",
5475+
"kind": "interfaceName"
5476+
},
5477+
{
5478+
"text": "\n",
5479+
"kind": "lineBreak"
5480+
},
54655481
{
54665482
"text": "new",
54675483
"kind": "keyword"
@@ -5470,10 +5486,6 @@
54705486
"text": " ",
54715487
"kind": "space"
54725488
},
5473-
{
5474-
"text": "I1",
5475-
"kind": "interfaceName"
5476-
},
54775489
{
54785490
"text": "<",
54795491
"kind": "punctuation"
@@ -5748,6 +5760,10 @@
57485760
"text": "I1",
57495761
"kind": "interfaceName"
57505762
},
5763+
{
5764+
"text": "\n",
5765+
"kind": "lineBreak"
5766+
},
57515767
{
57525768
"text": "<",
57535769
"kind": "punctuation"

tests/cases/fourslash/commentsInterface.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ goTo.marker('16');
113113
verify.currentSignatureHelpDocCommentIs("new method");
114114
verify.currentParameterHelpArgumentDocCommentIs("param");
115115
verify.quickInfos({
116-
"16q": ["var i2_i: new i2(i: i1) => any", "new method"],
116+
"16q": ["var i2_i: i2\nnew (i: i1) => any", "new method"],
117117

118118
17: "var i2_i_nc_x: number",
119119
18: "(property) i2.nc_x: number",
@@ -133,7 +133,7 @@ verify.quickInfos({
133133
goTo.marker('24');
134134
verify.currentSignatureHelpDocCommentIs("this is call signature");
135135
verify.currentParameterHelpArgumentDocCommentIs("paramhelp a");
136-
verify.quickInfoAt("24q", "var i2_i: i2(a: number, b: number) => number", "this is call signature");
136+
verify.quickInfoAt("24q", "var i2_i: i2\n(a: number, b: number) => number", "this is call signature");
137137

138138
goTo.marker('25');
139139
verify.currentSignatureHelpDocCommentIs("this is call signature");

tests/cases/fourslash/commentsOverloads.ts

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -296,34 +296,34 @@ verify.completionListContains('f4', 'function f4(a: number): number (+1 overload
296296

297297
goTo.marker('18');
298298
verify.not.completionListContains('i1', 'interface i1', '');
299-
verify.completionListContains('i1_i', 'var i1_i: new i1(b: number) => any (+1 overload)', '');
299+
verify.completionListContains('i1_i', 'var i1_i: i1\nnew (b: number) => any (+1 overload)', '');
300300
verify.not.completionListContains('i2', 'interface i2', '');
301-
verify.completionListContains('i2_i', 'var i2_i: new i2(a: string) => any (+1 overload)', '');
301+
verify.completionListContains('i2_i', 'var i2_i: i2\nnew (a: string) => any (+1 overload)', '');
302302
verify.not.completionListContains('i3', 'interface i3', '');
303-
verify.completionListContains('i3_i', 'var i3_i: new i3(a: string) => any (+1 overload)', 'new 1');
303+
verify.completionListContains('i3_i', 'var i3_i: i3\nnew (a: string) => any (+1 overload)', 'new 1');
304304
verify.not.completionListContains('i4', 'interface i4', '');
305-
verify.completionListContains('i4_i', 'var i4_i: new i4(a: string) => any (+1 overload)', '');
305+
verify.completionListContains('i4_i', 'var i4_i: i4\nnew (a: string) => any (+1 overload)', '');
306306

307307
goTo.marker('19');
308308
verify.currentSignatureHelpDocCommentIs("");
309309
verify.currentParameterHelpArgumentDocCommentIs("");
310-
verify.quickInfoAt("19q", "var i1_i: new i1(b: number) => any (+1 overload)");
310+
verify.quickInfoAt("19q", "var i1_i: i1\nnew (b: number) => any (+1 overload)");
311311

312312
goTo.marker('20');
313313
verify.currentSignatureHelpDocCommentIs("new 1");
314314
verify.currentParameterHelpArgumentDocCommentIs("");
315-
verify.quickInfoAt("20q", "var i1_i: new i1(a: string) => any (+1 overload)", "new 1");
315+
verify.quickInfoAt("20q", "var i1_i: i1\nnew (a: string) => any (+1 overload)", "new 1");
316316

317317
goTo.marker('21');
318318
verify.currentSignatureHelpDocCommentIs("this signature 1");
319319
verify.currentParameterHelpArgumentDocCommentIs("param a");
320-
verify.quickInfoAt("21q", "var i1_i: i1(a: number) => number (+1 overload)", "this signature 1");
320+
verify.quickInfoAt("21q", "var i1_i: i1\n(a: number) => number (+1 overload)", "this signature 1");
321321

322322
goTo.marker('22');
323323
verify.currentSignatureHelpDocCommentIs("this is signature 2");
324324
verify.currentParameterHelpArgumentDocCommentIs("");
325325
goTo.marker('22q');
326-
verify.quickInfoAt("22q", "var i1_i: i1(b: string) => number (+1 overload)", "this is signature 2");
326+
verify.quickInfoAt("22q", "var i1_i: i1\n(b: string) => number (+1 overload)", "this is signature 2");
327327

328328
goTo.marker('23');
329329
verify.completionListContains('foo', '(method) i1.foo(a: number): number (+1 overload)', 'foo 1');
@@ -374,62 +374,62 @@ verify.quickInfoAt("31q", "(method) i1.foo4(b: string): number (+1 overload)");
374374
goTo.marker('32');
375375
verify.currentSignatureHelpDocCommentIs("new 2");
376376
verify.currentParameterHelpArgumentDocCommentIs("");
377-
verify.quickInfoAt("32q", "var i2_i: new i2(b: number) => any (+1 overload)", "new 2");
377+
verify.quickInfoAt("32q", "var i2_i: i2\nnew (b: number) => any (+1 overload)", "new 2");
378378

379379
goTo.marker('33');
380380
verify.currentSignatureHelpDocCommentIs("");
381381
verify.currentParameterHelpArgumentDocCommentIs("");
382-
verify.quickInfoAt("33q", "var i2_i: new i2(a: string) => any (+1 overload)");
382+
verify.quickInfoAt("33q", "var i2_i: i2\nnew (a: string) => any (+1 overload)");
383383

384384
goTo.marker('34');
385385
verify.currentSignatureHelpDocCommentIs("");
386386
verify.currentParameterHelpArgumentDocCommentIs("");
387-
verify.quickInfoAt("34q", "var i2_i: i2(a: number) => number (+1 overload)");
387+
verify.quickInfoAt("34q", "var i2_i: i2\n(a: number) => number (+1 overload)");
388388

389389
goTo.marker('35');
390390
verify.currentSignatureHelpDocCommentIs("this is signature 2");
391391
verify.currentParameterHelpArgumentDocCommentIs("");
392-
verify.quickInfoAt("35q", "var i2_i: i2(b: string) => number (+1 overload)", "this is signature 2");
392+
verify.quickInfoAt("35q", "var i2_i: i2\n(b: string) => number (+1 overload)", "this is signature 2");
393393

394394
goTo.marker('36');
395395
verify.currentSignatureHelpDocCommentIs("new 2");
396396
verify.currentParameterHelpArgumentDocCommentIs("");
397-
verify.quickInfoAt("36q", "var i3_i: new i3(b: number) => any (+1 overload)", "new 2");
397+
verify.quickInfoAt("36q", "var i3_i: i3\nnew (b: number) => any (+1 overload)", "new 2");
398398

399399
goTo.marker('37');
400400
verify.currentSignatureHelpDocCommentIs("new 1");
401401
verify.currentParameterHelpArgumentDocCommentIs("");
402-
verify.quickInfoAt("37q", "var i3_i: new i3(a: string) => any (+1 overload)", "new 1");
402+
verify.quickInfoAt("37q", "var i3_i: i3\nnew (a: string) => any (+1 overload)", "new 1");
403403

404404
goTo.marker('38');
405405
verify.currentSignatureHelpDocCommentIs("this is signature 1");
406406
verify.currentParameterHelpArgumentDocCommentIs("");
407-
verify.quickInfoAt("38q", "var i3_i: i3(a: number) => number (+1 overload)", "this is signature 1");
407+
verify.quickInfoAt("38q", "var i3_i: i3\n(a: number) => number (+1 overload)", "this is signature 1");
408408

409409
goTo.marker('39');
410410
verify.currentSignatureHelpDocCommentIs("");
411411
verify.currentParameterHelpArgumentDocCommentIs("");
412-
verify.quickInfoAt("39q", "var i3_i: i3(b: string) => number (+1 overload)");
412+
verify.quickInfoAt("39q", "var i3_i: i3\n(b: string) => number (+1 overload)");
413413

414414
goTo.marker('40');
415415
verify.currentSignatureHelpDocCommentIs("");
416416
verify.currentParameterHelpArgumentDocCommentIs("");
417-
verify.quickInfoAt("40q", "var i4_i: new i4(b: number) => any (+1 overload)");
417+
verify.quickInfoAt("40q", "var i4_i: i4\nnew (b: number) => any (+1 overload)");
418418

419419
goTo.marker('41');
420420
verify.currentSignatureHelpDocCommentIs("");
421421
verify.currentParameterHelpArgumentDocCommentIs("");
422-
verify.quickInfoAt("41q", "var i4_i: new i4(a: string) => any (+1 overload)");
422+
verify.quickInfoAt("41q", "var i4_i: i4\nnew (a: string) => any (+1 overload)");
423423

424424
goTo.marker('42');
425425
verify.currentSignatureHelpDocCommentIs("");
426426
verify.currentParameterHelpArgumentDocCommentIs("");
427-
verify.quickInfoAt("42q", "var i4_i: i4(a: number) => number (+1 overload)");
427+
verify.quickInfoAt("42q", "var i4_i: i4\n(a: number) => number (+1 overload)");
428428

429429
goTo.marker('43');
430430
verify.currentSignatureHelpDocCommentIs("");
431431
verify.currentParameterHelpArgumentDocCommentIs("");
432-
verify.quickInfoAt("43q", "var i4_i: i4(b: string) => number (+1 overload)");
432+
verify.quickInfoAt("43q", "var i4_i: i4\n(b: string) => number (+1 overload)");
433433

434434
goTo.marker('44');
435435
verify.completionListContains('prop1', '(method) c.prop1(a: number): number (+1 overload)', '');

tests/cases/fourslash/externalModuleWithExportAssignment.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ verify.quickInfoAt("1", 'import a1 = require("./externalModuleWithExportAssignme
3333
verify.quickInfoAt("2", "var a: {\n (): a1.connectExport;\n test1: a1.connectModule;\n test2(): a1.connectModule;\n}", undefined);
3434

3535
goTo.marker('3');
36-
verify.quickInfoIs("(property) test1: a1.connectModule(res: any, req: any, next: any) => void", undefined);
37-
verify.completionListContains("test1", "(property) test1: a1.connectModule(res: any, req: any, next: any) => void", undefined);
36+
verify.quickInfoIs("(property) test1: a1.connectModule\n(res: any, req: any, next: any) => void", undefined);
37+
verify.completionListContains("test1", "(property) test1: a1.connectModule\n(res: any, req: any, next: any) => void", undefined);
3838
verify.completionListContains("test2", "(method) test2(): a1.connectModule", undefined);
3939
verify.not.completionListContains("connectModule");
4040
verify.not.completionListContains("connectExport");
@@ -53,8 +53,8 @@ verify.currentSignatureHelpIs("a(): a1.connectExport");
5353
verify.quickInfoAt("8", "var r2: a1.connectExport", undefined);
5454

5555
goTo.marker('9');
56-
verify.quickInfoIs("(property) test1: a1.connectModule(res: any, req: any, next: any) => void", undefined);
57-
verify.completionListContains("test1", "(property) test1: a1.connectModule(res: any, req: any, next: any) => void", undefined);
56+
verify.quickInfoIs("(property) test1: a1.connectModule\n(res: any, req: any, next: any) => void", undefined);
57+
verify.completionListContains("test1", "(property) test1: a1.connectModule\n(res: any, req: any, next: any) => void", undefined);
5858
verify.completionListContains("test2", "(method) test2(): a1.connectModule", undefined);
5959
verify.not.completionListContains("connectModule");
6060
verify.not.completionListContains("connectExport");

0 commit comments

Comments
 (0)