Skip to content

Commit 256441c

Browse files
authored
Completions fixes (#1404)
1 parent e62a044 commit 256441c

15 files changed

+109
-67
lines changed

internal/fourslash/_scripts/convertFourslash.mts

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,7 @@ function parseVerifyCompletionArg(arg: ts.Expression): VerifyCompletionsCmd | un
389389
return {
390390
kind: "verifyCompletions",
391391
marker: marker ? marker : "nil",
392-
args: undefined,
392+
args: "nil",
393393
};
394394
}
395395
let expected: string;
@@ -787,7 +787,7 @@ interface VerifyCompletionsCmd {
787787
kind: "verifyCompletions";
788788
marker: string;
789789
isNewIdentifierLocation?: true;
790-
args?: VerifyCompletionsArgs;
790+
args?: VerifyCompletionsArgs | "nil";
791791
}
792792

793793
interface VerifyCompletionsArgs {
@@ -824,13 +824,16 @@ interface EditCmd {
824824
type Cmd = VerifyCompletionsCmd | VerifyBaselineFindAllReferencesCmd | GoToCmd | EditCmd;
825825

826826
function generateVerifyCompletions({ marker, args, isNewIdentifierLocation }: VerifyCompletionsCmd): string {
827-
let expectedList = "nil";
828-
if (args) {
827+
let expectedList: string;
828+
if (args === "nil") {
829+
expectedList = "nil";
830+
}
831+
else {
829832
const expected = [];
830-
if (args.includes) expected.push(`Includes: ${args.includes},`);
831-
if (args.excludes) expected.push(`Excludes: ${args.excludes},`);
832-
if (args.exact) expected.push(`Exact: ${args.exact},`);
833-
if (args.unsorted) expected.push(`Unsorted: ${args.unsorted},`);
833+
if (args?.includes) expected.push(`Includes: ${args.includes},`);
834+
if (args?.excludes) expected.push(`Excludes: ${args.excludes},`);
835+
if (args?.exact) expected.push(`Exact: ${args.exact},`);
836+
if (args?.unsorted) expected.push(`Unsorted: ${args.unsorted},`);
834837
// !!! isIncomplete
835838
const commitCharacters = isNewIdentifierLocation ? "[]string{}" : "defaultCommitCharacters";
836839
expectedList = `&fourslash.CompletionsExpectedList{

internal/fourslash/_scripts/failingTests.txt

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
TestAugmentedTypesClass1
2-
TestAutoImportsWithRootDirsAndRootedPath01
32
TestClosedCommentsInConstructor
43
TestCodeCompletionEscaping
54
TestCompletionAfterQuestionDot
@@ -140,7 +139,6 @@ TestCompletionsECMAPrivateMember
140139
TestCompletionsECMAPrivateMemberTriggerCharacter
141140
TestCompletionsExportImport
142141
TestCompletionsGenericTypeWithMultipleBases1
143-
TestCompletionsImport_computedSymbolName
144142
TestCompletionsInRequire
145143
TestCompletionsInterfaceElement
146144
TestCompletionsJSDocImportTagAttributesEmptyModuleSpecifier1
@@ -160,7 +158,6 @@ TestCompletionsLiteralFromInferenceWithinInferredType3
160158
TestCompletionsLiterals
161159
TestCompletionsMergedDeclarations1
162160
TestCompletionsNamespaceMergedWithClass
163-
TestCompletionsNamespaceName
164161
TestCompletionsNewTarget
165162
TestCompletionsOptionalKindModifier
166163
TestCompletionsOptionalMethod
@@ -192,7 +189,6 @@ TestCompletionsTypeOnlyNamespace
192189
TestCompletionsUniqueSymbol1
193190
TestCompletionsWithDeprecatedTag5
194191
TestCompletionsWithDeprecatedTag6
195-
TestCompletionsWithDeprecatedTag9
196192
TestCompletionsWithStringReplacementMode1
197193
TestDoubleUnderscoreCompletions
198194
TestExportDefaultClass
@@ -223,15 +219,13 @@ TestGetJavaScriptCompletions19
223219
TestGetJavaScriptCompletions2
224220
TestGetJavaScriptCompletions20
225221
TestGetJavaScriptCompletions21
226-
TestGetJavaScriptCompletions22
227222
TestGetJavaScriptCompletions3
228223
TestGetJavaScriptCompletions4
229224
TestGetJavaScriptCompletions5
230225
TestGetJavaScriptCompletions8
231226
TestGetJavaScriptCompletions9
232227
TestGetJavaScriptGlobalCompletions1
233228
TestGetJavaScriptQuickInfo8
234-
TestGlobalThisCompletion
235229
TestImportCompletionsPackageJsonExportsSpecifierEndsInTs
236230
TestImportCompletionsPackageJsonExportsTrailingSlash1
237231
TestImportCompletionsPackageJsonImportsConditions1
@@ -270,7 +264,6 @@ TestJsdocImplementsTagCompletion
270264
TestJsdocImportTagCompletion1
271265
TestJsdocLink_findAllReferences1
272266
TestJsdocOverloadTagCompletion
273-
TestJsdocParamTagSpecialKeywords
274267
TestJsdocParameterNameCompletion
275268
TestJsdocPropTagCompletion
276269
TestJsdocPropertyTagCompletion
@@ -279,13 +272,10 @@ TestJsdocSatisfiesTagCompletion2
279272
TestJsdocTemplatePrototypeCompletions
280273
TestJsdocTemplateTagCompletion
281274
TestJsdocThrowsTagCompletion
282-
TestJsdocTypedefTag1
283275
TestJsdocTypedefTag2
284276
TestJsdocTypedefTagNamespace
285277
TestJsdocTypedefTagTypeExpressionCompletion
286-
TestJsxAriaLikeCompletions
287278
TestJsxFindAllReferencesOnRuntimeImportWithPaths1
288-
TestJsxQualifiedTagCompletion
289279
TestLocalGetReferences
290280
TestMemberCompletionOnTypeParameters
291281
TestMemberListErrorRecovery
@@ -356,7 +346,6 @@ TestReferencesIsAvailableThroughGlobalNoCrash
356346
TestSelfReferencedExternalModule
357347
TestStringCompletionsImportOrExportSpecifier
358348
TestStringCompletionsVsEscaping
359-
TestStringLiteralTypeCompletionsInTypeArgForNonGeneric1
360349
TestTripleSlashRefPathCompletionAbsolutePaths
361350
TestTripleSlashRefPathCompletionContext
362351
TestTripleSlashRefPathCompletionExtensionsAllowJSFalse

internal/fourslash/tests/gen/autoImportsWithRootDirsAndRootedPath01_test.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import (
99

1010
func TestAutoImportsWithRootDirsAndRootedPath01(t *testing.T) {
1111
t.Parallel()
12-
t.Skip()
12+
1313
defer testutil.RecoverAndFail(t, "Panic on fourslash test")
1414
const content = `// @Filename: /dir/foo.ts
1515
export function foo() {}
@@ -25,5 +25,12 @@ func TestAutoImportsWithRootDirsAndRootedPath01(t *testing.T) {
2525
}`
2626
f := fourslash.NewFourslash(t, nil /*capabilities*/, content)
2727
f.GoToMarker(t, "$")
28-
f.VerifyCompletions(t, nil, nil)
28+
f.VerifyCompletions(t, nil, &fourslash.CompletionsExpectedList{
29+
IsIncomplete: false,
30+
ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{
31+
CommitCharacters: &defaultCommitCharacters,
32+
EditRange: ignored,
33+
},
34+
Items: &fourslash.CompletionsExpectedItems{},
35+
})
2936
}

internal/fourslash/tests/gen/completionsImport_computedSymbolName_test.go

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import (
99

1010
func TestCompletionsImport_computedSymbolName(t *testing.T) {
1111
t.Parallel()
12-
t.Skip()
12+
1313
defer testutil.RecoverAndFail(t, "Panic on fourslash test")
1414
const content = `// @Filename: /home/src/workspaces/project/tsconfig.json
1515
{ "compilerOptions": { "module": "commonjs" } }
@@ -38,7 +38,21 @@ declare module "process" {
3838
// @Filename: /home/src/workspaces/project/index.ts
3939
I/**/`
4040
f := fourslash.NewFourslash(t, nil /*capabilities*/, content)
41-
f.VerifyCompletions(t, "", nil)
41+
f.VerifyCompletions(t, "", &fourslash.CompletionsExpectedList{
42+
IsIncomplete: false,
43+
ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{
44+
CommitCharacters: &defaultCommitCharacters,
45+
EditRange: ignored,
46+
},
47+
Items: &fourslash.CompletionsExpectedItems{},
48+
})
4249
f.Insert(t, "N")
43-
f.VerifyCompletions(t, "", nil)
50+
f.VerifyCompletions(t, "", &fourslash.CompletionsExpectedList{
51+
IsIncomplete: false,
52+
ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{
53+
CommitCharacters: &defaultCommitCharacters,
54+
EditRange: ignored,
55+
},
56+
Items: &fourslash.CompletionsExpectedItems{},
57+
})
4458
}

internal/fourslash/tests/gen/completionsNamespaceName_test.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import (
99

1010
func TestCompletionsNamespaceName(t *testing.T) {
1111
t.Parallel()
12-
t.Skip()
12+
1313
defer testutil.RecoverAndFail(t, "Panic on fourslash test")
1414
const content = `{ namespace /*0*/ }
1515
namespace N/*1*/ {}
@@ -20,7 +20,14 @@ namespace N1.M/*3*/ {}
2020
namespace N2.M {}
2121
namespace N2.M/*4*/`
2222
f := fourslash.NewFourslash(t, nil /*capabilities*/, content)
23-
f.VerifyCompletions(t, []string{"0", "1"}, nil)
23+
f.VerifyCompletions(t, []string{"0", "1"}, &fourslash.CompletionsExpectedList{
24+
IsIncomplete: false,
25+
ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{
26+
CommitCharacters: &[]string{},
27+
EditRange: ignored,
28+
},
29+
Items: &fourslash.CompletionsExpectedItems{},
30+
})
2431
f.VerifyCompletions(t, "2", &fourslash.CompletionsExpectedList{
2532
IsIncomplete: false,
2633
ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{

internal/fourslash/tests/gen/completionsWithDeprecatedTag9_test.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import (
1111

1212
func TestCompletionsWithDeprecatedTag9(t *testing.T) {
1313
t.Parallel()
14-
t.Skip()
14+
1515
defer testutil.RecoverAndFail(t, "Panic on fourslash test")
1616
const content = `// @lib: dom
1717
// @allowJs: true
@@ -42,5 +42,12 @@ class Foo {
4242
},
4343
},
4444
})
45-
f.VerifyCompletions(t, nil, nil)
45+
f.VerifyCompletions(t, nil, &fourslash.CompletionsExpectedList{
46+
IsIncomplete: false,
47+
ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{
48+
CommitCharacters: &defaultCommitCharacters,
49+
EditRange: ignored,
50+
},
51+
Items: &fourslash.CompletionsExpectedItems{},
52+
})
4653
}

internal/fourslash/tests/gen/getJavaScriptCompletions22_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import (
99

1010
func TestGetJavaScriptCompletions22(t *testing.T) {
1111
t.Parallel()
12-
t.Skip()
12+
1313
defer testutil.RecoverAndFail(t, "Panic on fourslash test")
1414
const content = `// @allowNonTsExtensions: true
1515
// @Filename: file.js

internal/fourslash/tests/gen/globalThisCompletion_test.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import (
99

1010
func TestGlobalThisCompletion(t *testing.T) {
1111
t.Parallel()
12-
t.Skip()
12+
1313
defer testutil.RecoverAndFail(t, "Panic on fourslash test")
1414
const content = `// @allowJs: true
1515
// @target: esnext
@@ -22,5 +22,12 @@ func TestGlobalThisCompletion(t *testing.T) {
2222
declare var foo: typeof globalThis;`
2323
f := fourslash.NewFourslash(t, nil /*capabilities*/, content)
2424
f.GoToMarker(t, "")
25-
f.VerifyCompletions(t, "", nil)
25+
f.VerifyCompletions(t, "", &fourslash.CompletionsExpectedList{
26+
IsIncomplete: false,
27+
ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{
28+
CommitCharacters: &defaultCommitCharacters,
29+
EditRange: ignored,
30+
},
31+
Items: &fourslash.CompletionsExpectedItems{},
32+
})
2633
}

internal/fourslash/tests/gen/jsdocParamTagSpecialKeywords_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import (
99

1010
func TestJsdocParamTagSpecialKeywords(t *testing.T) {
1111
t.Parallel()
12-
t.Skip()
12+
1313
defer testutil.RecoverAndFail(t, "Panic on fourslash test")
1414
const content = `// @allowNonTsExtensions: true
1515
// @Filename: test.js

internal/fourslash/tests/gen/jsdocTypedefTag1_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import (
99

1010
func TestJsdocTypedefTag1(t *testing.T) {
1111
t.Parallel()
12-
t.Skip()
12+
1313
defer testutil.RecoverAndFail(t, "Panic on fourslash test")
1414
const content = `// @allowNonTsExtensions: true
1515
// @Filename: jsdocCompletion_typedef.js

0 commit comments

Comments
 (0)