@@ -108,6 +108,7 @@ import {
108
108
TypeParameter ,
109
109
typeToDisplayParts ,
110
110
VariableDeclaration ,
111
+ WriterContextOut ,
111
112
} from "./_namespaces/ts.js" ;
112
113
113
114
const symbolDisplayNodeBuilderFlags = NodeBuilderFlags . OmitParameterModifiers | NodeBuilderFlags . IgnoreErrors | NodeBuilderFlags . UseAliasDefinedOutsideCurrentScope ;
@@ -254,9 +255,20 @@ export interface SymbolDisplayPartsDocumentationAndSymbolKind {
254
255
documentation : SymbolDisplayPart [ ] ;
255
256
symbolKind : ScriptElementKind ;
256
257
tags : JSDocTagInfo [ ] | undefined ;
258
+ canIncreaseVerbosityLevel ?: boolean ;
257
259
}
258
260
259
- function getSymbolDisplayPartsDocumentationAndSymbolKindWorker ( typeChecker : TypeChecker , symbol : Symbol , sourceFile : SourceFile , enclosingDeclaration : Node | undefined , location : Node , type : Type | undefined , semanticMeaning : SemanticMeaning , alias ?: Symbol ) : SymbolDisplayPartsDocumentationAndSymbolKind {
261
+ function getSymbolDisplayPartsDocumentationAndSymbolKindWorker (
262
+ typeChecker : TypeChecker ,
263
+ symbol : Symbol ,
264
+ sourceFile : SourceFile ,
265
+ enclosingDeclaration : Node | undefined ,
266
+ location : Node ,
267
+ type : Type | undefined ,
268
+ semanticMeaning : SemanticMeaning ,
269
+ alias ?: Symbol ,
270
+ verbosityLevel ?: number ,
271
+ ) : SymbolDisplayPartsDocumentationAndSymbolKind {
260
272
const displayParts : SymbolDisplayPart [ ] = [ ] ;
261
273
let documentation : SymbolDisplayPart [ ] = [ ] ;
262
274
let tags : JSDocTagInfo [ ] = [ ] ;
@@ -267,6 +279,7 @@ function getSymbolDisplayPartsDocumentationAndSymbolKindWorker(typeChecker: Type
267
279
let documentationFromAlias : SymbolDisplayPart [ ] | undefined ;
268
280
let tagsFromAlias : JSDocTagInfo [ ] | undefined ;
269
281
let hasMultipleSignatures = false ;
282
+ const typeWriterOut : WriterContextOut | undefined = verbosityLevel !== undefined ? { couldUnfoldMore : false } : undefined ;
270
283
271
284
if ( location . kind === SyntaxKind . ThisKeyword && ! isThisExpression ) {
272
285
return { displayParts : [ keywordPart ( SyntaxKind . ThisKeyword ) ] , documentation : [ ] , symbolKind : ScriptElementKind . primitiveType , tags : undefined } ;
@@ -462,7 +475,17 @@ function getSymbolDisplayPartsDocumentationAndSymbolKindWorker(typeChecker: Type
462
475
displayParts . push ( spacePart ( ) ) ;
463
476
displayParts . push ( operatorPart ( SyntaxKind . EqualsToken ) ) ;
464
477
displayParts . push ( spacePart ( ) ) ;
465
- addRange ( displayParts , typeToDisplayParts ( typeChecker , location . parent && isConstTypeReference ( location . parent ) ? typeChecker . getTypeAtLocation ( location . parent ) : typeChecker . getDeclaredTypeOfSymbol ( symbol ) , enclosingDeclaration , TypeFormatFlags . InTypeAlias ) ) ;
478
+ addRange (
479
+ displayParts ,
480
+ typeToDisplayParts (
481
+ typeChecker ,
482
+ location . parent && isConstTypeReference ( location . parent ) ? typeChecker . getTypeAtLocation ( location . parent ) : typeChecker . getDeclaredTypeOfSymbol ( symbol ) ,
483
+ enclosingDeclaration ,
484
+ TypeFormatFlags . InTypeAlias ,
485
+ verbosityLevel ,
486
+ typeWriterOut ,
487
+ ) ,
488
+ ) ;
466
489
}
467
490
if ( symbolFlags & SymbolFlags . Enum ) {
468
491
prefixNextMeaning ( ) ;
@@ -650,13 +673,30 @@ function getSymbolDisplayPartsDocumentationAndSymbolKindWorker(typeChecker: Type
650
673
// If the type is type parameter, format it specially
651
674
if ( type . symbol && type . symbol . flags & SymbolFlags . TypeParameter && symbolKind !== ScriptElementKind . indexSignatureElement ) {
652
675
const typeParameterParts = mapToDisplayParts ( writer => {
653
- const param = typeChecker . typeParameterToDeclaration ( type as TypeParameter , enclosingDeclaration , symbolDisplayNodeBuilderFlags ) ! ;
676
+ const param = typeChecker . typeParameterToDeclaration (
677
+ type as TypeParameter ,
678
+ enclosingDeclaration ,
679
+ symbolDisplayNodeBuilderFlags ,
680
+ /*internalFlags*/ undefined ,
681
+ /*tracker*/ undefined ,
682
+ verbosityLevel ,
683
+ ) ! ;
654
684
getPrinter ( ) . writeNode ( EmitHint . Unspecified , param , getSourceFileOfNode ( getParseTreeNode ( enclosingDeclaration ) ) , writer ) ;
655
685
} ) ;
656
686
addRange ( displayParts , typeParameterParts ) ;
657
687
}
658
688
else {
659
- addRange ( displayParts , typeToDisplayParts ( typeChecker , type , enclosingDeclaration ) ) ;
689
+ addRange (
690
+ displayParts ,
691
+ typeToDisplayParts (
692
+ typeChecker ,
693
+ type ,
694
+ enclosingDeclaration ,
695
+ /*flags*/ undefined ,
696
+ verbosityLevel ,
697
+ typeWriterOut ,
698
+ ) ,
699
+ ) ;
660
700
}
661
701
if ( isTransientSymbol ( symbol ) && symbol . links . target && isTransientSymbol ( symbol . links . target ) && symbol . links . target . links . tupleLabelDeclaration ) {
662
702
const labelDecl = symbol . links . target . links . tupleLabelDeclaration ;
@@ -742,7 +782,13 @@ function getSymbolDisplayPartsDocumentationAndSymbolKindWorker(typeChecker: Type
742
782
tags = tagsFromAlias ;
743
783
}
744
784
745
- return { displayParts, documentation, symbolKind, tags : tags . length === 0 ? undefined : tags } ;
785
+ return {
786
+ displayParts,
787
+ documentation,
788
+ symbolKind,
789
+ tags : tags . length === 0 ? undefined : tags ,
790
+ canIncreaseVerbosityLevel : typeWriterOut ?. couldUnfoldMore ,
791
+ } ;
746
792
747
793
function getPrinter ( ) {
748
794
return createPrinterWithRemoveComments ( ) ;
@@ -874,8 +920,9 @@ export function getSymbolDisplayPartsDocumentationAndSymbolKind(
874
920
location : Node ,
875
921
semanticMeaning : SemanticMeaning = getMeaningFromLocation ( location ) ,
876
922
alias ?: Symbol ,
923
+ verbosityLevel ?: number ,
877
924
) : SymbolDisplayPartsDocumentationAndSymbolKind {
878
- return getSymbolDisplayPartsDocumentationAndSymbolKindWorker ( typeChecker , symbol , sourceFile , enclosingDeclaration , location , /*type*/ undefined , semanticMeaning , alias ) ;
925
+ return getSymbolDisplayPartsDocumentationAndSymbolKindWorker ( typeChecker , symbol , sourceFile , enclosingDeclaration , location , /*type*/ undefined , semanticMeaning , alias , verbosityLevel ) ;
879
926
}
880
927
881
928
function isLocalVariableOrFunction ( symbol : Symbol ) {
0 commit comments