Skip to content

Commit 6b60f4a

Browse files
Server-to-client refresh requests for user preference updates (#2174)
1 parent 487416c commit 6b60f4a

File tree

75 files changed

+345
-147
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

75 files changed

+345
-147
lines changed

Herebyfile.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ export const generate = task({
270270
description: "Runs go generate on the project.",
271271
run: async () => {
272272
assertTypeScriptCloned();
273-
await $`go generate ./...`;
273+
await $`go generate -v ./...`;
274274
},
275275
});
276276

internal/fourslash/_scripts/convertFourslash.mts

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1399,6 +1399,7 @@ function stringToTristate(s: string): string {
13991399
}
14001400

14011401
function parseUserPreferences(arg: ts.ObjectLiteralExpression): string | undefined {
1402+
const inlayHintPreferences: string[] = [];
14021403
const preferences: string[] = [];
14031404
for (const prop of arg.properties) {
14041405
if (ts.isPropertyAssignment(prop)) {
@@ -1441,28 +1442,28 @@ function parseUserPreferences(arg: ts.ObjectLiteralExpression): string | undefin
14411442
paramHint = "lsutil.IncludeInlayParameterNameHintsAll";
14421443
break;
14431444
}
1444-
preferences.push(`IncludeInlayParameterNameHints: ${paramHint}`);
1445+
inlayHintPreferences.push(`IncludeInlayParameterNameHints: ${paramHint}`);
14451446
break;
14461447
case "includeInlayParameterNameHintsWhenArgumentMatchesName":
1447-
preferences.push(`IncludeInlayParameterNameHintsWhenArgumentMatchesName: ${prop.initializer.getText()}`);
1448+
inlayHintPreferences.push(`IncludeInlayParameterNameHintsWhenArgumentMatchesName: ${prop.initializer.getText()}`);
14481449
break;
14491450
case "includeInlayFunctionParameterTypeHints":
1450-
preferences.push(`IncludeInlayFunctionParameterTypeHints: ${prop.initializer.getText()}`);
1451+
inlayHintPreferences.push(`IncludeInlayFunctionParameterTypeHints: ${prop.initializer.getText()}`);
14511452
break;
14521453
case "includeInlayVariableTypeHints":
1453-
preferences.push(`IncludeInlayVariableTypeHints: ${prop.initializer.getText()}`);
1454+
inlayHintPreferences.push(`IncludeInlayVariableTypeHints: ${prop.initializer.getText()}`);
14541455
break;
14551456
case "includeInlayVariableTypeHintsWhenTypeMatchesName":
1456-
preferences.push(`IncludeInlayVariableTypeHintsWhenTypeMatchesName: ${prop.initializer.getText()}`);
1457+
inlayHintPreferences.push(`IncludeInlayVariableTypeHintsWhenTypeMatchesName: ${prop.initializer.getText()}`);
14571458
break;
14581459
case "includeInlayPropertyDeclarationTypeHints":
1459-
preferences.push(`IncludeInlayPropertyDeclarationTypeHints: ${prop.initializer.getText()}`);
1460+
inlayHintPreferences.push(`IncludeInlayPropertyDeclarationTypeHints: ${prop.initializer.getText()}`);
14601461
break;
14611462
case "includeInlayFunctionLikeReturnTypeHints":
1462-
preferences.push(`IncludeInlayFunctionLikeReturnTypeHints: ${prop.initializer.getText()}`);
1463+
inlayHintPreferences.push(`IncludeInlayFunctionLikeReturnTypeHints: ${prop.initializer.getText()}`);
14631464
break;
14641465
case "includeInlayEnumMemberValueHints":
1465-
preferences.push(`IncludeInlayEnumMemberValueHints: ${prop.initializer.getText()}`);
1466+
inlayHintPreferences.push(`IncludeInlayEnumMemberValueHints: ${prop.initializer.getText()}`);
14661467
break;
14671468
case "interactiveInlayHints":
14681469
// Ignore, deprecated
@@ -1473,6 +1474,10 @@ function parseUserPreferences(arg: ts.ObjectLiteralExpression): string | undefin
14731474
return undefined;
14741475
}
14751476
}
1477+
1478+
if (inlayHintPreferences.length > 0) {
1479+
preferences.push(`InlayHints: lsutil.InlayHintsPreferences{${inlayHintPreferences.join(",")}}`);
1480+
}
14761481
if (preferences.length === 0) {
14771482
return "nil /*preferences*/";
14781483
}

internal/fourslash/tests/codeLensFunctionExpressions01_test.go

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,13 @@ const namedFn4 = function namedFn4() {};
4343
`
4444
f := fourslash.NewFourslash(t, nil /*capabilities*/, content)
4545
f.VerifyBaselineCodeLens(t, &lsutil.UserPreferences{
46-
ReferencesCodeLensEnabled: true,
47-
ReferencesCodeLensShowOnAllFunctions: true,
48-
49-
ImplementationsCodeLensEnabled: true,
50-
ImplementationsCodeLensShowOnInterfaceMethods: true,
51-
ImplementationsCodeLensShowOnAllClassMethods: true,
46+
CodeLens: lsutil.CodeLensUserPreferences{
47+
ReferencesCodeLensEnabled: true,
48+
ReferencesCodeLensShowOnAllFunctions: true,
49+
50+
ImplementationsCodeLensEnabled: true,
51+
ImplementationsCodeLensShowOnInterfaceMethods: true,
52+
ImplementationsCodeLensShowOnAllClassMethods: true,
53+
},
5254
})
5355
}

internal/fourslash/tests/codeLensFunctionsAndConstants01_test.go

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,13 @@ console.log(bar);
4040
`
4141
f := fourslash.NewFourslash(t, nil /*capabilities*/, content)
4242
f.VerifyBaselineCodeLens(t, &lsutil.UserPreferences{
43-
ReferencesCodeLensEnabled: true,
44-
ReferencesCodeLensShowOnAllFunctions: true,
45-
46-
ImplementationsCodeLensEnabled: true,
47-
ImplementationsCodeLensShowOnInterfaceMethods: true,
48-
ImplementationsCodeLensShowOnAllClassMethods: true,
43+
CodeLens: lsutil.CodeLensUserPreferences{
44+
ReferencesCodeLensEnabled: true,
45+
ReferencesCodeLensShowOnAllFunctions: true,
46+
47+
ImplementationsCodeLensEnabled: true,
48+
ImplementationsCodeLensShowOnInterfaceMethods: true,
49+
ImplementationsCodeLensShowOnAllClassMethods: true,
50+
},
4951
})
5052
}

