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:
Nathan Shively-Sanders
2018-06-25 15:27:49 -07:00
committed by GitHub
parent 6a9e077110
commit 99ebcd788f
4 changed files with 45 additions and 1 deletions

View File

@@ -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

View File

@@ -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", () => {

View File

@@ -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"
}