Revert PR 61928 (#62423)

This commit is contained in:
Jake Bailey 2025-09-25 10:22:27 -07:00 committed by GitHub
parent 6f6efb419a
commit 5f183ad73d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 16 additions and 21 deletions

View File

@ -4288,7 +4288,6 @@ export interface SourceFileLike {
lineMap?: readonly number[];
/** @internal */
getPositionOfLineAndCharacter?(line: number, character: number, allowEdits?: true): number;
languageVariant?: LanguageVariant;
}
/** @internal */

View File

@ -1595,7 +1595,7 @@ function getJsxClosingTagCompletion(location: Node | undefined, sourceFile: Sour
switch (node.kind) {
case SyntaxKind.JsxClosingElement:
return true;
case SyntaxKind.LessThanSlashToken:
case SyntaxKind.SlashToken:
case SyntaxKind.GreaterThanToken:
case SyntaxKind.Identifier:
case SyntaxKind.PropertyAccessExpression:
@ -3508,7 +3508,7 @@ function getCompletionData(
}
break;
case SyntaxKind.LessThanSlashToken:
case SyntaxKind.SlashToken:
if (currentToken.parent.kind === SyntaxKind.JsxSelfClosingElement) {
location = currentToken;
}
@ -3518,7 +3518,7 @@ function getCompletionData(
switch (parent.kind) {
case SyntaxKind.JsxClosingElement:
if (contextToken.kind === SyntaxKind.LessThanSlashToken) {
if (contextToken.kind === SyntaxKind.SlashToken) {
isStartingCloseTag = true;
location = contextToken;
}
@ -5809,7 +5809,7 @@ function isValidTrigger(sourceFile: SourceFile, triggerCharacter: CompletionsTri
case "/":
return !!contextToken && (isStringLiteralLike(contextToken)
? !!tryGetImportFromModuleSpecifier(contextToken)
: contextToken.kind === SyntaxKind.LessThanSlashToken && isJsxClosingElement(contextToken.parent));
: contextToken.kind === SyntaxKind.SlashToken && isJsxClosingElement(contextToken.parent));
case " ":
return !!contextToken && isImportKeyword(contextToken) && contextToken.parent.kind === SyntaxKind.SourceFile;
default:

View File

@ -504,9 +504,8 @@ function createChildren(node: Node, sourceFile: SourceFileLike | undefined): rea
});
return children;
}
const languageVariant = sourceFile?.languageVariant ?? LanguageVariant.Standard;
scanner.setText((sourceFile || node.getSourceFile()).text);
scanner.setLanguageVariant(languageVariant);
let pos = node.pos;
const processNode = (child: Node) => {
addSyntheticNodes(children, pos, child.pos, node);
@ -527,7 +526,6 @@ function createChildren(node: Node, sourceFile: SourceFileLike | undefined): rea
node.forEachChild(processNode, processNodes);
addSyntheticNodes(children, pos, node.end, node);
scanner.setText(undefined);
scanner.setLanguageVariant(LanguageVariant.Standard);
return children;
}

View File

@ -1889,7 +1889,7 @@ export function isInsideJsxElementOrAttribute(sourceFile: SourceFile, position:
}
// <div>|</div>
if (token.kind === SyntaxKind.LessThanSlashToken && token.parent.kind === SyntaxKind.JsxClosingElement) {
if (token.kind === SyntaxKind.LessThanToken && token.parent.kind === SyntaxKind.JsxClosingElement) {
return true;
}
@ -1934,7 +1934,6 @@ export function isInsideJsxElement(sourceFile: SourceFile, position: number): bo
|| node.kind === SyntaxKind.CloseBraceToken
|| node.kind === SyntaxKind.OpenBraceToken
|| node.kind === SyntaxKind.SlashToken
|| node.kind === SyntaxKind.LessThanSlashToken
) {
node = node.parent;
}

View File

@ -5908,7 +5908,6 @@ declare namespace ts {
*/
interface SourceFileLike {
readonly text: string;
languageVariant?: LanguageVariant;
}
interface SourceFileLike {
getLineAndCharacterOfPosition(pos: number): LineAndCharacter;

View File

@ -18,7 +18,7 @@ verify.syntacticClassificationsAre(
c.jsxText(`
some jsx text
`),
c.punctuation("</"), c.jsxCloseTagName("div"), c.punctuation(">"), c.punctuation(";"),
c.punctuation("<"), c.punctuation("/"), c.jsxCloseTagName("div"), c.punctuation(">"), c.punctuation(";"),
c.keyword("let"), c.identifier("y"), c.operator("="),
c.punctuation("<"),
c.jsxSelfClosingTagName("element"),
@ -26,8 +26,8 @@ verify.syntacticClassificationsAre(
c.punctuation("/"), c.punctuation(">")
)
const c2 = classification("2020");
verify.semanticClassificationsAre("2020",
c2.semanticToken("variable.declaration", "x"),
c2.semanticToken("variable.declaration", "y"),
const c2 = classification("2020");
verify.semanticClassificationsAre("2020",
c2.semanticToken("variable.declaration", "x"),
c2.semanticToken("variable.declaration", "y"),
);

View File

@ -18,7 +18,7 @@ verify.syntacticClassificationsAre(
c.jsxText(`
some jsx text
`),
c.punctuation("</"), c.jsxCloseTagName("div.name"), c.punctuation(">"), c.punctuation(";"),
c.punctuation("<"), c.punctuation("/"), c.jsxCloseTagName("div.name"), c.punctuation(">"), c.punctuation(";"),
c.keyword("let"), c.identifier("y"), c.operator("="),
c.punctuation("<"),
c.jsxSelfClosingTagName("element.name"),
@ -26,8 +26,8 @@ verify.syntacticClassificationsAre(
c.punctuation("/"), c.punctuation(">")
)
const c2 = classification("2020");
verify.semanticClassificationsAre("2020",
c2.semanticToken("variable.declaration", "x"),
c2.semanticToken("variable.declaration", "y"),
const c2 = classification("2020");
verify.semanticClassificationsAre("2020",
c2.semanticToken("variable.declaration", "x"),
c2.semanticToken("variable.declaration", "y"),
);