Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix scanner offset and make it easier to read
  • Loading branch information
sandersn committed Aug 5, 2020
commit cf63bce7afa3e92d4b77d64ea2c28cec7bc37370
6 changes: 3 additions & 3 deletions src/compiler/scanner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1745,10 +1745,10 @@ namespace ts {
case CharacterCodes.slash:
// Single-line comment
if (text.charCodeAt(pos + 1) === CharacterCodes.slash) {
pos += 2;
if (text.charCodeAt(pos + 2) === CharacterCodes.slash) {
tokenFlags |= TokenFlags.PrecedingJSDocComment;
}
pos += 2;

while (pos < end) {
if (isLineBreak(text.charCodeAt(pos))) {
Expand All @@ -1773,10 +1773,10 @@ namespace ts {
}
// Multi-line comment
if (text.charCodeAt(pos + 1) === CharacterCodes.asterisk) {
pos += 2;
if (text.charCodeAt(pos) === CharacterCodes.asterisk && text.charCodeAt(pos + 1) !== CharacterCodes.slash) {
if (text.charCodeAt(pos + 2) === CharacterCodes.asterisk && text.charCodeAt(pos + 3) !== CharacterCodes.slash) {
tokenFlags |= TokenFlags.PrecedingJSDocComment;
}
pos += 2;

let commentClosed = false;
let lastLineStart = tokenPos;
Expand Down
40 changes: 40 additions & 0 deletions tests/baselines/reference/tripleSlashJsdoc.symbols
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
=== tests/cases/conformance/jsdoc/tripleSlash.js ===
/// @type {number} - TODO this is still skipped for some reason
var x;
>x : Symbol(x, Decl(tripleSlash.js, 1, 3))

/// Adds one
/// @param {number} n - this is a long,
/// multiline comment
///
/// @return {number}
function add1(n) {
>add1 : Symbol(add1, Decl(tripleSlash.js, 1, 6))
>n : Symbol(n, Decl(tripleSlash.js, 8, 14))

return n + 1
>n : Symbol(n, Decl(tripleSlash.js, 8, 14))
}

// Should be the same

/** Adds one
* @param {number} n - this is a long,
* multiline comment
*
* @return {number}
*/
function add2(n) {
>add2 : Symbol(add2, Decl(tripleSlash.js, 10, 1))
>n : Symbol(n, Decl(tripleSlash.js, 20, 14))

return n + 1
>n : Symbol(n, Decl(tripleSlash.js, 20, 14))
}

/// I documented this const
const documented = ""
>documented : Symbol(documented, Decl(tripleSlash.js, 25, 5))



45 changes: 45 additions & 0 deletions tests/baselines/reference/tripleSlashJsdoc.types
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
=== tests/cases/conformance/jsdoc/tripleSlash.js ===
/// @type {number} - TODO this is still skipped for some reason
var x;
>x : number

/// Adds one
/// @param {number} n - this is a long,
/// multiline comment
///
/// @return {number}
function add1(n) {
>add1 : (n: number) => number
>n : number

return n + 1
>n + 1 : number
>n : number
>1 : 1
}

// Should be the same

/** Adds one
* @param {number} n - this is a long,
* multiline comment
*
* @return {number}
*/
function add2(n) {
>add2 : (n: number) => number
>n : number

return n + 1
>n + 1 : number
>n : number
>1 : 1
}

/// I documented this const
const documented = ""
>documented : ""
>"" : ""



2 changes: 1 addition & 1 deletion tests/cases/fourslash/commentsCommentParsing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@
////class NoQuic/*50*/kInfoClass {
////}

verify.signatureHelp({ marker: "1", docComment: "" });
verify.signatureHelp({ marker: "1", docComment: " This is simple /// comments" });
verify.quickInfoAt("1q", "function simple(): void");

verify.signatureHelp({ marker: "2", docComment: "" });
Expand Down