Consistently pass indent to 'parseTagComments' (#27055)
* Consistently pass indent to 'parseTagComments' * Update baselines
This commit is contained in:
parent
d3463ce356
commit
2b888c30f9
4 changed files with 17 additions and 21 deletions
|
@ -6724,7 +6724,7 @@ namespace ts {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function parseParameterOrPropertyTag(atToken: AtToken, tagName: Identifier, target: PropertyLikeParse, indent: number | undefined): JSDocParameterTag | JSDocPropertyTag {
|
function parseParameterOrPropertyTag(atToken: AtToken, tagName: Identifier, target: PropertyLikeParse, indent: number): JSDocParameterTag | JSDocPropertyTag {
|
||||||
let typeExpression = tryParseTypeExpression();
|
let typeExpression = tryParseTypeExpression();
|
||||||
let isNameFirst = !typeExpression;
|
let isNameFirst = !typeExpression;
|
||||||
skipWhitespaceOrAsterisk();
|
skipWhitespaceOrAsterisk();
|
||||||
|
@ -6739,9 +6739,8 @@ namespace ts {
|
||||||
const result = target === PropertyLikeParse.Property ?
|
const result = target === PropertyLikeParse.Property ?
|
||||||
<JSDocPropertyTag>createNode(SyntaxKind.JSDocPropertyTag, atToken.pos) :
|
<JSDocPropertyTag>createNode(SyntaxKind.JSDocPropertyTag, atToken.pos) :
|
||||||
<JSDocParameterTag>createNode(SyntaxKind.JSDocParameterTag, atToken.pos);
|
<JSDocParameterTag>createNode(SyntaxKind.JSDocParameterTag, atToken.pos);
|
||||||
let comment: string | undefined;
|
const comment = parseTagComments(indent + scanner.getStartPos() - atToken.pos);
|
||||||
if (indent !== undefined) comment = parseTagComments(indent + scanner.getStartPos() - atToken.pos);
|
const nestedTypeLiteral = target !== PropertyLikeParse.CallbackParameter && parseNestedTypeLiteral(typeExpression, name, target, indent);
|
||||||
const nestedTypeLiteral = target !== PropertyLikeParse.CallbackParameter && parseNestedTypeLiteral(typeExpression, name, target);
|
|
||||||
if (nestedTypeLiteral) {
|
if (nestedTypeLiteral) {
|
||||||
typeExpression = nestedTypeLiteral;
|
typeExpression = nestedTypeLiteral;
|
||||||
isNameFirst = true;
|
isNameFirst = true;
|
||||||
|
@ -6756,14 +6755,14 @@ namespace ts {
|
||||||
return finishNode(result);
|
return finishNode(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
function parseNestedTypeLiteral(typeExpression: JSDocTypeExpression | undefined, name: EntityName, target: PropertyLikeParse) {
|
function parseNestedTypeLiteral(typeExpression: JSDocTypeExpression | undefined, name: EntityName, target: PropertyLikeParse, indent: number) {
|
||||||
if (typeExpression && isObjectOrObjectArrayTypeReference(typeExpression.type)) {
|
if (typeExpression && isObjectOrObjectArrayTypeReference(typeExpression.type)) {
|
||||||
const typeLiteralExpression = <JSDocTypeExpression>createNode(SyntaxKind.JSDocTypeExpression, scanner.getTokenPos());
|
const typeLiteralExpression = <JSDocTypeExpression>createNode(SyntaxKind.JSDocTypeExpression, scanner.getTokenPos());
|
||||||
let child: JSDocPropertyLikeTag | JSDocTypeTag | false;
|
let child: JSDocPropertyLikeTag | JSDocTypeTag | false;
|
||||||
let jsdocTypeLiteral: JSDocTypeLiteral;
|
let jsdocTypeLiteral: JSDocTypeLiteral;
|
||||||
const start = scanner.getStartPos();
|
const start = scanner.getStartPos();
|
||||||
let children: JSDocPropertyLikeTag[] | undefined;
|
let children: JSDocPropertyLikeTag[] | undefined;
|
||||||
while (child = tryParse(() => parseChildParameterOrPropertyTag(target, name))) {
|
while (child = tryParse(() => parseChildParameterOrPropertyTag(target, indent, name))) {
|
||||||
if (child.kind === SyntaxKind.JSDocParameterTag || child.kind === SyntaxKind.JSDocPropertyTag) {
|
if (child.kind === SyntaxKind.JSDocParameterTag || child.kind === SyntaxKind.JSDocPropertyTag) {
|
||||||
children = append(children, child);
|
children = append(children, child);
|
||||||
}
|
}
|
||||||
|
@ -6879,7 +6878,7 @@ namespace ts {
|
||||||
let jsdocTypeLiteral: JSDocTypeLiteral | undefined;
|
let jsdocTypeLiteral: JSDocTypeLiteral | undefined;
|
||||||
let childTypeTag: JSDocTypeTag | undefined;
|
let childTypeTag: JSDocTypeTag | undefined;
|
||||||
const start = atToken.pos;
|
const start = atToken.pos;
|
||||||
while (child = tryParse(() => parseChildPropertyTag())) {
|
while (child = tryParse(() => parseChildPropertyTag(indent))) {
|
||||||
if (!jsdocTypeLiteral) {
|
if (!jsdocTypeLiteral) {
|
||||||
jsdocTypeLiteral = <JSDocTypeLiteral>createNode(SyntaxKind.JSDocTypeLiteral, start);
|
jsdocTypeLiteral = <JSDocTypeLiteral>createNode(SyntaxKind.JSDocTypeLiteral, start);
|
||||||
}
|
}
|
||||||
|
@ -6945,7 +6944,7 @@ namespace ts {
|
||||||
const start = scanner.getStartPos();
|
const start = scanner.getStartPos();
|
||||||
const jsdocSignature = createNode(SyntaxKind.JSDocSignature, start) as JSDocSignature;
|
const jsdocSignature = createNode(SyntaxKind.JSDocSignature, start) as JSDocSignature;
|
||||||
jsdocSignature.parameters = [];
|
jsdocSignature.parameters = [];
|
||||||
while (child = tryParse(() => parseChildParameterOrPropertyTag(PropertyLikeParse.CallbackParameter) as JSDocParameterTag)) {
|
while (child = tryParse(() => parseChildParameterOrPropertyTag(PropertyLikeParse.CallbackParameter, indent) as JSDocParameterTag)) {
|
||||||
jsdocSignature.parameters = append(jsdocSignature.parameters as MutableNodeArray<JSDocParameterTag>, child);
|
jsdocSignature.parameters = append(jsdocSignature.parameters as MutableNodeArray<JSDocParameterTag>, child);
|
||||||
}
|
}
|
||||||
const returnTag = tryParse(() => {
|
const returnTag = tryParse(() => {
|
||||||
|
@ -6988,18 +6987,18 @@ namespace ts {
|
||||||
return a.escapedText === b.escapedText;
|
return a.escapedText === b.escapedText;
|
||||||
}
|
}
|
||||||
|
|
||||||
function parseChildPropertyTag() {
|
function parseChildPropertyTag(indent: number) {
|
||||||
return parseChildParameterOrPropertyTag(PropertyLikeParse.Property) as JSDocTypeTag | JSDocPropertyTag | false;
|
return parseChildParameterOrPropertyTag(PropertyLikeParse.Property, indent) as JSDocTypeTag | JSDocPropertyTag | false;
|
||||||
}
|
}
|
||||||
|
|
||||||
function parseChildParameterOrPropertyTag(target: PropertyLikeParse, name?: EntityName): JSDocTypeTag | JSDocPropertyTag | JSDocParameterTag | false {
|
function parseChildParameterOrPropertyTag(target: PropertyLikeParse, indent: number, name?: EntityName): JSDocTypeTag | JSDocPropertyTag | JSDocParameterTag | false {
|
||||||
let canParseTag = true;
|
let canParseTag = true;
|
||||||
let seenAsterisk = false;
|
let seenAsterisk = false;
|
||||||
while (true) {
|
while (true) {
|
||||||
switch (nextJSDocToken()) {
|
switch (nextJSDocToken()) {
|
||||||
case SyntaxKind.AtToken:
|
case SyntaxKind.AtToken:
|
||||||
if (canParseTag) {
|
if (canParseTag) {
|
||||||
const child = tryParseChildTag(target);
|
const child = tryParseChildTag(target, indent);
|
||||||
if (child && (child.kind === SyntaxKind.JSDocParameterTag || child.kind === SyntaxKind.JSDocPropertyTag) &&
|
if (child && (child.kind === SyntaxKind.JSDocParameterTag || child.kind === SyntaxKind.JSDocPropertyTag) &&
|
||||||
target !== PropertyLikeParse.CallbackParameter &&
|
target !== PropertyLikeParse.CallbackParameter &&
|
||||||
name && (ts.isIdentifier(child.name) || !escapedTextsEqual(name, child.name.left))) {
|
name && (ts.isIdentifier(child.name) || !escapedTextsEqual(name, child.name.left))) {
|
||||||
|
@ -7028,7 +7027,7 @@ namespace ts {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function tryParseChildTag(target: PropertyLikeParse): JSDocTypeTag | JSDocPropertyTag | JSDocParameterTag | false {
|
function tryParseChildTag(target: PropertyLikeParse, indent: number): JSDocTypeTag | JSDocPropertyTag | JSDocParameterTag | false {
|
||||||
Debug.assert(token() === SyntaxKind.AtToken);
|
Debug.assert(token() === SyntaxKind.AtToken);
|
||||||
const atToken = <AtToken>createNode(SyntaxKind.AtToken);
|
const atToken = <AtToken>createNode(SyntaxKind.AtToken);
|
||||||
atToken.end = scanner.getTextPos();
|
atToken.end = scanner.getTextPos();
|
||||||
|
@ -7055,9 +7054,7 @@ namespace ts {
|
||||||
if (!(target & t)) {
|
if (!(target & t)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
const tag = parseParameterOrPropertyTag(atToken, tagName, target, /*indent*/ undefined);
|
return parseParameterOrPropertyTag(atToken, tagName, target, indent);
|
||||||
tag.comment = parseTagComments(tag.end - tag.pos);
|
|
||||||
return tag;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function parseTemplateTag(atToken: AtToken, tagName: Identifier): JSDocTemplateTag {
|
function parseTemplateTag(atToken: AtToken, tagName: Identifier): JSDocTemplateTag {
|
||||||
|
|
|
@ -30,7 +30,7 @@
|
||||||
{
|
{
|
||||||
"kind": "JSDocParameterTag",
|
"kind": "JSDocParameterTag",
|
||||||
"pos": 34,
|
"pos": 34,
|
||||||
"end": 54,
|
"end": 64,
|
||||||
"atToken": {
|
"atToken": {
|
||||||
"kind": "AtToken",
|
"kind": "AtToken",
|
||||||
"pos": 34,
|
"pos": 34,
|
||||||
|
|
|
@ -38,7 +38,7 @@
|
||||||
{
|
{
|
||||||
"kind": "JSDocPropertyTag",
|
"kind": "JSDocPropertyTag",
|
||||||
"pos": 47,
|
"pos": 47,
|
||||||
"end": 72,
|
"end": 74,
|
||||||
"atToken": {
|
"atToken": {
|
||||||
"kind": "AtToken",
|
"kind": "AtToken",
|
||||||
"pos": 47,
|
"pos": 47,
|
||||||
|
@ -72,7 +72,7 @@
|
||||||
{
|
{
|
||||||
"kind": "JSDocPropertyTag",
|
"kind": "JSDocPropertyTag",
|
||||||
"pos": 74,
|
"pos": 74,
|
||||||
"end": 97,
|
"end": 100,
|
||||||
"atToken": {
|
"atToken": {
|
||||||
"kind": "AtToken",
|
"kind": "AtToken",
|
||||||
"pos": 74,
|
"pos": 74,
|
||||||
|
|
|
@ -12,5 +12,4 @@
|
||||||
/////** @type {I} */
|
/////** @type {I} */
|
||||||
////const obj = { /**/x: 10 };
|
////const obj = { /**/x: 10 };
|
||||||
|
|
||||||
// TODO: GH#21123 There shouldn't be a " " before "More doc"
|
|
||||||
verify.quickInfoAt("", "(property) x: number", "Doc\nMore doc");
|
verify.quickInfoAt("", "(property) x: number", "Doc\nMore doc");
|
||||||
|
|
Loading…
Reference in a new issue