Skip to content

Commit 98eb23a

Browse files
committed
Avoid document comment map
1 parent efbf539 commit 98eb23a

File tree

1 file changed

+12
-19
lines changed

1 file changed

+12
-19
lines changed

src/services/services.ts

Lines changed: 12 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -283,12 +283,6 @@ namespace ts {
283283
}
284284
}
285285

286-
enum ContextualDocumentationType {
287-
None = "None",
288-
GetAccessor = "GetAccessor",
289-
SetAccessor = "SetAccessor"
290-
}
291-
292286
class SymbolObject implements Symbol {
293287
flags: SymbolFlags;
294288
escapedName: __String;
@@ -299,7 +293,8 @@ namespace ts {
299293
// symbol has no doc comment, then the empty array will be returned.
300294
documentationComment?: SymbolDisplayPart[];
301295

302-
contextualDocumentationComment?: Map<SymbolDisplayPart[]>;
296+
contextualGetAccessorDocumentationComment?: SymbolDisplayPart[];
297+
contextualSetAccessorDocumentationComment?: SymbolDisplayPart[];
303298

304299
// Undefined is used to indicate the value has not been computed. If, after computing, the
305300
// symbol has no JSDoc tags, then the empty array will be returned.
@@ -341,24 +336,22 @@ namespace ts {
341336
getContextualDocumentationComment(context: Node | undefined, checker: TypeChecker | undefined): SymbolDisplayPart[] {
342337
switch (context?.kind) {
343338
case SyntaxKind.GetAccessor:
344-
return this.getContextualDocumentationCommentCached(ContextualDocumentationType.GetAccessor, filter(this.declarations, isGetAccessor), checker);
339+
if (!this.contextualGetAccessorDocumentationComment) {
340+
this.contextualGetAccessorDocumentationComment = emptyArray;
341+
this.contextualGetAccessorDocumentationComment = getDocumentationComment(filter(this.declarations, isGetAccessor), checker);
342+
}
343+
return this.contextualGetAccessorDocumentationComment
345344
case SyntaxKind.SetAccessor:
346-
return this.getContextualDocumentationCommentCached(ContextualDocumentationType.SetAccessor, filter(this.declarations, isSetAccessor), checker);
345+
if (!this.contextualSetAccessorDocumentationComment) {
346+
this.contextualSetAccessorDocumentationComment = emptyArray;
347+
this.contextualSetAccessorDocumentationComment = getDocumentationComment(filter(this.declarations, isSetAccessor), checker);
348+
}
349+
return this.contextualSetAccessorDocumentationComment
347350
default:
348351
return this.getDocumentationComment(checker);
349352
}
350353
}
351354

352-
getContextualDocumentationCommentCached(type: ContextualDocumentationType, declarations: Declaration[], checker: TypeChecker | undefined): SymbolDisplayPart[] {
353-
if (!this.contextualDocumentationComment) {
354-
this.contextualDocumentationComment = createMultiMap<SymbolDisplayPart>();
355-
}
356-
if (!this.contextualDocumentationComment.has(type)) {
357-
this.contextualDocumentationComment.set(type, getDocumentationComment(declarations, checker));
358-
}
359-
return this.contextualDocumentationComment.get(type)!;
360-
}
361-
362355
getJsDocTags(): JSDocTagInfo[] {
363356
if (this.tags === undefined) {
364357
this.tags = JsDoc.getJsDocTagsFromDeclarations(this.declarations);

0 commit comments

Comments
 (0)