@@ -1491,11 +1491,14 @@ module ts {
1491
1491
var formattingRulesProvider : TypeScript . Services . Formatting . RulesProvider ;
1492
1492
var hostCache : HostCache ; // A cache of all the information about the files on the host side.
1493
1493
var program : Program ;
1494
+
1494
1495
// this checker is used to answer all LS questions except errors
1495
1496
var typeInfoResolver : TypeChecker ;
1497
+
1496
1498
// the sole purpose of this checker is to return semantic diagnostics
1497
1499
// creation is deferred - use getFullTypeCheckChecker to get instance
1498
1500
var fullTypeCheckChecker_doNotAccessDirectly : TypeChecker ;
1501
+
1499
1502
var useCaseSensitivefilenames = false ;
1500
1503
var sourceFilesByName : Map < SourceFile > = { } ;
1501
1504
var documentRegistry = documentRegistry ;
@@ -2258,31 +2261,35 @@ module ts {
2258
2261
// Having all this logic here is pretty unclean. Consider moving to the roslyn model
2259
2262
// where all symbol display logic is encapsulated into visitors and options.
2260
2263
var totalParts : SymbolDisplayPart [ ] = [ ] ;
2261
- var addType = false ;
2262
2264
2263
2265
if ( symbol . flags & SymbolFlags . Class ) {
2264
2266
totalParts . push ( { text : "class" , kind : SymbolDisplayPartKind . keyword , symbol : undefined } ) ;
2265
2267
totalParts . push ( { text : " " , kind : SymbolDisplayPartKind . space , symbol : undefined } ) ;
2268
+ totalParts . push . apply ( totalParts , typeInfoResolver . symbolToDisplayParts ( symbol , sourceFile ) ) ;
2266
2269
}
2267
2270
else if ( symbol . flags & SymbolFlags . Interface ) {
2268
2271
totalParts . push ( { text : "interface" , kind : SymbolDisplayPartKind . keyword , symbol : undefined } ) ;
2269
2272
totalParts . push ( { text : " " , kind : SymbolDisplayPartKind . space , symbol : undefined } ) ;
2273
+ totalParts . push . apply ( totalParts , typeInfoResolver . symbolToDisplayParts ( symbol , sourceFile ) ) ;
2270
2274
}
2271
2275
else if ( symbol . flags & SymbolFlags . Enum ) {
2272
2276
totalParts . push ( { text : "enum" , kind : SymbolDisplayPartKind . keyword , symbol : undefined } ) ;
2273
2277
totalParts . push ( { text : " " , kind : SymbolDisplayPartKind . space , symbol : undefined } ) ;
2278
+ totalParts . push . apply ( totalParts , typeInfoResolver . symbolToDisplayParts ( symbol , sourceFile ) ) ;
2274
2279
}
2275
2280
else if ( symbol . flags & SymbolFlags . Module ) {
2276
2281
totalParts . push ( { text : "module" , kind : SymbolDisplayPartKind . keyword , symbol : undefined } ) ;
2277
2282
totalParts . push ( { text : " " , kind : SymbolDisplayPartKind . space , symbol : undefined } ) ;
2283
+ totalParts . push . apply ( totalParts , typeInfoResolver . symbolToDisplayParts ( symbol , sourceFile ) ) ;
2278
2284
}
2279
2285
else if ( symbol . flags & SymbolFlags . TypeParameter ) {
2280
2286
totalParts . push ( { text : "(" , kind : SymbolDisplayPartKind . punctuation , symbol : undefined } ) ;
2281
2287
totalParts . push ( { text : "type parameter" , kind : SymbolDisplayPartKind . text , symbol : undefined } ) ;
2282
2288
totalParts . push ( { text : ")" , kind : SymbolDisplayPartKind . punctuation , symbol : undefined } ) ;
2289
+ totalParts . push ( { text : " " , kind : SymbolDisplayPartKind . space , symbol : undefined } ) ;
2290
+ totalParts . push . apply ( totalParts , typeInfoResolver . symbolToDisplayParts ( symbol ) ) ;
2283
2291
}
2284
2292
else {
2285
- addType = true ;
2286
2293
totalParts . push ( { text : "(" , kind : SymbolDisplayPartKind . punctuation , symbol : undefined } ) ;
2287
2294
var text : string ;
2288
2295
@@ -2299,24 +2306,37 @@ module ts {
2299
2306
totalParts . push ( { text : text , kind : SymbolDisplayPartKind . text , symbol : undefined } ) ;
2300
2307
totalParts . push ( { text : ")" , kind : SymbolDisplayPartKind . punctuation , symbol : undefined } ) ;
2301
2308
totalParts . push ( { text : " " , kind : SymbolDisplayPartKind . space , symbol : undefined } ) ;
2302
- }
2303
2309
2304
- totalParts . push . apply ( totalParts , typeInfoResolver . symbolToDisplayParts ( symbol , getContainerNode ( node ) ) ) ;
2310
+ totalParts . push . apply ( totalParts , typeInfoResolver . symbolToDisplayParts ( symbol , getContainerNode ( node ) ) ) ;
2305
2311
2306
- if ( symbol . flags & SymbolFlags . Property ||
2307
- symbol . flags & SymbolFlags . Variable ) {
2308
-
2309
- totalParts . push ( { text : ":" , kind : SymbolDisplayPartKind . punctuation , symbol : undefined } ) ;
2310
- totalParts . push ( { text : " " , kind : SymbolDisplayPartKind . space , symbol : undefined } ) ;
2311
- }
2312
- else if ( symbol . flags & SymbolFlags . EnumMember ) {
2312
+ var type = typeInfoResolver . getTypeOfSymbol ( symbol ) ;
2313
2313
2314
- }
2314
+ if ( symbol . flags & SymbolFlags . Property ||
2315
+ symbol . flags & SymbolFlags . Variable ) {
2315
2316
2316
- if ( addType ) {
2317
- var type = typeInfoResolver . getTypeOfSymbol ( symbol ) ;
2318
- if ( type ) {
2319
- totalParts . push . apply ( totalParts , typeInfoResolver . typeToDisplayParts ( type ) ) ;
2317
+ if ( type ) {
2318
+ totalParts . push ( { text : ":" , kind : SymbolDisplayPartKind . punctuation , symbol : undefined } ) ;
2319
+ totalParts . push ( { text : " " , kind : SymbolDisplayPartKind . space , symbol : undefined } ) ;
2320
+ totalParts . push . apply ( totalParts , typeInfoResolver . typeToDisplayParts ( type , getContainerNode ( node ) ) ) ;
2321
+ }
2322
+ }
2323
+ else if ( symbol . flags & SymbolFlags . Function ||
2324
+ symbol . flags & SymbolFlags . Method ) {
2325
+ if ( type ) {
2326
+ totalParts . push . apply ( totalParts , typeInfoResolver . typeToDisplayParts ( type , getContainerNode ( node ) ) ) ;
2327
+ }
2328
+ }
2329
+ else if ( symbol . flags & SymbolFlags . EnumMember ) {
2330
+ var declaration = symbol . declarations [ 0 ] ;
2331
+ if ( declaration . kind === SyntaxKind . EnumMember ) {
2332
+ var constantValue = typeInfoResolver . getEnumMemberValue ( < EnumMember > declaration ) ;
2333
+ if ( constantValue !== undefined ) {
2334
+ totalParts . push ( { text : " " , kind : SymbolDisplayPartKind . space , symbol : undefined } ) ;
2335
+ totalParts . push ( { text : "=" , kind : SymbolDisplayPartKind . operator , symbol : undefined } ) ;
2336
+ totalParts . push ( { text : " " , kind : SymbolDisplayPartKind . space , symbol : undefined } ) ;
2337
+ totalParts . push ( { text : constantValue . toString ( ) , kind : SymbolDisplayPartKind . numericLiteral , symbol : undefined } ) ;
2338
+ }
2339
+ }
2320
2340
}
2321
2341
}
2322
2342
0 commit comments