Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions internal/fourslash/_scripts/failingTests.txt
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,6 @@ TestCompletionsJSDocImportTagAttributesErrorModuleSpecifier1
TestCompletionsJSDocImportTagEmptyModuleSpecifier1
TestCompletionsJSDocNoCrash1
TestCompletionsJsdocTypeTagCast
TestCompletionsJsxAttribute2
TestCompletionsJsxAttributeInitializer2
TestCompletionsLiteralFromInferenceWithinInferredType3
TestCompletionsLiterals
Expand Down Expand Up @@ -458,11 +457,8 @@ TestTripleSlashRefPathCompletionExtensionsAllowJSTrue
TestTripleSlashRefPathCompletionHiddenFile
TestTripleSlashRefPathCompletionRootdirs
TestTslibFindAllReferencesOnRuntimeImportWithPaths1
TestTsxCompletion12
TestTsxCompletion13
TestTsxCompletion14
TestTsxCompletion15
TestTsxCompletion8
TestTsxCompletionNonTagLessThan
TestTsxQuickInfo1
TestTsxQuickInfo4
Expand Down
1 change: 1 addition & 0 deletions internal/fourslash/_scripts/manualTests.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ completionListInClosedFunction05
completionsAtIncompleteObjectLiteralProperty
completionsSelfDeclaring1
completionsWithDeprecatedTag4
tsxCompletion12
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (

func TestCompletionsJsxAttribute2(t *testing.T) {
t.Parallel()
t.Skip()

defer testutil.RecoverAndFail(t, "Panic on fourslash test")
const content = `// @jsx: preserve
// @Filename: /a.tsx
Expand Down
2 changes: 1 addition & 1 deletion internal/fourslash/tests/gen/tsxCompletion13_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (

func TestTsxCompletion13(t *testing.T) {
t.Parallel()
t.Skip()

defer testutil.RecoverAndFail(t, "Panic on fourslash test")
const content = `//@Filename: file.tsx
// @jsx: preserve
Expand Down
2 changes: 1 addition & 1 deletion internal/fourslash/tests/gen/tsxCompletion8_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (

func TestTsxCompletion8(t *testing.T) {
t.Parallel()
t.Skip()

defer testutil.RecoverAndFail(t, "Panic on fourslash test")
const content = `//@Filename: file.tsx
declare module JSX {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (

func TestTsxCompletion12(t *testing.T) {
t.Parallel()
t.Skip()

defer testutil.RecoverAndFail(t, "Panic on fourslash test")
const content = `//@Filename: file.tsx
// @jsx: preserve
Expand All @@ -30,12 +30,12 @@ func TestTsxCompletion12(t *testing.T) {
}
declare function Opt(attributes: OptionPropBag): JSX.Element;
let opt = <Opt /*1*/ />;
let opt1 = <Opt prop/*2*/ />;
let opt1 = <Opt [|prop|]/*2*/ />;
let opt2 = <Opt propx={100} /*3*/ />;
let opt3 = <Opt propx={100} optional /*4*/ />;
let opt4 = <Opt wrong /*5*/ />;`
f := fourslash.NewFourslash(t, nil /*capabilities*/, content)
f.VerifyCompletions(t, []string{"1", "2", "5"}, &fourslash.CompletionsExpectedList{
f.VerifyCompletions(t, []string{"1", "5"}, &fourslash.CompletionsExpectedList{
IsIncomplete: false,
ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{
CommitCharacters: &DefaultCommitCharacters,
Expand All @@ -55,6 +55,32 @@ func TestTsxCompletion12(t *testing.T) {
},
},
})
f.VerifyCompletions(t, "2", &fourslash.CompletionsExpectedList{
IsIncomplete: false,
ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{
CommitCharacters: &DefaultCommitCharacters,
EditRange: Ignored,
},
Items: &fourslash.CompletionsExpectedItems{
Exact: []fourslash.CompletionsExpectedItem{
"propString",
"propx",
&lsproto.CompletionItem{
Label: "optional?",
FilterText: PtrTo("optional"),
Kind: PtrTo(lsproto.CompletionItemKindField),
SortText: PtrTo(string(ls.SortTextOptionalMember)),
TextEdit: &lsproto.TextEditOrInsertReplaceEdit{
InsertReplaceEdit: &lsproto.InsertReplaceEdit{
NewText: "optional",
Insert: f.Ranges()[0].LSRange,
Replace: f.Ranges()[0].LSRange,
},
},
},
},
},
})
f.VerifyCompletions(t, "3", &fourslash.CompletionsExpectedList{
IsIncomplete: false,
ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{
Expand Down
6 changes: 6 additions & 0 deletions internal/ls/completions.go
Original file line number Diff line number Diff line change
Expand Up @@ -4283,6 +4283,12 @@ func tryGetContainingJsxElement(contextToken *ast.Node, file *ast.SourceFile) *a
}
}
return parent
} else if parent != nil && parent.Kind == ast.KindJsxAttribute {
// Currently we parse JsxOpeningLikeElement as:
// JsxOpeningLikeElement
// attributes: JsxAttributes
// properties: NodeArray<JsxAttributeLike>
return parent.Parent.Parent
}
// The context token is the closing } or " of an attribute, which means
// its parent is a JsxExpression, whose parent is a JsxAttribute,
Expand Down
Loading