We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 78c1679 commit 0009056Copy full SHA for 0009056
5 files changed
src/services/completions.ts
@@ -1595,7 +1595,7 @@ function getJsxClosingTagCompletion(location: Node | undefined, sourceFile: Sour
1595
switch (node.kind) {
1596
case SyntaxKind.JsxClosingElement:
1597
return true;
1598
- case SyntaxKind.SlashToken:
+ case SyntaxKind.LessThanSlashToken:
1599
case SyntaxKind.GreaterThanToken:
1600
case SyntaxKind.Identifier:
1601
case SyntaxKind.PropertyAccessExpression:
@@ -3508,7 +3508,7 @@ function getCompletionData(
3508
}
3509
break;
3510
3511
3512
if (currentToken.parent.kind === SyntaxKind.JsxSelfClosingElement) {
3513
location = currentToken;
3514
@@ -3518,7 +3518,7 @@ function getCompletionData(
3518
3519
switch (parent.kind) {
3520
3521
- if (contextToken.kind === SyntaxKind.SlashToken) {
+ if (contextToken.kind === SyntaxKind.LessThanSlashToken) {
3522
isStartingCloseTag = true;
3523
location = contextToken;
3524
@@ -5805,7 +5805,7 @@ function isValidTrigger(sourceFile: SourceFile, triggerCharacter: CompletionsTri
5805
case "/":
5806
return !!contextToken && (isStringLiteralLike(contextToken)
5807
? !!tryGetImportFromModuleSpecifier(contextToken)
5808
- : contextToken.kind === SyntaxKind.SlashToken && isJsxClosingElement(contextToken.parent));
+ : contextToken.kind === SyntaxKind.LessThanSlashToken && isJsxClosingElement(contextToken.parent));
5809
case " ":
5810
return !!contextToken && isImportKeyword(contextToken) && contextToken.parent.kind === SyntaxKind.SourceFile;
5811
default:
src/services/services.ts
@@ -504,8 +504,9 @@ function createChildren(node: Node, sourceFile: SourceFileLike | undefined): rea
504
});
505
return children;
506
507
-
+ const languageVariant = (sourceFile as SourceFile)?.languageVariant ?? LanguageVariant.Standard;
508
scanner.setText((sourceFile || node.getSourceFile()).text);
509
+ scanner.setLanguageVariant(languageVariant);
510
let pos = node.pos;
511
const processNode = (child: Node) => {
512
addSyntheticNodes(children, pos, child.pos, node);
@@ -526,6 +527,7 @@ function createChildren(node: Node, sourceFile: SourceFileLike | undefined): rea
526
527
node.forEachChild(processNode, processNodes);
528
addSyntheticNodes(children, pos, node.end, node);
529
scanner.setText(undefined);
530
+ scanner.setLanguageVariant(LanguageVariant.Standard);
531
532
533
src/services/utilities.ts
@@ -1889,7 +1889,7 @@ export function isInsideJsxElementOrAttribute(sourceFile: SourceFile, position:
1889
1890
1891
// <div>|</div>
1892
- if (token.kind === SyntaxKind.LessThanToken && token.parent.kind === SyntaxKind.JsxClosingElement) {
+ if (token.kind === SyntaxKind.LessThanSlashToken && token.parent.kind === SyntaxKind.JsxClosingElement) {
1893
1894
1895
@@ -1934,6 +1934,7 @@ export function isInsideJsxElement(sourceFile: SourceFile, position: number): bo
1934
|| node.kind === SyntaxKind.CloseBraceToken
1935
|| node.kind === SyntaxKind.OpenBraceToken
1936
|| node.kind === SyntaxKind.SlashToken
1937
+ || node.kind === SyntaxKind.LessThanSlashToken
1938
) {
1939
node = node.parent;
1940
tests/cases/fourslash/syntacticClassificationsJsx1.ts
@@ -18,16 +18,16 @@ verify.syntacticClassificationsAre(
18
c.jsxText(`
19
some jsx text
20
`),
21
- c.punctuation("<"), c.punctuation("/"), c.jsxCloseTagName("div"), c.punctuation(">"), c.punctuation(";"),
+ c.punctuation("</"), c.jsxCloseTagName("div"), c.punctuation(">"), c.punctuation(";"),
22
c.keyword("let"), c.identifier("y"), c.operator("="),
23
c.punctuation("<"),
24
c.jsxSelfClosingTagName("element"),
25
c.jsxAttribute("attr"), c.operator("="), c.jsxAttributeStringLiteralValue(`"123"`),
26
c.punctuation("/"), c.punctuation(">")
27
)
28
29
-const c2 = classification("2020");
30
-verify.semanticClassificationsAre("2020",
31
- c2.semanticToken("variable.declaration", "x"),
32
- c2.semanticToken("variable.declaration", "y"),
+const c2 = classification("2020");
+verify.semanticClassificationsAre("2020",
+ c2.semanticToken("variable.declaration", "x"),
+ c2.semanticToken("variable.declaration", "y"),
33
);
tests/cases/fourslash/syntacticClassificationsJsx2.ts
- c.punctuation("<"), c.punctuation("/"), c.jsxCloseTagName("div.name"), c.punctuation(">"), c.punctuation(";"),
+ c.punctuation("</"), c.jsxCloseTagName("div.name"), c.punctuation(">"), c.punctuation(";"),
c.jsxSelfClosingTagName("element.name"),
0 commit comments