Skip to content

Commit

Permalink
Update LKG
Browse files Browse the repository at this point in the history
  • Loading branch information
mhegazy committed Apr 4, 2017
1 parent 57913d2 commit 154d25c
Show file tree
Hide file tree
Showing 9 changed files with 265 additions and 33 deletions.
17 changes: 17 additions & 0 deletions lib/protocol.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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[];
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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,
Expand Down
3 changes: 2 additions & 1 deletion lib/tsc.js
Original file line number Diff line number Diff line change
Expand Up @@ -6243,6 +6243,7 @@ var ts;
cache = ts.concatenate(cache, node.jsDoc);
}
}
ts.getJSDocs = getJSDocs;
function getJSDocParameterTags(param) {
if (!isParameter(param)) {
return undefined;
Expand Down Expand Up @@ -16627,7 +16628,7 @@ var ts;
}
function parseTagComments(indent) {
var comments = [];
var state = 1;
var state = 0;
var margin;
function pushComment(text) {
if (!margin) {
Expand Down
62 changes: 54 additions & 8 deletions lib/tsserver.js
Original file line number Diff line number Diff line change
Expand Up @@ -6417,6 +6417,7 @@ var ts;
cache = ts.concatenate(cache, node.jsDoc);
}
}
ts.getJSDocs = getJSDocs;
function getJSDocParameterTags(param) {
if (!isParameter(param)) {
return undefined;
Expand Down Expand Up @@ -18434,7 +18435,7 @@ var ts;
}
function parseTagComments(indent) {
var comments = [];
var state = 1;
var state = 0;
var margin;
function pushComment(text) {
if (!margin) {
Expand Down Expand Up @@ -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
};
}
}
Expand All @@ -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;
Expand Down Expand Up @@ -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++) {
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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++) {
Expand All @@ -65569,14 +65598,15 @@ var ts;
continue;
}
documentation = rhsSymbol.getDocumentationComment();
tags = rhsSymbol.getJsDocTags();
if (documentation.length > 0) {
break;
}
}
}
}
}
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());
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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
};
}
}
Expand All @@ -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) {
Expand Down Expand Up @@ -76212,6 +76257,7 @@ var ts;
end: scriptInfo.positionToLineOffset(ts.textSpanEnd(quickInfo.textSpan)),
displayString: displayString,
documentation: docString,
tags: quickInfo.tags || []
};
}
else {
Expand Down
12 changes: 12 additions & 0 deletions lib/tsserverlibrary.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2809,6 +2809,7 @@ declare namespace ts {
getName(): string;
getDeclarations(): Declaration[];
getDocumentationComment(): SymbolDisplayPart[];
getJsDocTags(): JSDocTagInfo[];
}
interface Type {
getFlags(): TypeFlags;
Expand All @@ -2829,6 +2830,7 @@ declare namespace ts {
getParameters(): Symbol[];
getReturnType(): Type;
getDocumentationComment(): SymbolDisplayPart[];
getJsDocTags(): JSDocTagInfo[];
}
interface SourceFile {
getLineAndCharacterOfPosition(pos: number): LineAndCharacter;
Expand Down Expand Up @@ -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;
Expand All @@ -3148,6 +3155,7 @@ declare namespace ts {
separatorDisplayParts: SymbolDisplayPart[];
parameters: SignatureHelpParameter[];
documentation: SymbolDisplayPart[];
tags: JSDocTagInfo[];
}
interface SignatureHelpItems {
items: SignatureHelpItem[];
Expand Down Expand Up @@ -3175,6 +3183,7 @@ declare namespace ts {
kindModifiers: string;
displayParts: SymbolDisplayPart[];
documentation: SymbolDisplayPart[];
tags: JSDocTagInfo[];
}
interface OutliningSpan {
textSpan: TextSpan;
Expand Down Expand Up @@ -3936,6 +3945,7 @@ declare namespace ts.server.protocol {
end: Location;
displayString: string;
documentation: string;
tags: JSDocTagInfo[];
}
interface QuickInfoResponse extends Response {
body?: QuickInfoResponseBody;
Expand Down Expand Up @@ -4007,6 +4017,7 @@ declare namespace ts.server.protocol {
kindModifiers: string;
displayParts: SymbolDisplayPart[];
documentation: SymbolDisplayPart[];
tags: JSDocTagInfo[];
}
interface CompletionsResponse extends Response {
body?: CompletionEntry[];
Expand All @@ -4027,6 +4038,7 @@ declare namespace ts.server.protocol {
separatorDisplayParts: SymbolDisplayPart[];
parameters: SignatureHelpParameter[];
documentation: SymbolDisplayPart[];
tags: JSDocTagInfo[];
}
interface SignatureHelpItems {
items: SignatureHelpItem[];
Expand Down
Loading

0 comments on commit 154d25c

Please sign in to comment.