@@ -722,7 +722,7 @@ module ts {
722
722
currentParameterIsTypeParameter : boolean ; // current parameter is a type argument or a normal argument
723
723
currentParameter : number ; // Index of active parameter in "parameters" or "typeParamters" array
724
724
}
725
-
725
+
726
726
export interface ClassifiedSpan {
727
727
textSpan : TypeScript . TextSpan ;
728
728
classificationType : string ; // ClassificationTypeNames
@@ -833,8 +833,8 @@ module ts {
833
833
834
834
export interface SignatureHelpParameter {
835
835
name : string ;
836
- documentation : string ;
837
- display : string ;
836
+ documentation : SymbolDisplayPart [ ] ;
837
+ displayParts : SymbolDisplayPart [ ] ;
838
838
isOptional : boolean ;
839
839
}
840
840
@@ -847,11 +847,11 @@ module ts {
847
847
*/
848
848
export interface SignatureHelpItem {
849
849
isVariadic : boolean ;
850
- prefix : string ;
851
- suffix : string ;
852
- separator : string ;
850
+ prefixDisplayParts : SymbolDisplayPart [ ] ;
851
+ suffixDisplayParts : SymbolDisplayPart [ ] ;
852
+ separatorDisplayParts : SymbolDisplayPart [ ] ;
853
853
parameters : SignatureHelpParameter [ ] ;
854
- documentation : string ;
854
+ documentation : SymbolDisplayPart [ ] ;
855
855
}
856
856
857
857
/**
@@ -1622,6 +1622,11 @@ module ts {
1622
1622
} ) ;
1623
1623
}
1624
1624
1625
+ export function getSymbolDocumentationDisplayParts ( symbol : Symbol ) : SymbolDisplayPart [ ] {
1626
+ var documentation = symbol . getDocumentationComment ( ) ;
1627
+ return documentation === "" ? [ ] : [ new SymbolDisplayPart ( documentation , SymbolDisplayPartKind . text , /*symbol:*/ null ) ] ;
1628
+ }
1629
+
1625
1630
export function createLanguageService ( host : LanguageServiceHost , documentRegistry : DocumentRegistry ) : LanguageService {
1626
1631
var syntaxTreeCache : SyntaxTreeCache = new SyntaxTreeCache ( host ) ;
1627
1632
var formattingRulesProvider : TypeScript . Services . Formatting . RulesProvider ;
@@ -2372,42 +2377,41 @@ module ts {
2372
2377
return undefined ;
2373
2378
}
2374
2379
2375
- var documentation = symbol . getDocumentationComment ( ) ;
2376
- var documentationParts = documentation === "" ? [ ] : [ new SymbolDisplayPart ( documentation , SymbolDisplayPartKind . text , /*symbol:*/ null ) ] ;
2380
+ var documentationParts = getSymbolDocumentationDisplayParts ( symbol ) ;
2377
2381
2378
2382
// Having all this logic here is pretty unclean. Consider moving to the roslyn model
2379
2383
// where all symbol display logic is encapsulated into visitors and options.
2380
2384
var totalParts : SymbolDisplayPart [ ] = [ ] ;
2381
2385
2382
2386
if ( symbol . flags & SymbolFlags . Class ) {
2383
- totalParts . push ( new SymbolDisplayPart ( "class" , SymbolDisplayPartKind . keyword , undefined ) ) ;
2384
- totalParts . push ( new SymbolDisplayPart ( " " , SymbolDisplayPartKind . space , undefined ) ) ;
2387
+ totalParts . push ( keywordPart ( SyntaxKind . ClassKeyword ) ) ;
2388
+ totalParts . push ( spacePart ( ) ) ;
2385
2389
totalParts . push . apply ( totalParts , typeInfoResolver . symbolToDisplayParts ( symbol , sourceFile ) ) ;
2386
2390
}
2387
2391
else if ( symbol . flags & SymbolFlags . Interface ) {
2388
- totalParts . push ( new SymbolDisplayPart ( "interface" , SymbolDisplayPartKind . keyword , undefined ) ) ;
2389
- totalParts . push ( new SymbolDisplayPart ( " " , SymbolDisplayPartKind . space , undefined ) ) ;
2392
+ totalParts . push ( keywordPart ( SyntaxKind . InterfaceKeyword ) ) ;
2393
+ totalParts . push ( spacePart ( ) ) ;
2390
2394
totalParts . push . apply ( totalParts , typeInfoResolver . symbolToDisplayParts ( symbol , sourceFile ) ) ;
2391
2395
}
2392
2396
else if ( symbol . flags & SymbolFlags . Enum ) {
2393
- totalParts . push ( new SymbolDisplayPart ( "enum" , SymbolDisplayPartKind . keyword , undefined ) ) ;
2394
- totalParts . push ( new SymbolDisplayPart ( " " , SymbolDisplayPartKind . space , undefined ) ) ;
2397
+ totalParts . push ( keywordPart ( SyntaxKind . EnumKeyword ) ) ;
2398
+ totalParts . push ( spacePart ( ) ) ;
2395
2399
totalParts . push . apply ( totalParts , typeInfoResolver . symbolToDisplayParts ( symbol , sourceFile ) ) ;
2396
2400
}
2397
2401
else if ( symbol . flags & SymbolFlags . Module ) {
2398
- totalParts . push ( new SymbolDisplayPart ( "module" , SymbolDisplayPartKind . keyword , undefined ) ) ;
2399
- totalParts . push ( new SymbolDisplayPart ( " " , SymbolDisplayPartKind . space , undefined ) ) ;
2402
+ totalParts . push ( keywordPart ( SyntaxKind . ModuleKeyword ) ) ;
2403
+ totalParts . push ( spacePart ( ) ) ;
2400
2404
totalParts . push . apply ( totalParts , typeInfoResolver . symbolToDisplayParts ( symbol , sourceFile ) ) ;
2401
2405
}
2402
2406
else if ( symbol . flags & SymbolFlags . TypeParameter ) {
2403
- totalParts . push ( new SymbolDisplayPart ( "(" , SymbolDisplayPartKind . punctuation , undefined ) ) ;
2407
+ totalParts . push ( punctuationPart ( SyntaxKind . OpenParenToken ) ) ;
2404
2408
totalParts . push ( new SymbolDisplayPart ( "type parameter" , SymbolDisplayPartKind . text , undefined ) ) ;
2405
- totalParts . push ( new SymbolDisplayPart ( ")" , SymbolDisplayPartKind . punctuation , undefined ) ) ;
2406
- totalParts . push ( new SymbolDisplayPart ( " " , SymbolDisplayPartKind . space , undefined ) ) ;
2409
+ totalParts . push ( punctuationPart ( SyntaxKind . CloseParenToken ) ) ;
2410
+ totalParts . push ( spacePart ( ) ) ;
2407
2411
totalParts . push . apply ( totalParts , typeInfoResolver . symbolToDisplayParts ( symbol ) ) ;
2408
2412
}
2409
2413
else {
2410
- totalParts . push ( new SymbolDisplayPart ( "(" , SymbolDisplayPartKind . punctuation , undefined ) ) ;
2414
+ totalParts . push ( punctuationPart ( SyntaxKind . OpenParenToken ) ) ;
2411
2415
var text : string ;
2412
2416
2413
2417
if ( symbol . flags & SymbolFlags . Property ) { text = "property" }
@@ -2421,8 +2425,8 @@ module ts {
2421
2425
}
2422
2426
2423
2427
totalParts . push ( new SymbolDisplayPart ( text , SymbolDisplayPartKind . text , undefined ) ) ;
2424
- totalParts . push ( new SymbolDisplayPart ( ")" , SymbolDisplayPartKind . punctuation , undefined ) ) ;
2425
- totalParts . push ( new SymbolDisplayPart ( " " , SymbolDisplayPartKind . space , undefined ) ) ;
2428
+ totalParts . push ( punctuationPart ( SyntaxKind . CloseParenToken ) ) ;
2429
+ totalParts . push ( spacePart ( ) ) ;
2426
2430
2427
2431
totalParts . push . apply ( totalParts , typeInfoResolver . symbolToDisplayParts ( symbol , getContainerNode ( node ) ) ) ;
2428
2432
@@ -2432,8 +2436,8 @@ module ts {
2432
2436
symbol . flags & SymbolFlags . Variable ) {
2433
2437
2434
2438
if ( type ) {
2435
- totalParts . push ( new SymbolDisplayPart ( ":" , SymbolDisplayPartKind . punctuation , undefined ) ) ;
2436
- totalParts . push ( new SymbolDisplayPart ( " " , SymbolDisplayPartKind . space , undefined ) ) ;
2439
+ totalParts . push ( punctuationPart ( SyntaxKind . ColonToken ) ) ;
2440
+ totalParts . push ( spacePart ( ) ) ;
2437
2441
totalParts . push . apply ( totalParts , typeInfoResolver . typeToDisplayParts ( type , getContainerNode ( node ) ) ) ;
2438
2442
}
2439
2443
}
@@ -2448,9 +2452,9 @@ module ts {
2448
2452
if ( declaration . kind === SyntaxKind . EnumMember ) {
2449
2453
var constantValue = typeInfoResolver . getEnumMemberValue ( < EnumMember > declaration ) ;
2450
2454
if ( constantValue !== undefined ) {
2451
- totalParts . push ( new SymbolDisplayPart ( " " , SymbolDisplayPartKind . space , undefined ) ) ;
2452
- totalParts . push ( new SymbolDisplayPart ( "=" , SymbolDisplayPartKind . operator , undefined ) ) ;
2453
- totalParts . push ( new SymbolDisplayPart ( " " , SymbolDisplayPartKind . space , undefined ) ) ;
2455
+ totalParts . push ( spacePart ( ) ) ;
2456
+ totalParts . push ( operatorPart ( SyntaxKind . EqualsToken ) ) ;
2457
+ totalParts . push ( spacePart ( ) ) ;
2454
2458
totalParts . push ( new SymbolDisplayPart ( constantValue . toString ( ) , SymbolDisplayPartKind . numericLiteral , undefined ) ) ;
2455
2459
}
2456
2460
}
@@ -3782,7 +3786,7 @@ module ts {
3782
3786
3783
3787
var formalSignatures : FormalSignatureItemInfo [ ] = [ ] ;
3784
3788
forEach ( signatureHelpItems . items , signature => {
3785
- var signatureInfoString = signature . prefix ;
3789
+ var signatureInfoString = ts . SymbolDisplayPart . toString ( signature . prefixDisplayParts ) ;
3786
3790
3787
3791
var parameters : FormalParameterInfo [ ] = [ ] ;
3788
3792
if ( signature . parameters ) {
@@ -3791,32 +3795,31 @@ module ts {
3791
3795
3792
3796
// add the parameter to the string
3793
3797
if ( i ) {
3794
- signatureInfoString += signature . separator ;
3798
+ signatureInfoString += ts . SymbolDisplayPart . toString ( signature . separatorDisplayParts ) ;
3795
3799
}
3796
3800
3797
3801
var start = signatureInfoString . length ;
3798
- signatureInfoString += parameter . display ;
3802
+ signatureInfoString += ts . SymbolDisplayPart . toString ( parameter . displayParts ) ;
3799
3803
var end = signatureInfoString . length - 1 ;
3800
3804
3801
3805
// add the parameter to the list
3802
3806
parameters . push ( {
3803
3807
name : parameter . name ,
3804
3808
isVariable : i == n - 1 && signature . isVariadic ,
3805
- docComment : parameter . documentation ,
3809
+ docComment : ts . SymbolDisplayPart . toString ( parameter . documentation ) ,
3806
3810
minChar : start ,
3807
3811
limChar : end
3808
3812
} ) ;
3809
3813
}
3810
3814
}
3811
3815
3812
- signatureInfoString += signature . suffix ;
3816
+ signatureInfoString += ts . SymbolDisplayPart . toString ( signature . suffixDisplayParts ) ;
3813
3817
3814
3818
formalSignatures . push ( {
3815
3819
signatureInfo : signatureInfoString ,
3816
- docComment : signature . documentation ,
3820
+ docComment : ts . SymbolDisplayPart . toString ( signature . documentation ) ,
3817
3821
parameters : parameters ,
3818
3822
typeParameters : [ ] ,
3819
- docComments : signature . documentation
3820
3823
} ) ;
3821
3824
} ) ;
3822
3825
0 commit comments