Skip to content

Commit 154055f

Browse files
committed
update convert fourslash
1 parent cf1f976 commit 154055f

File tree

1 file changed

+18
-4
lines changed

1 file changed

+18
-4
lines changed

internal/fourslash/_scripts/convertFourslash.mts

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -911,17 +911,28 @@ function parseBaselineRenameArgs(funcName: string, args: readonly ts.Expression[
911911
}];
912912
}
913913

914+
function stringToTristate(s: string): string {
915+
switch (s) {
916+
case "true":
917+
return "core.TSTrue";
918+
case "false":
919+
return "core.TSFalse";
920+
default:
921+
return "core.TSUnknown";
922+
}
923+
}
924+
914925
function parseUserPreferences(arg: ts.ObjectLiteralExpression): string | undefined {
915926
const preferences: string[] = [];
916927
for (const prop of arg.properties) {
917928
if (ts.isPropertyAssignment(prop)) {
918929
switch (prop.name.getText()) {
919930
// !!! other preferences
920931
case "providePrefixAndSuffixTextForRename":
921-
preferences.push(`UseAliasesForRename: PtrTo(${prop.initializer.getText()})`);
932+
preferences.push(`UseAliasesForRename: ${stringToTristate(prop.initializer.getText())}`);
922933
break;
923934
case "quotePreference":
924-
preferences.push(`QuotePreference: PtrTo(ls.QuotePreference(${prop.initializer.getText()}))`);
935+
preferences.push(`QuotePreference: ls.QuotePreference(${prop.initializer.getText()})`);
925936
break;
926937
}
927938
}
@@ -1465,13 +1476,16 @@ function generateGoTest(failingTests: Set<string>, test: GoTest): string {
14651476
const commands = test.commands.map(cmd => generateCmd(cmd)).join("\n");
14661477
const imports = [`"github.com/microsoft/typescript-go/internal/fourslash"`];
14671478
// Only include these imports if the commands use them to avoid unused import errors.
1479+
if (commands.includes("core.")) {
1480+
imports.unshift(`"github.com/microsoft/typescript-go/internal/core"`);
1481+
}
14681482
if (commands.includes("ls.")) {
14691483
imports.push(`"github.com/microsoft/typescript-go/internal/ls"`);
14701484
}
14711485
if (commands.includes("lsproto.")) {
14721486
imports.push(`"github.com/microsoft/typescript-go/internal/lsp/lsproto"`);
14731487
}
1474-
if (usesHelper(commands)) {
1488+
if (usesFourslashUtil(commands)) {
14751489
imports.push(`. "github.com/microsoft/typescript-go/internal/fourslash/tests/util"`);
14761490
}
14771491
imports.push(`"github.com/microsoft/typescript-go/internal/testutil"`);
@@ -1494,7 +1508,7 @@ func Test${testName}(t *testing.T) {
14941508
return template;
14951509
}
14961510

1497-
function usesHelper(goTxt: string): boolean {
1511+
function usesFourslashUtil(goTxt: string): boolean {
14981512
for (const [_, constant] of completionConstants) {
14991513
if (goTxt.includes(constant)) {
15001514
return true;

0 commit comments

Comments
 (0)