@@ -81,7 +81,7 @@ module ts.server {
81
81
function formatDiag ( fileName : string , project : Project , diag : ts . Diagnostic ) {
82
82
return {
83
83
start : project . compilerService . host . positionToLineCol ( fileName , diag . start ) ,
84
- end : project . compilerService . host . positionToLineCol ( fileName , diag . start + diag . length ) ,
84
+ end : project . compilerService . host . positionToLineCol ( fileName , diag . start + diag . length ) ,
85
85
text : ts . flattenDiagnosticMessageText ( diag . messageText , "\n" )
86
86
} ;
87
87
}
@@ -104,6 +104,7 @@ module ts.server {
104
104
export var Change = "change" ;
105
105
export var Close = "close" ;
106
106
export var Completions = "completions" ;
107
+ export var CompletionDetails = "completionEntryDetails" ;
107
108
export var Definition = "definition" ;
108
109
export var Format = "format" ;
109
110
export var Formatonkey = "formatonkey" ;
@@ -486,8 +487,8 @@ module ts.server {
486
487
} ;
487
488
} ) ;
488
489
}
489
-
490
- getCompletions ( line : number , col : number , prefix : string , fileName : string ) : protocol . CompletionItem [ ] {
490
+
491
+ getCompletions ( line : number , col : number , prefix : string , fileName : string ) : protocol . CompletionEntry [ ] {
491
492
if ( ! prefix ) {
492
493
prefix = "" ;
493
494
}
@@ -505,27 +506,34 @@ module ts.server {
505
506
throw Errors . NoContent ;
506
507
}
507
508
508
- return completions . entries . reduce ( ( result : ts . CompletionEntryDetails [ ] , entry : ts . CompletionEntry ) => {
509
+ return completions . entries . reduce ( ( result : protocol . CompletionEntry [ ] , entry : ts . CompletionEntry ) => {
509
510
if ( completions . isMemberCompletion || entry . name . indexOf ( prefix ) == 0 ) {
510
- var protoEntry = < ts . CompletionEntryDetails > { } ;
511
- protoEntry . name = entry . name ;
512
- protoEntry . kind = entry . kind ;
513
- if ( entry . kindModifiers && ( entry . kindModifiers . length > 0 ) ) {
514
- protoEntry . kindModifiers = entry . kindModifiers ;
515
- }
516
- var details = compilerService . languageService . getCompletionEntryDetails ( file , position , entry . name ) ;
517
- if ( details && ( details . documentation ) && ( details . documentation . length > 0 ) ) {
518
- protoEntry . documentation = details . documentation ;
519
- }
520
- if ( details && ( details . displayParts ) && ( details . displayParts . length > 0 ) ) {
521
- protoEntry . displayParts = details . displayParts ;
522
- }
523
- result . push ( protoEntry ) ;
511
+ result . push ( entry ) ;
524
512
}
525
513
return result ;
526
514
} , [ ] ) ;
527
515
}
528
516
517
+ getCompletionEntryDetails ( line : number , col : number ,
518
+ entryNames : string [ ] , fileName : string ) : protocol . CompletionEntryDetails [ ] {
519
+ var file = ts . normalizePath ( fileName ) ;
520
+ var project = this . projectService . getProjectForFile ( file ) ;
521
+ if ( ! project ) {
522
+ throw Errors . NoProject ;
523
+ }
524
+
525
+ var compilerService = project . compilerService ;
526
+ var position = compilerService . host . lineColToPosition ( file , line , col ) ;
527
+
528
+ return entryNames . reduce ( ( accum : protocol . CompletionEntryDetails [ ] , entryName : string ) => {
529
+ var details = compilerService . languageService . getCompletionEntryDetails ( file , position , entryName ) ;
530
+ if ( details ) {
531
+ accum . push ( details ) ;
532
+ }
533
+ return accum ;
534
+ } , [ ] ) ;
535
+ }
536
+
529
537
getDiagnostics ( delay : number , fileNames : string [ ] ) {
530
538
var checkList = fileNames . reduce ( ( accum : PendingErrorCheck [ ] , fileName : string ) => {
531
539
fileName = ts . normalizePath ( fileName ) ;
@@ -724,6 +732,12 @@ module ts.server {
724
732
response = this . getCompletions ( request . arguments . line , request . arguments . col , completionsArgs . prefix , request . arguments . file ) ;
725
733
break ;
726
734
}
735
+ case CommandNames . CompletionDetails : {
736
+ var completionDetailsArgs = < protocol . CompletionDetailsRequestArgs > request . arguments ;
737
+ response = this . getCompletionEntryDetails ( request . arguments . line , request . arguments . col , completionDetailsArgs . entryNames ,
738
+ request . arguments . file ) ;
739
+ break ;
740
+ }
727
741
case CommandNames . Geterr : {
728
742
var geterrArgs = < protocol . GeterrRequestArgs > request . arguments ;
729
743
response = this . getDiagnostics ( geterrArgs . delay , geterrArgs . files ) ;
0 commit comments