mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-07-04 14:56:16 -05:00
Add support of contextual quick info (#37451)
* Add support of contextual quick info * Avoid document comment map * Make lint happy Co-authored-by: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com>
This commit is contained in:
@@ -293,6 +293,9 @@ namespace ts {
|
||||
// symbol has no doc comment, then the empty array will be returned.
|
||||
documentationComment?: SymbolDisplayPart[];
|
||||
|
||||
contextualGetAccessorDocumentationComment?: SymbolDisplayPart[];
|
||||
contextualSetAccessorDocumentationComment?: SymbolDisplayPart[];
|
||||
|
||||
// Undefined is used to indicate the value has not been computed. If, after computing, the
|
||||
// symbol has no JSDoc tags, then the empty array will be returned.
|
||||
tags?: JSDocTagInfo[];
|
||||
@@ -330,6 +333,25 @@ namespace ts {
|
||||
return this.documentationComment;
|
||||
}
|
||||
|
||||
getContextualDocumentationComment(context: Node | undefined, checker: TypeChecker | undefined): SymbolDisplayPart[] {
|
||||
switch (context?.kind) {
|
||||
case SyntaxKind.GetAccessor:
|
||||
if (!this.contextualGetAccessorDocumentationComment) {
|
||||
this.contextualGetAccessorDocumentationComment = emptyArray;
|
||||
this.contextualGetAccessorDocumentationComment = getDocumentationComment(filter(this.declarations, isGetAccessor), checker);
|
||||
}
|
||||
return this.contextualGetAccessorDocumentationComment;
|
||||
case SyntaxKind.SetAccessor:
|
||||
if (!this.contextualSetAccessorDocumentationComment) {
|
||||
this.contextualSetAccessorDocumentationComment = emptyArray;
|
||||
this.contextualSetAccessorDocumentationComment = getDocumentationComment(filter(this.declarations, isSetAccessor), checker);
|
||||
}
|
||||
return this.contextualSetAccessorDocumentationComment;
|
||||
default:
|
||||
return this.getDocumentationComment(checker);
|
||||
}
|
||||
}
|
||||
|
||||
getJsDocTags(): JSDocTagInfo[] {
|
||||
if (this.tags === undefined) {
|
||||
this.tags = JsDoc.getJsDocTagsFromDeclarations(this.declarations);
|
||||
|
||||
@@ -502,7 +502,7 @@ namespace ts.SymbolDisplay {
|
||||
}
|
||||
|
||||
if (documentation.length === 0 && !hasMultipleSignatures) {
|
||||
documentation = symbol.getDocumentationComment(typeChecker);
|
||||
documentation = symbol.getContextualDocumentationComment(enclosingDeclaration, typeChecker);
|
||||
}
|
||||
|
||||
if (documentation.length === 0 && symbolFlags & SymbolFlags.Property) {
|
||||
|
||||
@@ -41,6 +41,8 @@ namespace ts {
|
||||
getName(): string;
|
||||
getDeclarations(): Declaration[] | undefined;
|
||||
getDocumentationComment(typeChecker: TypeChecker | undefined): SymbolDisplayPart[];
|
||||
/* @internal */
|
||||
getContextualDocumentationComment(context: Node | undefined, checker: TypeChecker | undefined): SymbolDisplayPart[]
|
||||
getJsDocTags(): JSDocTagInfo[];
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user