Skip to content

Commit 99ebcd7

Browse files
authored
Treat link tag as comment (microsoft#25206)
* First attempt at parsing. Doesn't work But my machine is dying, so this is an emergency commit. * Parsing sort of works But it's not right yet; the test I added fails. See the TODO I added. * Parse link tag as comment
1 parent 6a9e077 commit 99ebcd7

File tree

4 files changed

+45
-1
lines changed

4 files changed

+45
-1
lines changed

src/compiler/parser.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6567,6 +6567,16 @@ namespace ts {
65676567
indent += whitespace.length;
65686568
}
65696569
break;
6570+
case SyntaxKind.OpenBraceToken:
6571+
state = JSDocState.SavingComments;
6572+
if (lookAhead(() => nextJSDocToken() === SyntaxKind.AtToken && tokenIsIdentifierOrKeyword(nextJSDocToken()) && scanner.getTokenText() === "link")) {
6573+
pushComment(scanner.getTokenText());
6574+
nextJSDocToken();
6575+
pushComment(scanner.getTokenText());
6576+
nextJSDocToken();
6577+
}
6578+
pushComment(scanner.getTokenText());
6579+
break;
65706580
case SyntaxKind.AsteriskToken:
65716581
if (state === JSDocState.BeginningOfLine) {
65726582
// leading asterisks start recording on the *next* (non-whitespace) token

src/testRunner/unittests/jsDocParsing.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,12 @@ namespace ts {
308308
* @param {object} o Doc doc
309309
* @param {string} o.f Doc for f
310310
*/`);
311+
parsesCorrectly("",
312+
`/**
313+
* {@link first link}
314+
* Inside {@link link text} thing
315+
* @see {@link second link text} and {@link Foo|a foo} as well.
316+
*/`);
311317
});
312318
});
313319
describe("getFirstToken", () => {
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{
2+
"kind": "JSDocComment",
3+
"pos": 0,
4+
"end": 127,
5+
"tags": {
6+
"0": {
7+
"kind": "JSDocTag",
8+
"pos": 63,
9+
"end": 68,
10+
"atToken": {
11+
"kind": "AtToken",
12+
"pos": 63,
13+
"end": 64
14+
},
15+
"tagName": {
16+
"kind": "Identifier",
17+
"pos": 64,
18+
"end": 67,
19+
"escapedText": "see"
20+
},
21+
"comment": "{@link second link text} and {@link Foo|a foo} as well."
22+
},
23+
"length": 1,
24+
"pos": 63,
25+
"end": 68
26+
},
27+
"comment": "{@link first link}\nInside {@link link text} thing"
28+
}

0 commit comments

Comments
 (0)