@@ -108,6 +108,7 @@ import {
108108 TypeParameter ,
109109 typeToDisplayParts ,
110110 VariableDeclaration ,
111+ WriterContextOut ,
111112} from "./_namespaces/ts.js" ;
112113
113114const symbolDisplayNodeBuilderFlags = NodeBuilderFlags . OmitParameterModifiers | NodeBuilderFlags . IgnoreErrors | NodeBuilderFlags . UseAliasDefinedOutsideCurrentScope ;
@@ -254,9 +255,20 @@ export interface SymbolDisplayPartsDocumentationAndSymbolKind {
254255 documentation : SymbolDisplayPart [ ] ;
255256 symbolKind : ScriptElementKind ;
256257 tags : JSDocTagInfo [ ] | undefined ;
258+ canIncreaseVerbosityLevel ?: boolean ;
257259}
258260
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 {
260272 const displayParts : SymbolDisplayPart [ ] = [ ] ;
261273 let documentation : SymbolDisplayPart [ ] = [ ] ;
262274 let tags : JSDocTagInfo [ ] = [ ] ;
@@ -267,6 +279,7 @@ function getSymbolDisplayPartsDocumentationAndSymbolKindWorker(typeChecker: Type
267279 let documentationFromAlias : SymbolDisplayPart [ ] | undefined ;
268280 let tagsFromAlias : JSDocTagInfo [ ] | undefined ;
269281 let hasMultipleSignatures = false ;
282+ const typeWriterOut : WriterContextOut | undefined = verbosityLevel !== undefined ? { couldUnfoldMore : false } : undefined ;
270283
271284 if ( location . kind === SyntaxKind . ThisKeyword && ! isThisExpression ) {
272285 return { displayParts : [ keywordPart ( SyntaxKind . ThisKeyword ) ] , documentation : [ ] , symbolKind : ScriptElementKind . primitiveType , tags : undefined } ;
@@ -462,7 +475,17 @@ function getSymbolDisplayPartsDocumentationAndSymbolKindWorker(typeChecker: Type
462475 displayParts . push ( spacePart ( ) ) ;
463476 displayParts . push ( operatorPart ( SyntaxKind . EqualsToken ) ) ;
464477 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+ ) ;
466489 }
467490 if ( symbolFlags & SymbolFlags . Enum ) {
468491 prefixNextMeaning ( ) ;
@@ -650,13 +673,30 @@ function getSymbolDisplayPartsDocumentationAndSymbolKindWorker(typeChecker: Type
650673 // If the type is type parameter, format it specially
651674 if ( type . symbol && type . symbol . flags & SymbolFlags . TypeParameter && symbolKind !== ScriptElementKind . indexSignatureElement ) {
652675 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+ ) ! ;
654684 getPrinter ( ) . writeNode ( EmitHint . Unspecified , param , getSourceFileOfNode ( getParseTreeNode ( enclosingDeclaration ) ) , writer ) ;
655685 } ) ;
656686 addRange ( displayParts , typeParameterParts ) ;
657687 }
658688 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+ ) ;
660700 }
661701 if ( isTransientSymbol ( symbol ) && symbol . links . target && isTransientSymbol ( symbol . links . target ) && symbol . links . target . links . tupleLabelDeclaration ) {
662702 const labelDecl = symbol . links . target . links . tupleLabelDeclaration ;
@@ -742,7 +782,13 @@ function getSymbolDisplayPartsDocumentationAndSymbolKindWorker(typeChecker: Type
742782 tags = tagsFromAlias ;
743783 }
744784
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+ } ;
746792
747793 function getPrinter ( ) {
748794 return createPrinterWithRemoveComments ( ) ;
@@ -874,8 +920,9 @@ export function getSymbolDisplayPartsDocumentationAndSymbolKind(
874920 location : Node ,
875921 semanticMeaning : SemanticMeaning = getMeaningFromLocation ( location ) ,
876922 alias ?: Symbol ,
923+ verbosityLevel ?: number ,
877924) : 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 ) ;
879926}
880927
881928function isLocalVariableOrFunction ( symbol : Symbol ) {
0 commit comments