internal/fourslash/tests/codeLensInterface01_test.go

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,13 @@ const p: Pointable = {
4949
`
5050
f := fourslash.NewFourslash(t, nil /*capabilities*/, content)
5151
f.VerifyBaselineCodeLens(t, &lsutil.UserPreferences{
52-
ReferencesCodeLensEnabled: true,
53-
ReferencesCodeLensShowOnAllFunctions: true,
54-
55-
ImplementationsCodeLensEnabled: true,
56-
ImplementationsCodeLensShowOnInterfaceMethods: true,
57-
ImplementationsCodeLensShowOnAllClassMethods: true,
52+
CodeLens: lsutil.CodeLensUserPreferences{
53+
ReferencesCodeLensEnabled: true,
54+
ReferencesCodeLensShowOnAllFunctions: true,
55+
56+
ImplementationsCodeLensEnabled: true,
57+
ImplementationsCodeLensShowOnInterfaceMethods: true,
58+
ImplementationsCodeLensShowOnAllClassMethods: true,
59+
},
5860
})
5961
}

internal/fourslash/tests/codeLensOverloads01_test.go

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,13 @@ foo(Math.random() ? 1 : "hello");
2929
`
3030
f := fourslash.NewFourslash(t, nil /*capabilities*/, content)
3131
f.VerifyBaselineCodeLens(t, &lsutil.UserPreferences{
32-
ReferencesCodeLensEnabled: true,
33-
ReferencesCodeLensShowOnAllFunctions: true,
34-
35-
ImplementationsCodeLensEnabled: true,
36-
ImplementationsCodeLensShowOnInterfaceMethods: true,
37-
ImplementationsCodeLensShowOnAllClassMethods: true,
32+
CodeLens: lsutil.CodeLensUserPreferences{
33+
ReferencesCodeLensEnabled: true,
34+
ReferencesCodeLensShowOnAllFunctions: true,
35+
36+
ImplementationsCodeLensEnabled: true,
37+
ImplementationsCodeLensShowOnInterfaceMethods: true,
38+
ImplementationsCodeLensShowOnAllClassMethods: true,
39+
},
3840
})
3941
}

