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

Lines changed: 2 additions & 6 deletions
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

Lines changed: 10 additions & 14 deletions
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

Lines changed: 31 additions & 64 deletions
Large diffs are not rendered by default.

src/compiler/factory/nodeTests.ts

Lines changed: 0 additions & 4 deletions
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

Lines changed: 62 additions & 130 deletions
Large diffs are not rendered by default.

src/compiler/types.ts

Lines changed: 44 additions & 61 deletions
Large diffs are not rendered by default.

src/compiler/utilitiesPublic.ts

Lines changed: 1 addition & 12 deletions
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

Lines changed: 2 additions & 2 deletions
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

Lines changed: 4 additions & 12 deletions
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

Lines changed: 1 addition & 1 deletion
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)[] = [

0 commit comments

Comments
 (0)