@@ -661,6 +661,8 @@ module ts {
661
661
getSignatureHelpItems ( fileName : string , position : number ) : SignatureHelpItems ;
662
662
getSignatureHelpCurrentArgumentState ( fileName : string , position : number , applicableSpanStart : number ) : SignatureHelpState ;
663
663
664
+ getSignatureAtPosition ( fileName : string , position : number ) : SignatureInfo ;
665
+
664
666
getRenameInfo ( fileName : string , position : number ) : RenameInfo ;
665
667
getDefinitionAtPosition ( fileName : string , position : number ) : DefinitionInfo [ ] ;
666
668
getReferencesAtPosition ( fileName : string , position : number ) : ReferenceEntry [ ] ;
@@ -686,6 +688,42 @@ module ts {
686
688
dispose ( ) : void ;
687
689
}
688
690
691
+ export interface SignatureInfo {
692
+ actual : ActualSignatureInfo ;
693
+ formal : FormalSignatureItemInfo [ ] ; // Formal signatures
694
+ activeFormal : number ; // Index of the "best match" formal signature
695
+ }
696
+
697
+ export interface FormalSignatureItemInfo {
698
+ signatureInfo : string ;
699
+ typeParameters : FormalTypeParameterInfo [ ] ;
700
+ parameters : FormalParameterInfo [ ] ; // Array of parameters
701
+ docComment : string ; // Help for the signature
702
+ }
703
+
704
+ export interface FormalTypeParameterInfo {
705
+ name : string ; // Type parameter name
706
+ docComment : string ; // Comments that contain help for the parameter
707
+ minChar : number ; // minChar for parameter info in the formal signature info string
708
+ limChar : number ; // lim char for parameter info in the formal signature info string
709
+ }
710
+
711
+ export interface FormalParameterInfo {
712
+ name : string ; // Parameter name
713
+ isVariable : boolean ; // true if parameter is var args
714
+ docComment : string ; // Comments that contain help for the parameter
715
+ minChar : number ; // minChar for parameter info in the formal signature info string
716
+ limChar : number ; // lim char for parameter info in the formal signature info string
717
+ }
718
+
719
+ export interface ActualSignatureInfo {
720
+ parameterMinChar : number ;
721
+ parameterLimChar : number ;
722
+ currentParameterIsTypeParameter : boolean ; // current parameter is a type argument or a normal argument
723
+ currentParameter : number ; // Index of active parameter in "parameters" or "typeParamters" array
724
+ }
725
+
726
+
689
727
export class ClassificationTypeNames {
690
728
public static comment = "comment" ;
691
729
public static identifier = "identifier" ;
@@ -3748,6 +3786,67 @@ module ts {
3748
3786
return SignatureHelp . getSignatureHelpCurrentArgumentState ( sourceFile , position , applicableSpanStart ) ;
3749
3787
}
3750
3788
3789
+ function getSignatureAtPosition ( filename : string , position : number ) : SignatureInfo {
3790
+ var signatureHelpItems = getSignatureHelpItems ( filename , position ) ;
3791
+
3792
+ if ( ! signatureHelpItems ) {
3793
+ return undefined ;
3794
+ }
3795
+
3796
+ var currentArguemntState = getSignatureHelpCurrentArgumentState ( filename , position , signatureHelpItems . applicableSpan . start ( ) ) ;
3797
+
3798
+ var formalSignatures : FormalSignatureItemInfo [ ] = [ ] ;
3799
+ forEach ( signatureHelpItems . items , signature => {
3800
+ var signatureInfoString = signature . prefix ;
3801
+
3802
+ var paramters : FormalParameterInfo [ ] = [ ] ;
3803
+ for ( var i = 0 , n = signature . parameters . length ; i < n ; i ++ ) {
3804
+ var paramter = signature . parameters [ i ] ;
3805
+
3806
+ // add the parameter to the string
3807
+ if ( i ) {
3808
+ signatureInfoString += signature . separator ;
3809
+ }
3810
+ var start = signatureInfoString . length ;
3811
+ signatureInfoString += paramter . display ;
3812
+ var end = signatureInfoString . length - 1 ;
3813
+
3814
+ // add the parameter to the list
3815
+ paramters . push ( {
3816
+ name : paramter . name ,
3817
+ isVariable : i == n - 1 && signature . isVariadic ,
3818
+ docComment : paramter . documentation ,
3819
+ minChar : start ,
3820
+ limChar : end
3821
+ } ) ;
3822
+
3823
+ }
3824
+
3825
+ signatureInfoString += signature . suffix ;
3826
+
3827
+ formalSignatures . push ( {
3828
+ signatureInfo : signatureInfoString ,
3829
+ docComment : signature . documentation ,
3830
+ parameters : paramters ,
3831
+ typeParameters : [ ] ,
3832
+ docComments : signature . documentation
3833
+ } ) ;
3834
+ } ) ;
3835
+
3836
+ var actualSignature : ActualSignatureInfo = {
3837
+ parameterMinChar : 0 ,
3838
+ parameterLimChar : 0 ,
3839
+ currentParameterIsTypeParameter : false ,
3840
+ currentParameter : currentArguemntState . argumentIndex
3841
+ } ;
3842
+
3843
+ return {
3844
+ actual : actualSignature ,
3845
+ formal : formalSignatures ,
3846
+ activeFormal : 0
3847
+ } ;
3848
+ }
3849
+
3751
3850
/// Syntactic features
3752
3851
function getSyntaxTree ( filename : string ) : TypeScript . SyntaxTree {
3753
3852
filename = TypeScript . switchToForwardSlashes ( filename ) ;
@@ -4364,6 +4463,7 @@ module ts {
4364
4463
getFormattingEditsForDocument : getFormattingEditsForDocument ,
4365
4464
getFormattingEditsAfterKeystroke : getFormattingEditsAfterKeystroke ,
4366
4465
getEmitOutput : getEmitOutput ,
4466
+ getSignatureAtPosition : getSignatureAtPosition ,
4367
4467
} ;
4368
4468
}
4369
4469
0 commit comments