@@ -643,14 +643,19 @@ module ts {
643
643
getTypeOfNode ( node : Node ) : Type ;
644
644
getApparentType ( type : Type ) : ApparentType ;
645
645
typeToString ( type : Type , enclosingDeclaration ?: Node , flags ?: TypeFormatFlags ) : string ;
646
+ writeType ( type : Type , writer : SymbolWriter , enclosingDeclaration ?: Node , flags ?: TypeFormatFlags ) : void ;
646
647
symbolToString ( symbol : Symbol , enclosingDeclaration ?: Node , meaning ?: SymbolFlags ) : string ;
647
- typeToDisplayParts ( type : Type , enclosingDeclaration ?: Node , flags ?: TypeFormatFlags ) : SymbolDisplayPart [ ] ;
648
- symbolToDisplayParts ( symbol : Symbol , enclosingDeclaration ?: Node , meaning ?: SymbolFlags ) : SymbolDisplayPart [ ] ;
648
+ writeSymbol ( symbol : Symbol , writer : SymbolWriter , enclosingDeclaration ?: Node , meaning ?: SymbolFlags , flags ?: SymbolFormatFlags ) : void ;
649
649
getFullyQualifiedName ( symbol : Symbol ) : string ;
650
650
getAugmentedPropertiesOfApparentType ( type : Type ) : Symbol [ ] ;
651
651
getRootSymbol ( symbol : Symbol ) : Symbol ;
652
652
getContextualType ( node : Node ) : Type ;
653
653
getResolvedSignature ( node : CallExpression , candidatesOutArray ?: Signature [ ] ) : Signature ;
654
+ getSignatureFromDeclaration ( declaration : SignatureDeclaration ) : Signature ;
655
+ writeSignature ( signatures : Signature , writer : SymbolWriter , enclosingDeclaration ?: Node , flags ?: TypeFormatFlags ) : void ;
656
+ writeTypeParameter ( tp : TypeParameter , writer : SymbolWriter , enclosingDeclaration ?: Node , flags ?: TypeFormatFlags ) : void ;
657
+ writeTypeParametersOfSymbol ( symbol : Symbol , writer : SymbolWriter , enclosingDeclaraiton ?: Node , flags ?: TypeFormatFlags ) : void ;
658
+ isImplementationOfOverload ( node : FunctionDeclaration ) : boolean ;
654
659
655
660
// Returns the constant value of this enum member, or 'undefined' if the enum member has a
656
661
// computed value.
@@ -660,20 +665,36 @@ module ts {
660
665
getAliasedSymbol ( symbol : Symbol ) : Symbol ;
661
666
}
662
667
663
- export interface TextWriter {
664
- write ( s : string ) : void ;
665
- trackSymbol ( symbol : Symbol , enclosingDeclaration ?: Node , meaning ?: SymbolFlags ) : void ;
668
+ export interface SymbolWriter {
669
+ writeKind ( text : string , kind : SymbolDisplayPartKind ) : void ;
670
+ writeSymbol ( text : string , symbol : Symbol ) : void ;
666
671
writeLine ( ) : void ;
667
672
increaseIndent ( ) : void ;
668
673
decreaseIndent ( ) : void ;
669
- getText ( ) : string ;
674
+ clear ( ) : void ;
675
+
676
+ // Called when the symbol writer encounters a symbol to write. Currently only used by the
677
+ // declaration emitter to help determine if it should patch up the final declaration file
678
+ // with import statements it previously saw (but chose not to emit).
679
+ trackSymbol ( symbol : Symbol , enclosingDeclaration ?: Node , meaning ?: SymbolFlags ) : void ;
670
680
}
671
681
672
682
export enum TypeFormatFlags {
673
- None = 0x00000000 ,
674
- WriteArrayAsGenericType = 0x00000001 , // Write Array<T> instead T[]
675
- UseTypeOfFunction = 0x00000002 , // Write typeof instead of function type literal
676
- NoTruncation = 0x00000004 , // Don't truncate typeToString result
683
+ None = 0x00000000 ,
684
+ WriteArrayAsGenericType = 0x00000001 , // Write Array<T> instead T[]
685
+ UseTypeOfFunction = 0x00000002 , // Write typeof instead of function type literal
686
+ NoTruncation = 0x00000004 , // Don't truncate typeToString result
687
+ WriteArrowStyleSignature = 0x00000008 , // Write arrow style signature
688
+ WriteOwnNameForAnyLike = 0x00000010 , // Write symbol's own name instead of 'any' for any like types (eg. unknown, __resolving__ etc)
689
+ WriteTypeArgumentsOfSignature = 0x00000020 , // Write the type arguments instead of type parameters of the signature
690
+ }
691
+
692
+ export enum SymbolFormatFlags {
693
+ None = 0x00000000 ,
694
+ WriteTypeParametersOrArguments = 0x00000001 , // Write symbols's type argument if it is instantiated symbol
695
+ // eg. class C<T> { p: T } <-- Show p as C<T>.p here
696
+ // var a: C<number>;
697
+ // var p = a.p; <--- Here p is property of C<number> so show it as C<number>.p instead of just C.p
677
698
}
678
699
679
700
export enum SymbolAccessibility {
@@ -701,8 +722,8 @@ module ts {
701
722
hasSemanticErrors ( ) : boolean ;
702
723
isDeclarationVisible ( node : Declaration ) : boolean ;
703
724
isImplementationOfOverload ( node : FunctionDeclaration ) : boolean ;
704
- writeTypeAtLocation ( location : Node , enclosingDeclaration : Node , flags : TypeFormatFlags , writer : TextWriter ) : void ;
705
- writeReturnTypeOfSignatureDeclaration ( signatureDeclaration : SignatureDeclaration , enclosingDeclaration : Node , flags : TypeFormatFlags , writer : TextWriter ) : void ;
725
+ writeTypeAtLocation ( location : Node , enclosingDeclaration : Node , flags : TypeFormatFlags , writer : SymbolWriter ) : void ;
726
+ writeReturnTypeOfSignatureDeclaration ( signatureDeclaration : SignatureDeclaration , enclosingDeclaration : Node , flags : TypeFormatFlags , writer : SymbolWriter ) : void ;
706
727
isSymbolAccessible ( symbol : Symbol , enclosingDeclaration : Node , meaning : SymbolFlags ) : SymbolAccessiblityResult ;
707
728
isImportDeclarationEntityNameReferenceDeclarationVisibile ( entityName : EntityName ) : SymbolAccessiblityResult ;
708
729
@@ -743,6 +764,8 @@ module ts {
743
764
Transient = 0x02000000 , // Transient symbol (created during type check)
744
765
Prototype = 0x04000000 , // Symbol for the prototype property (without source code representation)
745
766
767
+ Undefined = 0x08000000 , // Symbol for the undefined
768
+
746
769
Value = Variable | Property | EnumMember | Function | Class | Enum | ValueModule | Method | GetAccessor | SetAccessor ,
747
770
Type = Class | Interface | Enum | TypeLiteral | ObjectLiteral | TypeParameter ,
748
771
Namespace = ValueModule | NamespaceModule ,
@@ -1190,45 +1213,24 @@ module ts {
1190
1213
verticalTab = 0x0B , // \v
1191
1214
}
1192
1215
1193
- export class SymbolDisplayPart {
1194
- constructor ( public text : string ,
1195
- public kind : SymbolDisplayPartKind ,
1196
- public symbol : Symbol ) {
1197
- }
1198
-
1199
- public toJSON ( ) {
1200
- return {
1201
- text : this . text ,
1202
- kind : SymbolDisplayPartKind [ this . kind ]
1203
- } ;
1204
- }
1205
-
1206
- public static toString ( parts : SymbolDisplayPart [ ] ) {
1207
- return parts . map ( p => p . text ) . join ( "" ) ;
1208
- }
1209
- }
1210
-
1211
1216
export enum SymbolDisplayPartKind {
1212
1217
aliasName ,
1213
1218
className ,
1214
1219
enumName ,
1215
1220
fieldName ,
1216
1221
interfaceName ,
1217
1222
keyword ,
1218
- labelName ,
1219
1223
lineBreak ,
1220
1224
numericLiteral ,
1221
1225
stringLiteral ,
1222
1226
localName ,
1223
1227
methodName ,
1224
1228
moduleName ,
1225
- namespaceName ,
1226
1229
operator ,
1227
1230
parameterName ,
1228
1231
propertyName ,
1229
1232
punctuation ,
1230
1233
space ,
1231
- anonymousTypeIndicator ,
1232
1234
text ,
1233
1235
typeParameterName ,
1234
1236
enumMemberName ,
0 commit comments