Skip to content

Commit 451d435

Browse files
authored
Revert "Editor support for link tag (#41877)" (#43302)
This reverts commit ec77bff.
1 parent a21f61f commit 451d435

File tree

155 files changed

+1604
-20458
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

155 files changed

+1604
-20458
lines changed

src/compiler/checker.ts

+2-6
Original file line numberDiff line numberDiff line change
@@ -5187,7 +5187,7 @@ namespace ts {
51875187
function preserveCommentsOn<T extends Node>(node: T) {
51885188
if (some(propertySymbol.declarations, d => d.kind === SyntaxKind.JSDocPropertyTag)) {
51895189
const d = propertySymbol.declarations?.find(d => d.kind === SyntaxKind.JSDocPropertyTag)! as JSDocPropertyTag;
5190-
const commentText = getTextOfJSDocComment(d.comment);
5190+
const commentText = d.comment;
51915191
if (commentText) {
51925192
setSyntheticLeadingComments(node, [{ kind: SyntaxKind.MultiLineCommentTrivia, text: "*\n * " + commentText.replace(/\n/g, "\n * ") + "\n ", pos: -1, end: -1, hasTrailingNewLine: true }]);
51935193
}
@@ -6702,7 +6702,7 @@ namespace ts {
67026702
const typeParams = getSymbolLinks(symbol).typeParameters;
67036703
const typeParamDecls = map(typeParams, p => typeParameterToDeclaration(p, context));
67046704
const jsdocAliasDecl = symbol.declarations?.find(isJSDocTypeAlias);
6705-
const commentText = getTextOfJSDocComment(jsdocAliasDecl ? jsdocAliasDecl.comment || jsdocAliasDecl.parent.comment : undefined);
6705+
const commentText = jsdocAliasDecl ? jsdocAliasDecl.comment || jsdocAliasDecl.parent.comment : undefined;
67066706
const oldFlags = context.flags;
67076707
context.flags |= NodeBuilderFlags.InTypeAlias;
67086708
const oldEnclosingDecl = context.enclosingDeclaration;
@@ -38593,10 +38593,6 @@ namespace ts {
3859338593
const meaning = SymbolFlags.Type | SymbolFlags.Namespace | SymbolFlags.Value;
3859438594
return resolveEntityName(<EntityName>name, meaning, /*ignoreErrors*/ false, /*dontResolveAlias*/ true, getHostSignatureFromJSDoc(name));
3859538595
}
38596-
else if (isJSDocLink(name.parent)) {
38597-
const meaning = SymbolFlags.Type | SymbolFlags.Namespace | SymbolFlags.Value;
38598-
return resolveEntityName(<EntityName>name, meaning, /*ignoreErrors*/ true);
38599-
}
3860038596

3860138597
if (name.parent.kind === SyntaxKind.TypePredicate) {
3860238598
return resolveEntityName(<Identifier>name, /*meaning*/ SymbolFlags.FunctionScopedVariable);

src/compiler/emitter.ts

+10-14
Original file line numberDiff line numberDiff line change
@@ -3565,16 +3565,13 @@ namespace ts {
35653565
function emitJSDoc(node: JSDoc) {
35663566
write("/**");
35673567
if (node.comment) {
3568-
const text = getTextOfJSDocComment(node.comment);
3569-
if (text) {
3570-
const lines = text.split(/\r\n?|\n/g);
3571-
for (const line of lines) {
3572-
writeLine();
3573-
writeSpace();
3574-
writePunctuation("*");
3575-
writeSpace();
3576-
write(line);
3577-
}
3568+
const lines = node.comment.split(/\r\n?|\n/g);
3569+
for (const line of lines) {
3570+
writeLine();
3571+
writeSpace();
3572+
writePunctuation("*");
3573+
writeSpace();
3574+
write(line);
35783575
}
35793576
}
35803577
if (node.tags) {
@@ -3707,11 +3704,10 @@ namespace ts {
37073704
emit(tagName);
37083705
}
37093706

3710-
function emitJSDocComment(comment: NodeArray<JSDocText | JSDocLink> | undefined) {
3711-
const text = getTextOfJSDocComment(comment);
3712-
if (text) {
3707+
function emitJSDocComment(comment: string | undefined) {
3708+
if (comment) {
37133709
writeSpace();
3714-
write(text);
3710+
write(comment);
37153711
}
37163712
}
37173713

src/compiler/factory/nodeFactory.ts

+31-64
Large diffs are not rendered by default.

src/compiler/factory/nodeTests.ts

-4
Original file line numberDiff line numberDiff line change
@@ -770,10 +770,6 @@ namespace ts {
770770
return node.kind === SyntaxKind.JSDocNameReference;
771771
}
772772

773-
export function isJSDocLink(node: Node): node is JSDocLink {
774-
return node.kind === SyntaxKind.JSDocLink;
775-
}
776-
777773
export function isJSDocAllType(node: Node): node is JSDocAllType {
778774
return node.kind === SyntaxKind.JSDocAllType;
779775
}

src/compiler/parser.ts

+62-130
Large diffs are not rendered by default.

src/compiler/types.ts

+44-61
Large diffs are not rendered by default.

src/compiler/utilitiesPublic.ts

+1-12
Original file line numberDiff line numberDiff line change
@@ -896,11 +896,6 @@ namespace ts {
896896
return getJSDocTags(node).filter(doc => doc.kind === kind);
897897
}
898898

899-
/** Gets the text of a jsdoc comment, flattening links to their text. */
900-
export function getTextOfJSDocComment(comment?: NodeArray<JSDocText | JSDocLink>) {
901-
return comment?.map(c => c.kind === SyntaxKind.JSDocText ? c.text : `{@link ${c.name ? entityNameToString(c.name) + " " : ""}${c.text}}`).join("");
902-
}
903-
904899
/**
905900
* Gets the effective type parameters. If the node was parsed in a
906901
* JavaScript file, gets the type parameters from the `@template` tag from JSDoc.
@@ -1865,13 +1860,7 @@ namespace ts {
18651860

18661861
/** True if node is of a kind that may contain comment text. */
18671862
export function isJSDocCommentContainingNode(node: Node): boolean {
1868-
return node.kind === SyntaxKind.JSDocComment
1869-
|| node.kind === SyntaxKind.JSDocNamepathType
1870-
|| node.kind === SyntaxKind.JSDocText
1871-
|| node.kind === SyntaxKind.JSDocLink
1872-
|| isJSDocTag(node)
1873-
|| isJSDocTypeLiteral(node)
1874-
|| isJSDocSignature(node);
1863+
return node.kind === SyntaxKind.JSDocComment || node.kind === SyntaxKind.JSDocNamepathType || isJSDocTag(node) || isJSDocTypeLiteral(node) || isJSDocSignature(node);
18751864
}
18761865

18771866
// TODO: determine what this does before making it public.

src/deprecatedCompat/deprecations.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1229,7 +1229,7 @@ namespace ts {
12291229

12301230
/** @deprecated Use `factory.createJSDocParameterTag` or the factory supplied by your transformation context instead. */
12311231
export const createJSDocParamTag = Debug.deprecate(function createJSDocParamTag(name: EntityName, isBracketed: boolean, typeExpression?: JSDocTypeExpression, comment?: string): JSDocParameterTag {
1232-
return factory.createJSDocParameterTag(/*tagName*/ undefined, name, isBracketed, typeExpression, /*isNameFirst*/ false, comment ? factory.createNodeArray([factory.createJSDocText(comment)]) : undefined);
1232+
return factory.createJSDocParameterTag(/*tagName*/ undefined, name, isBracketed, typeExpression, /*isNameFirst*/ false, comment);
12331233
}, factoryDeprecation);
12341234

12351235
/** @deprecated Use `factory.createComma` or the factory supplied by your transformation context instead. */
@@ -1374,4 +1374,4 @@ namespace ts {
13741374
});
13751375

13761376
// #endregion Renamed node Tests
1377-
}
1377+
}

src/harness/client.ts

+4-12
Original file line numberDiff line numberDiff line change
@@ -175,8 +175,8 @@ namespace ts.server {
175175
kindModifiers: body.kindModifiers,
176176
textSpan: this.decodeSpan(body, fileName),
177177
displayParts: [{ kind: "text", text: body.displayString }],
178-
documentation: typeof body.documentation === "string" ? [{ kind: "text", text: body.documentation }] : body.documentation,
179-
tags: this.decodeLinkDisplayParts(body.tags)
178+
documentation: [{ kind: "text", text: body.documentation }],
179+
tags: body.tags
180180
};
181181
}
182182

@@ -536,13 +536,6 @@ namespace ts.server {
536536
this.lineOffsetToPosition(fileName, span.end, lineMap));
537537
}
538538

539-
private decodeLinkDisplayParts(tags: (protocol.JSDocTagInfo | JSDocTagInfo)[]): JSDocTagInfo[] {
540-
return tags.map(tag => typeof tag.text === "string" ? {
541-
...tag,
542-
text: [textPart(tag.text)]
543-
} : (tag as JSDocTagInfo));
544-
}
545-
546539
getNameOrDottedNameSpan(_fileName: string, _startPos: number, _endPos: number): TextSpan {
547540
return notImplemented();
548541
}
@@ -561,10 +554,9 @@ namespace ts.server {
561554
return undefined;
562555
}
563556

564-
const { items: encodedItems, applicableSpan: encodedApplicableSpan, selectedItemIndex, argumentIndex, argumentCount } = response.body;
557+
const { items, applicableSpan: encodedApplicableSpan, selectedItemIndex, argumentIndex, argumentCount } = response.body;
565558

566-
const applicableSpan = encodedApplicableSpan as unknown as TextSpan;
567-
const items = (encodedItems as (SignatureHelpItem | protocol.SignatureHelpItem)[]).map(item => ({ ...item, tags: this.decodeLinkDisplayParts(item.tags) }));
559+
const applicableSpan = this.decodeSpan(encodedApplicableSpan, fileName);
568560

569561
return { items, applicableSpan, selectedItemIndex, argumentIndex, argumentCount };
570562
}

src/harness/fourslashImpl.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1583,7 +1583,7 @@ namespace FourSlash {
15831583
assert.equal(actualTags.length, (options.tags || ts.emptyArray).length, this.assertionMessageAtLastKnownMarker("signature help tags"));
15841584
ts.zipWith((options.tags || ts.emptyArray), actualTags, (expectedTag, actualTag) => {
15851585
assert.equal(actualTag.name, expectedTag.name);
1586-
assert.deepEqual(actualTag.text, expectedTag.text, this.assertionMessageAtLastKnownMarker("signature help tag " + actualTag.name));
1586+
assert.equal(actualTag.text, expectedTag.text, this.assertionMessageAtLastKnownMarker("signature help tag " + actualTag.name));
15871587
});
15881588

15891589
const allKeys: readonly (keyof FourSlashInterface.VerifySignatureHelpOptions)[] = [

src/server/protocol.ts

+1-20
Original file line numberDiff line numberDiff line change
@@ -979,16 +979,6 @@ namespace ts.server.protocol {
979979
file: string;
980980
}
981981

982-
export interface JSDocTagInfo {
983-
/** Name of the JSDoc tag */
984-
name: string;
985-
/**
986-
* Comment text after the JSDoc tag -- the text after the tag name until the next tag or end of comment
987-
* Display parts when UserPreferences.displayPartsForJSDoc is true, flattened to string otherwise.
988-
*/
989-
text?: string | SymbolDisplayPart[];
990-
}
991-
992982
export interface TextSpanWithContext extends TextSpan {
993983
contextStart?: Location;
994984
contextEnd?: Location;
@@ -1961,7 +1951,6 @@ namespace ts.server.protocol {
19611951
*/
19621952
export interface QuickInfoRequest extends FileLocationRequest {
19631953
command: CommandTypes.Quickinfo;
1964-
arguments: FileLocationRequestArgs;
19651954
}
19661955

19671956
/**
@@ -1995,9 +1984,8 @@ namespace ts.server.protocol {
19951984

19961985
/**
19971986
* Documentation associated with symbol.
1998-
* Display parts when UserPreferences.displayPartsForJSDoc is true, flattened to string otherwise.
19991987
*/
2000-
documentation: string | SymbolDisplayPart[];
1988+
documentation: string;
20011989

20021990
/**
20031991
* JSDoc tags associated with symbol.
@@ -2220,12 +2208,6 @@ namespace ts.server.protocol {
22202208
kind: string;
22212209
}
22222210

2223-
/** A part of a symbol description that links from a jsdoc @link tag to a declaration */
2224-
export interface JSDocLinkDisplayPart extends SymbolDisplayPart {
2225-
/** The location of the declaration that the @link tag links to. */
2226-
target: FileSpan;
2227-
}
2228-
22292211
/**
22302212
* An item found in a completion response.
22312213
*/
@@ -3319,7 +3301,6 @@ namespace ts.server.protocol {
33193301
readonly allowRenameOfImportPath?: boolean;
33203302
readonly includePackageJsonAutoImports?: "auto" | "on" | "off";
33213303

3322-
readonly displayPartsForJSDoc?: boolean;
33233304
readonly generateReturnInDocTemplate?: boolean;
33243305
}
33253306

src/server/session.ts

+21-56
Original file line numberDiff line numberDiff line change
@@ -1274,32 +1274,6 @@ namespace ts.server {
12741274
result;
12751275
}
12761276

1277-
private mapJSDocTagInfo(tags: JSDocTagInfo[] | undefined, project: Project, richResponse: boolean): protocol.JSDocTagInfo[] {
1278-
return tags ? tags.map(tag => ({
1279-
...tag,
1280-
text: richResponse ? this.mapDisplayParts(tag.text, project) : tag.text?.map(part => part.text).join("")
1281-
})) : [];
1282-
}
1283-
1284-
private mapDisplayParts(parts: SymbolDisplayPart[] | undefined, project: Project): protocol.SymbolDisplayPart[] {
1285-
if (!parts) {
1286-
return [];
1287-
}
1288-
return parts.map(part => part.kind !== "linkName" ? part : {
1289-
...part,
1290-
target: this.toFileSpan((part as JSDocLinkDisplayPart).target.fileName, (part as JSDocLinkDisplayPart).target.textSpan, project),
1291-
});
1292-
}
1293-
1294-
private mapSignatureHelpItems(items: SignatureHelpItem[], project: Project, richResponse: boolean): protocol.SignatureHelpItem[] {
1295-
return items.map(item => ({
1296-
...item,
1297-
documentation: this.mapDisplayParts(item.documentation, project),
1298-
parameters: item.parameters.map(p => ({ ...p, documentation: this.mapDisplayParts(p.documentation, project) })),
1299-
tags: this.mapJSDocTagInfo(item.tags, project, richResponse),
1300-
}));
1301-
}
1302-
13031277
private mapDefinitionInfo(definitions: readonly DefinitionInfo[], project: Project): readonly protocol.FileSpanWithContext[] {
13041278
return definitions.map(def => this.toFileSpanWithContext(def.fileName, def.textSpan, def.contextSpan, project));
13051279
}
@@ -1711,24 +1685,22 @@ namespace ts.server {
17111685
return undefined;
17121686
}
17131687

1714-
const useDisplayParts = !!this.getPreferences(file).displayPartsForJSDoc;
17151688
if (simplifiedResult) {
17161689
const displayString = displayPartsToString(quickInfo.displayParts);
1690+
const docString = displayPartsToString(quickInfo.documentation);
1691+
17171692
return {
17181693
kind: quickInfo.kind,
17191694
kindModifiers: quickInfo.kindModifiers,
17201695
start: scriptInfo.positionToLineOffset(quickInfo.textSpan.start),
17211696
end: scriptInfo.positionToLineOffset(textSpanEnd(quickInfo.textSpan)),
17221697
displayString,
1723-
documentation: useDisplayParts ? this.mapDisplayParts(quickInfo.documentation, project) : displayPartsToString(quickInfo.documentation),
1724-
tags: this.mapJSDocTagInfo(quickInfo.tags, project, useDisplayParts),
1698+
documentation: docString,
1699+
tags: quickInfo.tags || []
17251700
};
17261701
}
17271702
else {
1728-
return useDisplayParts ? quickInfo : {
1729-
...quickInfo,
1730-
tags: this.mapJSDocTagInfo(quickInfo.tags, project, /*useDisplayParts*/ false) as JSDocTagInfo[]
1731-
};
1703+
return quickInfo;
17321704
}
17331705
}
17341706

@@ -1858,25 +1830,19 @@ namespace ts.server {
18581830
return res;
18591831
}
18601832

1861-
private getCompletionEntryDetails(args: protocol.CompletionDetailsRequestArgs, fullResult: boolean): readonly protocol.CompletionEntryDetails[] | readonly CompletionEntryDetails[] {
1833+
private getCompletionEntryDetails(args: protocol.CompletionDetailsRequestArgs, simplifiedResult: boolean): readonly protocol.CompletionEntryDetails[] | readonly CompletionEntryDetails[] {
18621834
const { file, project } = this.getFileAndProject(args);
18631835
const scriptInfo = this.projectService.getScriptInfoForNormalizedPath(file)!;
18641836
const position = this.getPosition(args, scriptInfo);
18651837
const formattingOptions = project.projectService.getFormatCodeOptions(file);
1866-
const useDisplayParts = !!this.getPreferences(file).displayPartsForJSDoc;
18671838

18681839
const result = mapDefined(args.entryNames, entryName => {
18691840
const { name, source, data } = typeof entryName === "string" ? { name: entryName, source: undefined, data: undefined } : entryName;
18701841
return project.getLanguageService().getCompletionEntryDetails(file, position, name, formattingOptions, source, this.getPreferences(file), data ? cast(data, isCompletionEntryData) : undefined);
18711842
});
1872-
return fullResult
1873-
? (useDisplayParts ? result : result.map(details => ({ ...details, tags: this.mapJSDocTagInfo(details.tags, project, /*richResponse*/ false) as JSDocTagInfo[] })))
1874-
: result.map(details => ({
1875-
...details,
1876-
codeActions: map(details.codeActions, action => this.mapCodeAction(action)),
1877-
documentation: this.mapDisplayParts(details.documentation, project),
1878-
tags: this.mapJSDocTagInfo(details.tags, project, useDisplayParts),
1879-
}));
1843+
return simplifiedResult
1844+
? result.map(details => ({ ...details, codeActions: map(details.codeActions, action => this.mapCodeAction(action)) }))
1845+
: result;
18801846
}
18811847

18821848
private getCompileOnSaveAffectedFileList(args: protocol.FileRequestArgs): readonly protocol.CompileOnSaveAffectedFileListSingleProject[] {
@@ -1936,26 +1902,25 @@ namespace ts.server {
19361902
const scriptInfo = this.projectService.getScriptInfoForNormalizedPath(file)!;
19371903
const position = this.getPosition(args, scriptInfo);
19381904
const helpItems = project.getLanguageService().getSignatureHelpItems(file, position, args);
1939-
const useDisplayParts = !!this.getPreferences(file).displayPartsForJSDoc;
1940-
if (helpItems && simplifiedResult) {
1905+
if (!helpItems) {
1906+
return undefined;
1907+
}
1908+
1909+
if (simplifiedResult) {
19411910
const span = helpItems.applicableSpan;
19421911
return {
1943-
...helpItems,
1912+
items: helpItems.items,
19441913
applicableSpan: {
19451914
start: scriptInfo.positionToLineOffset(span.start),
19461915
end: scriptInfo.positionToLineOffset(span.start + span.length)
19471916
},
1948-
items: this.mapSignatureHelpItems(helpItems.items, project, useDisplayParts),
1917+
selectedItemIndex: helpItems.selectedItemIndex,
1918+
argumentIndex: helpItems.argumentIndex,
1919+
argumentCount: helpItems.argumentCount,
19491920
};
19501921
}
1951-
else if (useDisplayParts || !helpItems) {
1952-
return helpItems;
1953-
}
19541922
else {
1955-
return {
1956-
...helpItems,
1957-
items: helpItems.items.map(item => ({ ...item, tags: this.mapJSDocTagInfo(item.tags, project, /*richResponse*/ false) as JSDocTagInfo[] }))
1958-
};
1923+
return helpItems;
19591924
}
19601925
}
19611926

@@ -2735,10 +2700,10 @@ namespace ts.server {
27352700
return this.requiredResponse(this.getCompletions(request.arguments, CommandNames.CompletionsFull));
27362701
},
27372702
[CommandNames.CompletionDetails]: (request: protocol.CompletionDetailsRequest) => {
2738-
return this.requiredResponse(this.getCompletionEntryDetails(request.arguments, /*fullResult*/ false));
2703+
return this.requiredResponse(this.getCompletionEntryDetails(request.arguments, /*simplifiedResult*/ true));
27392704
},
27402705
[CommandNames.CompletionDetailsFull]: (request: protocol.CompletionDetailsRequest) => {
2741-
return this.requiredResponse(this.getCompletionEntryDetails(request.arguments, /*fullResult*/ true));
2706+
return this.requiredResponse(this.getCompletionEntryDetails(request.arguments, /*simplifiedResult*/ false));
27422707
},
27432708
[CommandNames.CompileOnSaveAffectedFileList]: (request: protocol.CompileOnSaveAffectedFileListRequest) => {
27442709
return this.requiredResponse(this.getCompileOnSaveAffectedFileList(request.arguments));

src/services/classifier.ts

-3
Original file line numberDiff line numberDiff line change
@@ -740,9 +740,6 @@ namespace ts {
740740
pos = tag.end;
741741
break;
742742
}
743-
if (tag.comment) {
744-
pushCommentRange(tag.comment.pos, tag.comment.end - tag.comment.pos);
745-
}
746743
}
747744
}
748745

0 commit comments

Comments
 (0)