internal/fourslash/tests/codeLensShowOnAllClassMethods_test.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,10 @@ export abstract class ABC {
3535
`
3636
f := fourslash.NewFourslash(t, nil /*capabilities*/, content)
3737
f.VerifyBaselineCodeLens(t, &lsutil.UserPreferences{
38-
ImplementationsCodeLensEnabled: true,
39-
ImplementationsCodeLensShowOnAllClassMethods: value,
38+
CodeLens: lsutil.CodeLensUserPreferences{
39+
ImplementationsCodeLensEnabled: true,
40+
ImplementationsCodeLensShowOnAllClassMethods: value,
41+
},
4042
})
4143
})
4244
}

internal/fourslash/tests/codeLensShowOnAllFunctions_test.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,10 @@ const f5 = function() {};
3030
`
3131
f := fourslash.NewFourslash(t, nil /*capabilities*/, content)
3232
f.VerifyBaselineCodeLens(t, &lsutil.UserPreferences{
33-
ReferencesCodeLensEnabled: true,
34-
ReferencesCodeLensShowOnAllFunctions: value,
33+
CodeLens: lsutil.CodeLensUserPreferences{
34+
ReferencesCodeLensEnabled: true,
35+
ReferencesCodeLensShowOnAllFunctions: value,
36+
},
3537
})
3638
})
3739
}

internal/fourslash/tests/codeLensShowOnInterfaceMethods_test.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,10 @@ class AbstractC implements J {
4444
`
4545
f := fourslash.NewFourslash(t, nil /*capabilities*/, content)
4646
f.VerifyBaselineCodeLens(t, &lsutil.UserPreferences{
47-
ImplementationsCodeLensEnabled: true,
48-
ImplementationsCodeLensShowOnInterfaceMethods: value,
47+
CodeLens: lsutil.CodeLensUserPreferences{
48+
ImplementationsCodeLensEnabled: true,
49+
ImplementationsCodeLensShowOnInterfaceMethods: value,
50+
},
4951
})
5052
})
5153
}

internal/fourslash/tests/gen/inlayHintsCrash1_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,5 @@ function doThing(f) {
2222
f(100)
2323
}`
2424
f := fourslash.NewFourslash(t, nil /*capabilities*/, content)
25-
f.VerifyBaselineInlayHints(t, nil /*span*/, &lsutil.UserPreferences{IncludeInlayVariableTypeHints: true, IncludeInlayParameterNameHints: lsutil.IncludeInlayParameterNameHintsAll})
25+
f.VerifyBaselineInlayHints(t, nil /*span*/, &lsutil.UserPreferences{InlayHints: lsutil.InlayHintsPreferences{IncludeInlayVariableTypeHints: true, IncludeInlayParameterNameHints: lsutil.IncludeInlayParameterNameHintsAll}})
2626
}

0 commit comments

Comments
 (0)