mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
Fix scanner offset and make it easier to read
This commit is contained in:
@@ -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))) {
|
||||
@@ -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;
|
||||
|
||||
@@ -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))
|
||||
|
||||
|
||||
|
||||
@@ -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 : ""
|
||||
>"" : ""
|
||||
|
||||
|
||||
|
||||
@@ -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: "" });
|
||||
|
||||
Reference in New Issue
Block a user