From 154d25c5fa2e6c7add01b1ebabe40dd31369a65a Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy Date: Tue, 4 Apr 2017 14:47:47 -0700 Subject: [PATCH] Update LKG --- lib/protocol.d.ts | 17 ++++++++++ lib/tsc.js | 3 +- lib/tsserver.js | 62 ++++++++++++++++++++++++++++++++----- lib/tsserverlibrary.d.ts | 12 +++++++ lib/tsserverlibrary.js | 62 ++++++++++++++++++++++++++++++++----- lib/typescript.d.ts | 9 ++++++ lib/typescript.js | 62 ++++++++++++++++++++++++++++++++----- lib/typescriptServices.d.ts | 9 ++++++ lib/typescriptServices.js | 62 ++++++++++++++++++++++++++++++++----- 9 files changed, 265 insertions(+), 33 deletions(-) diff --git a/lib/protocol.d.ts b/lib/protocol.d.ts index 0c0bdb8421c30..ee0cfa2d8cc23 100644 --- a/lib/protocol.d.ts +++ b/lib/protocol.d.ts @@ -973,6 +973,10 @@ declare namespace ts.server.protocol { * Documentation associated with symbol. */ documentation: string; + /** + * JSDoc tags associated with symbol. + */ + tags: JSDocTagInfo[]; } /** * Quickinfo response message. @@ -1174,6 +1178,10 @@ declare namespace ts.server.protocol { * Documentation strings for the symbol. */ documentation: SymbolDisplayPart[]; + /** + * JSDoc tags for the symbol. + */ + tags: JSDocTagInfo[]; } interface CompletionsResponse extends Response { body?: CompletionEntry[]; @@ -1230,6 +1238,10 @@ declare namespace ts.server.protocol { * The signature's documentation */ documentation: SymbolDisplayPart[]; + /** + * The signature's JSDoc tags + */ + tags: JSDocTagInfo[]; } /** * Signature help items found in the response of a signature help request. @@ -1891,6 +1903,11 @@ declare namespace ts.server.protocol { isMixedContent: boolean; } + interface JSDocTagInfo { + name: string; + text?: string; + } + /** * Type of objects whose values are all of the same type. * The `in` and `for-in` operators can *not* be safely used, diff --git a/lib/tsc.js b/lib/tsc.js index e7d6d8613d8be..ef6585fb861f5 100644 --- a/lib/tsc.js +++ b/lib/tsc.js @@ -6243,6 +6243,7 @@ var ts; cache = ts.concatenate(cache, node.jsDoc); } } + ts.getJSDocs = getJSDocs; function getJSDocParameterTags(param) { if (!isParameter(param)) { return undefined; @@ -16627,7 +16628,7 @@ var ts; } function parseTagComments(indent) { var comments = []; - var state = 1; + var state = 0; var margin; function pushComment(text) { if (!margin) { diff --git a/lib/tsserver.js b/lib/tsserver.js index d190c460d91af..21da050138302 100644 --- a/lib/tsserver.js +++ b/lib/tsserver.js @@ -6417,6 +6417,7 @@ var ts; cache = ts.concatenate(cache, node.jsDoc); } } + ts.getJSDocs = getJSDocs; function getJSDocParameterTags(param) { if (!isParameter(param)) { return undefined; @@ -18434,7 +18435,7 @@ var ts; } function parseTagComments(indent) { var comments = []; - var state = 1; + var state = 0; var margin; function pushComment(text) { if (!margin) { @@ -60253,13 +60254,14 @@ var ts; var symbols = completionData.symbols, location_1 = completionData.location; var symbol = ts.forEach(symbols, function (s) { return getCompletionEntryDisplayNameForSymbol(typeChecker, s, compilerOptions.target, false, location_1) === entryName ? s : undefined; }); if (symbol) { - var _a = ts.SymbolDisplay.getSymbolDisplayPartsDocumentationAndSymbolKind(typeChecker, symbol, sourceFile, location_1, location_1, 7), displayParts = _a.displayParts, documentation = _a.documentation, symbolKind = _a.symbolKind; + var _a = ts.SymbolDisplay.getSymbolDisplayPartsDocumentationAndSymbolKind(typeChecker, symbol, sourceFile, location_1, location_1, 7), displayParts = _a.displayParts, documentation = _a.documentation, symbolKind = _a.symbolKind, tags = _a.tags; return { name: entryName, kindModifiers: ts.SymbolDisplay.getSymbolModifiers(symbol), kind: symbolKind, displayParts: displayParts, - documentation: documentation + documentation: documentation, + tags: tags }; } } @@ -60270,7 +60272,8 @@ var ts; kind: ts.ScriptElementKind.keyword, kindModifiers: ts.ScriptElementKindModifier.none, displayParts: [ts.displayPart(entryName, ts.SymbolDisplayPartKind.keyword)], - documentation: undefined + documentation: undefined, + tags: undefined }; } return undefined; @@ -62939,6 +62942,29 @@ var ts; return documentationComment; } JsDoc.getJsDocCommentsFromDeclarations = getJsDocCommentsFromDeclarations; + function getJsDocTagsFromDeclarations(declarations) { + var tags = []; + forEachUnique(declarations, function (declaration) { + var jsDocs = ts.getJSDocs(declaration); + if (!jsDocs) { + return; + } + for (var _i = 0, jsDocs_1 = jsDocs; _i < jsDocs_1.length; _i++) { + var doc = jsDocs_1[_i]; + var tagsForDoc = doc.tags; + if (tagsForDoc) { + tags.push.apply(tags, tagsForDoc.filter(function (tag) { return tag.kind === 283; }).map(function (jsDocTag) { + return { + name: jsDocTag.tagName.text, + text: jsDocTag.comment + }; + })); + } + } + }); + return tags; + } + JsDoc.getJsDocTagsFromDeclarations = getJsDocTagsFromDeclarations; function forEachUnique(array, callback) { if (array) { for (var i = 0; i < array.length; i++) { @@ -65130,7 +65156,8 @@ var ts; suffixDisplayParts: suffixDisplayParts, separatorDisplayParts: [ts.punctuationPart(25), ts.spacePart()], parameters: signatureHelpParameters, - documentation: candidateSignature.getDocumentationComment() + documentation: candidateSignature.getDocumentationComment(), + tags: candidateSignature.getJsDocTags() }; }); var argumentIndex = argumentListInfo.argumentIndex; @@ -65271,6 +65298,7 @@ var ts; if (semanticMeaning === void 0) { semanticMeaning = ts.getMeaningFromLocation(location); } var displayParts = []; var documentation; + var tags; var symbolFlags = symbol.flags; var symbolKind = getSymbolKindOfConstructorPropertyMethodAccessorFunctionOrVar(typeChecker, symbol, location); var hasAddedSymbolInfo; @@ -65557,6 +65585,7 @@ var ts; } if (!documentation) { documentation = symbol.getDocumentationComment(); + tags = symbol.getJsDocTags(); if (documentation.length === 0 && symbol.flags & 4) { if (symbol.parent && ts.forEach(symbol.parent.declarations, function (declaration) { return declaration.kind === 264; })) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { @@ -65569,6 +65598,7 @@ var ts; continue; } documentation = rhsSymbol.getDocumentationComment(); + tags = rhsSymbol.getJsDocTags(); if (documentation.length > 0) { break; } @@ -65576,7 +65606,7 @@ var ts; } } } - return { displayParts: displayParts, documentation: documentation, symbolKind: symbolKind }; + return { displayParts: displayParts, documentation: documentation, symbolKind: symbolKind, tags: tags }; function addNewLineIfDisplayPartsExist() { if (displayParts.length) { displayParts.push(ts.lineBreakPart()); @@ -65627,6 +65657,7 @@ var ts; displayParts.push(ts.punctuationPart(19)); } documentation = signature.getDocumentationComment(); + tags = signature.getJsDocTags(); } function writeTypeParametersOfSymbol(symbol, enclosingDeclaration) { var typeParameterParts = ts.mapToDisplayParts(function (writer) { @@ -70133,6 +70164,12 @@ var ts; } return this.documentationComment; }; + SymbolObject.prototype.getJsDocTags = function () { + if (this.tags === undefined) { + this.tags = ts.JsDoc.getJsDocTagsFromDeclarations(this.declarations); + } + return this.tags; + }; return SymbolObject; }()); var TokenObject = (function (_super) { @@ -70216,6 +70253,12 @@ var ts; } return this.documentationComment; }; + SignatureObject.prototype.getJsDocTags = function () { + if (this.jsDocTags === undefined) { + this.jsDocTags = this.declaration ? ts.JsDoc.getJsDocTagsFromDeclarations([this.declaration]) : []; + } + return this.jsDocTags; + }; return SignatureObject; }()); var SourceFileObject = (function (_super) { @@ -70847,7 +70890,8 @@ var ts; kindModifiers: ts.ScriptElementKindModifier.none, textSpan: ts.createTextSpan(node.getStart(), node.getWidth()), displayParts: ts.typeToDisplayParts(typeChecker, type, ts.getContainerNode(node)), - documentation: type.symbol ? type.symbol.getDocumentationComment() : undefined + documentation: type.symbol ? type.symbol.getDocumentationComment() : undefined, + tags: type.symbol ? type.symbol.getJsDocTags() : undefined }; } } @@ -70859,7 +70903,8 @@ var ts; kindModifiers: ts.SymbolDisplay.getSymbolModifiers(symbol), textSpan: ts.createTextSpan(node.getStart(), node.getWidth()), displayParts: displayPartsDocumentationsAndKind.displayParts, - documentation: displayPartsDocumentationsAndKind.documentation + documentation: displayPartsDocumentationsAndKind.documentation, + tags: displayPartsDocumentationsAndKind.tags }; } function getDefinitionAtPosition(fileName, position) { @@ -76212,6 +76257,7 @@ var ts; end: scriptInfo.positionToLineOffset(ts.textSpanEnd(quickInfo.textSpan)), displayString: displayString, documentation: docString, + tags: quickInfo.tags || [] }; } else { diff --git a/lib/tsserverlibrary.d.ts b/lib/tsserverlibrary.d.ts index 8d9eb32b3d447..9d924bded2af9 100644 --- a/lib/tsserverlibrary.d.ts +++ b/lib/tsserverlibrary.d.ts @@ -2809,6 +2809,7 @@ declare namespace ts { getName(): string; getDeclarations(): Declaration[]; getDocumentationComment(): SymbolDisplayPart[]; + getJsDocTags(): JSDocTagInfo[]; } interface Type { getFlags(): TypeFlags; @@ -2829,6 +2830,7 @@ declare namespace ts { getParameters(): Symbol[]; getReturnType(): Type; getDocumentationComment(): SymbolDisplayPart[]; + getJsDocTags(): JSDocTagInfo[]; } interface SourceFile { getLineAndCharacterOfPosition(pos: number): LineAndCharacter; @@ -3119,12 +3121,17 @@ declare namespace ts { text: string; kind: string; } + interface JSDocTagInfo { + name: string; + text?: string; + } interface QuickInfo { kind: string; kindModifiers: string; textSpan: TextSpan; displayParts: SymbolDisplayPart[]; documentation: SymbolDisplayPart[]; + tags: JSDocTagInfo[]; } interface RenameInfo { canRename: boolean; @@ -3148,6 +3155,7 @@ declare namespace ts { separatorDisplayParts: SymbolDisplayPart[]; parameters: SignatureHelpParameter[]; documentation: SymbolDisplayPart[]; + tags: JSDocTagInfo[]; } interface SignatureHelpItems { items: SignatureHelpItem[]; @@ -3175,6 +3183,7 @@ declare namespace ts { kindModifiers: string; displayParts: SymbolDisplayPart[]; documentation: SymbolDisplayPart[]; + tags: JSDocTagInfo[]; } interface OutliningSpan { textSpan: TextSpan; @@ -3936,6 +3945,7 @@ declare namespace ts.server.protocol { end: Location; displayString: string; documentation: string; + tags: JSDocTagInfo[]; } interface QuickInfoResponse extends Response { body?: QuickInfoResponseBody; @@ -4007,6 +4017,7 @@ declare namespace ts.server.protocol { kindModifiers: string; displayParts: SymbolDisplayPart[]; documentation: SymbolDisplayPart[]; + tags: JSDocTagInfo[]; } interface CompletionsResponse extends Response { body?: CompletionEntry[]; @@ -4027,6 +4038,7 @@ declare namespace ts.server.protocol { separatorDisplayParts: SymbolDisplayPart[]; parameters: SignatureHelpParameter[]; documentation: SymbolDisplayPart[]; + tags: JSDocTagInfo[]; } interface SignatureHelpItems { items: SignatureHelpItem[]; diff --git a/lib/tsserverlibrary.js b/lib/tsserverlibrary.js index 328b3f67b4763..335d8a4fb1f7d 100644 --- a/lib/tsserverlibrary.js +++ b/lib/tsserverlibrary.js @@ -9322,6 +9322,7 @@ var ts; cache = ts.concatenate(cache, node.jsDoc); } } + ts.getJSDocs = getJSDocs; function getJSDocParameterTags(param) { if (!isParameter(param)) { return undefined; @@ -19777,7 +19778,7 @@ var ts; } function parseTagComments(indent) { var comments = []; - var state = 1; + var state = 0; var margin; function pushComment(text) { if (!margin) { @@ -60253,13 +60254,14 @@ var ts; var symbols = completionData.symbols, location_1 = completionData.location; var symbol = ts.forEach(symbols, function (s) { return getCompletionEntryDisplayNameForSymbol(typeChecker, s, compilerOptions.target, false, location_1) === entryName ? s : undefined; }); if (symbol) { - var _a = ts.SymbolDisplay.getSymbolDisplayPartsDocumentationAndSymbolKind(typeChecker, symbol, sourceFile, location_1, location_1, 7), displayParts = _a.displayParts, documentation = _a.documentation, symbolKind = _a.symbolKind; + var _a = ts.SymbolDisplay.getSymbolDisplayPartsDocumentationAndSymbolKind(typeChecker, symbol, sourceFile, location_1, location_1, 7), displayParts = _a.displayParts, documentation = _a.documentation, symbolKind = _a.symbolKind, tags = _a.tags; return { name: entryName, kindModifiers: ts.SymbolDisplay.getSymbolModifiers(symbol), kind: symbolKind, displayParts: displayParts, - documentation: documentation + documentation: documentation, + tags: tags }; } } @@ -60270,7 +60272,8 @@ var ts; kind: ts.ScriptElementKind.keyword, kindModifiers: ts.ScriptElementKindModifier.none, displayParts: [ts.displayPart(entryName, ts.SymbolDisplayPartKind.keyword)], - documentation: undefined + documentation: undefined, + tags: undefined }; } return undefined; @@ -62939,6 +62942,29 @@ var ts; return documentationComment; } JsDoc.getJsDocCommentsFromDeclarations = getJsDocCommentsFromDeclarations; + function getJsDocTagsFromDeclarations(declarations) { + var tags = []; + forEachUnique(declarations, function (declaration) { + var jsDocs = ts.getJSDocs(declaration); + if (!jsDocs) { + return; + } + for (var _i = 0, jsDocs_1 = jsDocs; _i < jsDocs_1.length; _i++) { + var doc = jsDocs_1[_i]; + var tagsForDoc = doc.tags; + if (tagsForDoc) { + tags.push.apply(tags, tagsForDoc.filter(function (tag) { return tag.kind === 283; }).map(function (jsDocTag) { + return { + name: jsDocTag.tagName.text, + text: jsDocTag.comment + }; + })); + } + } + }); + return tags; + } + JsDoc.getJsDocTagsFromDeclarations = getJsDocTagsFromDeclarations; function forEachUnique(array, callback) { if (array) { for (var i = 0; i < array.length; i++) { @@ -65130,7 +65156,8 @@ var ts; suffixDisplayParts: suffixDisplayParts, separatorDisplayParts: [ts.punctuationPart(25), ts.spacePart()], parameters: signatureHelpParameters, - documentation: candidateSignature.getDocumentationComment() + documentation: candidateSignature.getDocumentationComment(), + tags: candidateSignature.getJsDocTags() }; }); var argumentIndex = argumentListInfo.argumentIndex; @@ -65271,6 +65298,7 @@ var ts; if (semanticMeaning === void 0) { semanticMeaning = ts.getMeaningFromLocation(location); } var displayParts = []; var documentation; + var tags; var symbolFlags = symbol.flags; var symbolKind = getSymbolKindOfConstructorPropertyMethodAccessorFunctionOrVar(typeChecker, symbol, location); var hasAddedSymbolInfo; @@ -65557,6 +65585,7 @@ var ts; } if (!documentation) { documentation = symbol.getDocumentationComment(); + tags = symbol.getJsDocTags(); if (documentation.length === 0 && symbol.flags & 4) { if (symbol.parent && ts.forEach(symbol.parent.declarations, function (declaration) { return declaration.kind === 264; })) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { @@ -65569,6 +65598,7 @@ var ts; continue; } documentation = rhsSymbol.getDocumentationComment(); + tags = rhsSymbol.getJsDocTags(); if (documentation.length > 0) { break; } @@ -65576,7 +65606,7 @@ var ts; } } } - return { displayParts: displayParts, documentation: documentation, symbolKind: symbolKind }; + return { displayParts: displayParts, documentation: documentation, symbolKind: symbolKind, tags: tags }; function addNewLineIfDisplayPartsExist() { if (displayParts.length) { displayParts.push(ts.lineBreakPart()); @@ -65627,6 +65657,7 @@ var ts; displayParts.push(ts.punctuationPart(19)); } documentation = signature.getDocumentationComment(); + tags = signature.getJsDocTags(); } function writeTypeParametersOfSymbol(symbol, enclosingDeclaration) { var typeParameterParts = ts.mapToDisplayParts(function (writer) { @@ -70133,6 +70164,12 @@ var ts; } return this.documentationComment; }; + SymbolObject.prototype.getJsDocTags = function () { + if (this.tags === undefined) { + this.tags = ts.JsDoc.getJsDocTagsFromDeclarations(this.declarations); + } + return this.tags; + }; return SymbolObject; }()); var TokenObject = (function (_super) { @@ -70216,6 +70253,12 @@ var ts; } return this.documentationComment; }; + SignatureObject.prototype.getJsDocTags = function () { + if (this.jsDocTags === undefined) { + this.jsDocTags = this.declaration ? ts.JsDoc.getJsDocTagsFromDeclarations([this.declaration]) : []; + } + return this.jsDocTags; + }; return SignatureObject; }()); var SourceFileObject = (function (_super) { @@ -70847,7 +70890,8 @@ var ts; kindModifiers: ts.ScriptElementKindModifier.none, textSpan: ts.createTextSpan(node.getStart(), node.getWidth()), displayParts: ts.typeToDisplayParts(typeChecker, type, ts.getContainerNode(node)), - documentation: type.symbol ? type.symbol.getDocumentationComment() : undefined + documentation: type.symbol ? type.symbol.getDocumentationComment() : undefined, + tags: type.symbol ? type.symbol.getJsDocTags() : undefined }; } } @@ -70859,7 +70903,8 @@ var ts; kindModifiers: ts.SymbolDisplay.getSymbolModifiers(symbol), textSpan: ts.createTextSpan(node.getStart(), node.getWidth()), displayParts: displayPartsDocumentationsAndKind.displayParts, - documentation: displayPartsDocumentationsAndKind.documentation + documentation: displayPartsDocumentationsAndKind.documentation, + tags: displayPartsDocumentationsAndKind.tags }; } function getDefinitionAtPosition(fileName, position) { @@ -72676,6 +72721,7 @@ var ts; end: scriptInfo.positionToLineOffset(ts.textSpanEnd(quickInfo.textSpan)), displayString: displayString, documentation: docString, + tags: quickInfo.tags || [] }; } else { diff --git a/lib/typescript.d.ts b/lib/typescript.d.ts index 6c4503f64f992..5839aeafac353 100644 --- a/lib/typescript.d.ts +++ b/lib/typescript.d.ts @@ -3272,6 +3272,7 @@ declare namespace ts { getName(): string; getDeclarations(): Declaration[]; getDocumentationComment(): SymbolDisplayPart[]; + getJsDocTags(): JSDocTagInfo[]; } interface Type { getFlags(): TypeFlags; @@ -3292,6 +3293,7 @@ declare namespace ts { getParameters(): Symbol[]; getReturnType(): Type; getDocumentationComment(): SymbolDisplayPart[]; + getJsDocTags(): JSDocTagInfo[]; } interface SourceFile { getLineAndCharacterOfPosition(pos: number): LineAndCharacter; @@ -3628,12 +3630,17 @@ declare namespace ts { text: string; kind: string; } + interface JSDocTagInfo { + name: string; + text?: string; + } interface QuickInfo { kind: string; kindModifiers: string; textSpan: TextSpan; displayParts: SymbolDisplayPart[]; documentation: SymbolDisplayPart[]; + tags: JSDocTagInfo[]; } interface RenameInfo { canRename: boolean; @@ -3664,6 +3671,7 @@ declare namespace ts { separatorDisplayParts: SymbolDisplayPart[]; parameters: SignatureHelpParameter[]; documentation: SymbolDisplayPart[]; + tags: JSDocTagInfo[]; } /** * Represents a set of signature help items, and the preferred item that should be selected. @@ -3702,6 +3710,7 @@ declare namespace ts { kindModifiers: string; displayParts: SymbolDisplayPart[]; documentation: SymbolDisplayPart[]; + tags: JSDocTagInfo[]; } interface OutliningSpan { /** The span of the document to actually collapse. */ diff --git a/lib/typescript.js b/lib/typescript.js index 759611d801365..811f3d488967d 100644 --- a/lib/typescript.js +++ b/lib/typescript.js @@ -8043,6 +8043,7 @@ var ts; cache = ts.concatenate(cache, node.jsDoc); } } + ts.getJSDocs = getJSDocs; function getJSDocParameterTags(param) { if (!isParameter(param)) { return undefined; @@ -20403,7 +20404,7 @@ var ts; } function parseTagComments(indent) { var comments = []; - var state = 1 /* SawAsterisk */; + var state = 0 /* BeginningOfLine */; var margin; function pushComment(text) { if (!margin) { @@ -72593,13 +72594,14 @@ var ts; // completion entry. var symbol = ts.forEach(symbols, function (s) { return getCompletionEntryDisplayNameForSymbol(typeChecker, s, compilerOptions.target, /*performCharacterChecks*/ false, location_1) === entryName ? s : undefined; }); if (symbol) { - var _a = ts.SymbolDisplay.getSymbolDisplayPartsDocumentationAndSymbolKind(typeChecker, symbol, sourceFile, location_1, location_1, 7 /* All */), displayParts = _a.displayParts, documentation = _a.documentation, symbolKind = _a.symbolKind; + var _a = ts.SymbolDisplay.getSymbolDisplayPartsDocumentationAndSymbolKind(typeChecker, symbol, sourceFile, location_1, location_1, 7 /* All */), displayParts = _a.displayParts, documentation = _a.documentation, symbolKind = _a.symbolKind, tags = _a.tags; return { name: entryName, kindModifiers: ts.SymbolDisplay.getSymbolModifiers(symbol), kind: symbolKind, displayParts: displayParts, - documentation: documentation + documentation: documentation, + tags: tags }; } } @@ -72611,7 +72613,8 @@ var ts; kind: ts.ScriptElementKind.keyword, kindModifiers: ts.ScriptElementKindModifier.none, displayParts: [ts.displayPart(entryName, ts.SymbolDisplayPartKind.keyword)], - documentation: undefined + documentation: undefined, + tags: undefined }; } return undefined; @@ -75815,6 +75818,30 @@ var ts; return documentationComment; } JsDoc.getJsDocCommentsFromDeclarations = getJsDocCommentsFromDeclarations; + function getJsDocTagsFromDeclarations(declarations) { + // Only collect doc comments from duplicate declarations once. + var tags = []; + forEachUnique(declarations, function (declaration) { + var jsDocs = ts.getJSDocs(declaration); + if (!jsDocs) { + return; + } + for (var _i = 0, jsDocs_1 = jsDocs; _i < jsDocs_1.length; _i++) { + var doc = jsDocs_1[_i]; + var tagsForDoc = doc.tags; + if (tagsForDoc) { + tags.push.apply(tags, tagsForDoc.filter(function (tag) { return tag.kind === 283 /* JSDocTag */; }).map(function (jsDocTag) { + return { + name: jsDocTag.tagName.text, + text: jsDocTag.comment + }; + })); + } + } + }); + return tags; + } + JsDoc.getJsDocTagsFromDeclarations = getJsDocTagsFromDeclarations; /** * Iterates through 'array' by index and performs the callback on each element of array until the callback * returns a truthy value, then returns that value. @@ -78634,7 +78661,8 @@ var ts; suffixDisplayParts: suffixDisplayParts, separatorDisplayParts: [ts.punctuationPart(25 /* CommaToken */), ts.spacePart()], parameters: signatureHelpParameters, - documentation: candidateSignature.getDocumentationComment() + documentation: candidateSignature.getDocumentationComment(), + tags: candidateSignature.getJsDocTags() }; }); var argumentIndex = argumentListInfo.argumentIndex; @@ -78782,6 +78810,7 @@ var ts; if (semanticMeaning === void 0) { semanticMeaning = ts.getMeaningFromLocation(location); } var displayParts = []; var documentation; + var tags; var symbolFlags = symbol.flags; var symbolKind = getSymbolKindOfConstructorPropertyMethodAccessorFunctionOrVar(typeChecker, symbol, location); var hasAddedSymbolInfo; @@ -79092,6 +79121,7 @@ var ts; } if (!documentation) { documentation = symbol.getDocumentationComment(); + tags = symbol.getJsDocTags(); if (documentation.length === 0 && symbol.flags & 4 /* Property */) { // For some special property access expressions like `exports.foo = foo` or `module.exports.foo = foo` // there documentation comments might be attached to the right hand side symbol of their declarations. @@ -79107,6 +79137,7 @@ var ts; continue; } documentation = rhsSymbol.getDocumentationComment(); + tags = rhsSymbol.getJsDocTags(); if (documentation.length > 0) { break; } @@ -79114,7 +79145,7 @@ var ts; } } } - return { displayParts: displayParts, documentation: documentation, symbolKind: symbolKind }; + return { displayParts: displayParts, documentation: documentation, symbolKind: symbolKind, tags: tags }; function addNewLineIfDisplayPartsExist() { if (displayParts.length) { displayParts.push(ts.lineBreakPart()); @@ -79165,6 +79196,7 @@ var ts; displayParts.push(ts.punctuationPart(19 /* CloseParenToken */)); } documentation = signature.getDocumentationComment(); + tags = signature.getJsDocTags(); } function writeTypeParametersOfSymbol(symbol, enclosingDeclaration) { var typeParameterParts = ts.mapToDisplayParts(function (writer) { @@ -84399,6 +84431,12 @@ var ts; } return this.documentationComment; }; + SymbolObject.prototype.getJsDocTags = function () { + if (this.tags === undefined) { + this.tags = ts.JsDoc.getJsDocTagsFromDeclarations(this.declarations); + } + return this.tags; + }; return SymbolObject; }()); var TokenObject = (function (_super) { @@ -84482,6 +84520,12 @@ var ts; } return this.documentationComment; }; + SignatureObject.prototype.getJsDocTags = function () { + if (this.jsDocTags === undefined) { + this.jsDocTags = this.declaration ? ts.JsDoc.getJsDocTagsFromDeclarations([this.declaration]) : []; + } + return this.jsDocTags; + }; return SignatureObject; }()); var SourceFileObject = (function (_super) { @@ -85221,7 +85265,8 @@ var ts; kindModifiers: ts.ScriptElementKindModifier.none, textSpan: ts.createTextSpan(node.getStart(), node.getWidth()), displayParts: ts.typeToDisplayParts(typeChecker, type, ts.getContainerNode(node)), - documentation: type.symbol ? type.symbol.getDocumentationComment() : undefined + documentation: type.symbol ? type.symbol.getDocumentationComment() : undefined, + tags: type.symbol ? type.symbol.getJsDocTags() : undefined }; } } @@ -85233,7 +85278,8 @@ var ts; kindModifiers: ts.SymbolDisplay.getSymbolModifiers(symbol), textSpan: ts.createTextSpan(node.getStart(), node.getWidth()), displayParts: displayPartsDocumentationsAndKind.displayParts, - documentation: displayPartsDocumentationsAndKind.documentation + documentation: displayPartsDocumentationsAndKind.documentation, + tags: displayPartsDocumentationsAndKind.tags }; } /// Goto definition diff --git a/lib/typescriptServices.d.ts b/lib/typescriptServices.d.ts index 7d72a5f9373dd..98f0e225d17e8 100644 --- a/lib/typescriptServices.d.ts +++ b/lib/typescriptServices.d.ts @@ -3272,6 +3272,7 @@ declare namespace ts { getName(): string; getDeclarations(): Declaration[]; getDocumentationComment(): SymbolDisplayPart[]; + getJsDocTags(): JSDocTagInfo[]; } interface Type { getFlags(): TypeFlags; @@ -3292,6 +3293,7 @@ declare namespace ts { getParameters(): Symbol[]; getReturnType(): Type; getDocumentationComment(): SymbolDisplayPart[]; + getJsDocTags(): JSDocTagInfo[]; } interface SourceFile { getLineAndCharacterOfPosition(pos: number): LineAndCharacter; @@ -3628,12 +3630,17 @@ declare namespace ts { text: string; kind: string; } + interface JSDocTagInfo { + name: string; + text?: string; + } interface QuickInfo { kind: string; kindModifiers: string; textSpan: TextSpan; displayParts: SymbolDisplayPart[]; documentation: SymbolDisplayPart[]; + tags: JSDocTagInfo[]; } interface RenameInfo { canRename: boolean; @@ -3664,6 +3671,7 @@ declare namespace ts { separatorDisplayParts: SymbolDisplayPart[]; parameters: SignatureHelpParameter[]; documentation: SymbolDisplayPart[]; + tags: JSDocTagInfo[]; } /** * Represents a set of signature help items, and the preferred item that should be selected. @@ -3702,6 +3710,7 @@ declare namespace ts { kindModifiers: string; displayParts: SymbolDisplayPart[]; documentation: SymbolDisplayPart[]; + tags: JSDocTagInfo[]; } interface OutliningSpan { /** The span of the document to actually collapse. */ diff --git a/lib/typescriptServices.js b/lib/typescriptServices.js index 759611d801365..811f3d488967d 100644 --- a/lib/typescriptServices.js +++ b/lib/typescriptServices.js @@ -8043,6 +8043,7 @@ var ts; cache = ts.concatenate(cache, node.jsDoc); } } + ts.getJSDocs = getJSDocs; function getJSDocParameterTags(param) { if (!isParameter(param)) { return undefined; @@ -20403,7 +20404,7 @@ var ts; } function parseTagComments(indent) { var comments = []; - var state = 1 /* SawAsterisk */; + var state = 0 /* BeginningOfLine */; var margin; function pushComment(text) { if (!margin) { @@ -72593,13 +72594,14 @@ var ts; // completion entry. var symbol = ts.forEach(symbols, function (s) { return getCompletionEntryDisplayNameForSymbol(typeChecker, s, compilerOptions.target, /*performCharacterChecks*/ false, location_1) === entryName ? s : undefined; }); if (symbol) { - var _a = ts.SymbolDisplay.getSymbolDisplayPartsDocumentationAndSymbolKind(typeChecker, symbol, sourceFile, location_1, location_1, 7 /* All */), displayParts = _a.displayParts, documentation = _a.documentation, symbolKind = _a.symbolKind; + var _a = ts.SymbolDisplay.getSymbolDisplayPartsDocumentationAndSymbolKind(typeChecker, symbol, sourceFile, location_1, location_1, 7 /* All */), displayParts = _a.displayParts, documentation = _a.documentation, symbolKind = _a.symbolKind, tags = _a.tags; return { name: entryName, kindModifiers: ts.SymbolDisplay.getSymbolModifiers(symbol), kind: symbolKind, displayParts: displayParts, - documentation: documentation + documentation: documentation, + tags: tags }; } } @@ -72611,7 +72613,8 @@ var ts; kind: ts.ScriptElementKind.keyword, kindModifiers: ts.ScriptElementKindModifier.none, displayParts: [ts.displayPart(entryName, ts.SymbolDisplayPartKind.keyword)], - documentation: undefined + documentation: undefined, + tags: undefined }; } return undefined; @@ -75815,6 +75818,30 @@ var ts; return documentationComment; } JsDoc.getJsDocCommentsFromDeclarations = getJsDocCommentsFromDeclarations; + function getJsDocTagsFromDeclarations(declarations) { + // Only collect doc comments from duplicate declarations once. + var tags = []; + forEachUnique(declarations, function (declaration) { + var jsDocs = ts.getJSDocs(declaration); + if (!jsDocs) { + return; + } + for (var _i = 0, jsDocs_1 = jsDocs; _i < jsDocs_1.length; _i++) { + var doc = jsDocs_1[_i]; + var tagsForDoc = doc.tags; + if (tagsForDoc) { + tags.push.apply(tags, tagsForDoc.filter(function (tag) { return tag.kind === 283 /* JSDocTag */; }).map(function (jsDocTag) { + return { + name: jsDocTag.tagName.text, + text: jsDocTag.comment + }; + })); + } + } + }); + return tags; + } + JsDoc.getJsDocTagsFromDeclarations = getJsDocTagsFromDeclarations; /** * Iterates through 'array' by index and performs the callback on each element of array until the callback * returns a truthy value, then returns that value. @@ -78634,7 +78661,8 @@ var ts; suffixDisplayParts: suffixDisplayParts, separatorDisplayParts: [ts.punctuationPart(25 /* CommaToken */), ts.spacePart()], parameters: signatureHelpParameters, - documentation: candidateSignature.getDocumentationComment() + documentation: candidateSignature.getDocumentationComment(), + tags: candidateSignature.getJsDocTags() }; }); var argumentIndex = argumentListInfo.argumentIndex; @@ -78782,6 +78810,7 @@ var ts; if (semanticMeaning === void 0) { semanticMeaning = ts.getMeaningFromLocation(location); } var displayParts = []; var documentation; + var tags; var symbolFlags = symbol.flags; var symbolKind = getSymbolKindOfConstructorPropertyMethodAccessorFunctionOrVar(typeChecker, symbol, location); var hasAddedSymbolInfo; @@ -79092,6 +79121,7 @@ var ts; } if (!documentation) { documentation = symbol.getDocumentationComment(); + tags = symbol.getJsDocTags(); if (documentation.length === 0 && symbol.flags & 4 /* Property */) { // For some special property access expressions like `exports.foo = foo` or `module.exports.foo = foo` // there documentation comments might be attached to the right hand side symbol of their declarations. @@ -79107,6 +79137,7 @@ var ts; continue; } documentation = rhsSymbol.getDocumentationComment(); + tags = rhsSymbol.getJsDocTags(); if (documentation.length > 0) { break; } @@ -79114,7 +79145,7 @@ var ts; } } } - return { displayParts: displayParts, documentation: documentation, symbolKind: symbolKind }; + return { displayParts: displayParts, documentation: documentation, symbolKind: symbolKind, tags: tags }; function addNewLineIfDisplayPartsExist() { if (displayParts.length) { displayParts.push(ts.lineBreakPart()); @@ -79165,6 +79196,7 @@ var ts; displayParts.push(ts.punctuationPart(19 /* CloseParenToken */)); } documentation = signature.getDocumentationComment(); + tags = signature.getJsDocTags(); } function writeTypeParametersOfSymbol(symbol, enclosingDeclaration) { var typeParameterParts = ts.mapToDisplayParts(function (writer) { @@ -84399,6 +84431,12 @@ var ts; } return this.documentationComment; }; + SymbolObject.prototype.getJsDocTags = function () { + if (this.tags === undefined) { + this.tags = ts.JsDoc.getJsDocTagsFromDeclarations(this.declarations); + } + return this.tags; + }; return SymbolObject; }()); var TokenObject = (function (_super) { @@ -84482,6 +84520,12 @@ var ts; } return this.documentationComment; }; + SignatureObject.prototype.getJsDocTags = function () { + if (this.jsDocTags === undefined) { + this.jsDocTags = this.declaration ? ts.JsDoc.getJsDocTagsFromDeclarations([this.declaration]) : []; + } + return this.jsDocTags; + }; return SignatureObject; }()); var SourceFileObject = (function (_super) { @@ -85221,7 +85265,8 @@ var ts; kindModifiers: ts.ScriptElementKindModifier.none, textSpan: ts.createTextSpan(node.getStart(), node.getWidth()), displayParts: ts.typeToDisplayParts(typeChecker, type, ts.getContainerNode(node)), - documentation: type.symbol ? type.symbol.getDocumentationComment() : undefined + documentation: type.symbol ? type.symbol.getDocumentationComment() : undefined, + tags: type.symbol ? type.symbol.getJsDocTags() : undefined }; } } @@ -85233,7 +85278,8 @@ var ts; kindModifiers: ts.SymbolDisplay.getSymbolModifiers(symbol), textSpan: ts.createTextSpan(node.getStart(), node.getWidth()), displayParts: displayPartsDocumentationsAndKind.displayParts, - documentation: displayPartsDocumentationsAndKind.documentation + documentation: displayPartsDocumentationsAndKind.documentation, + tags: displayPartsDocumentationsAndKind.tags }; } /// Goto definition