Skip to content

Commit cf1f976

Browse files
committed
userpreferences refactor
1 parent 6277711 commit cf1f976

17 files changed

+259
-121
lines changed

internal/checker/nodebuilderimpl.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1207,8 +1207,8 @@ func (b *nodeBuilderImpl) getSpecifierForModuleSymbol(symbol *ast.Symbol, overri
12071207
contextFile,
12081208
host,
12091209
modulespecifiers.UserPreferences{
1210-
ImportModuleSpecifierPreference: specifierPref,
1211-
ImportModuleSpecifierEndingPreference: endingPref,
1210+
ImportModuleSpecifierPreference: specifierPref,
1211+
ImportModuleSpecifierEnding: endingPref,
12121212
},
12131213
modulespecifiers.ModuleSpecifierOptions{
12141214
OverrideImportMode: overrideImportMode,

internal/fourslash/fourslash.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1611,11 +1611,11 @@ func (f *FourslashTest) verifyBaselineRename(
16111611

16121612
var renameOptions strings.Builder
16131613
if preferences != nil {
1614-
if preferences.UseAliasesForRename != nil {
1615-
fmt.Fprintf(&renameOptions, "// @useAliasesForRename: %v\n", *preferences.UseAliasesForRename)
1614+
if preferences.UseAliasesForRename != core.TSUnknown {
1615+
fmt.Fprintf(&renameOptions, "// @useAliasesForRename: %v\n", preferences.UseAliasesForRename.IsTrue())
16161616
}
1617-
if preferences.QuotePreference != nil {
1618-
fmt.Fprintf(&renameOptions, "// @quotePreference: %v\n", *preferences.QuotePreference)
1617+
if preferences.QuotePreference != ls.QuotePreferenceUnknown {
1618+
fmt.Fprintf(&renameOptions, "// @quotePreference: %v\n", preferences.QuotePreference)
16191619
}
16201620
}
16211621

internal/fourslash/tests/autoImportCompletion_test.go

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package fourslash_test
33
import (
44
"testing"
55

6+
"github.com/microsoft/typescript-go/internal/core"
67
"github.com/microsoft/typescript-go/internal/fourslash"
78
. "github.com/microsoft/typescript-go/internal/fourslash/tests/util"
89
"github.com/microsoft/typescript-go/internal/ls"
@@ -26,8 +27,8 @@ a/**/
2627
f := fourslash.NewFourslash(t, nil /*capabilities*/, content)
2728
f.VerifyCompletions(t, "", &fourslash.CompletionsExpectedList{
2829
UserPreferences: &ls.UserPreferences{
29-
IncludeCompletionsForModuleExports: PtrTo(true),
30-
IncludeCompletionsForImportStatements: PtrTo(true),
30+
IncludeCompletionsForModuleExports: core.TSTrue,
31+
IncludeCompletionsForImportStatements: core.TSTrue,
3132
},
3233
IsIncomplete: false,
3334
ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{
@@ -56,8 +57,8 @@ a/**/
5657
f := fourslash.NewFourslash(t, nil /*capabilities*/, content)
5758
f.VerifyCompletions(t, "", &fourslash.CompletionsExpectedList{
5859
UserPreferences: &ls.UserPreferences{
59-
IncludeCompletionsForModuleExports: PtrTo(true),
60-
IncludeCompletionsForImportStatements: PtrTo(true),
60+
IncludeCompletionsForModuleExports: core.TSTrue,
61+
IncludeCompletionsForImportStatements: core.TSTrue,
6162
},
6263
IsIncomplete: false,
6364
ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{
@@ -87,8 +88,8 @@ b/**/
8788
f := fourslash.NewFourslash(t, nil /*capabilities*/, content)
8889
f.VerifyCompletions(t, "", &fourslash.CompletionsExpectedList{
8990
UserPreferences: &ls.UserPreferences{
90-
IncludeCompletionsForModuleExports: PtrTo(true),
91-
IncludeCompletionsForImportStatements: PtrTo(true),
91+
IncludeCompletionsForModuleExports: core.TSTrue,
92+
IncludeCompletionsForImportStatements: core.TSTrue,
9293
},
9394
IsIncomplete: false,
9495
ItemDefaults: &fourslash.CompletionsExpectedItemDefaults{

internal/fourslash/tests/gen/renameExportSpecifier2_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ package fourslash_test
33
import (
44
"testing"
55

6+
"github.com/microsoft/typescript-go/internal/core"
67
"github.com/microsoft/typescript-go/internal/fourslash"
7-
. "github.com/microsoft/typescript-go/internal/fourslash/tests/util"
88
"github.com/microsoft/typescript-go/internal/ls"
99
"github.com/microsoft/typescript-go/internal/testutil"
1010
)
@@ -20,5 +20,5 @@ export { name/**/ };
2020
import { name } from './a';
2121
const x = name.toString();`
2222
f := fourslash.NewFourslash(t, nil /*capabilities*/, content)
23-
f.VerifyBaselineRename(t, &ls.UserPreferences{UseAliasesForRename: PtrTo(false)}, "")
23+
f.VerifyBaselineRename(t, &ls.UserPreferences{UseAliasesForRename: core.TSFalse}, "")
2424
}

internal/fourslash/tests/gen/renameExportSpecifier_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ package fourslash_test
33
import (
44
"testing"
55

6+
"github.com/microsoft/typescript-go/internal/core"
67
"github.com/microsoft/typescript-go/internal/fourslash"
7-
. "github.com/microsoft/typescript-go/internal/fourslash/tests/util"
88
"github.com/microsoft/typescript-go/internal/ls"
99
"github.com/microsoft/typescript-go/internal/testutil"
1010
)
@@ -20,5 +20,5 @@ export { name as name/**/ };
2020
import { name } from './a';
2121
const x = name.toString();`
2222
f := fourslash.NewFourslash(t, nil /*capabilities*/, content)
23-
f.VerifyBaselineRename(t, &ls.UserPreferences{UseAliasesForRename: PtrTo(false)}, "")
23+
f.VerifyBaselineRename(t, &ls.UserPreferences{UseAliasesForRename: core.TSFalse}, "")
2424
}

internal/fourslash/tests/gen/renameModuleExportsProperties1_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ package fourslash_test
33
import (
44
"testing"
55

6+
"github.com/microsoft/typescript-go/internal/core"
67
"github.com/microsoft/typescript-go/internal/fourslash"
7-
. "github.com/microsoft/typescript-go/internal/fourslash/tests/util"
88
"github.com/microsoft/typescript-go/internal/ls"
99
"github.com/microsoft/typescript-go/internal/testutil"
1010
)
@@ -16,5 +16,5 @@ func TestRenameModuleExportsProperties1(t *testing.T) {
1616
const content = `[|class [|{| "contextRangeIndex": 0 |}A|] {}|]
1717
module.exports = { [|A|] }`
1818
f := fourslash.NewFourslash(t, nil /*capabilities*/, content)
19-
f.VerifyBaselineRename(t, &ls.UserPreferences{UseAliasesForRename: PtrTo(true)}, f.Ranges()[1], f.Ranges()[2])
19+
f.VerifyBaselineRename(t, &ls.UserPreferences{UseAliasesForRename: core.TSTrue}, f.Ranges()[1], f.Ranges()[2])
2020
}

internal/fourslash/tests/gen/renameModuleExportsProperties3_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ package fourslash_test
33
import (
44
"testing"
55

6+
"github.com/microsoft/typescript-go/internal/core"
67
"github.com/microsoft/typescript-go/internal/fourslash"
7-
. "github.com/microsoft/typescript-go/internal/fourslash/tests/util"
88
"github.com/microsoft/typescript-go/internal/ls"
99
"github.com/microsoft/typescript-go/internal/testutil"
1010
)
@@ -18,5 +18,5 @@ func TestRenameModuleExportsProperties3(t *testing.T) {
1818
[|class [|{| "contextRangeIndex": 0 |}A|] {}|]
1919
module.exports = { [|A|] }`
2020
f := fourslash.NewFourslash(t, nil /*capabilities*/, content)
21-
f.VerifyBaselineRename(t, &ls.UserPreferences{UseAliasesForRename: PtrTo(true)}, f.Ranges()[1], f.Ranges()[2])
21+
f.VerifyBaselineRename(t, &ls.UserPreferences{UseAliasesForRename: core.TSTrue}, f.Ranges()[1], f.Ranges()[2])
2222
}

internal/fourslash/tests/gen/renameNamedImport_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ package fourslash_test
33
import (
44
"testing"
55

6+
"github.com/microsoft/typescript-go/internal/core"
67
"github.com/microsoft/typescript-go/internal/fourslash"
7-
. "github.com/microsoft/typescript-go/internal/fourslash/tests/util"
88
"github.com/microsoft/typescript-go/internal/ls"
99
"github.com/microsoft/typescript-go/internal/testutil"
1010
)
@@ -28,5 +28,5 @@ someExportedVariable;
2828
f := fourslash.NewFourslash(t, nil /*capabilities*/, content)
2929
f.GoToFile(t, "/home/src/workspaces/project/lib/index.ts")
3030
f.GoToFile(t, "/home/src/workspaces/project/src/index.ts")
31-
f.VerifyBaselineRename(t, &ls.UserPreferences{UseAliasesForRename: PtrTo(true)}, "i")
31+
f.VerifyBaselineRename(t, &ls.UserPreferences{UseAliasesForRename: core.TSTrue}, "i")
3232
}

internal/fourslash/tests/gen/renameNumericalIndexSingleQuoted_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import (
44
"testing"
55

66
"github.com/microsoft/typescript-go/internal/fourslash"
7-
. "github.com/microsoft/typescript-go/internal/fourslash/tests/util"
87
"github.com/microsoft/typescript-go/internal/ls"
98
"github.com/microsoft/typescript-go/internal/testutil"
109
)
@@ -16,5 +15,5 @@ func TestRenameNumericalIndexSingleQuoted(t *testing.T) {
1615
const content = `const foo = { [|0|]: true };
1716
foo[[|0|]];`
1817
f := fourslash.NewFourslash(t, nil /*capabilities*/, content)
19-
f.VerifyBaselineRenameAtRangesWithText(t, &ls.UserPreferences{QuotePreference: PtrTo(ls.QuotePreference("single"))}, "0")
18+
f.VerifyBaselineRenameAtRangesWithText(t, &ls.UserPreferences{QuotePreference: ls.QuotePreference("single")}, "0")
2019
}

internal/fourslash/tests/gen/renameRestBindingElement_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ package fourslash_test
33
import (
44
"testing"
55

6+
"github.com/microsoft/typescript-go/internal/core"
67
"github.com/microsoft/typescript-go/internal/fourslash"
7-
. "github.com/microsoft/typescript-go/internal/fourslash/tests/util"
88
"github.com/microsoft/typescript-go/internal/ls"
99
"github.com/microsoft/typescript-go/internal/testutil"
1010
)
@@ -22,5 +22,5 @@ function foo([|{ a, ...[|{| "contextRangeIndex": 0 |}rest|] }: I|]) {
2222
[|rest|];
2323
}`
2424
f := fourslash.NewFourslash(t, nil /*capabilities*/, content)
25-
f.VerifyBaselineRename(t, &ls.UserPreferences{UseAliasesForRename: PtrTo(true)}, f.Ranges()[1])
25+
f.VerifyBaselineRename(t, &ls.UserPreferences{UseAliasesForRename: core.TSTrue}, f.Ranges()[1])
2626
}

0 commit comments

Comments
 (0)