mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-17 21:06:50 -05:00
Add JSXText check into isValidLocationToAddComment (#27653)
* Add JSXText check into isValidLocationToAddComment * Small simplification
This commit is contained in:
@@ -1075,7 +1075,7 @@ namespace ts.textChanges {
|
||||
}
|
||||
|
||||
export function isValidLocationToAddComment(sourceFile: SourceFile, position: number) {
|
||||
return !isInComment(sourceFile, position) && !isInString(sourceFile, position) && !isInTemplateString(sourceFile, position);
|
||||
return !isInComment(sourceFile, position) && !isInString(sourceFile, position) && !isInTemplateString(sourceFile, position) && !isInJSXText(sourceFile, position);
|
||||
}
|
||||
|
||||
function needSemicolonBetween(a: Node, b: Node): boolean {
|
||||
|
||||
@@ -909,6 +909,20 @@ namespace ts {
|
||||
return isTemplateLiteralKind(token.kind) && position > token.getStart(sourceFile);
|
||||
}
|
||||
|
||||
export function isInJSXText(sourceFile: SourceFile, position: number) {
|
||||
const token = getTokenAtPosition(sourceFile, position);
|
||||
if (isJsxText(token)) {
|
||||
return true;
|
||||
}
|
||||
if (token.kind === SyntaxKind.OpenBraceToken && isJsxExpression(token.parent) && isJsxElement(token.parent.parent)) {
|
||||
return true;
|
||||
}
|
||||
if (token.kind === SyntaxKind.LessThanToken && isJsxOpeningLikeElement(token.parent) && isJsxElement(token.parent.parent)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
export function findPrecedingMatchingToken(token: Node, matchingTokenKind: SyntaxKind, sourceFile: SourceFile) {
|
||||
const tokenKind = token.kind;
|
||||
let remainingMatchingTokens = 0;
|
||||
|
||||
Reference in New Issue
Block a user