mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-04-17 01:49:41 -05:00
Treat link tag as comment (#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
This commit is contained in:
committed by
GitHub
parent
6a9e077110
commit
99ebcd788f
@@ -6567,6 +6567,16 @@ namespace ts {
|
||||
indent += whitespace.length;
|
||||
}
|
||||
break;
|
||||
case SyntaxKind.OpenBraceToken:
|
||||
state = JSDocState.SavingComments;
|
||||
if (lookAhead(() => nextJSDocToken() === SyntaxKind.AtToken && tokenIsIdentifierOrKeyword(nextJSDocToken()) && scanner.getTokenText() === "link")) {
|
||||
pushComment(scanner.getTokenText());
|
||||
nextJSDocToken();
|
||||
pushComment(scanner.getTokenText());
|
||||
nextJSDocToken();
|
||||
}
|
||||
pushComment(scanner.getTokenText());
|
||||
break;
|
||||
case SyntaxKind.AsteriskToken:
|
||||
if (state === JSDocState.BeginningOfLine) {
|
||||
// leading asterisks start recording on the *next* (non-whitespace) token
|
||||
|
||||
@@ -308,6 +308,12 @@ namespace ts {
|
||||
* @param {object} o Doc doc
|
||||
* @param {string} o.f Doc for f
|
||||
*/`);
|
||||
parsesCorrectly("",
|
||||
`/**
|
||||
* {@link first link}
|
||||
* Inside {@link link text} thing
|
||||
* @see {@link second link text} and {@link Foo|a foo} as well.
|
||||
*/`);
|
||||
});
|
||||
});
|
||||
describe("getFirstToken", () => {
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
{
|
||||
"kind": "JSDocComment",
|
||||
"pos": 0,
|
||||
"end": 127,
|
||||
"tags": {
|
||||
"0": {
|
||||
"kind": "JSDocTag",
|
||||
"pos": 63,
|
||||
"end": 68,
|
||||
"atToken": {
|
||||
"kind": "AtToken",
|
||||
"pos": 63,
|
||||
"end": 64
|
||||
},
|
||||
"tagName": {
|
||||
"kind": "Identifier",
|
||||
"pos": 64,
|
||||
"end": 67,
|
||||
"escapedText": "see"
|
||||
},
|
||||
"comment": "{@link second link text} and {@link Foo|a foo} as well."
|
||||
},
|
||||
"length": 1,
|
||||
"pos": 63,
|
||||
"end": 68
|
||||
},
|
||||
"comment": "{@link first link}\nInside {@link link text} thing"
|
||||
}
|
||||
Reference in New Issue
Block a user