From 37d3b3e90488746f0d68b1196cf05e58a60269e4 Mon Sep 17 00:00:00 2001 From: Jake Bailey <5341706+jakebailey@users.noreply.github.com> Date: Wed, 22 Oct 2025 14:14:19 -0700 Subject: [PATCH 1/9] Scaffolding --- .../fourslash/_scripts/convertFourslash.mts | 20 +++++++++++++++ internal/fourslash/fourslash.go | 4 +++ .../gen/smartSelection_JSDocTags10_test.go | 22 ++++++++++++++++ .../gen/smartSelection_JSDocTags11_test.go | 21 ++++++++++++++++ .../gen/smartSelection_JSDocTags12_test.go | 20 +++++++++++++++ .../gen/smartSelection_JSDocTags13_test.go | 23 +++++++++++++++++ .../gen/smartSelection_JSDocTags1_test.go | 20 +++++++++++++++ .../gen/smartSelection_JSDocTags2_test.go | 20 +++++++++++++++ .../gen/smartSelection_JSDocTags3_test.go | 20 +++++++++++++++ .../gen/smartSelection_JSDocTags4_test.go | 25 +++++++++++++++++++ .../gen/smartSelection_JSDocTags5_test.go | 25 +++++++++++++++++++ .../gen/smartSelection_JSDocTags6_test.go | 24 ++++++++++++++++++ .../gen/smartSelection_JSDocTags7_test.go | 22 ++++++++++++++++ .../gen/smartSelection_JSDocTags8_test.go | 22 ++++++++++++++++ .../gen/smartSelection_JSDocTags9_test.go | 21 ++++++++++++++++ .../tests/gen/smartSelection_JSDoc_test.go | 23 +++++++++++++++++ .../gen/smartSelection_behindCaret_test.go | 17 +++++++++++++ .../smartSelection_bindingPatterns_test.go | 17 +++++++++++++ .../tests/gen/smartSelection_comment1_test.go | 17 +++++++++++++ .../tests/gen/smartSelection_comment2_test.go | 17 +++++++++++++ .../tests/gen/smartSelection_complex_test.go | 17 +++++++++++++ .../gen/smartSelection_emptyRanges_test.go | 23 +++++++++++++++++ .../gen/smartSelection_function1_test.go | 19 ++++++++++++++ .../gen/smartSelection_function2_test.go | 19 ++++++++++++++ .../gen/smartSelection_function3_test.go | 19 ++++++++++++++ .../smartSelection_functionParams1_test.go | 17 +++++++++++++ .../smartSelection_functionParams2_test.go | 20 +++++++++++++++ .../tests/gen/smartSelection_imports_test.go | 20 +++++++++++++++ .../gen/smartSelection_lastBlankLine_test.go | 18 +++++++++++++ ...tSelection_loneVariableDeclaration_test.go | 17 +++++++++++++ .../gen/smartSelection_mappedTypes_test.go | 17 +++++++++++++ .../gen/smartSelection_objectTypes_test.go | 21 ++++++++++++++++ ...smartSelection_punctuationPriority_test.go | 17 +++++++++++++ .../tests/gen/smartSelection_simple1_test.go | 24 ++++++++++++++++++ .../tests/gen/smartSelection_simple2_test.go | 22 ++++++++++++++++ .../gen/smartSelection_stringLiteral_test.go | 18 +++++++++++++ .../smartSelection_templateStrings2_test.go | 17 +++++++++++++ .../smartSelection_templateStrings_test.go | 19 ++++++++++++++ internal/ls/selectionranges.go | 11 ++++++++ internal/lsp/server.go | 8 ++++++ 40 files changed, 763 insertions(+) create mode 100644 internal/fourslash/tests/gen/smartSelection_JSDocTags10_test.go create mode 100644 internal/fourslash/tests/gen/smartSelection_JSDocTags11_test.go create mode 100644 internal/fourslash/tests/gen/smartSelection_JSDocTags12_test.go create mode 100644 internal/fourslash/tests/gen/smartSelection_JSDocTags13_test.go create mode 100644 internal/fourslash/tests/gen/smartSelection_JSDocTags1_test.go create mode 100644 internal/fourslash/tests/gen/smartSelection_JSDocTags2_test.go create mode 100644 internal/fourslash/tests/gen/smartSelection_JSDocTags3_test.go create mode 100644 internal/fourslash/tests/gen/smartSelection_JSDocTags4_test.go create mode 100644 internal/fourslash/tests/gen/smartSelection_JSDocTags5_test.go create mode 100644 internal/fourslash/tests/gen/smartSelection_JSDocTags6_test.go create mode 100644 internal/fourslash/tests/gen/smartSelection_JSDocTags7_test.go create mode 100644 internal/fourslash/tests/gen/smartSelection_JSDocTags8_test.go create mode 100644 internal/fourslash/tests/gen/smartSelection_JSDocTags9_test.go create mode 100644 internal/fourslash/tests/gen/smartSelection_JSDoc_test.go create mode 100644 internal/fourslash/tests/gen/smartSelection_behindCaret_test.go create mode 100644 internal/fourslash/tests/gen/smartSelection_bindingPatterns_test.go create mode 100644 internal/fourslash/tests/gen/smartSelection_comment1_test.go create mode 100644 internal/fourslash/tests/gen/smartSelection_comment2_test.go create mode 100644 internal/fourslash/tests/gen/smartSelection_complex_test.go create mode 100644 internal/fourslash/tests/gen/smartSelection_emptyRanges_test.go create mode 100644 internal/fourslash/tests/gen/smartSelection_function1_test.go create mode 100644 internal/fourslash/tests/gen/smartSelection_function2_test.go create mode 100644 internal/fourslash/tests/gen/smartSelection_function3_test.go create mode 100644 internal/fourslash/tests/gen/smartSelection_functionParams1_test.go create mode 100644 internal/fourslash/tests/gen/smartSelection_functionParams2_test.go create mode 100644 internal/fourslash/tests/gen/smartSelection_imports_test.go create mode 100644 internal/fourslash/tests/gen/smartSelection_lastBlankLine_test.go create mode 100644 internal/fourslash/tests/gen/smartSelection_loneVariableDeclaration_test.go create mode 100644 internal/fourslash/tests/gen/smartSelection_mappedTypes_test.go create mode 100644 internal/fourslash/tests/gen/smartSelection_objectTypes_test.go create mode 100644 internal/fourslash/tests/gen/smartSelection_punctuationPriority_test.go create mode 100644 internal/fourslash/tests/gen/smartSelection_simple1_test.go create mode 100644 internal/fourslash/tests/gen/smartSelection_simple2_test.go create mode 100644 internal/fourslash/tests/gen/smartSelection_stringLiteral_test.go create mode 100644 internal/fourslash/tests/gen/smartSelection_templateStrings2_test.go create mode 100644 internal/fourslash/tests/gen/smartSelection_templateStrings_test.go create mode 100644 internal/ls/selectionranges.go diff --git a/internal/fourslash/_scripts/convertFourslash.mts b/internal/fourslash/_scripts/convertFourslash.mts index 72a6d879a6..687b3fe4ff 100644 --- a/internal/fourslash/_scripts/convertFourslash.mts +++ b/internal/fourslash/_scripts/convertFourslash.mts @@ -190,6 +190,8 @@ function parseFourslashStatement(statement: ts.Statement): Cmd[] | undefined { return parseBaselineQuickInfo(callExpression.arguments); case "baselineSignatureHelp": return [parseBaselineSignatureHelp(callExpression.arguments)]; + case "baselineSmartSelection": + return [parseBaselineSmartSelection(callExpression.arguments)]; case "baselineGoToDefinition": case "baselineGetDefinitionAtPosition": case "baselineGoToType": @@ -1422,6 +1424,16 @@ function parseBaselineSignatureHelp(args: ts.NodeArray): Cmd { }; } +function parseBaselineSmartSelection(args: ts.NodeArray): Cmd { + if (args.length !== 0) { + // All calls are currently empty! + throw new Error("Expected no arguments in verify.baselineSignatureHelp"); + } + return { + kind: "verifyBaselineSmartSelection", + }; +} + function parseKind(expr: ts.Expression): string | undefined { if (!ts.isStringLiteral(expr)) { console.error(`Expected string literal for kind, got ${expr.getText()}`); @@ -1591,6 +1603,10 @@ interface VerifyBaselineSignatureHelpCmd { kind: "verifyBaselineSignatureHelp"; } +interface VerifyBaselineSmartSelection { + kind: "verifyBaselineSmartSelection"; +} + interface VerifyBaselineRenameCmd { kind: "verifyBaselineRename" | "verifyBaselineRenameAtRangesWithText"; args: string[]; @@ -1635,6 +1651,7 @@ type Cmd = | VerifyBaselineGoToDefinitionCmd | VerifyBaselineQuickInfoCmd | VerifyBaselineSignatureHelpCmd + | VerifyBaselineSmartSelection | GoToCmd | EditCmd | VerifyQuickInfoCmd @@ -1754,6 +1771,8 @@ function generateCmd(cmd: Cmd): string { return `f.VerifyBaselineHover(t)`; case "verifyBaselineSignatureHelp": return `f.VerifyBaselineSignatureHelp(t)`; + case "verifyBaselineSmartSelection": + return `f.VerifyBaselineSelectionRanges(t)`; case "goTo": return generateGoToCommand(cmd); case "edit": @@ -1770,6 +1789,7 @@ function generateCmd(cmd: Cmd): string { return `f.VerifyRenameSucceeded(t, ${cmd.preferences})`; case "renameInfoFailed": return `f.VerifyRenameFailed(t, ${cmd.preferences})`; + default: let neverCommand: never = cmd; throw new Error(`Unknown command kind: ${neverCommand as Cmd["kind"]}`); diff --git a/internal/fourslash/fourslash.go b/internal/fourslash/fourslash.go index c6ac77bf22..b6657d7fed 100644 --- a/internal/fourslash/fourslash.go +++ b/internal/fourslash/fourslash.go @@ -1294,6 +1294,10 @@ func (f *FourslashTest) VerifyBaselineSignatureHelp(t *testing.T) { } } +func (f *FourslashTest) VerifyBaselineSelectionRanges(t *testing.T) { + t.Error("TODO") +} + func (f *FourslashTest) VerifyBaselineDocumentHighlights( t *testing.T, preferences *ls.UserPreferences, diff --git a/internal/fourslash/tests/gen/smartSelection_JSDocTags10_test.go b/internal/fourslash/tests/gen/smartSelection_JSDocTags10_test.go new file mode 100644 index 0000000000..a323c1da47 --- /dev/null +++ b/internal/fourslash/tests/gen/smartSelection_JSDocTags10_test.go @@ -0,0 +1,22 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestSmartSelection_JSDocTags10(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `/** + * @template T + * @extends {/**/Set} + */ +class A extends B { +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineSelectionRanges(t) +} diff --git a/internal/fourslash/tests/gen/smartSelection_JSDocTags11_test.go b/internal/fourslash/tests/gen/smartSelection_JSDocTags11_test.go new file mode 100644 index 0000000000..1eedc0f74c --- /dev/null +++ b/internal/fourslash/tests/gen/smartSelection_JSDocTags11_test.go @@ -0,0 +1,21 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestSmartSelection_JSDocTags11(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `const x = 1; +type Foo = { + /** comment */ + /*2*/readonly /*1*/status: number; +};` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineSelectionRanges(t) +} diff --git a/internal/fourslash/tests/gen/smartSelection_JSDocTags12_test.go b/internal/fourslash/tests/gen/smartSelection_JSDocTags12_test.go new file mode 100644 index 0000000000..7ec86103a2 --- /dev/null +++ b/internal/fourslash/tests/gen/smartSelection_JSDocTags12_test.go @@ -0,0 +1,20 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestSmartSelection_JSDocTags12(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `type B = {}; +type A = { + a(/** Comment */ /*1*/p0: number, /** Comment */ /*2*/p1: number, /** Comment */ /*3*/p2: number): string; +};` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineSelectionRanges(t) +} diff --git a/internal/fourslash/tests/gen/smartSelection_JSDocTags13_test.go b/internal/fourslash/tests/gen/smartSelection_JSDocTags13_test.go new file mode 100644 index 0000000000..a3c4b2d4c6 --- /dev/null +++ b/internal/fourslash/tests/gen/smartSelection_JSDocTags13_test.go @@ -0,0 +1,23 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestSmartSelection_JSDocTags13(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `let a; +let b: { + /** Comment */ /*1*/p0: number + /** Comment */ /*2*/p1: number + /** Comment */ /*3*/p2: number +}; +let c;` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineSelectionRanges(t) +} diff --git a/internal/fourslash/tests/gen/smartSelection_JSDocTags1_test.go b/internal/fourslash/tests/gen/smartSelection_JSDocTags1_test.go new file mode 100644 index 0000000000..fcc56e525a --- /dev/null +++ b/internal/fourslash/tests/gen/smartSelection_JSDocTags1_test.go @@ -0,0 +1,20 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestSmartSelection_JSDocTags1(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `/** + * @returns {Array<{ value: /**/string }>} + */ +function foo() { return [] }` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineSelectionRanges(t) +} diff --git a/internal/fourslash/tests/gen/smartSelection_JSDocTags2_test.go b/internal/fourslash/tests/gen/smartSelection_JSDocTags2_test.go new file mode 100644 index 0000000000..0db6205655 --- /dev/null +++ b/internal/fourslash/tests/gen/smartSelection_JSDocTags2_test.go @@ -0,0 +1,20 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestSmartSelection_JSDocTags2(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `/** + * @type {/**/string} + */ +const foo;` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineSelectionRanges(t) +} diff --git a/internal/fourslash/tests/gen/smartSelection_JSDocTags3_test.go b/internal/fourslash/tests/gen/smartSelection_JSDocTags3_test.go new file mode 100644 index 0000000000..fb4b5ecdaf --- /dev/null +++ b/internal/fourslash/tests/gen/smartSelection_JSDocTags3_test.go @@ -0,0 +1,20 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestSmartSelection_JSDocTags3(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `/** + * @param {/**/string} x + */ +function foo(x) {}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineSelectionRanges(t) +} diff --git a/internal/fourslash/tests/gen/smartSelection_JSDocTags4_test.go b/internal/fourslash/tests/gen/smartSelection_JSDocTags4_test.go new file mode 100644 index 0000000000..7d1d7bb0fc --- /dev/null +++ b/internal/fourslash/tests/gen/smartSelection_JSDocTags4_test.go @@ -0,0 +1,25 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestSmartSelection_JSDocTags4(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `/** + * @typedef {object} Foo + * @property {string} a + * @property {number} b + * @property {/**/number} c + */ + +/** @type {Foo} */ +const foo;` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineSelectionRanges(t) +} diff --git a/internal/fourslash/tests/gen/smartSelection_JSDocTags5_test.go b/internal/fourslash/tests/gen/smartSelection_JSDocTags5_test.go new file mode 100644 index 0000000000..c14320ca6a --- /dev/null +++ b/internal/fourslash/tests/gen/smartSelection_JSDocTags5_test.go @@ -0,0 +1,25 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestSmartSelection_JSDocTags5(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `/** + * @callback Foo + * @param {string} data + * @param {/**/number} [index] - comment + * @return {boolean} + */ + +/** @type {Foo} */ +const foo = s => !(s.length % 2);` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineSelectionRanges(t) +} diff --git a/internal/fourslash/tests/gen/smartSelection_JSDocTags6_test.go b/internal/fourslash/tests/gen/smartSelection_JSDocTags6_test.go new file mode 100644 index 0000000000..ac7904a3b6 --- /dev/null +++ b/internal/fourslash/tests/gen/smartSelection_JSDocTags6_test.go @@ -0,0 +1,24 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestSmartSelection_JSDocTags6(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `/** + * @template T + * @param {/**/T} x + * @return {T} + */ +function foo(x) { + return x; +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineSelectionRanges(t) +} diff --git a/internal/fourslash/tests/gen/smartSelection_JSDocTags7_test.go b/internal/fourslash/tests/gen/smartSelection_JSDocTags7_test.go new file mode 100644 index 0000000000..fbfc577b24 --- /dev/null +++ b/internal/fourslash/tests/gen/smartSelection_JSDocTags7_test.go @@ -0,0 +1,22 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestSmartSelection_JSDocTags7(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `/** + * @constructor + * @param {/**/number} data + */ +function Foo(data) { +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineSelectionRanges(t) +} diff --git a/internal/fourslash/tests/gen/smartSelection_JSDocTags8_test.go b/internal/fourslash/tests/gen/smartSelection_JSDocTags8_test.go new file mode 100644 index 0000000000..7a6dbfa501 --- /dev/null +++ b/internal/fourslash/tests/gen/smartSelection_JSDocTags8_test.go @@ -0,0 +1,22 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestSmartSelection_JSDocTags8(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `/** + * @this {/*1*/Foo} + * @param {/*2*/*} e + */ +function callback(e) { +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineSelectionRanges(t) +} diff --git a/internal/fourslash/tests/gen/smartSelection_JSDocTags9_test.go b/internal/fourslash/tests/gen/smartSelection_JSDocTags9_test.go new file mode 100644 index 0000000000..cd4cfd9672 --- /dev/null +++ b/internal/fourslash/tests/gen/smartSelection_JSDocTags9_test.go @@ -0,0 +1,21 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestSmartSelection_JSDocTags9(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `/** @enum {/**/number} */ +const Foo = { + x: 0, + y: 1, +};` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineSelectionRanges(t) +} diff --git a/internal/fourslash/tests/gen/smartSelection_JSDoc_test.go b/internal/fourslash/tests/gen/smartSelection_JSDoc_test.go new file mode 100644 index 0000000000..df80bc98fc --- /dev/null +++ b/internal/fourslash/tests/gen/smartSelection_JSDoc_test.go @@ -0,0 +1,23 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestSmartSelection_JSDoc(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// Not a JSDoc comment +/** + * @param {number} x The number to square + */ +function /**/square(x) { + return x * x; +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineSelectionRanges(t) +} diff --git a/internal/fourslash/tests/gen/smartSelection_behindCaret_test.go b/internal/fourslash/tests/gen/smartSelection_behindCaret_test.go new file mode 100644 index 0000000000..60616d9619 --- /dev/null +++ b/internal/fourslash/tests/gen/smartSelection_behindCaret_test.go @@ -0,0 +1,17 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestSmartSelection_behindCaret(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `let/**/ x: string` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineSelectionRanges(t) +} diff --git a/internal/fourslash/tests/gen/smartSelection_bindingPatterns_test.go b/internal/fourslash/tests/gen/smartSelection_bindingPatterns_test.go new file mode 100644 index 0000000000..2af1ad8ece --- /dev/null +++ b/internal/fourslash/tests/gen/smartSelection_bindingPatterns_test.go @@ -0,0 +1,17 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestSmartSelection_bindingPatterns(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `const { /*1*/x, y: /*2*/a, .../*3*/zs = {} } = {};` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineSelectionRanges(t) +} diff --git a/internal/fourslash/tests/gen/smartSelection_comment1_test.go b/internal/fourslash/tests/gen/smartSelection_comment1_test.go new file mode 100644 index 0000000000..07ce0c89a1 --- /dev/null +++ b/internal/fourslash/tests/gen/smartSelection_comment1_test.go @@ -0,0 +1,17 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestSmartSelection_comment1(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `const a = 1; ///**/comment content` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineSelectionRanges(t) +} diff --git a/internal/fourslash/tests/gen/smartSelection_comment2_test.go b/internal/fourslash/tests/gen/smartSelection_comment2_test.go new file mode 100644 index 0000000000..5f85d31719 --- /dev/null +++ b/internal/fourslash/tests/gen/smartSelection_comment2_test.go @@ -0,0 +1,17 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestSmartSelection_comment2(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `const a = 1; //a b/**/c d` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineSelectionRanges(t) +} diff --git a/internal/fourslash/tests/gen/smartSelection_complex_test.go b/internal/fourslash/tests/gen/smartSelection_complex_test.go new file mode 100644 index 0000000000..f5e70e3505 --- /dev/null +++ b/internal/fourslash/tests/gen/smartSelection_complex_test.go @@ -0,0 +1,17 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestSmartSelection_complex(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `type X = IsExactlyAny

extends true ? T : ({ [K in keyof P]: IsExactlyAny extends true ? K extends keyof T ? T[K] : P[/**/K] : P[K]; } & Pick>)` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineSelectionRanges(t) +} diff --git a/internal/fourslash/tests/gen/smartSelection_emptyRanges_test.go b/internal/fourslash/tests/gen/smartSelection_emptyRanges_test.go new file mode 100644 index 0000000000..bfe284f963 --- /dev/null +++ b/internal/fourslash/tests/gen/smartSelection_emptyRanges_test.go @@ -0,0 +1,23 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestSmartSelection_emptyRanges(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `class HomePage { + componentDidMount(/*1*/) { + if (this.props.username/*2*/) { + return '/*3*/'; + } + } +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineSelectionRanges(t) +} diff --git a/internal/fourslash/tests/gen/smartSelection_function1_test.go b/internal/fourslash/tests/gen/smartSelection_function1_test.go new file mode 100644 index 0000000000..69f55b9433 --- /dev/null +++ b/internal/fourslash/tests/gen/smartSelection_function1_test.go @@ -0,0 +1,19 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestSmartSelection_function1(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `const f1 = () => { + /**/ +};` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineSelectionRanges(t) +} diff --git a/internal/fourslash/tests/gen/smartSelection_function2_test.go b/internal/fourslash/tests/gen/smartSelection_function2_test.go new file mode 100644 index 0000000000..ae9342a804 --- /dev/null +++ b/internal/fourslash/tests/gen/smartSelection_function2_test.go @@ -0,0 +1,19 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestSmartSelection_function2(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `function f2() { + /**/ +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineSelectionRanges(t) +} diff --git a/internal/fourslash/tests/gen/smartSelection_function3_test.go b/internal/fourslash/tests/gen/smartSelection_function3_test.go new file mode 100644 index 0000000000..277f17a16e --- /dev/null +++ b/internal/fourslash/tests/gen/smartSelection_function3_test.go @@ -0,0 +1,19 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestSmartSelection_function3(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `const f3 = function () { + /**/ +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineSelectionRanges(t) +} diff --git a/internal/fourslash/tests/gen/smartSelection_functionParams1_test.go b/internal/fourslash/tests/gen/smartSelection_functionParams1_test.go new file mode 100644 index 0000000000..9e72094748 --- /dev/null +++ b/internal/fourslash/tests/gen/smartSelection_functionParams1_test.go @@ -0,0 +1,17 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestSmartSelection_functionParams1(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `function f(/*1*/p, /*2*/q?, /*3*/...r: any[] = []) {}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineSelectionRanges(t) +} diff --git a/internal/fourslash/tests/gen/smartSelection_functionParams2_test.go b/internal/fourslash/tests/gen/smartSelection_functionParams2_test.go new file mode 100644 index 0000000000..23742a790c --- /dev/null +++ b/internal/fourslash/tests/gen/smartSelection_functionParams2_test.go @@ -0,0 +1,20 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestSmartSelection_functionParams2(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `function f( + a, + /**/b +) {}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineSelectionRanges(t) +} diff --git a/internal/fourslash/tests/gen/smartSelection_imports_test.go b/internal/fourslash/tests/gen/smartSelection_imports_test.go new file mode 100644 index 0000000000..fb6fdaf283 --- /dev/null +++ b/internal/fourslash/tests/gen/smartSelection_imports_test.go @@ -0,0 +1,20 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestSmartSelection_imports(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `import { /**/x as y, z } from './z'; +import { b } from './'; + +console.log(1);` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineSelectionRanges(t) +} diff --git a/internal/fourslash/tests/gen/smartSelection_lastBlankLine_test.go b/internal/fourslash/tests/gen/smartSelection_lastBlankLine_test.go new file mode 100644 index 0000000000..707384913d --- /dev/null +++ b/internal/fourslash/tests/gen/smartSelection_lastBlankLine_test.go @@ -0,0 +1,18 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestSmartSelection_lastBlankLine(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `class C {} +/**/` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineSelectionRanges(t) +} diff --git a/internal/fourslash/tests/gen/smartSelection_loneVariableDeclaration_test.go b/internal/fourslash/tests/gen/smartSelection_loneVariableDeclaration_test.go new file mode 100644 index 0000000000..da1f4af3a8 --- /dev/null +++ b/internal/fourslash/tests/gen/smartSelection_loneVariableDeclaration_test.go @@ -0,0 +1,17 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestSmartSelection_loneVariableDeclaration(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `const /**/x = 3;` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineSelectionRanges(t) +} diff --git a/internal/fourslash/tests/gen/smartSelection_mappedTypes_test.go b/internal/fourslash/tests/gen/smartSelection_mappedTypes_test.go new file mode 100644 index 0000000000..7467f4d8eb --- /dev/null +++ b/internal/fourslash/tests/gen/smartSelection_mappedTypes_test.go @@ -0,0 +1,17 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestSmartSelection_mappedTypes(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `type M = { /*1*/-re/*2*/adonly /*3*/[K in ke/*4*/yof any]/*5*/-/*6*/?: any };` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineSelectionRanges(t) +} diff --git a/internal/fourslash/tests/gen/smartSelection_objectTypes_test.go b/internal/fourslash/tests/gen/smartSelection_objectTypes_test.go new file mode 100644 index 0000000000..98fa38286b --- /dev/null +++ b/internal/fourslash/tests/gen/smartSelection_objectTypes_test.go @@ -0,0 +1,21 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestSmartSelection_objectTypes(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `type X = { + /*1*/foo?: string; + /*2*/readonly /*3*/bar: { x: num/*4*/ber }; + /*5*/meh +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineSelectionRanges(t) +} diff --git a/internal/fourslash/tests/gen/smartSelection_punctuationPriority_test.go b/internal/fourslash/tests/gen/smartSelection_punctuationPriority_test.go new file mode 100644 index 0000000000..d63add6b39 --- /dev/null +++ b/internal/fourslash/tests/gen/smartSelection_punctuationPriority_test.go @@ -0,0 +1,17 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestSmartSelection_punctuationPriority(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `console/**/.log();` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineSelectionRanges(t) +} diff --git a/internal/fourslash/tests/gen/smartSelection_simple1_test.go b/internal/fourslash/tests/gen/smartSelection_simple1_test.go new file mode 100644 index 0000000000..e24d9bb2bb --- /dev/null +++ b/internal/fourslash/tests/gen/smartSelection_simple1_test.go @@ -0,0 +1,24 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestSmartSelection_simple1(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `class Foo { + bar(a, b) { + if (/*1*/a === b) { + return tr/*2*/ue; + } + return false; + } +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineSelectionRanges(t) +} diff --git a/internal/fourslash/tests/gen/smartSelection_simple2_test.go b/internal/fourslash/tests/gen/smartSelection_simple2_test.go new file mode 100644 index 0000000000..a2b31dfe05 --- /dev/null +++ b/internal/fourslash/tests/gen/smartSelection_simple2_test.go @@ -0,0 +1,22 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestSmartSelection_simple2(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `export interface IService { + _serviceBrand: any; + + open(ho/*1*/st: number, data: any): Promise; + bar(): void/*2*/ +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineSelectionRanges(t) +} diff --git a/internal/fourslash/tests/gen/smartSelection_stringLiteral_test.go b/internal/fourslash/tests/gen/smartSelection_stringLiteral_test.go new file mode 100644 index 0000000000..789cac8a04 --- /dev/null +++ b/internal/fourslash/tests/gen/smartSelection_stringLiteral_test.go @@ -0,0 +1,18 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestSmartSelection_stringLiteral(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `const a = 'a'; +const b = /**/'b';` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineSelectionRanges(t) +} diff --git a/internal/fourslash/tests/gen/smartSelection_templateStrings2_test.go b/internal/fourslash/tests/gen/smartSelection_templateStrings2_test.go new file mode 100644 index 0000000000..fa210cb690 --- /dev/null +++ b/internal/fourslash/tests/gen/smartSelection_templateStrings2_test.go @@ -0,0 +1,17 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestSmartSelection_templateStrings2(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `` + "`" + `a ${b} /**/c` + "`" + `` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineSelectionRanges(t) +} diff --git a/internal/fourslash/tests/gen/smartSelection_templateStrings_test.go b/internal/fourslash/tests/gen/smartSelection_templateStrings_test.go new file mode 100644 index 0000000000..ef7a4d7fbb --- /dev/null +++ b/internal/fourslash/tests/gen/smartSelection_templateStrings_test.go @@ -0,0 +1,19 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestSmartSelection_templateStrings(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `` + "`" + `a /*1*/b ${ + '/*2*/c' +} d` + "`" + `` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineSelectionRanges(t) +} diff --git a/internal/ls/selectionranges.go b/internal/ls/selectionranges.go new file mode 100644 index 0000000000..7db9641122 --- /dev/null +++ b/internal/ls/selectionranges.go @@ -0,0 +1,11 @@ +package ls + +import ( + "context" + + "github.com/microsoft/typescript-go/internal/lsp/lsproto" +) + +func (l *LanguageService) ProvideSelectionRanges(ctx context.Context, params *lsproto.SelectionRangeParams) (lsproto.SelectionRangeResponse, error) { + panic("TODO") +} diff --git a/internal/lsp/server.go b/internal/lsp/server.go index 1eafc75712..275e1c92df 100644 --- a/internal/lsp/server.go +++ b/internal/lsp/server.go @@ -487,6 +487,7 @@ var handlers = sync.OnceValue(func() handlerMap { registerLanguageServiceDocumentRequestHandler(handlers, lsproto.TextDocumentDocumentSymbolInfo, (*Server).handleDocumentSymbol) registerLanguageServiceDocumentRequestHandler(handlers, lsproto.TextDocumentRenameInfo, (*Server).handleRename) registerLanguageServiceDocumentRequestHandler(handlers, lsproto.TextDocumentDocumentHighlightInfo, (*Server).handleDocumentHighlight) + registerLanguageServiceDocumentRequestHandler(handlers, lsproto.TextDocumentSelectionRangeInfo, (*Server).handleSelectionRange) registerRequestHandler(handlers, lsproto.WorkspaceSymbolInfo, (*Server).handleWorkspaceSymbol) registerRequestHandler(handlers, lsproto.CompletionItemResolveInfo, (*Server).handleCompletionItemResolve) @@ -666,6 +667,9 @@ func (s *Server) handleInitialize(ctx context.Context, params *lsproto.Initializ DocumentHighlightProvider: &lsproto.BooleanOrDocumentHighlightOptions{ Boolean: ptrTo(true), }, + SelectionRangeProvider: &lsproto.BooleanOrSelectionRangeOptionsOrSelectionRangeRegistrationOptions{ + Boolean: ptrTo(true), + }, }, } @@ -904,6 +908,10 @@ func (s *Server) handleDocumentHighlight(ctx context.Context, ls *ls.LanguageSer return ls.ProvideDocumentHighlights(ctx, params.TextDocument.Uri, params.Position) } +func (s *Server) handleSelectionRange(ctx context.Context, ls *ls.LanguageService, params *lsproto.SelectionRangeParams) (lsproto.SelectionRangeResponse, error) { + return ls.ProvideSelectionRanges(ctx, params) +} + func (s *Server) Log(msg ...any) { fmt.Fprintln(s.stderr, msg...) } From 6b716807a6e321613e1226db27ae209c8f09bbb5 Mon Sep 17 00:00:00 2001 From: Jake Bailey <5341706+jakebailey@users.noreply.github.com> Date: Wed, 22 Oct 2025 22:29:08 -0700 Subject: [PATCH 2/9] Make it work --- internal/ast/ast.go | 20 +++ internal/fourslash/baselineutil.go | 7 +- internal/fourslash/fourslash.go | 138 ++++++++++++++- internal/ls/selectionranges.go | 148 +++++++++++++++- internal/ls/utilities.go | 7 + .../smartSelection_JSDoc.baseline | 20 +++ .../smartSelection_JSDoc.baseline.diff | 28 +++ .../smartSelection_JSDocTags1.baseline | 10 ++ .../smartSelection_JSDocTags1.baseline.diff | 31 ++++ .../smartSelection_JSDocTags10.baseline | 14 ++ .../smartSelection_JSDocTags10.baseline.diff | 25 +++ .../smartSelection_JSDocTags11.baseline | 46 +++++ .../smartSelection_JSDocTags11.baseline.diff | 76 +++++++++ .../smartSelection_JSDocTags12.baseline | 64 +++++++ .../smartSelection_JSDocTags12.baseline.diff | 119 +++++++++++++ .../smartSelection_JSDocTags13.baseline | 97 +++++++++++ .../smartSelection_JSDocTags13.baseline.diff | 127 ++++++++++++++ .../smartSelection_JSDocTags2.baseline | 10 ++ .../smartSelection_JSDocTags2.baseline.diff | 22 +++ .../smartSelection_JSDocTags3.baseline | 10 ++ .../smartSelection_JSDocTags3.baseline.diff | 21 +++ .../smartSelection_JSDocTags4.baseline | 19 +++ .../smartSelection_JSDocTags4.baseline.diff | 36 ++++ .../smartSelection_JSDocTags5.baseline | 19 +++ .../smartSelection_JSDocTags5.baseline.diff | 36 ++++ .../smartSelection_JSDocTags6.baseline | 18 ++ .../smartSelection_JSDocTags6.baseline.diff | 23 +++ .../smartSelection_JSDocTags7.baseline | 14 ++ .../smartSelection_JSDocTags7.baseline.diff | 22 +++ .../smartSelection_JSDocTags8.baseline | 30 ++++ .../smartSelection_JSDocTags8.baseline.diff | 42 +++++ .../smartSelection_JSDocTags9.baseline | 12 ++ .../smartSelection_JSDocTags9.baseline.diff | 19 +++ .../smartSelection_behindCaret.baseline | 4 + .../smartSelection_behindCaret.baseline.diff | 8 + .../smartSelection_bindingPatterns.baseline | 27 +++ ...artSelection_bindingPatterns.baseline.diff | 10 ++ .../smartSelection_comment1.baseline | 4 + .../smartSelection_comment1.baseline.diff | 9 + .../smartSelection_comment2.baseline | 4 + .../smartSelection_comment2.baseline.diff | 9 + .../smartSelection_complex.baseline | 12 ++ .../smartSelection_complex.baseline.diff | 11 ++ .../smartSelection_emptyRanges.baseline | 85 ++++++++++ .../smartSelection_emptyRanges.baseline.diff | 133 +++++++++++++++ .../smartSelection_function1.baseline | 14 ++ .../smartSelection_function1.baseline.diff | 18 ++ .../smartSelection_function2.baseline | 11 ++ .../smartSelection_function2.baseline.diff | 14 ++ .../smartSelection_function3.baseline | 14 ++ .../smartSelection_function3.baseline.diff | 18 ++ .../smartSelection_functionParams1.baseline | 24 +++ ...artSelection_functionParams1.baseline.diff | 11 ++ .../smartSelection_functionParams2.baseline | 13 ++ ...artSelection_functionParams2.baseline.diff | 21 +++ .../smartSelection_imports.baseline | 14 ++ .../smartSelection_imports.baseline.diff | 37 ++++ .../smartSelection_lastBlankLine.baseline | 5 + ...smartSelection_lastBlankLine.baseline.diff | 8 + ...Selection_loneVariableDeclaration.baseline | 5 + .../smartSelection_mappedTypes.baseline | 44 +++++ .../smartSelection_mappedTypes.baseline.diff | 67 ++++++++ .../smartSelection_objectTypes.baseline | 119 +++++++++++++ .../smartSelection_objectTypes.baseline.diff | 159 ++++++++++++++++++ ...martSelection_punctuationPriority.baseline | 6 + ...election_punctuationPriority.baseline.diff | 10 ++ .../smartSelection_simple1.baseline | 80 +++++++++ .../smartSelection_simple1.baseline.diff | 123 ++++++++++++++ .../smartSelection_simple2.baseline | 35 ++++ .../smartSelection_simple2.baseline.diff | 61 +++++++ .../smartSelection_stringLiteral.baseline | 8 + ...smartSelection_stringLiteral.baseline.diff | 13 ++ .../smartSelection_templateStrings.baseline | 21 +++ ...artSelection_templateStrings.baseline.diff | 39 +++++ .../smartSelection_templateStrings2.baseline | 5 + ...rtSelection_templateStrings2.baseline.diff | 9 + 76 files changed, 2669 insertions(+), 3 deletions(-) create mode 100644 testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDoc.baseline create mode 100644 testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDoc.baseline.diff create mode 100644 testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags1.baseline create mode 100644 testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags1.baseline.diff create mode 100644 testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags10.baseline create mode 100644 testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags10.baseline.diff create mode 100644 testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags11.baseline create mode 100644 testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags11.baseline.diff create mode 100644 testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags12.baseline create mode 100644 testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags12.baseline.diff create mode 100644 testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags13.baseline create mode 100644 testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags13.baseline.diff create mode 100644 testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags2.baseline create mode 100644 testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags2.baseline.diff create mode 100644 testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags3.baseline create mode 100644 testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags3.baseline.diff create mode 100644 testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags4.baseline create mode 100644 testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags4.baseline.diff create mode 100644 testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags5.baseline create mode 100644 testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags5.baseline.diff create mode 100644 testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags6.baseline create mode 100644 testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags6.baseline.diff create mode 100644 testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags7.baseline create mode 100644 testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags7.baseline.diff create mode 100644 testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags8.baseline create mode 100644 testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags8.baseline.diff create mode 100644 testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags9.baseline create mode 100644 testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags9.baseline.diff create mode 100644 testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_behindCaret.baseline create mode 100644 testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_behindCaret.baseline.diff create mode 100644 testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_bindingPatterns.baseline create mode 100644 testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_bindingPatterns.baseline.diff create mode 100644 testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_comment1.baseline create mode 100644 testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_comment1.baseline.diff create mode 100644 testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_comment2.baseline create mode 100644 testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_comment2.baseline.diff create mode 100644 testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_complex.baseline create mode 100644 testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_complex.baseline.diff create mode 100644 testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_emptyRanges.baseline create mode 100644 testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_emptyRanges.baseline.diff create mode 100644 testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_function1.baseline create mode 100644 testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_function1.baseline.diff create mode 100644 testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_function2.baseline create mode 100644 testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_function2.baseline.diff create mode 100644 testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_function3.baseline create mode 100644 testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_function3.baseline.diff create mode 100644 testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_functionParams1.baseline create mode 100644 testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_functionParams1.baseline.diff create mode 100644 testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_functionParams2.baseline create mode 100644 testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_functionParams2.baseline.diff create mode 100644 testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_imports.baseline create mode 100644 testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_imports.baseline.diff create mode 100644 testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_lastBlankLine.baseline create mode 100644 testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_lastBlankLine.baseline.diff create mode 100644 testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_loneVariableDeclaration.baseline create mode 100644 testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_mappedTypes.baseline create mode 100644 testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_mappedTypes.baseline.diff create mode 100644 testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_objectTypes.baseline create mode 100644 testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_objectTypes.baseline.diff create mode 100644 testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_punctuationPriority.baseline create mode 100644 testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_punctuationPriority.baseline.diff create mode 100644 testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_simple1.baseline create mode 100644 testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_simple1.baseline.diff create mode 100644 testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_simple2.baseline create mode 100644 testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_simple2.baseline.diff create mode 100644 testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_stringLiteral.baseline create mode 100644 testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_stringLiteral.baseline.diff create mode 100644 testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_templateStrings.baseline create mode 100644 testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_templateStrings.baseline.diff create mode 100644 testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_templateStrings2.baseline create mode 100644 testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_templateStrings2.baseline.diff diff --git a/internal/ast/ast.go b/internal/ast/ast.go index 718bbda8b2..2e04d3682c 100644 --- a/internal/ast/ast.go +++ b/internal/ast/ast.go @@ -8706,6 +8706,10 @@ func (node *TemplateHead) Clone(f NodeFactoryCoercible) *Node { return cloneNode(f.AsNodeFactory().NewTemplateHead(node.Text, node.RawText, node.TemplateFlags), node.AsNode(), f.AsNodeFactory().hooks) } +func IsTemplateHead(node *Node) bool { + return node.Kind == KindTemplateHead +} + // TemplateMiddle type TemplateMiddle struct { @@ -8726,6 +8730,10 @@ func (node *TemplateMiddle) Clone(f NodeFactoryCoercible) *Node { return cloneNode(f.AsNodeFactory().NewTemplateMiddle(node.Text, node.RawText, node.TemplateFlags), node.AsNode(), f.AsNodeFactory().hooks) } +func IsTemplateMiddle(node *Node) bool { + return node.Kind == KindTemplateMiddle +} + // TemplateTail type TemplateTail struct { @@ -8746,6 +8754,14 @@ func (node *TemplateTail) Clone(f NodeFactoryCoercible) *Node { return cloneNode(f.AsNodeFactory().NewTemplateTail(node.Text, node.RawText, node.TemplateFlags), node.AsNode(), f.AsNodeFactory().hooks) } +func IsTemplateTail(node *Node) bool { + return node.Kind == KindTemplateTail +} + +func IsTemplateMiddleOrTemplateTail(node *Node) bool { + return node.Kind == KindTemplateMiddle || node.Kind == KindTemplateTail +} + // TemplateLiteralTypeNode type TemplateLiteralTypeNode struct { @@ -9430,6 +9446,10 @@ func (node *SyntaxList) Clone(f NodeFactoryCoercible) *Node { return cloneNode(f.AsNodeFactory().NewSyntaxList(node.Children), node.AsNode(), f.AsNodeFactory().hooks) } +func IsSyntaxList(node *Node) bool { + return node.Kind == KindSyntaxList +} + /// JSDoc /// type JSDoc struct { diff --git a/internal/fourslash/baselineutil.go b/internal/fourslash/baselineutil.go index 83e683b1d4..1a659331d9 100644 --- a/internal/fourslash/baselineutil.go +++ b/internal/fourslash/baselineutil.go @@ -47,7 +47,7 @@ func getBaselineFileName(t *testing.T, command string) string { func getBaselineExtension(command string) string { switch command { - case "QuickInfo", "SignatureHelp": + case "QuickInfo", "SignatureHelp", "Smart Selection": return "baseline" case "Auto Imports": return "baseline.md" @@ -61,6 +61,11 @@ func getBaselineExtension(command string) string { func getBaselineOptions(command string) baseline.Options { subfolder := "fourslash/" + normalizeCommandName(command) switch command { + case "Smart Selection": + return baseline.Options{ + Subfolder: subfolder, + IsSubmodule: true, + } case "findRenameLocations": return baseline.Options{ Subfolder: subfolder, diff --git a/internal/fourslash/fourslash.go b/internal/fourslash/fourslash.go index b6657d7fed..d1eb84004c 100644 --- a/internal/fourslash/fourslash.go +++ b/internal/fourslash/fourslash.go @@ -1295,7 +1295,143 @@ func (f *FourslashTest) VerifyBaselineSignatureHelp(t *testing.T) { } func (f *FourslashTest) VerifyBaselineSelectionRanges(t *testing.T) { - t.Error("TODO") + markers := f.Markers() + var result strings.Builder + newLine := "\n" + + for i, marker := range markers { + if i > 0 { + result.WriteString(newLine + strings.Repeat("=", 80) + newLine + newLine) + } + + script := f.getScriptInfo(marker.FileName()) + fileContent := script.content + + // Add the marker position indicator + markerPos := marker.Position + baselineContent := fileContent[:markerPos] + "/**/" + fileContent[markerPos:] + newLine + result.WriteString(baselineContent) + + // Get selection ranges at this marker + params := &lsproto.SelectionRangeParams{ + TextDocument: lsproto.TextDocumentIdentifier{ + Uri: ls.FileNameToDocumentURI(marker.FileName()), + }, + Positions: []lsproto.Position{marker.LSPosition}, + } + + resMsg, selectionRangeResult, resultOk := sendRequest(t, f, lsproto.TextDocumentSelectionRangeInfo, params) + markerNameStr := *core.OrElse(marker.Name, ptrTo("(unnamed)")) + if resMsg == nil { + t.Fatalf("Nil response received for selection range request at marker '%s'", markerNameStr) + } + if !resultOk { + if resMsg.AsResponse().Error != nil { + t.Fatalf("Error response for selection range request at marker '%s': %v", markerNameStr, resMsg.AsResponse().Error) + } + t.Fatalf("Unexpected selection range response type at marker '%s': %T", markerNameStr, resMsg.AsResponse().Result) + } + + if selectionRangeResult.SelectionRanges == nil || len(*selectionRangeResult.SelectionRanges) == 0 { + result.WriteString("No selection ranges available\n") + continue + } + + selectionRange := (*selectionRangeResult.SelectionRanges)[0] + + // Add blank line before first range + result.WriteString(newLine) + + // Walk through the selection range chain + for selectionRange != nil { + start := int(f.converters.LineAndCharacterToPosition(script, selectionRange.Range.Start)) + end := int(f.converters.LineAndCharacterToPosition(script, selectionRange.Range.End)) + + // Create a masked version of the file showing only this range + runes := []rune(fileContent) + masked := make([]rune, len(runes)) + + for i, ch := range runes { + if i >= start && i < end { + // Keep characters in the selection range + if ch == ' ' { + masked[i] = '•' + } else if ch == '\n' || ch == '\r' { + masked[i] = ch // Keep line breaks as-is, will add arrow later + } else { + masked[i] = ch + } + } else { + // Replace characters outside the range + if ch == '\n' || ch == '\r' { + masked[i] = ch + } else { + masked[i] = ' ' + } + } + } + + maskedStr := string(masked) + + // Add line break arrows + maskedStr = strings.ReplaceAll(maskedStr, "\n", "↲\n") + maskedStr = strings.ReplaceAll(maskedStr, "\r", "↲\r") + + // Remove blank lines + lines := strings.Split(maskedStr, "\n") + var nonBlankLines []string + for _, line := range lines { + trimmed := strings.TrimSpace(line) + if trimmed != "" && trimmed != "↲" { + nonBlankLines = append(nonBlankLines, line) + } + } + maskedStr = strings.Join(nonBlankLines, "\n") + + // Find leading and trailing width of non-whitespace characters + maskedRunes := []rune(maskedStr) + isRealCharacter := func(ch rune) bool { + return ch != '•' && ch != '↲' && !stringutil.IsWhiteSpaceLike(ch) + } + + leadingWidth := -1 + for i, ch := range maskedRunes { + if isRealCharacter(ch) { + leadingWidth = i + break + } + } + + trailingWidth := -1 + for j := len(maskedRunes) - 1; j >= 0; j-- { + if isRealCharacter(maskedRunes[j]) { + trailingWidth = j + break + } + } + + if leadingWidth != -1 && trailingWidth != -1 && leadingWidth <= trailingWidth { + // Clean up middle section + prefix := string(maskedRunes[:leadingWidth]) + middle := string(maskedRunes[leadingWidth : trailingWidth+1]) + suffix := string(maskedRunes[trailingWidth+1:]) + + middle = strings.ReplaceAll(middle, "•", " ") + middle = strings.ReplaceAll(middle, "↲", "") + + maskedStr = prefix + middle + suffix + } + + result.WriteString(maskedStr) + if !strings.HasSuffix(maskedStr, "\n") { + result.WriteString(newLine) + } + + selectionRange = selectionRange.Parent + } + } + + f.addResultToBaseline(t, "Smart Selection", strings.TrimSuffix(result.String(), "\n")) } func (f *FourslashTest) VerifyBaselineDocumentHighlights( diff --git a/internal/ls/selectionranges.go b/internal/ls/selectionranges.go index 7db9641122..bc3d3693b7 100644 --- a/internal/ls/selectionranges.go +++ b/internal/ls/selectionranges.go @@ -3,9 +3,155 @@ package ls import ( "context" + "github.com/microsoft/typescript-go/internal/ast" + "github.com/microsoft/typescript-go/internal/astnav" + "github.com/microsoft/typescript-go/internal/core" "github.com/microsoft/typescript-go/internal/lsp/lsproto" + "github.com/microsoft/typescript-go/internal/scanner" ) func (l *LanguageService) ProvideSelectionRanges(ctx context.Context, params *lsproto.SelectionRangeParams) (lsproto.SelectionRangeResponse, error) { - panic("TODO") + _, sourceFile := l.getProgramAndFile(params.TextDocument.Uri) + if sourceFile == nil { + return lsproto.SelectionRangesOrNull{}, nil + } + + var results []*lsproto.SelectionRange + for _, position := range params.Positions { + pos := l.converters.LineAndCharacterToPosition(sourceFile, position) + selectionRange := getSmartSelectionRange(l, sourceFile, int(pos)) + if selectionRange != nil { + results = append(results, selectionRange) + } + } + + return lsproto.SelectionRangesOrNull{SelectionRanges: &results}, nil +} + +func getSmartSelectionRange(l *LanguageService, sourceFile *ast.SourceFile, pos int) *lsproto.SelectionRange { + nodeContainsPosition := func(node *ast.Node) bool { + if node == nil { + return false + } + start := scanner.GetTokenPosOfNode(node, sourceFile, true /*includeJSDoc*/) + end := node.End() + return start <= pos && pos < end + } + + pushSelectionRange := func(current *lsproto.SelectionRange, start, end int) *lsproto.SelectionRange { + if start == end { + return current + } + + if !(start <= pos && pos <= end) { + return current + } + + lspRange := l.converters.ToLSPRange(sourceFile, core.NewTextRange(start, end)) + + if current != nil && current.Range.Start == lspRange.Start && current.Range.End == lspRange.End { + return current + } + + return &lsproto.SelectionRange{ + Range: lspRange, + Parent: current, + } + } + + positionsAreOnSameLine := func(pos1, pos2 int) bool { + if pos1 == pos2 { + return true + } + lspPos1 := l.converters.PositionToLineAndCharacter(sourceFile, core.TextPos(pos1)) + lspPos2 := l.converters.PositionToLineAndCharacter(sourceFile, core.TextPos(pos2)) + return lspPos1.Line == lspPos2.Line + } + + shouldSkipNode := func(node *ast.Node, parent *ast.Node) bool { + if ast.IsBlock(node) { + return true + } + + if ast.IsTemplateSpan(node) || ast.IsTemplateHead(node) || ast.IsTemplateTail(node) { + return true + } + + if parent != nil && ast.IsVariableDeclarationList(node) && ast.IsVariableStatement(parent) { + return true + } + + // Skip lone variable declarations + if parent != nil && ast.IsVariableDeclaration(node) && ast.IsVariableDeclarationList(parent) { + decl := parent.AsVariableDeclarationList() + if decl != nil && len(decl.Declarations.Nodes) == 1 { + return true + } + } + + if node.Kind == ast.KindJSDocTypeExpression || ast.IsJSDocSignature(node) || node.Kind == ast.KindJSDocTypeLiteral { + return true + } + + return false + } + + fullRange := l.converters.ToLSPRange(sourceFile, core.NewTextRange(sourceFile.Pos(), sourceFile.End())) + result := &lsproto.SelectionRange{ + Range: fullRange, + } + + var current *ast.Node + for current = sourceFile.AsNode(); current != nil; { + var next *ast.Node + parent := current + + visit := func(node *ast.Node) *ast.Node { + if node != nil && next == nil { + if nodeContainsPosition(node) { + // Add range for multi-line function bodies before skipping the block + if ast.IsBlock(node) && ast.IsFunctionLikeDeclaration(parent) { + if !positionsAreOnSameLine(astnav.GetStartOfNode(node, sourceFile, false), node.End()) { + start := astnav.GetStartOfNode(node, sourceFile, false) + end := node.End() + result = pushSelectionRange(result, start, end) + } + } + + if !shouldSkipNode(node, parent) { + start := astnav.GetStartOfNode(node, sourceFile, false) + end := node.End() + result = pushSelectionRange(result, start, end) + } + + next = node + } + } + return node + } + + visitNodes := func(nodes *ast.NodeList, v *ast.NodeVisitor) *ast.NodeList { + if nodes != nil && len(nodes.Nodes) > 0 { + shouldSkipList := parent != nil && ast.IsVariableDeclarationList(parent) + + if !shouldSkipList { + start := astnav.GetStartOfNode(nodes.Nodes[0], sourceFile, false) + end := nodes.Nodes[len(nodes.Nodes)-1].End() + + if start <= pos && pos < end { + result = pushSelectionRange(result, start, end) + } + } + } + return v.VisitNodes(nodes) + } + + tempVisitor := ast.NewNodeVisitor(visit, nil, ast.NodeVisitorHooks{ + VisitNodes: visitNodes, + }) + + current.VisitEachChild(tempVisitor) + current = next + } + return result } diff --git a/internal/ls/utilities.go b/internal/ls/utilities.go index 95659b8a60..09d5a070a4 100644 --- a/internal/ls/utilities.go +++ b/internal/ls/utilities.go @@ -1678,6 +1678,13 @@ func getChildrenFromNonJSDocNode(node *ast.Node, sourceFile *ast.SourceFile) []* childNodes = append(childNodes, child) return false }) + + // If the node has no children, don't scan for tokens. + // This prevents creating tokens for leaf nodes' own text. + if len(childNodes) == 0 { + return nil + } + var children []*ast.Node pos := node.Pos() for _, child := range childNodes { diff --git a/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDoc.baseline b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDoc.baseline new file mode 100644 index 0000000000..51e36d04d7 --- /dev/null +++ b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDoc.baseline @@ -0,0 +1,20 @@ +// === Smart Selection === +// Not a JSDoc comment +/** + * @param {number} x The number to square + */ +function /**/square(x) { + return x * x; +} + + square ↲ +function square(x) { + return x * x; +} +// Not a JSDoc comment +/** + * @param {number} x The number to square + */ +function square(x) { + return x * x; +} \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDoc.baseline.diff b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDoc.baseline.diff new file mode 100644 index 0000000000..91dcc06e88 --- /dev/null +++ b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDoc.baseline.diff @@ -0,0 +1,28 @@ +--- old.smartSelection_JSDoc.baseline ++++ new.smartSelection_JSDoc.baseline +@@= skipped -6, +6 lines =@@ + return x * x; + } + +- +- square +- +- +-function square(x) { +- return x * x; +-} +- +-/** +- * @param {number} x The number to square +- */ +-function square(x) { +- return x * x; +-} +- ++ square ↲ ++function square(x) { ++ return x * x; ++} + // Not a JSDoc comment + /** + * @param {number} x The number to square \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags1.baseline b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags1.baseline new file mode 100644 index 0000000000..46760b8ad3 --- /dev/null +++ b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags1.baseline @@ -0,0 +1,10 @@ +// === Smart Selection === +/** + * @returns {Array<{ value: /**/string }>} + */ +function foo() { return [] } + +/** + * @returns {Array<{ value: string }>} + */ +function foo() { return [] } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags1.baseline.diff b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags1.baseline.diff new file mode 100644 index 0000000000..e30d12a21d --- /dev/null +++ b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags1.baseline.diff @@ -0,0 +1,31 @@ +--- old.smartSelection_JSDocTags1.baseline ++++ new.smartSelection_JSDocTags1.baseline +@@= skipped -3, +3 lines =@@ + */ + function foo() { return [] } + +- +- string +- +- +- value: string +- +- +- { value: string } +- +- +- Array<{ value: string }> +- +- +- @returns {Array<{ value: string }>}↲ +-• +- +- +-/** +- * @returns {Array<{ value: string }>} +- */ +- +- + /** + * @returns {Array<{ value: string }>} + */ \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags10.baseline b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags10.baseline new file mode 100644 index 0000000000..d230e63663 --- /dev/null +++ b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags10.baseline @@ -0,0 +1,14 @@ +// === Smart Selection === +/** + * @template T + * @extends {/**/Set} + */ +class A extends B { +} + +/** + * @template T + * @extends {Set} + */ +class A extends B { +} \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags10.baseline.diff b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags10.baseline.diff new file mode 100644 index 0000000000..7562eee0f0 --- /dev/null +++ b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags10.baseline.diff @@ -0,0 +1,25 @@ +--- old.smartSelection_JSDocTags10.baseline ++++ new.smartSelection_JSDocTags10.baseline +@@= skipped -5, +5 lines =@@ + class A extends B { + } + +- +- Set +- +- +- Set +- +- +- @extends {Set} +- +- +-/** +- * @template T +- * @extends {Set} +- */ +- +- + /** + * @template T + * @extends {Set} \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags11.baseline b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags11.baseline new file mode 100644 index 0000000000..e53d115446 --- /dev/null +++ b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags11.baseline @@ -0,0 +1,46 @@ +// === Smart Selection === +const x = 1; +type Foo = { + /** comment */ + /**/readonly status: number; +}; + + readonly ↲ + readonly status: number;↲ + { + /** comment */ + readonly status: number; +} +type Foo = { + /** comment */ + readonly status: number; +}; +const x = 1; +type Foo = { + /** comment */ + readonly status: number; +}; + +================================================================================ + +const x = 1; +type Foo = { + /** comment */ + readonly /**/status: number; +}; + + status ↲ + readonly status: number;↲ + { + /** comment */ + readonly status: number; +} +type Foo = { + /** comment */ + readonly status: number; +}; +const x = 1; +type Foo = { + /** comment */ + readonly status: number; +}; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags11.baseline.diff b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags11.baseline.diff new file mode 100644 index 0000000000..09ae904d60 --- /dev/null +++ b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags11.baseline.diff @@ -0,0 +1,76 @@ +--- old.smartSelection_JSDocTags11.baseline ++++ new.smartSelection_JSDocTags11.baseline +@@= skipped -4, +4 lines =@@ + /**/readonly status: number; + }; + +- +- readonly +- +- +- readonly status +- +- +- readonly status: number; +- +- +- /** comment */ +- readonly status: number; +- +- +- ↲ +-••/** comment */ ++ readonly ↲ + readonly status: number;↲ +- +- + { + /** comment */ + readonly status: number; + } +- + type Foo = { + /** comment */ + readonly status: number; + }; +- + const x = 1; + type Foo = { + /** comment */ +@@= skipped -43, +24 lines =@@ + readonly /**/status: number; + }; + +- +- status +- +- +- readonly status +- +- +- readonly status: number; +- +- +- /** comment */ +- readonly status: number; +- +- +- ↲ +-••/** comment */ ++ status ↲ + readonly status: number;↲ +- +- + { + /** comment */ + readonly status: number; + } +- + type Foo = { + /** comment */ + readonly status: number; + }; +- + const x = 1; + type Foo = { + /** comment */ \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags12.baseline b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags12.baseline new file mode 100644 index 0000000000..90e0a2ef61 --- /dev/null +++ b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags12.baseline @@ -0,0 +1,64 @@ +// === Smart Selection === +type B = {}; +type A = { + a(/** Comment */ /**/p0: number, /** Comment */ p1: number, /** Comment */ p2: number): string; +}; + + p0 ↲ + p0: number ↲ + p0: number, /** Comment */ p1: number, /** Comment */ p2: number ↲ + a(/** Comment */ p0: number, /** Comment */ p1: number, /** Comment */ p2: number): string;↲ + { + a(/** Comment */ p0: number, /** Comment */ p1: number, /** Comment */ p2: number): string; +} +type A = { + a(/** Comment */ p0: number, /** Comment */ p1: number, /** Comment */ p2: number): string; +}; +type B = {}; +type A = { + a(/** Comment */ p0: number, /** Comment */ p1: number, /** Comment */ p2: number): string; +}; + +================================================================================ + +type B = {}; +type A = { + a(/** Comment */ p0: number, /** Comment */ /**/p1: number, /** Comment */ p2: number): string; +}; + + p1 ↲ + p1: number ↲ + p0: number, /** Comment */ p1: number, /** Comment */ p2: number ↲ + a(/** Comment */ p0: number, /** Comment */ p1: number, /** Comment */ p2: number): string;↲ + { + a(/** Comment */ p0: number, /** Comment */ p1: number, /** Comment */ p2: number): string; +} +type A = { + a(/** Comment */ p0: number, /** Comment */ p1: number, /** Comment */ p2: number): string; +}; +type B = {}; +type A = { + a(/** Comment */ p0: number, /** Comment */ p1: number, /** Comment */ p2: number): string; +}; + +================================================================================ + +type B = {}; +type A = { + a(/** Comment */ p0: number, /** Comment */ p1: number, /** Comment */ /**/p2: number): string; +}; + + p2 ↲ + p2: number ↲ + p0: number, /** Comment */ p1: number, /** Comment */ p2: number ↲ + a(/** Comment */ p0: number, /** Comment */ p1: number, /** Comment */ p2: number): string;↲ + { + a(/** Comment */ p0: number, /** Comment */ p1: number, /** Comment */ p2: number): string; +} +type A = { + a(/** Comment */ p0: number, /** Comment */ p1: number, /** Comment */ p2: number): string; +}; +type B = {}; +type A = { + a(/** Comment */ p0: number, /** Comment */ p1: number, /** Comment */ p2: number): string; +}; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags12.baseline.diff b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags12.baseline.diff new file mode 100644 index 0000000000..478a71307a --- /dev/null +++ b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags12.baseline.diff @@ -0,0 +1,119 @@ +--- old.smartSelection_JSDocTags12.baseline ++++ new.smartSelection_JSDocTags12.baseline +@@= skipped -3, +3 lines =@@ + a(/** Comment */ /**/p0: number, /** Comment */ p1: number, /** Comment */ p2: number): string; + }; + +- +- p0 +- +- +- p0: number +- +- +- /** Comment */ p0: number +- +- +- /** Comment */ p0: number, /** Comment */ p1: number, /** Comment */ p2: number +- +- +- a(/** Comment */ p0: number, /** Comment */ p1: number, /** Comment */ p2: number): string; +- +- +- ↲ +-••••a(/** Comment */ p0: number, /** Comment */ p1: number, /** Comment */ p2: number): string;↲ +- +- ++ p0 ↲ ++ p0: number ↲ ++ p0: number, /** Comment */ p1: number, /** Comment */ p2: number ↲ ++ a(/** Comment */ p0: number, /** Comment */ p1: number, /** Comment */ p2: number): string;↲ + { + a(/** Comment */ p0: number, /** Comment */ p1: number, /** Comment */ p2: number): string; + } +- + type A = { + a(/** Comment */ p0: number, /** Comment */ p1: number, /** Comment */ p2: number): string; + }; +- + type B = {}; + type A = { + a(/** Comment */ p0: number, /** Comment */ p1: number, /** Comment */ p2: number): string; +@@= skipped -40, +22 lines =@@ + a(/** Comment */ p0: number, /** Comment */ /**/p1: number, /** Comment */ p2: number): string; + }; + +- +- p1 +- +- +- p1: number +- +- +- /** Comment */ p1: number +- +- +- /** Comment */ p0: number, /** Comment */ p1: number, /** Comment */ p2: number +- +- +- a(/** Comment */ p0: number, /** Comment */ p1: number, /** Comment */ p2: number): string; +- +- +- ↲ +-••••a(/** Comment */ p0: number, /** Comment */ p1: number, /** Comment */ p2: number): string;↲ +- +- ++ p1 ↲ ++ p1: number ↲ ++ p0: number, /** Comment */ p1: number, /** Comment */ p2: number ↲ ++ a(/** Comment */ p0: number, /** Comment */ p1: number, /** Comment */ p2: number): string;↲ + { + a(/** Comment */ p0: number, /** Comment */ p1: number, /** Comment */ p2: number): string; + } +- + type A = { + a(/** Comment */ p0: number, /** Comment */ p1: number, /** Comment */ p2: number): string; + }; +- + type B = {}; + type A = { + a(/** Comment */ p0: number, /** Comment */ p1: number, /** Comment */ p2: number): string; +@@= skipped -40, +22 lines =@@ + a(/** Comment */ p0: number, /** Comment */ p1: number, /** Comment */ /**/p2: number): string; + }; + +- +- p2 +- +- +- p2: number +- +- +- /** Comment */ p2: number +- +- +- /** Comment */ p0: number, /** Comment */ p1: number, /** Comment */ p2: number +- +- +- a(/** Comment */ p0: number, /** Comment */ p1: number, /** Comment */ p2: number): string; +- +- +- ↲ +-••••a(/** Comment */ p0: number, /** Comment */ p1: number, /** Comment */ p2: number): string;↲ +- +- ++ p2 ↲ ++ p2: number ↲ ++ p0: number, /** Comment */ p1: number, /** Comment */ p2: number ↲ ++ a(/** Comment */ p0: number, /** Comment */ p1: number, /** Comment */ p2: number): string;↲ + { + a(/** Comment */ p0: number, /** Comment */ p1: number, /** Comment */ p2: number): string; + } +- + type A = { + a(/** Comment */ p0: number, /** Comment */ p1: number, /** Comment */ p2: number): string; + }; +- + type B = {}; + type A = { + a(/** Comment */ p0: number, /** Comment */ p1: number, /** Comment */ p2: number): string; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags13.baseline b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags13.baseline new file mode 100644 index 0000000000..de02bad534 --- /dev/null +++ b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags13.baseline @@ -0,0 +1,97 @@ +// === Smart Selection === +let a; +let b: { + /** Comment */ /**/p0: number + /** Comment */ p1: number + /** Comment */ p2: number +}; +let c; + + p0 ↲ + p0: number↲ + p0: number + /** Comment */ p1: number + /** Comment */ p2: number↲ + { + /** Comment */ p0: number + /** Comment */ p1: number + /** Comment */ p2: number +} ↲ +let b: { + /** Comment */ p0: number + /** Comment */ p1: number + /** Comment */ p2: number +};↲ +let a; +let b: { + /** Comment */ p0: number + /** Comment */ p1: number + /** Comment */ p2: number +}; +let c; + +================================================================================ + +let a; +let b: { + /** Comment */ p0: number + /** Comment */ /**/p1: number + /** Comment */ p2: number +}; +let c; + + p1 ↲ + p1: number↲ + p0: number + /** Comment */ p1: number + /** Comment */ p2: number↲ + { + /** Comment */ p0: number + /** Comment */ p1: number + /** Comment */ p2: number +} ↲ +let b: { + /** Comment */ p0: number + /** Comment */ p1: number + /** Comment */ p2: number +};↲ +let a; +let b: { + /** Comment */ p0: number + /** Comment */ p1: number + /** Comment */ p2: number +}; +let c; + +================================================================================ + +let a; +let b: { + /** Comment */ p0: number + /** Comment */ p1: number + /** Comment */ /**/p2: number +}; +let c; + + p2 ↲ + p2: number↲ + p0: number + /** Comment */ p1: number + /** Comment */ p2: number↲ + { + /** Comment */ p0: number + /** Comment */ p1: number + /** Comment */ p2: number +} ↲ +let b: { + /** Comment */ p0: number + /** Comment */ p1: number + /** Comment */ p2: number +};↲ +let a; +let b: { + /** Comment */ p0: number + /** Comment */ p1: number + /** Comment */ p2: number +}; +let c; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags13.baseline.diff b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags13.baseline.diff new file mode 100644 index 0000000000..948731287e --- /dev/null +++ b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags13.baseline.diff @@ -0,0 +1,127 @@ +--- old.smartSelection_JSDocTags13.baseline ++++ new.smartSelection_JSDocTags13.baseline +@@= skipped -6, +6 lines =@@ + }; + let c; + +- +- p0 +- +- ++ p0 ↲ ++ p0: number↲ + p0: number +- +- +- /** Comment */ p0: number +- +- +- ↲ +-••••/** Comment */ p0: number + /** Comment */ p1: number + /** Comment */ p2: number↲ +- +- + { + /** Comment */ p0: number + /** Comment */ p1: number + /** Comment */ p2: number +-} +- +- ++} ↲ + let b: { + /** Comment */ p0: number + /** Comment */ p1: number + /** Comment */ p2: number +-}; +- +- ++};↲ + let a; + let b: { + /** Comment */ p0: number +@@= skipped -48, +33 lines =@@ + }; + let c; + +- +- p1 +- +- +- p1: number +- +- +- /** Comment */ p1: number +- +- +- ↲ +-••••/** Comment */ p0: number ++ p1 ↲ ++ p1: number↲ ++ p0: number + /** Comment */ p1: number + /** Comment */ p2: number↲ +- +- + { + /** Comment */ p0: number + /** Comment */ p1: number + /** Comment */ p2: number +-} +- +- ++} ↲ + let b: { + /** Comment */ p0: number + /** Comment */ p1: number + /** Comment */ p2: number +-}; +- +- ++};↲ + let a; + let b: { + /** Comment */ p0: number +@@= skipped -48, +33 lines =@@ + }; + let c; + +- +- p2 +- +- +- p2: number +- +- +- /** Comment */ p2: number +- +- +- ↲ +-••••/** Comment */ p0: number ++ p2 ↲ ++ p2: number↲ ++ p0: number + /** Comment */ p1: number + /** Comment */ p2: number↲ +- +- + { + /** Comment */ p0: number + /** Comment */ p1: number + /** Comment */ p2: number +-} +- +- ++} ↲ + let b: { + /** Comment */ p0: number + /** Comment */ p1: number + /** Comment */ p2: number +-}; +- +- ++};↲ + let a; + let b: { + /** Comment */ p0: number \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags2.baseline b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags2.baseline new file mode 100644 index 0000000000..5366fbf6b8 --- /dev/null +++ b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags2.baseline @@ -0,0 +1,10 @@ +// === Smart Selection === +/** + * @type {/**/string} + */ +const foo; + +/** + * @type {string} + */ +const foo; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags2.baseline.diff b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags2.baseline.diff new file mode 100644 index 0000000000..d13840b84f --- /dev/null +++ b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags2.baseline.diff @@ -0,0 +1,22 @@ +--- old.smartSelection_JSDocTags2.baseline ++++ new.smartSelection_JSDocTags2.baseline +@@= skipped -3, +3 lines =@@ + */ + const foo; + +- +- string +- +- +- @type {string}↲ +-• +- +- +-/** +- * @type {string} +- */ +- +- + /** + * @type {string} + */ \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags3.baseline b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags3.baseline new file mode 100644 index 0000000000..d614907474 --- /dev/null +++ b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags3.baseline @@ -0,0 +1,10 @@ +// === Smart Selection === +/** + * @param {/**/string} x + */ +function foo(x) {} + +/** + * @param {string} x + */ +function foo(x) {} \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags3.baseline.diff b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags3.baseline.diff new file mode 100644 index 0000000000..81fee0ceab --- /dev/null +++ b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags3.baseline.diff @@ -0,0 +1,21 @@ +--- old.smartSelection_JSDocTags3.baseline ++++ new.smartSelection_JSDocTags3.baseline +@@= skipped -3, +3 lines =@@ + */ + function foo(x) {} + +- +- string +- +- +- @param {string} x +- +- +-/** +- * @param {string} x +- */ +- +- + /** + * @param {string} x + */ \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags4.baseline b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags4.baseline new file mode 100644 index 0000000000..647d420d6e --- /dev/null +++ b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags4.baseline @@ -0,0 +1,19 @@ +// === Smart Selection === +/** + * @typedef {object} Foo + * @property {string} a + * @property {number} b + * @property {/**/number} c + */ + +/** @type {Foo} */ +const foo; + +/** + * @typedef {object} Foo + * @property {string} a + * @property {number} b + * @property {number} c + */ +/** @type {Foo} */ +const foo; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags4.baseline.diff b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags4.baseline.diff new file mode 100644 index 0000000000..c680483a45 --- /dev/null +++ b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags4.baseline.diff @@ -0,0 +1,36 @@ +--- old.smartSelection_JSDocTags4.baseline ++++ new.smartSelection_JSDocTags4.baseline +@@= skipped -8, +8 lines =@@ + /** @type {Foo} */ + const foo; + +- +- number +- +- +- @property {number} c +- +- +-/** +- * @typedef {object} Foo +- * @property {string} a +- * @property {number} b +- * @property {number} c +- */ +- +- +-/** +- * @typedef {object} Foo +- * @property {string} a +- * @property {number} b +- * @property {number} c +- */ +- ++/** ++ * @typedef {object} Foo ++ * @property {string} a ++ * @property {number} b ++ * @property {number} c ++ */ + /** @type {Foo} */ + const foo; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags5.baseline b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags5.baseline new file mode 100644 index 0000000000..fb9ed36519 --- /dev/null +++ b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags5.baseline @@ -0,0 +1,19 @@ +// === Smart Selection === +/** + * @callback Foo + * @param {string} data + * @param {/**/number} [index] - comment + * @return {boolean} + */ + +/** @type {Foo} */ +const foo = s => !(s.length % 2); + +/** + * @callback Foo + * @param {string} data + * @param {number} [index] - comment + * @return {boolean} + */ +/** @type {Foo} */ +const foo = s => !(s.length % 2); \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags5.baseline.diff b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags5.baseline.diff new file mode 100644 index 0000000000..a6e08c9ac1 --- /dev/null +++ b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags5.baseline.diff @@ -0,0 +1,36 @@ +--- old.smartSelection_JSDocTags5.baseline ++++ new.smartSelection_JSDocTags5.baseline +@@= skipped -8, +8 lines =@@ + /** @type {Foo} */ + const foo = s => !(s.length % 2); + +- +- number +- +- +- @param {number} [index] - comment +- +- +-/** +- * @callback Foo +- * @param {string} data +- * @param {number} [index] - comment +- * @return {boolean} +- */ +- +- +-/** +- * @callback Foo +- * @param {string} data +- * @param {number} [index] - comment +- * @return {boolean} +- */ +- ++/** ++ * @callback Foo ++ * @param {string} data ++ * @param {number} [index] - comment ++ * @return {boolean} ++ */ + /** @type {Foo} */ + const foo = s => !(s.length % 2); \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags6.baseline b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags6.baseline new file mode 100644 index 0000000000..ffcaf36145 --- /dev/null +++ b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags6.baseline @@ -0,0 +1,18 @@ +// === Smart Selection === +/** + * @template T + * @param {/**/T} x + * @return {T} + */ +function foo(x) { + return x; +} + +/** + * @template T + * @param {T} x + * @return {T} + */ +function foo(x) { + return x; +} \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags6.baseline.diff b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags6.baseline.diff new file mode 100644 index 0000000000..d0565c2661 --- /dev/null +++ b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags6.baseline.diff @@ -0,0 +1,23 @@ +--- old.smartSelection_JSDocTags6.baseline ++++ new.smartSelection_JSDocTags6.baseline +@@= skipped -7, +7 lines =@@ + return x; + } + +- +- T +- +- +- @param {T} x +- +- +-/** +- * @template T +- * @param {T} x +- * @return {T} +- */ +- +- + /** + * @template T + * @param {T} x \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags7.baseline b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags7.baseline new file mode 100644 index 0000000000..3fb81ec55c --- /dev/null +++ b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags7.baseline @@ -0,0 +1,14 @@ +// === Smart Selection === +/** + * @constructor + * @param {/**/number} data + */ +function Foo(data) { +} + +/** + * @constructor + * @param {number} data + */ +function Foo(data) { +} \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags7.baseline.diff b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags7.baseline.diff new file mode 100644 index 0000000000..dfa174419a --- /dev/null +++ b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags7.baseline.diff @@ -0,0 +1,22 @@ +--- old.smartSelection_JSDocTags7.baseline ++++ new.smartSelection_JSDocTags7.baseline +@@= skipped -5, +5 lines =@@ + function Foo(data) { + } + +- +- number +- +- +- @param {number} data +- +- +-/** +- * @constructor +- * @param {number} data +- */ +- +- + /** + * @constructor + * @param {number} data \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags8.baseline b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags8.baseline new file mode 100644 index 0000000000..85c97449ff --- /dev/null +++ b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags8.baseline @@ -0,0 +1,30 @@ +// === Smart Selection === +/** + * @this {/**/Foo} + * @param {*} e + */ +function callback(e) { +} + +/** + * @this {Foo} + * @param {*} e + */ +function callback(e) { +} + +================================================================================ + +/** + * @this {Foo} + * @param {/**/*} e + */ +function callback(e) { +} + +/** + * @this {Foo} + * @param {*} e + */ +function callback(e) { +} \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags8.baseline.diff b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags8.baseline.diff new file mode 100644 index 0000000000..210116bddb --- /dev/null +++ b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags8.baseline.diff @@ -0,0 +1,42 @@ +--- old.smartSelection_JSDocTags8.baseline ++++ new.smartSelection_JSDocTags8.baseline +@@= skipped -5, +5 lines =@@ + function callback(e) { + } + +- +- Foo +- +- +- @this {Foo} +- +- +-/** +- * @this {Foo} +- * @param {*} e +- */ +- +- + /** + * @this {Foo} + * @param {*} e +@@= skipped -28, +15 lines =@@ + */ + function callback(e) { + } +- +- +- * +- +- +- @param {*} e +- +- +-/** +- * @this {Foo} +- * @param {*} e +- */ +- + + /** + * @this {Foo} \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags9.baseline b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags9.baseline new file mode 100644 index 0000000000..d45f3e26f5 --- /dev/null +++ b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags9.baseline @@ -0,0 +1,12 @@ +// === Smart Selection === +/** @enum {/**/number} */ +const Foo = { + x: 0, + y: 1, +}; + +/** @enum {number} */ +const Foo = { + x: 0, + y: 1, +}; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags9.baseline.diff b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags9.baseline.diff new file mode 100644 index 0000000000..678d48b2e4 --- /dev/null +++ b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags9.baseline.diff @@ -0,0 +1,19 @@ +--- old.smartSelection_JSDocTags9.baseline ++++ new.smartSelection_JSDocTags9.baseline +@@= skipped -4, +4 lines =@@ + y: 1, + }; + +- +- number +- +- +- @enum {number}• +- +- +-/** @enum {number} */ +- +- + /** @enum {number} */ + const Foo = { + x: 0, \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_behindCaret.baseline b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_behindCaret.baseline new file mode 100644 index 0000000000..5bbf265e58 --- /dev/null +++ b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_behindCaret.baseline @@ -0,0 +1,4 @@ +// === Smart Selection === +let/**/ x: string + +let x: string \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_behindCaret.baseline.diff b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_behindCaret.baseline.diff new file mode 100644 index 0000000000..ddbddf3615 --- /dev/null +++ b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_behindCaret.baseline.diff @@ -0,0 +1,8 @@ +--- old.smartSelection_behindCaret.baseline ++++ new.smartSelection_behindCaret.baseline +@@= skipped -0, +0 lines =@@ + // === Smart Selection === + let/**/ x: string + +-let + let x: string \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_bindingPatterns.baseline b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_bindingPatterns.baseline new file mode 100644 index 0000000000..d6110452ef --- /dev/null +++ b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_bindingPatterns.baseline @@ -0,0 +1,27 @@ +// === Smart Selection === +const { /**/x, y: a, ...zs = {} } = {}; + + x + x, y: a, ...zs = {} + { x, y: a, ...zs = {} } +const { x, y: a, ...zs = {} } = {}; + +================================================================================ + +const { x, y: /**/a, ...zs = {} } = {}; + + a + y: a + x, y: a, ...zs = {} + { x, y: a, ...zs = {} } +const { x, y: a, ...zs = {} } = {}; + +================================================================================ + +const { x, y: a, .../**/zs = {} } = {}; + + zs + ...zs = {} + x, y: a, ...zs = {} + { x, y: a, ...zs = {} } +const { x, y: a, ...zs = {} } = {}; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_bindingPatterns.baseline.diff b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_bindingPatterns.baseline.diff new file mode 100644 index 0000000000..501f81c821 --- /dev/null +++ b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_bindingPatterns.baseline.diff @@ -0,0 +1,10 @@ +--- old.smartSelection_bindingPatterns.baseline ++++ new.smartSelection_bindingPatterns.baseline +@@= skipped -20, +20 lines =@@ + const { x, y: a, .../**/zs = {} } = {}; + + zs +- ...zs + ...zs = {} + x, y: a, ...zs = {} + { x, y: a, ...zs = {} } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_comment1.baseline b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_comment1.baseline new file mode 100644 index 0000000000..241a69dc06 --- /dev/null +++ b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_comment1.baseline @@ -0,0 +1,4 @@ +// === Smart Selection === +const a = 1; ///**/comment content + +const a = 1; //comment content \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_comment1.baseline.diff b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_comment1.baseline.diff new file mode 100644 index 0000000000..68eea77d85 --- /dev/null +++ b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_comment1.baseline.diff @@ -0,0 +1,9 @@ +--- old.smartSelection_comment1.baseline ++++ new.smartSelection_comment1.baseline +@@= skipped -0, +0 lines =@@ + // === Smart Selection === + const a = 1; ///**/comment content + +- comment content +- //comment content + const a = 1; //comment content \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_comment2.baseline b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_comment2.baseline new file mode 100644 index 0000000000..b89c3c096a --- /dev/null +++ b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_comment2.baseline @@ -0,0 +1,4 @@ +// === Smart Selection === +const a = 1; //a b/**/c d + +const a = 1; //a bc d \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_comment2.baseline.diff b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_comment2.baseline.diff new file mode 100644 index 0000000000..1f7b9c0348 --- /dev/null +++ b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_comment2.baseline.diff @@ -0,0 +1,9 @@ +--- old.smartSelection_comment2.baseline ++++ new.smartSelection_comment2.baseline +@@= skipped -0, +0 lines =@@ + // === Smart Selection === + const a = 1; //a b/**/c d + +- a bc d +- //a bc d + const a = 1; //a bc d \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_complex.baseline b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_complex.baseline new file mode 100644 index 0000000000..f844df6a1d --- /dev/null +++ b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_complex.baseline @@ -0,0 +1,12 @@ +// === Smart Selection === +type X = IsExactlyAny

extends true ? T : ({ [K in keyof P]: IsExactlyAny extends true ? K extends keyof T ? T[K] : P[/**/K] : P[K]; } & Pick>) + + K + P[K] + K extends keyof T ? T[K] : P[K] + IsExactlyAny extends true ? K extends keyof T ? T[K] : P[K] : P[K] + { [K in keyof P]: IsExactlyAny extends true ? K extends keyof T ? T[K] : P[K] : P[K]; } + { [K in keyof P]: IsExactlyAny extends true ? K extends keyof T ? T[K] : P[K] : P[K]; } & Pick> + ({ [K in keyof P]: IsExactlyAny extends true ? K extends keyof T ? T[K] : P[K] : P[K]; } & Pick>) + IsExactlyAny

extends true ? T : ({ [K in keyof P]: IsExactlyAny extends true ? K extends keyof T ? T[K] : P[K] : P[K]; } & Pick>) +type X = IsExactlyAny

extends true ? T : ({ [K in keyof P]: IsExactlyAny extends true ? K extends keyof T ? T[K] : P[K] : P[K]; } & Pick>) \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_complex.baseline.diff b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_complex.baseline.diff new file mode 100644 index 0000000000..940e0969cb --- /dev/null +++ b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_complex.baseline.diff @@ -0,0 +1,11 @@ +--- old.smartSelection_complex.baseline ++++ new.smartSelection_complex.baseline +@@= skipped -4, +4 lines =@@ + P[K] + K extends keyof T ? T[K] : P[K] + IsExactlyAny extends true ? K extends keyof T ? T[K] : P[K] : P[K] +- IsExactlyAny extends true ? K extends keyof T ? T[K] : P[K] : P[K]; +- [K in keyof P]: IsExactlyAny extends true ? K extends keyof T ? T[K] : P[K] : P[K]; + { [K in keyof P]: IsExactlyAny extends true ? K extends keyof T ? T[K] : P[K] : P[K]; } + { [K in keyof P]: IsExactlyAny extends true ? K extends keyof T ? T[K] : P[K] : P[K]; } & Pick> + ({ [K in keyof P]: IsExactlyAny extends true ? K extends keyof T ? T[K] : P[K] : P[K]; } & Pick>) \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_emptyRanges.baseline b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_emptyRanges.baseline new file mode 100644 index 0000000000..75438a7fc1 --- /dev/null +++ b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_emptyRanges.baseline @@ -0,0 +1,85 @@ +// === Smart Selection === +class HomePage { + componentDidMount(/**/) { + if (this.props.username) { + return ''; + } + } +} + + componentDidMount() { + if (this.props.username) { + return ''; + } + }↲ +class HomePage { + componentDidMount() { + if (this.props.username) { + return ''; + } + } +} + +================================================================================ + +class HomePage { + componentDidMount() { + if (this.props.username/**/) { + return ''; + } + } +} + + if (this.props.username) { + return ''; + }↲ + { + if (this.props.username) { + return ''; + } + }↲ + componentDidMount() { + if (this.props.username) { + return ''; + } + }↲ +class HomePage { + componentDidMount() { + if (this.props.username) { + return ''; + } + } +} + +================================================================================ + +class HomePage { + componentDidMount() { + if (this.props.username) { + return '/**/'; + } + } +} + + '' ↲ + return '';↲ + if (this.props.username) { + return ''; + }↲ + { + if (this.props.username) { + return ''; + } + }↲ + componentDidMount() { + if (this.props.username) { + return ''; + } + }↲ +class HomePage { + componentDidMount() { + if (this.props.username) { + return ''; + } + } +} \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_emptyRanges.baseline.diff b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_emptyRanges.baseline.diff new file mode 100644 index 0000000000..270dbbf9a9 --- /dev/null +++ b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_emptyRanges.baseline.diff @@ -0,0 +1,133 @@ +--- old.smartSelection_emptyRanges.baseline ++++ new.smartSelection_emptyRanges.baseline +@@= skipped -6, +6 lines =@@ + } + } + +- +- ) +- +- + componentDidMount() { + if (this.props.username) { + return ''; + } +- } +- +- +- ↲ +-••componentDidMount() { +- if (this.props.username) { +- return ''; +- } + }↲ +- +- + class HomePage { + componentDidMount() { + if (this.props.username) { +@@= skipped -37, +23 lines =@@ + } + } + +- +- username +- +- +- this.props.username +- +- + if (this.props.username) { +- return ''; +- } +- +- +- ↲ +-••••if (this.props.username) { + return ''; + }↲ +-•• +- +- + { + if (this.props.username) { + return ''; + } +- } +- +- ++ }↲ + componentDidMount() { + if (this.props.username) { + return ''; + } +- } +- +- +- ↲ +-••componentDidMount() { +- if (this.props.username) { +- return ''; +- } + }↲ +- +- + class HomePage { + componentDidMount() { + if (this.props.username) { +@@= skipped -59, +31 lines =@@ + } + } + +- +- '' +- +- +- return ''; +- +- +- ↲ +-••••••return '';↲ +-•••• +- +- ++ '' ↲ ++ return '';↲ + if (this.props.username) { +- return ''; +- } +- +- +- ↲ +-••••if (this.props.username) { + return ''; + }↲ +-•• +- +- + { + if (this.props.username) { + return ''; + } +- } +- +- ++ }↲ + componentDidMount() { + if (this.props.username) { + return ''; + } +- } +- +- +- ↲ +-••componentDidMount() { +- if (this.props.username) { +- return ''; +- } + }↲ +- +- + class HomePage { + componentDidMount() { + if (this.props.username) { \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_function1.baseline b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_function1.baseline new file mode 100644 index 0000000000..2a50431eef --- /dev/null +++ b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_function1.baseline @@ -0,0 +1,14 @@ +// === Smart Selection === +const f1 = () => { + /**/ +}; + + { + +} + () => { + +} +const f1 = () => { + +}; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_function1.baseline.diff b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_function1.baseline.diff new file mode 100644 index 0000000000..a3efa8b753 --- /dev/null +++ b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_function1.baseline.diff @@ -0,0 +1,18 @@ +--- old.smartSelection_function1.baseline ++++ new.smartSelection_function1.baseline +@@= skipped -2, +2 lines =@@ + /**/ + }; + +- + { + + } +- + () => { + + } +- + const f1 = () => { + + }; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_function2.baseline b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_function2.baseline new file mode 100644 index 0000000000..def3bc1703 --- /dev/null +++ b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_function2.baseline @@ -0,0 +1,11 @@ +// === Smart Selection === +function f2() { + /**/ +} + + { + +} +function f2() { + +} \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_function2.baseline.diff b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_function2.baseline.diff new file mode 100644 index 0000000000..a18698b35d --- /dev/null +++ b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_function2.baseline.diff @@ -0,0 +1,14 @@ +--- old.smartSelection_function2.baseline ++++ new.smartSelection_function2.baseline +@@= skipped -2, +2 lines =@@ + /**/ + } + +- + { + + } +- + function f2() { + + } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_function3.baseline b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_function3.baseline new file mode 100644 index 0000000000..ca8a14e884 --- /dev/null +++ b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_function3.baseline @@ -0,0 +1,14 @@ +// === Smart Selection === +const f3 = function () { + /**/ +} + + { + +} + function () { + +} +const f3 = function () { + +} \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_function3.baseline.diff b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_function3.baseline.diff new file mode 100644 index 0000000000..eeb1265fb5 --- /dev/null +++ b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_function3.baseline.diff @@ -0,0 +1,18 @@ +--- old.smartSelection_function3.baseline ++++ new.smartSelection_function3.baseline +@@= skipped -2, +2 lines =@@ + /**/ + } + +- + { + + } +- + function () { + + } +- + const f3 = function () { + + } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_functionParams1.baseline b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_functionParams1.baseline new file mode 100644 index 0000000000..b09fe5cf38 --- /dev/null +++ b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_functionParams1.baseline @@ -0,0 +1,24 @@ +// === Smart Selection === +function f(/**/p, q?, ...r: any[] = []) {} + + p + p, q?, ...r: any[] = [] +function f(p, q?, ...r: any[] = []) {} + +================================================================================ + +function f(p, /**/q?, ...r: any[] = []) {} + + q + q? + p, q?, ...r: any[] = [] +function f(p, q?, ...r: any[] = []) {} + +================================================================================ + +function f(p, q?, /**/...r: any[] = []) {} + + ... + ...r: any[] = [] + p, q?, ...r: any[] = [] +function f(p, q?, ...r: any[] = []) {} \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_functionParams1.baseline.diff b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_functionParams1.baseline.diff new file mode 100644 index 0000000000..e16b3ff653 --- /dev/null +++ b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_functionParams1.baseline.diff @@ -0,0 +1,11 @@ +--- old.smartSelection_functionParams1.baseline ++++ new.smartSelection_functionParams1.baseline +@@= skipped -18, +18 lines =@@ + function f(p, q?, /**/...r: any[] = []) {} + + ... +- ...r +- ...r: any[] + ...r: any[] = [] + p, q?, ...r: any[] = [] + function f(p, q?, ...r: any[] = []) {} \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_functionParams2.baseline b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_functionParams2.baseline new file mode 100644 index 0000000000..130a434904 --- /dev/null +++ b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_functionParams2.baseline @@ -0,0 +1,13 @@ +// === Smart Selection === +function f( + a, + /**/b +) {} + + b↲ + a, + b↲ +function f( + a, + b +) {} \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_functionParams2.baseline.diff b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_functionParams2.baseline.diff new file mode 100644 index 0000000000..bf421d0628 --- /dev/null +++ b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_functionParams2.baseline.diff @@ -0,0 +1,21 @@ +--- old.smartSelection_functionParams2.baseline ++++ new.smartSelection_functionParams2.baseline +@@= skipped -3, +3 lines =@@ + /**/b + ) {} + +- +- b +- +- +- ↲ +-••a, +- b↲ +- +- ++ b↲ ++ a, ++ b↲ + function f( + a, + b \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_imports.baseline b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_imports.baseline new file mode 100644 index 0000000000..22f95170ab --- /dev/null +++ b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_imports.baseline @@ -0,0 +1,14 @@ +// === Smart Selection === +import { /**/x as y, z } from './z'; +import { b } from './'; + +console.log(1); + + x ↲ + x as y ↲ + x as y, z ↲ + { x as y, z } ↲ +import { x as y, z } from './z';↲ +import { x as y, z } from './z'; +import { b } from './'; +console.log(1); \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_imports.baseline.diff b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_imports.baseline.diff new file mode 100644 index 0000000000..ed989358fb --- /dev/null +++ b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_imports.baseline.diff @@ -0,0 +1,37 @@ +--- old.smartSelection_imports.baseline ++++ new.smartSelection_imports.baseline +@@= skipped -3, +3 lines =@@ + + console.log(1); + +- +- x +- +- +- x as y +- +- +- x as y, z +- +- +- { x as y, z } +- +- +-import { x as y, z } from './z'; +- +- +-import { x as y, z } from './z'; +-import { b } from './'; +- +- +-import { x as y, z } from './z'; +-import { b } from './'; +- ++ x ↲ ++ x as y ↲ ++ x as y, z ↲ ++ { x as y, z } ↲ ++import { x as y, z } from './z';↲ ++import { x as y, z } from './z'; ++import { b } from './'; + console.log(1); \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_lastBlankLine.baseline b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_lastBlankLine.baseline new file mode 100644 index 0000000000..ad833f2342 --- /dev/null +++ b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_lastBlankLine.baseline @@ -0,0 +1,5 @@ +// === Smart Selection === +class C {} +/**/ + +class C {}↲ \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_lastBlankLine.baseline.diff b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_lastBlankLine.baseline.diff new file mode 100644 index 0000000000..70c334f791 --- /dev/null +++ b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_lastBlankLine.baseline.diff @@ -0,0 +1,8 @@ +--- old.smartSelection_lastBlankLine.baseline ++++ new.smartSelection_lastBlankLine.baseline +@@= skipped -1, +1 lines =@@ + class C {} + /**/ + +- + class C {}↲ \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_loneVariableDeclaration.baseline b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_loneVariableDeclaration.baseline new file mode 100644 index 0000000000..c1151f045f --- /dev/null +++ b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_loneVariableDeclaration.baseline @@ -0,0 +1,5 @@ +// === Smart Selection === +const /**/x = 3; + + x +const x = 3; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_mappedTypes.baseline b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_mappedTypes.baseline new file mode 100644 index 0000000000..e7f008d407 --- /dev/null +++ b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_mappedTypes.baseline @@ -0,0 +1,44 @@ +// === Smart Selection === +type M = { /**/-readonly [K in keyof any]-?: any }; + + - + { -readonly [K in keyof any]-?: any } +type M = { -readonly [K in keyof any]-?: any }; + +================================================================================ + +type M = { -re/**/adonly [K in keyof any]-?: any }; + + { -readonly [K in keyof any]-?: any } +type M = { -readonly [K in keyof any]-?: any }; + +================================================================================ + +type M = { -readonly /**/[K in keyof any]-?: any }; + + { -readonly [K in keyof any]-?: any } +type M = { -readonly [K in keyof any]-?: any }; + +================================================================================ + +type M = { -readonly [K in ke/**/yof any]-?: any }; + + keyof any + K in keyof any + { -readonly [K in keyof any]-?: any } +type M = { -readonly [K in keyof any]-?: any }; + +================================================================================ + +type M = { -readonly [K in keyof any]/**/-?: any }; + + - + { -readonly [K in keyof any]-?: any } +type M = { -readonly [K in keyof any]-?: any }; + +================================================================================ + +type M = { -readonly [K in keyof any]-/**/?: any }; + + { -readonly [K in keyof any]-?: any } +type M = { -readonly [K in keyof any]-?: any }; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_mappedTypes.baseline.diff b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_mappedTypes.baseline.diff new file mode 100644 index 0000000000..5a6c3570d4 --- /dev/null +++ b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_mappedTypes.baseline.diff @@ -0,0 +1,67 @@ +--- old.smartSelection_mappedTypes.baseline ++++ new.smartSelection_mappedTypes.baseline +@@= skipped -1, +1 lines =@@ + type M = { /**/-readonly [K in keyof any]-?: any }; + + - +- -readonly +- -readonly [K in keyof any]-? +- -readonly [K in keyof any]-?: any + { -readonly [K in keyof any]-?: any } + type M = { -readonly [K in keyof any]-?: any }; + +@@= skipped -10, +7 lines =@@ + + type M = { -re/**/adonly [K in keyof any]-?: any }; + +- readonly +- -readonly +- -readonly [K in keyof any]-? +- -readonly [K in keyof any]-?: any + { -readonly [K in keyof any]-?: any } + type M = { -readonly [K in keyof any]-?: any }; + +@@= skipped -11, +7 lines =@@ + + type M = { -readonly /**/[K in keyof any]-?: any }; + +- [ +- [K in keyof any] +- -readonly [K in keyof any]-? +- -readonly [K in keyof any]-?: any + { -readonly [K in keyof any]-?: any } + type M = { -readonly [K in keyof any]-?: any }; + +@@= skipped -11, +7 lines =@@ + + type M = { -readonly [K in ke/**/yof any]-?: any }; + +- keyof + keyof any + K in keyof any +- [K in keyof any] +- -readonly [K in keyof any]-? +- -readonly [K in keyof any]-?: any + { -readonly [K in keyof any]-?: any } + type M = { -readonly [K in keyof any]-?: any }; + +@@= skipped -14, +10 lines =@@ + type M = { -readonly [K in keyof any]/**/-?: any }; + + - +- -? +- -readonly [K in keyof any]-? +- -readonly [K in keyof any]-?: any + { -readonly [K in keyof any]-?: any } + type M = { -readonly [K in keyof any]-?: any }; + +@@= skipped -10, +7 lines =@@ + + type M = { -readonly [K in keyof any]-/**/?: any }; + +- ? +- -? +- -readonly [K in keyof any]-? +- -readonly [K in keyof any]-?: any + { -readonly [K in keyof any]-?: any } + type M = { -readonly [K in keyof any]-?: any }; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_objectTypes.baseline b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_objectTypes.baseline new file mode 100644 index 0000000000..1a5c16bd35 --- /dev/null +++ b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_objectTypes.baseline @@ -0,0 +1,119 @@ +// === Smart Selection === +type X = { + /**/foo?: string; + readonly bar: { x: number }; + meh +} + + foo ↲ + foo?: string;↲ + foo?: string; + readonly bar: { x: number }; + meh↲ + { + foo?: string; + readonly bar: { x: number }; + meh +} +type X = { + foo?: string; + readonly bar: { x: number }; + meh +} + +================================================================================ + +type X = { + foo?: string; + /**/readonly bar: { x: number }; + meh +} + + readonly ↲ + readonly bar: { x: number };↲ + foo?: string; + readonly bar: { x: number }; + meh↲ + { + foo?: string; + readonly bar: { x: number }; + meh +} +type X = { + foo?: string; + readonly bar: { x: number }; + meh +} + +================================================================================ + +type X = { + foo?: string; + readonly /**/bar: { x: number }; + meh +} + + bar ↲ + readonly bar: { x: number };↲ + foo?: string; + readonly bar: { x: number }; + meh↲ + { + foo?: string; + readonly bar: { x: number }; + meh +} +type X = { + foo?: string; + readonly bar: { x: number }; + meh +} + +================================================================================ + +type X = { + foo?: string; + readonly bar: { x: num/**/ber }; + meh +} + + number ↲ + x: number ↲ + { x: number } ↲ + readonly bar: { x: number };↲ + foo?: string; + readonly bar: { x: number }; + meh↲ + { + foo?: string; + readonly bar: { x: number }; + meh +} +type X = { + foo?: string; + readonly bar: { x: number }; + meh +} + +================================================================================ + +type X = { + foo?: string; + readonly bar: { x: number }; + /**/meh +} + + meh↲ + foo?: string; + readonly bar: { x: number }; + meh↲ + { + foo?: string; + readonly bar: { x: number }; + meh +} +type X = { + foo?: string; + readonly bar: { x: number }; + meh +} \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_objectTypes.baseline.diff b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_objectTypes.baseline.diff new file mode 100644 index 0000000000..178233ca12 --- /dev/null +++ b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_objectTypes.baseline.diff @@ -0,0 +1,159 @@ +--- old.smartSelection_objectTypes.baseline ++++ new.smartSelection_objectTypes.baseline +@@= skipped -4, +4 lines =@@ + meh + } + +- +- foo +- +- +- foo? +- +- ++ foo ↲ ++ foo?: string;↲ + foo?: string; +- +- +- ↲ +-••foo?: string; + readonly bar: { x: number }; + meh↲ +- +- + { + foo?: string; + readonly bar: { x: number }; + meh + } +- + type X = { + foo?: string; + readonly bar: { x: number }; +@@= skipped -36, +24 lines =@@ + meh + } + +- +- readonly +- +- +- readonly bar +- +- +- readonly bar: { x: number }; +- +- +- ↲ +-••foo?: string; ++ readonly ↲ ++ readonly bar: { x: number };↲ ++ foo?: string; + readonly bar: { x: number }; + meh↲ +- +- + { + foo?: string; + readonly bar: { x: number }; + meh + } +- + type X = { + foo?: string; + readonly bar: { x: number }; +@@= skipped -36, +24 lines =@@ + meh + } + +- +- bar +- +- +- readonly bar +- +- +- readonly bar: { x: number }; +- +- +- ↲ +-••foo?: string; ++ bar ↲ ++ readonly bar: { x: number };↲ ++ foo?: string; + readonly bar: { x: number }; + meh↲ +- +- + { + foo?: string; + readonly bar: { x: number }; + meh + } +- + type X = { + foo?: string; + readonly bar: { x: number }; +@@= skipped -36, +24 lines =@@ + meh + } + +- +- number +- +- +- x: number +- +- +- { x: number } +- +- +- readonly bar: { x: number }; +- +- +- ↲ +-••foo?: string; ++ number ↲ ++ x: number ↲ ++ { x: number } ↲ ++ readonly bar: { x: number };↲ ++ foo?: string; + readonly bar: { x: number }; + meh↲ +- +- + { + foo?: string; + readonly bar: { x: number }; + meh + } +- + type X = { + foo?: string; + readonly bar: { x: number }; +@@= skipped -39, +26 lines =@@ + /**/meh + } + +- +- meh +- +- +- ↲ +-••foo?: string; ++ meh↲ ++ foo?: string; + readonly bar: { x: number }; + meh↲ +- +- + { + foo?: string; + readonly bar: { x: number }; + meh + } +- + type X = { + foo?: string; + readonly bar: { x: number }; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_punctuationPriority.baseline b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_punctuationPriority.baseline new file mode 100644 index 0000000000..d23bdd4dd3 --- /dev/null +++ b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_punctuationPriority.baseline @@ -0,0 +1,6 @@ +// === Smart Selection === +console/**/.log(); + +console.log +console.log() +console.log(); \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_punctuationPriority.baseline.diff b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_punctuationPriority.baseline.diff new file mode 100644 index 0000000000..2ca3c1bf93 --- /dev/null +++ b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_punctuationPriority.baseline.diff @@ -0,0 +1,10 @@ +--- old.smartSelection_punctuationPriority.baseline ++++ new.smartSelection_punctuationPriority.baseline +@@= skipped -0, +0 lines =@@ + // === Smart Selection === + console/**/.log(); + +-console + console.log + console.log() + console.log(); \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_simple1.baseline b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_simple1.baseline new file mode 100644 index 0000000000..44b3b90605 --- /dev/null +++ b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_simple1.baseline @@ -0,0 +1,80 @@ +// === Smart Selection === +class Foo { + bar(a, b) { + if (/**/a === b) { + return true; + } + return false; + } +} + + a ↲ + a === b ↲ + if (a === b) { + return true; + }↲ + if (a === b) { + return true; + } + return false;↲ + { + if (a === b) { + return true; + } + return false; + }↲ + bar(a, b) { + if (a === b) { + return true; + } + return false; + }↲ +class Foo { + bar(a, b) { + if (a === b) { + return true; + } + return false; + } +} + +================================================================================ + +class Foo { + bar(a, b) { + if (a === b) { + return tr/**/ue; + } + return false; + } +} + + true ↲ + return true;↲ + if (a === b) { + return true; + }↲ + if (a === b) { + return true; + } + return false;↲ + { + if (a === b) { + return true; + } + return false; + }↲ + bar(a, b) { + if (a === b) { + return true; + } + return false; + }↲ +class Foo { + bar(a, b) { + if (a === b) { + return true; + } + return false; + } +} \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_simple1.baseline.diff b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_simple1.baseline.diff new file mode 100644 index 0000000000..8780f9a027 --- /dev/null +++ b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_simple1.baseline.diff @@ -0,0 +1,123 @@ +--- old.smartSelection_simple1.baseline ++++ new.smartSelection_simple1.baseline +@@= skipped -7, +7 lines =@@ + } + } + +- +- a +- +- +- a === b +- +- ++ a ↲ ++ a === b ↲ + if (a === b) { + return true; +- } +- +- +- ↲ +-••••••if (a === b) { ++ }↲ ++ if (a === b) { + return true; + } + return false;↲ +-•• +- +- + { + if (a === b) { + return true; + } + return false; +- } +- +- ++ }↲ + bar(a, b) { + if (a === b) { + return true; + } + return false; +- } +- +- +- ↲ +-••bar(a, b) { +- if (a === b) { +- return true; +- } +- return false; + }↲ +- +- + class Foo { + bar(a, b) { + if (a === b) { +@@= skipped -65, +41 lines =@@ + } + } + +- +- true +- +- +- return true; +- +- +- ↲ +-••••••••••return true;↲ +-•••••• +- +- +- if (a === b) { +- return true; +- } +- +- +- ↲ +-••••••if (a === b) { ++ true ↲ ++ return true;↲ ++ if (a === b) { ++ return true; ++ }↲ ++ if (a === b) { + return true; + } + return false;↲ +-•• +- +- + { + if (a === b) { + return true; + } + return false; +- } +- +- ++ }↲ + bar(a, b) { + if (a === b) { + return true; + } + return false; +- } +- +- +- ↲ +-••bar(a, b) { +- if (a === b) { +- return true; +- } +- return false; + }↲ +- +- + class Foo { + bar(a, b) { + if (a === b) { \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_simple2.baseline b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_simple2.baseline new file mode 100644 index 0000000000..46a124d294 --- /dev/null +++ b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_simple2.baseline @@ -0,0 +1,35 @@ +// === Smart Selection === +export interface IService { + _serviceBrand: any; + + open(ho/**/st: number, data: any): Promise; + bar(): void +} + + host ↲ + host: number ↲ + host: number, data: any ↲ + open(host: number, data: any): Promise;↲ + _serviceBrand: any; + open(host: number, data: any): Promise; + bar(): void↲ +export interface IService { + _serviceBrand: any; + open(host: number, data: any): Promise; + bar(): void +} + +================================================================================ + +export interface IService { + _serviceBrand: any; + + open(host: number, data: any): Promise; + bar(): void/**/ +} + +export interface IService { + _serviceBrand: any; + open(host: number, data: any): Promise; + bar(): void +} \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_simple2.baseline.diff b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_simple2.baseline.diff new file mode 100644 index 0000000000..cef4947937 --- /dev/null +++ b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_simple2.baseline.diff @@ -0,0 +1,61 @@ +--- old.smartSelection_simple2.baseline ++++ new.smartSelection_simple2.baseline +@@= skipped -5, +5 lines =@@ + bar(): void + } + +- +- host +- +- +- host: number +- +- +- host: number, data: any +- +- +- open(host: number, data: any): Promise; +- +- +- ↲ +-••_serviceBrand: any; +- ++ host ↲ ++ host: number ↲ ++ host: number, data: any ↲ ++ open(host: number, data: any): Promise;↲ ++ _serviceBrand: any; + open(host: number, data: any): Promise; + bar(): void↲ +- +- + export interface IService { + _serviceBrand: any; +- + open(host: number, data: any): Promise; + bar(): void + } +@@= skipped -36, +22 lines =@@ + bar(): void/**/ + } + +- +- void +- +- +- bar(): void +- +- +- ↲ +-••_serviceBrand: any; +- +- open(host: number, data: any): Promise; +- bar(): void↲ +- +- + export interface IService { + _serviceBrand: any; +- + open(host: number, data: any): Promise; + bar(): void + } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_stringLiteral.baseline b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_stringLiteral.baseline new file mode 100644 index 0000000000..2024479638 --- /dev/null +++ b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_stringLiteral.baseline @@ -0,0 +1,8 @@ +// === Smart Selection === +const a = 'a'; +const b = /**/'b'; + + 'b' +const b = 'b'; +const a = 'a'; +const b = 'b'; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_stringLiteral.baseline.diff b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_stringLiteral.baseline.diff new file mode 100644 index 0000000000..8709b33c41 --- /dev/null +++ b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_stringLiteral.baseline.diff @@ -0,0 +1,13 @@ +--- old.smartSelection_stringLiteral.baseline ++++ new.smartSelection_stringLiteral.baseline +@@= skipped -1, +1 lines =@@ + const a = 'a'; + const b = /**/'b'; + +- + 'b' +- + const b = 'b'; +- + const a = 'a'; + const b = 'b'; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_templateStrings.baseline b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_templateStrings.baseline new file mode 100644 index 0000000000..0e33fa815f --- /dev/null +++ b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_templateStrings.baseline @@ -0,0 +1,21 @@ +// === Smart Selection === +`a /**/b ${ + 'c' +} d` + +`a b ${ + 'c' +} d` + +================================================================================ + +`a b ${ + '/**/c' +} d` + + 'c'↲ + 'c' +} d` +`a b ${ + 'c' +} d` \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_templateStrings.baseline.diff b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_templateStrings.baseline.diff new file mode 100644 index 0000000000..f5418277fe --- /dev/null +++ b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_templateStrings.baseline.diff @@ -0,0 +1,39 @@ +--- old.smartSelection_templateStrings.baseline ++++ new.smartSelection_templateStrings.baseline +@@= skipped -2, +2 lines =@@ + 'c' + } d` + +- +- a b ${ +- 'c' +-} d +- + `a b ${ + 'c' + } d` +@@= skipped -15, +10 lines =@@ + '/**/c' + } d` + +- +- c +- +- +- 'c' +- +- +- ${ +- 'c' +-} +- +- a b ${ +- 'c' +-} d +- ++ 'c'↲ ++ 'c' ++} d` + `a b ${ + 'c' + } d` \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_templateStrings2.baseline b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_templateStrings2.baseline new file mode 100644 index 0000000000..02d752f0e4 --- /dev/null +++ b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_templateStrings2.baseline @@ -0,0 +1,5 @@ +// === Smart Selection === +`a ${b} /**/c` + + b} c` +`a ${b} c` \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_templateStrings2.baseline.diff b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_templateStrings2.baseline.diff new file mode 100644 index 0000000000..d16641c618 --- /dev/null +++ b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_templateStrings2.baseline.diff @@ -0,0 +1,9 @@ +--- old.smartSelection_templateStrings2.baseline ++++ new.smartSelection_templateStrings2.baseline +@@= skipped -0, +0 lines =@@ + // === Smart Selection === + `a ${b} /**/c` + +- a ${b} c ++ b} c` + `a ${b} c` \ No newline at end of file From 22a3a4befb7e29d387bce35487f34a967b53828c Mon Sep 17 00:00:00 2001 From: Jake Bailey <5341706+jakebailey@users.noreply.github.com> Date: Thu, 23 Oct 2025 09:14:10 -0700 Subject: [PATCH 3/9] remove ast helpers --- internal/ast/ast.go | 8 -------- 1 file changed, 8 deletions(-) diff --git a/internal/ast/ast.go b/internal/ast/ast.go index 2e04d3682c..4e8e59db6d 100644 --- a/internal/ast/ast.go +++ b/internal/ast/ast.go @@ -8758,10 +8758,6 @@ func IsTemplateTail(node *Node) bool { return node.Kind == KindTemplateTail } -func IsTemplateMiddleOrTemplateTail(node *Node) bool { - return node.Kind == KindTemplateMiddle || node.Kind == KindTemplateTail -} - // TemplateLiteralTypeNode type TemplateLiteralTypeNode struct { @@ -9446,10 +9442,6 @@ func (node *SyntaxList) Clone(f NodeFactoryCoercible) *Node { return cloneNode(f.AsNodeFactory().NewSyntaxList(node.Children), node.AsNode(), f.AsNodeFactory().hooks) } -func IsSyntaxList(node *Node) bool { - return node.Kind == KindSyntaxList -} - /// JSDoc /// type JSDoc struct { From 84d4a04509ffc075b12bd9a2d1e43961b4ae2e31 Mon Sep 17 00:00:00 2001 From: Jake Bailey <5341706+jakebailey@users.noreply.github.com> Date: Thu, 23 Oct 2025 09:15:36 -0700 Subject: [PATCH 4/9] readd others --- internal/ast/ast.go | 8 ++++++++ internal/ls/selectionranges.go | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/internal/ast/ast.go b/internal/ast/ast.go index 4e8e59db6d..4c15abd4fe 100644 --- a/internal/ast/ast.go +++ b/internal/ast/ast.go @@ -9647,6 +9647,10 @@ func (node *JSDocTypeExpression) Clone(f NodeFactoryCoercible) *Node { return cloneNode(f.AsNodeFactory().NewJSDocTypeExpression(node.Type), node.AsNode(), f.AsNodeFactory().hooks) } +func IsJSDocTypeExpression(node *Node) bool { + return node.Kind == KindJSDocTypeExpression +} + // JSDocNonNullableType type JSDocNonNullableType struct { @@ -10577,6 +10581,10 @@ func (node *JSDocTypeLiteral) Clone(f NodeFactoryCoercible) *Node { return cloneNode(f.AsNodeFactory().NewJSDocTypeLiteral(node.JSDocPropertyTags, node.IsArrayType), node.AsNode(), f.AsNodeFactory().hooks) } +func IsJSDocTypeLiteral(node *Node) bool { + return node.Kind == KindJSDocTypeLiteral +} + // JSDocSignature type JSDocSignature struct { TypeNodeBase diff --git a/internal/ls/selectionranges.go b/internal/ls/selectionranges.go index bc3d3693b7..d202dd355d 100644 --- a/internal/ls/selectionranges.go +++ b/internal/ls/selectionranges.go @@ -89,7 +89,7 @@ func getSmartSelectionRange(l *LanguageService, sourceFile *ast.SourceFile, pos } } - if node.Kind == ast.KindJSDocTypeExpression || ast.IsJSDocSignature(node) || node.Kind == ast.KindJSDocTypeLiteral { + if ast.IsJSDocTypeExpression(node) || ast.IsJSDocSignature(node) || ast.IsJSDocTypeLiteral(node) { return true } From 67d1e85832e0e4ae85869bd80a83878879ae1623 Mon Sep 17 00:00:00 2001 From: Jake Bailey <5341706+jakebailey@users.noreply.github.com> Date: Thu, 23 Oct 2025 09:17:53 -0700 Subject: [PATCH 5/9] Simplify --- internal/ls/selectionranges.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/ls/selectionranges.go b/internal/ls/selectionranges.go index d202dd355d..18255a36fa 100644 --- a/internal/ls/selectionranges.go +++ b/internal/ls/selectionranges.go @@ -49,7 +49,7 @@ func getSmartSelectionRange(l *LanguageService, sourceFile *ast.SourceFile, pos lspRange := l.converters.ToLSPRange(sourceFile, core.NewTextRange(start, end)) - if current != nil && current.Range.Start == lspRange.Start && current.Range.End == lspRange.End { + if current != nil && current.Range == lspRange { return current } From 1554197f3edf0768f2b4dbc700ca30bf2a6c4c06 Mon Sep 17 00:00:00 2001 From: Jake Bailey <5341706+jakebailey@users.noreply.github.com> Date: Thu, 23 Oct 2025 09:42:10 -0700 Subject: [PATCH 6/9] Handle comments --- internal/ls/selectionranges.go | 24 +++++++++++++++++++ .../smartSelection_comment1.baseline | 2 ++ .../smartSelection_comment1.baseline.diff | 9 ------- .../smartSelection_comment2.baseline | 2 ++ .../smartSelection_comment2.baseline.diff | 9 ------- 5 files changed, 28 insertions(+), 18 deletions(-) delete mode 100644 testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_comment1.baseline.diff delete mode 100644 testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_comment2.baseline.diff diff --git a/internal/ls/selectionranges.go b/internal/ls/selectionranges.go index 18255a36fa..a93e473e6c 100644 --- a/internal/ls/selectionranges.go +++ b/internal/ls/selectionranges.go @@ -29,6 +29,8 @@ func (l *LanguageService) ProvideSelectionRanges(ctx context.Context, params *ls } func getSmartSelectionRange(l *LanguageService, sourceFile *ast.SourceFile, pos int) *lsproto.SelectionRange { + factory := &ast.NodeFactory{} + nodeContainsPosition := func(node *ast.Node) bool { if node == nil { return false @@ -59,6 +61,19 @@ func getSmartSelectionRange(l *LanguageService, sourceFile *ast.SourceFile, pos } } + pushSelectionCommentRange := func(current *lsproto.SelectionRange, start, end int) *lsproto.SelectionRange { + current = pushSelectionRange(current, start, end) + + commentPos := start + text := sourceFile.Text() + for commentPos < end && commentPos < len(text) && text[commentPos] == '/' { + commentPos++ + } + current = pushSelectionRange(current, commentPos, end) + + return current + } + positionsAreOnSameLine := func(pos1, pos2 int) bool { if pos1 == pos2 { return true @@ -108,6 +123,15 @@ func getSmartSelectionRange(l *LanguageService, sourceFile *ast.SourceFile, pos visit := func(node *ast.Node) *ast.Node { if node != nil && next == nil { + var foundComment *ast.CommentRange + for comment := range scanner.GetTrailingCommentRanges(factory, sourceFile.Text(), node.End()) { + foundComment = &comment + break + } + if foundComment != nil && foundComment.Kind == ast.KindSingleLineCommentTrivia { + result = pushSelectionCommentRange(result, foundComment.Pos(), foundComment.End()) + } + if nodeContainsPosition(node) { // Add range for multi-line function bodies before skipping the block if ast.IsBlock(node) && ast.IsFunctionLikeDeclaration(parent) { diff --git a/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_comment1.baseline b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_comment1.baseline index 241a69dc06..2ce4a0f7c0 100644 --- a/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_comment1.baseline +++ b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_comment1.baseline @@ -1,4 +1,6 @@ // === Smart Selection === const a = 1; ///**/comment content + comment content + //comment content const a = 1; //comment content \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_comment1.baseline.diff b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_comment1.baseline.diff deleted file mode 100644 index 68eea77d85..0000000000 --- a/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_comment1.baseline.diff +++ /dev/null @@ -1,9 +0,0 @@ ---- old.smartSelection_comment1.baseline -+++ new.smartSelection_comment1.baseline -@@= skipped -0, +0 lines =@@ - // === Smart Selection === - const a = 1; ///**/comment content - -- comment content -- //comment content - const a = 1; //comment content \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_comment2.baseline b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_comment2.baseline index b89c3c096a..4ce50a231c 100644 --- a/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_comment2.baseline +++ b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_comment2.baseline @@ -1,4 +1,6 @@ // === Smart Selection === const a = 1; //a b/**/c d + a bc d + //a bc d const a = 1; //a bc d \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_comment2.baseline.diff b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_comment2.baseline.diff deleted file mode 100644 index 1f7b9c0348..0000000000 --- a/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_comment2.baseline.diff +++ /dev/null @@ -1,9 +0,0 @@ ---- old.smartSelection_comment2.baseline -+++ new.smartSelection_comment2.baseline -@@= skipped -0, +0 lines =@@ - // === Smart Selection === - const a = 1; //a b/**/c d - -- a bc d -- //a bc d - const a = 1; //a bc d \ No newline at end of file From ffec5b93799b2f9f66a8df2f8e7832538ba2d0f8 Mon Sep 17 00:00:00 2001 From: Jake Bailey <5341706+jakebailey@users.noreply.github.com> Date: Thu, 23 Oct 2025 10:26:32 -0700 Subject: [PATCH 7/9] Tweak baseline output to be closer --- internal/fourslash/fourslash.go | 9 ++- .../smartSelection_JSDoc.baseline | 2 + .../smartSelection_JSDoc.baseline.diff | 14 ++--- .../smartSelection_JSDocTags1.baseline | 1 + .../smartSelection_JSDocTags1.baseline.diff | 5 +- .../smartSelection_JSDocTags10.baseline | 1 + .../smartSelection_JSDocTags10.baseline.diff | 5 +- .../smartSelection_JSDocTags11.baseline | 6 ++ .../smartSelection_JSDocTags11.baseline.diff | 28 +-------- .../smartSelection_JSDocTags12.baseline | 9 +++ .../smartSelection_JSDocTags12.baseline.diff | 37 ++--------- .../smartSelection_JSDocTags13.baseline | 12 ++++ .../smartSelection_JSDocTags13.baseline.diff | 31 +++++----- .../smartSelection_JSDocTags2.baseline | 1 + .../smartSelection_JSDocTags2.baseline.diff | 5 +- .../smartSelection_JSDocTags3.baseline | 1 + .../smartSelection_JSDocTags3.baseline.diff | 5 +- .../smartSelection_JSDocTags4.baseline | 1 + .../smartSelection_JSDocTags4.baseline.diff | 5 +- .../smartSelection_JSDocTags5.baseline | 1 + .../smartSelection_JSDocTags5.baseline.diff | 5 +- .../smartSelection_JSDocTags6.baseline | 1 + .../smartSelection_JSDocTags6.baseline.diff | 5 +- .../smartSelection_JSDocTags7.baseline | 1 + .../smartSelection_JSDocTags7.baseline.diff | 5 +- .../smartSelection_JSDocTags8.baseline | 2 + .../smartSelection_JSDocTags8.baseline.diff | 12 ++-- .../smartSelection_JSDocTags9.baseline | 1 + .../smartSelection_JSDocTags9.baseline.diff | 5 +- .../smartSelection_emptyRanges.baseline | 10 +++ .../smartSelection_emptyRanges.baseline.diff | 33 +++++----- .../smartSelection_function1.baseline | 3 + .../smartSelection_function1.baseline.diff | 18 ------ .../smartSelection_function2.baseline | 2 + .../smartSelection_function2.baseline.diff | 14 ----- .../smartSelection_function3.baseline | 3 + .../smartSelection_function3.baseline.diff | 18 ------ .../smartSelection_functionParams2.baseline | 2 + ...artSelection_functionParams2.baseline.diff | 6 +- .../smartSelection_imports.baseline | 1 + .../smartSelection_imports.baseline.diff | 1 + .../smartSelection_objectTypes.baseline | 15 +++++ .../smartSelection_objectTypes.baseline.diff | 61 +++++-------------- .../smartSelection_simple1.baseline | 10 +++ .../smartSelection_simple1.baseline.diff | 23 +++---- .../smartSelection_simple2.baseline | 3 + .../smartSelection_simple2.baseline.diff | 8 +-- .../smartSelection_stringLiteral.baseline | 1 + ...smartSelection_stringLiteral.baseline.diff | 5 +- .../smartSelection_templateStrings.baseline | 3 + ...artSelection_templateStrings.baseline.diff | 13 ++-- 51 files changed, 206 insertions(+), 263 deletions(-) delete mode 100644 testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_function1.baseline.diff delete mode 100644 testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_function2.baseline.diff delete mode 100644 testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_function3.baseline.diff diff --git a/internal/fourslash/fourslash.go b/internal/fourslash/fourslash.go index d1eb84004c..93f61817ab 100644 --- a/internal/fourslash/fourslash.go +++ b/internal/fourslash/fourslash.go @@ -1339,7 +1339,7 @@ func (f *FourslashTest) VerifyBaselineSelectionRanges(t *testing.T) { selectionRange := (*selectionRangeResult.SelectionRanges)[0] - // Add blank line before first range + // Add blank line after source code section result.WriteString(newLine) // Walk through the selection range chain @@ -1350,7 +1350,6 @@ func (f *FourslashTest) VerifyBaselineSelectionRanges(t *testing.T) { // Create a masked version of the file showing only this range runes := []rune(fileContent) masked := make([]rune, len(runes)) - for i, ch := range runes { if i >= start && i < end { // Keep characters in the selection range @@ -1422,6 +1421,11 @@ func (f *FourslashTest) VerifyBaselineSelectionRanges(t *testing.T) { maskedStr = prefix + middle + suffix } + // Add blank line before multi-line ranges + if strings.Contains(maskedStr, "\n") { + result.WriteString(newLine) + } + result.WriteString(maskedStr) if !strings.HasSuffix(maskedStr, "\n") { result.WriteString(newLine) @@ -1430,7 +1434,6 @@ func (f *FourslashTest) VerifyBaselineSelectionRanges(t *testing.T) { selectionRange = selectionRange.Parent } } - f.addResultToBaseline(t, "Smart Selection", strings.TrimSuffix(result.String(), "\n")) } diff --git a/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDoc.baseline b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDoc.baseline index 51e36d04d7..46201c57a2 100644 --- a/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDoc.baseline +++ b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDoc.baseline @@ -8,9 +8,11 @@ function /**/square(x) { } square ↲ + function square(x) { return x * x; } + // Not a JSDoc comment /** * @param {number} x The number to square diff --git a/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDoc.baseline.diff b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDoc.baseline.diff index 91dcc06e88..e2db7538f0 100644 --- a/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDoc.baseline.diff +++ b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDoc.baseline.diff @@ -15,14 +15,8 @@ -/** - * @param {number} x The number to square - */ --function square(x) { -- return x * x; --} -- + square ↲ -+function square(x) { -+ return x * x; -+} - // Not a JSDoc comment - /** - * @param {number} x The number to square \ No newline at end of file ++ + function square(x) { + return x * x; + } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags1.baseline b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags1.baseline index 46760b8ad3..97057c429b 100644 --- a/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags1.baseline +++ b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags1.baseline @@ -4,6 +4,7 @@ */ function foo() { return [] } + /** * @returns {Array<{ value: string }>} */ diff --git a/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags1.baseline.diff b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags1.baseline.diff index e30d12a21d..b2b343c511 100644 --- a/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags1.baseline.diff +++ b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags1.baseline.diff @@ -1,10 +1,9 @@ --- old.smartSelection_JSDocTags1.baseline +++ new.smartSelection_JSDocTags1.baseline -@@= skipped -3, +3 lines =@@ - */ +@@= skipped -4, +4 lines =@@ function foo() { return [] } -- + - string - - diff --git a/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags10.baseline b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags10.baseline index d230e63663..3b002e2f42 100644 --- a/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags10.baseline +++ b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags10.baseline @@ -6,6 +6,7 @@ class A extends B { } + /** * @template T * @extends {Set} diff --git a/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags10.baseline.diff b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags10.baseline.diff index 7562eee0f0..862f9aa746 100644 --- a/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags10.baseline.diff +++ b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags10.baseline.diff @@ -1,10 +1,9 @@ --- old.smartSelection_JSDocTags10.baseline +++ new.smartSelection_JSDocTags10.baseline -@@= skipped -5, +5 lines =@@ - class A extends B { +@@= skipped -6, +6 lines =@@ } -- + - Set - - diff --git a/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags11.baseline b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags11.baseline index e53d115446..a3e89dbed1 100644 --- a/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags11.baseline +++ b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags11.baseline @@ -7,14 +7,17 @@ type Foo = { readonly ↲ readonly status: number;↲ + { /** comment */ readonly status: number; } + type Foo = { /** comment */ readonly status: number; }; + const x = 1; type Foo = { /** comment */ @@ -31,14 +34,17 @@ type Foo = { status ↲ readonly status: number;↲ + { /** comment */ readonly status: number; } + type Foo = { /** comment */ readonly status: number; }; + const x = 1; type Foo = { /** comment */ diff --git a/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags11.baseline.diff b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags11.baseline.diff index 09ae904d60..b436c05fa8 100644 --- a/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags11.baseline.diff +++ b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags11.baseline.diff @@ -23,21 +23,10 @@ + readonly ↲ readonly status: number;↲ - -- + { /** comment */ - readonly status: number; - } -- - type Foo = { - /** comment */ - readonly status: number; - }; -- - const x = 1; - type Foo = { - /** comment */ -@@= skipped -43, +24 lines =@@ +@@= skipped -43, +27 lines =@@ readonly /**/status: number; }; @@ -60,17 +49,6 @@ + status ↲ readonly status: number;↲ - -- + { - /** comment */ - readonly status: number; - } -- - type Foo = { - /** comment */ - readonly status: number; - }; -- - const x = 1; - type Foo = { /** comment */ \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags12.baseline b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags12.baseline index 90e0a2ef61..bc09cfe3ed 100644 --- a/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags12.baseline +++ b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags12.baseline @@ -8,12 +8,15 @@ type A = { p0: number ↲ p0: number, /** Comment */ p1: number, /** Comment */ p2: number ↲ a(/** Comment */ p0: number, /** Comment */ p1: number, /** Comment */ p2: number): string;↲ + { a(/** Comment */ p0: number, /** Comment */ p1: number, /** Comment */ p2: number): string; } + type A = { a(/** Comment */ p0: number, /** Comment */ p1: number, /** Comment */ p2: number): string; }; + type B = {}; type A = { a(/** Comment */ p0: number, /** Comment */ p1: number, /** Comment */ p2: number): string; @@ -30,12 +33,15 @@ type A = { p1: number ↲ p0: number, /** Comment */ p1: number, /** Comment */ p2: number ↲ a(/** Comment */ p0: number, /** Comment */ p1: number, /** Comment */ p2: number): string;↲ + { a(/** Comment */ p0: number, /** Comment */ p1: number, /** Comment */ p2: number): string; } + type A = { a(/** Comment */ p0: number, /** Comment */ p1: number, /** Comment */ p2: number): string; }; + type B = {}; type A = { a(/** Comment */ p0: number, /** Comment */ p1: number, /** Comment */ p2: number): string; @@ -52,12 +58,15 @@ type A = { p2: number ↲ p0: number, /** Comment */ p1: number, /** Comment */ p2: number ↲ a(/** Comment */ p0: number, /** Comment */ p1: number, /** Comment */ p2: number): string;↲ + { a(/** Comment */ p0: number, /** Comment */ p1: number, /** Comment */ p2: number): string; } + type A = { a(/** Comment */ p0: number, /** Comment */ p1: number, /** Comment */ p2: number): string; }; + type B = {}; type A = { a(/** Comment */ p0: number, /** Comment */ p1: number, /** Comment */ p2: number): string; diff --git a/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags12.baseline.diff b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags12.baseline.diff index 478a71307a..eabb41d041 100644 --- a/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags12.baseline.diff +++ b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags12.baseline.diff @@ -23,23 +23,14 @@ - ↲ -••••a(/** Comment */ p0: number, /** Comment */ p1: number, /** Comment */ p2: number): string;↲ - -- + p0 ↲ + p0: number ↲ + p0: number, /** Comment */ p1: number, /** Comment */ p2: number ↲ + a(/** Comment */ p0: number, /** Comment */ p1: number, /** Comment */ p2: number): string;↲ + { a(/** Comment */ p0: number, /** Comment */ p1: number, /** Comment */ p2: number): string; - } -- - type A = { - a(/** Comment */ p0: number, /** Comment */ p1: number, /** Comment */ p2: number): string; - }; -- - type B = {}; - type A = { - a(/** Comment */ p0: number, /** Comment */ p1: number, /** Comment */ p2: number): string; -@@= skipped -40, +22 lines =@@ +@@= skipped -40, +25 lines =@@ a(/** Comment */ p0: number, /** Comment */ /**/p1: number, /** Comment */ p2: number): string; }; @@ -62,23 +53,14 @@ - ↲ -••••a(/** Comment */ p0: number, /** Comment */ p1: number, /** Comment */ p2: number): string;↲ - -- + p1 ↲ + p1: number ↲ + p0: number, /** Comment */ p1: number, /** Comment */ p2: number ↲ + a(/** Comment */ p0: number, /** Comment */ p1: number, /** Comment */ p2: number): string;↲ + { a(/** Comment */ p0: number, /** Comment */ p1: number, /** Comment */ p2: number): string; - } -- - type A = { - a(/** Comment */ p0: number, /** Comment */ p1: number, /** Comment */ p2: number): string; - }; -- - type B = {}; - type A = { - a(/** Comment */ p0: number, /** Comment */ p1: number, /** Comment */ p2: number): string; -@@= skipped -40, +22 lines =@@ +@@= skipped -40, +25 lines =@@ a(/** Comment */ p0: number, /** Comment */ p1: number, /** Comment */ /**/p2: number): string; }; @@ -101,19 +83,10 @@ - ↲ -••••a(/** Comment */ p0: number, /** Comment */ p1: number, /** Comment */ p2: number): string;↲ - -- + p2 ↲ + p2: number ↲ + p0: number, /** Comment */ p1: number, /** Comment */ p2: number ↲ + a(/** Comment */ p0: number, /** Comment */ p1: number, /** Comment */ p2: number): string;↲ + { - a(/** Comment */ p0: number, /** Comment */ p1: number, /** Comment */ p2: number): string; - } -- - type A = { - a(/** Comment */ p0: number, /** Comment */ p1: number, /** Comment */ p2: number): string; - }; -- - type B = {}; - type A = { a(/** Comment */ p0: number, /** Comment */ p1: number, /** Comment */ p2: number): string; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags13.baseline b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags13.baseline index de02bad534..097324d32b 100644 --- a/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags13.baseline +++ b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags13.baseline @@ -9,19 +9,23 @@ let c; p0 ↲ p0: number↲ + p0: number /** Comment */ p1: number /** Comment */ p2: number↲ + { /** Comment */ p0: number /** Comment */ p1: number /** Comment */ p2: number } ↲ + let b: { /** Comment */ p0: number /** Comment */ p1: number /** Comment */ p2: number };↲ + let a; let b: { /** Comment */ p0: number @@ -42,19 +46,23 @@ let c; p1 ↲ p1: number↲ + p0: number /** Comment */ p1: number /** Comment */ p2: number↲ + { /** Comment */ p0: number /** Comment */ p1: number /** Comment */ p2: number } ↲ + let b: { /** Comment */ p0: number /** Comment */ p1: number /** Comment */ p2: number };↲ + let a; let b: { /** Comment */ p0: number @@ -75,19 +83,23 @@ let c; p2 ↲ p2: number↲ + p0: number /** Comment */ p1: number /** Comment */ p2: number↲ + { /** Comment */ p0: number /** Comment */ p1: number /** Comment */ p2: number } ↲ + let b: { /** Comment */ p0: number /** Comment */ p1: number /** Comment */ p2: number };↲ + let a; let b: { /** Comment */ p0: number diff --git a/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags13.baseline.diff b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags13.baseline.diff index 948731287e..229032e887 100644 --- a/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags13.baseline.diff +++ b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags13.baseline.diff @@ -7,9 +7,9 @@ - - p0 - -- + p0 ↲ + p0: number↲ + p0: number - - @@ -20,7 +20,7 @@ -••••/** Comment */ p0: number /** Comment */ p1: number /** Comment */ p2: number↲ -- + - { /** Comment */ p0: number @@ -28,20 +28,19 @@ /** Comment */ p2: number -} - -- +} ↲ + let b: { /** Comment */ p0: number /** Comment */ p1: number /** Comment */ p2: number -}; - -- +};↲ + let a; let b: { - /** Comment */ p0: number -@@= skipped -48, +33 lines =@@ +@@= skipped -48, +37 lines =@@ }; let c; @@ -59,10 +58,11 @@ -••••/** Comment */ p0: number + p1 ↲ + p1: number↲ ++ + p0: number /** Comment */ p1: number /** Comment */ p2: number↲ -- + - { /** Comment */ p0: number @@ -70,20 +70,19 @@ /** Comment */ p2: number -} - -- +} ↲ + let b: { /** Comment */ p0: number /** Comment */ p1: number /** Comment */ p2: number -}; - -- +};↲ + let a; let b: { - /** Comment */ p0: number -@@= skipped -48, +33 lines =@@ +@@= skipped -48, +37 lines =@@ }; let c; @@ -101,10 +100,11 @@ -••••/** Comment */ p0: number + p2 ↲ + p2: number↲ ++ + p0: number /** Comment */ p1: number /** Comment */ p2: number↲ -- + - { /** Comment */ p0: number @@ -112,16 +112,15 @@ /** Comment */ p2: number -} - -- +} ↲ + let b: { /** Comment */ p0: number /** Comment */ p1: number /** Comment */ p2: number -}; - -- +};↲ + let a; - let b: { - /** Comment */ p0: number \ No newline at end of file + let b: { \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags2.baseline b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags2.baseline index 5366fbf6b8..7e9f37d62b 100644 --- a/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags2.baseline +++ b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags2.baseline @@ -4,6 +4,7 @@ */ const foo; + /** * @type {string} */ diff --git a/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags2.baseline.diff b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags2.baseline.diff index d13840b84f..445190e48d 100644 --- a/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags2.baseline.diff +++ b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags2.baseline.diff @@ -1,10 +1,9 @@ --- old.smartSelection_JSDocTags2.baseline +++ new.smartSelection_JSDocTags2.baseline -@@= skipped -3, +3 lines =@@ - */ +@@= skipped -4, +4 lines =@@ const foo; -- + - string - - diff --git a/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags3.baseline b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags3.baseline index d614907474..9f447cef5f 100644 --- a/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags3.baseline +++ b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags3.baseline @@ -4,6 +4,7 @@ */ function foo(x) {} + /** * @param {string} x */ diff --git a/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags3.baseline.diff b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags3.baseline.diff index 81fee0ceab..39b7fd4745 100644 --- a/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags3.baseline.diff +++ b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags3.baseline.diff @@ -1,10 +1,9 @@ --- old.smartSelection_JSDocTags3.baseline +++ new.smartSelection_JSDocTags3.baseline -@@= skipped -3, +3 lines =@@ - */ +@@= skipped -4, +4 lines =@@ function foo(x) {} -- + - string - - diff --git a/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags4.baseline b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags4.baseline index 647d420d6e..cc40a448f6 100644 --- a/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags4.baseline +++ b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags4.baseline @@ -9,6 +9,7 @@ /** @type {Foo} */ const foo; + /** * @typedef {object} Foo * @property {string} a diff --git a/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags4.baseline.diff b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags4.baseline.diff index c680483a45..f15502d303 100644 --- a/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags4.baseline.diff +++ b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags4.baseline.diff @@ -1,10 +1,9 @@ --- old.smartSelection_JSDocTags4.baseline +++ new.smartSelection_JSDocTags4.baseline -@@= skipped -8, +8 lines =@@ - /** @type {Foo} */ +@@= skipped -9, +9 lines =@@ const foo; -- + - number - - diff --git a/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags5.baseline b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags5.baseline index fb9ed36519..8e06d293a0 100644 --- a/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags5.baseline +++ b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags5.baseline @@ -9,6 +9,7 @@ /** @type {Foo} */ const foo = s => !(s.length % 2); + /** * @callback Foo * @param {string} data diff --git a/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags5.baseline.diff b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags5.baseline.diff index a6e08c9ac1..59d1b1a933 100644 --- a/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags5.baseline.diff +++ b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags5.baseline.diff @@ -1,10 +1,9 @@ --- old.smartSelection_JSDocTags5.baseline +++ new.smartSelection_JSDocTags5.baseline -@@= skipped -8, +8 lines =@@ - /** @type {Foo} */ +@@= skipped -9, +9 lines =@@ const foo = s => !(s.length % 2); -- + - number - - diff --git a/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags6.baseline b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags6.baseline index ffcaf36145..47bbf2c4f9 100644 --- a/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags6.baseline +++ b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags6.baseline @@ -8,6 +8,7 @@ function foo(x) { return x; } + /** * @template T * @param {T} x diff --git a/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags6.baseline.diff b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags6.baseline.diff index d0565c2661..81f41814af 100644 --- a/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags6.baseline.diff +++ b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags6.baseline.diff @@ -1,10 +1,9 @@ --- old.smartSelection_JSDocTags6.baseline +++ new.smartSelection_JSDocTags6.baseline -@@= skipped -7, +7 lines =@@ - return x; +@@= skipped -8, +8 lines =@@ } -- + - T - - diff --git a/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags7.baseline b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags7.baseline index 3fb81ec55c..af95be534e 100644 --- a/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags7.baseline +++ b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags7.baseline @@ -6,6 +6,7 @@ function Foo(data) { } + /** * @constructor * @param {number} data diff --git a/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags7.baseline.diff b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags7.baseline.diff index dfa174419a..e2871c80eb 100644 --- a/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags7.baseline.diff +++ b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags7.baseline.diff @@ -1,10 +1,9 @@ --- old.smartSelection_JSDocTags7.baseline +++ new.smartSelection_JSDocTags7.baseline -@@= skipped -5, +5 lines =@@ - function Foo(data) { +@@= skipped -6, +6 lines =@@ } -- + - number - - diff --git a/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags8.baseline b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags8.baseline index 85c97449ff..4b0fe1916c 100644 --- a/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags8.baseline +++ b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags8.baseline @@ -6,6 +6,7 @@ function callback(e) { } + /** * @this {Foo} * @param {*} e @@ -22,6 +23,7 @@ function callback(e) { function callback(e) { } + /** * @this {Foo} * @param {*} e diff --git a/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags8.baseline.diff b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags8.baseline.diff index 210116bddb..0554a3c481 100644 --- a/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags8.baseline.diff +++ b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags8.baseline.diff @@ -1,10 +1,9 @@ --- old.smartSelection_JSDocTags8.baseline +++ new.smartSelection_JSDocTags8.baseline -@@= skipped -5, +5 lines =@@ - function callback(e) { +@@= skipped -6, +6 lines =@@ } -- + - Foo - - @@ -20,7 +19,7 @@ /** * @this {Foo} * @param {*} e -@@= skipped -28, +15 lines =@@ +@@= skipped -27, +15 lines =@@ */ function callback(e) { } @@ -36,7 +35,6 @@ - * @this {Foo} - * @param {*} e - */ -- - /** - * @this {Foo} \ No newline at end of file + + /** \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags9.baseline b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags9.baseline index d45f3e26f5..36d1c173c7 100644 --- a/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags9.baseline +++ b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags9.baseline @@ -5,6 +5,7 @@ const Foo = { y: 1, }; + /** @enum {number} */ const Foo = { x: 0, diff --git a/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags9.baseline.diff b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags9.baseline.diff index 678d48b2e4..a85e3aef9d 100644 --- a/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags9.baseline.diff +++ b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags9.baseline.diff @@ -1,10 +1,9 @@ --- old.smartSelection_JSDocTags9.baseline +++ new.smartSelection_JSDocTags9.baseline -@@= skipped -4, +4 lines =@@ - y: 1, +@@= skipped -5, +5 lines =@@ }; -- + - number - - diff --git a/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_emptyRanges.baseline b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_emptyRanges.baseline index 75438a7fc1..f17e19b22e 100644 --- a/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_emptyRanges.baseline +++ b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_emptyRanges.baseline @@ -7,11 +7,13 @@ class HomePage { } } + componentDidMount() { if (this.props.username) { return ''; } }↲ + class HomePage { componentDidMount() { if (this.props.username) { @@ -30,19 +32,23 @@ class HomePage { } } + if (this.props.username) { return ''; }↲ + { if (this.props.username) { return ''; } }↲ + componentDidMount() { if (this.props.username) { return ''; } }↲ + class HomePage { componentDidMount() { if (this.props.username) { @@ -63,19 +69,23 @@ class HomePage { '' ↲ return '';↲ + if (this.props.username) { return ''; }↲ + { if (this.props.username) { return ''; } }↲ + componentDidMount() { if (this.props.username) { return ''; } }↲ + class HomePage { componentDidMount() { if (this.props.username) { diff --git a/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_emptyRanges.baseline.diff b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_emptyRanges.baseline.diff index 270dbbf9a9..194bd64baa 100644 --- a/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_emptyRanges.baseline.diff +++ b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_emptyRanges.baseline.diff @@ -1,10 +1,9 @@ --- old.smartSelection_emptyRanges.baseline +++ new.smartSelection_emptyRanges.baseline -@@= skipped -6, +6 lines =@@ - } +@@= skipped -7, +7 lines =@@ } -- + - ) - - @@ -22,15 +21,13 @@ - } }↲ - -- + class HomePage { componentDidMount() { - if (this.props.username) { -@@= skipped -37, +23 lines =@@ - } +@@= skipped -37, +25 lines =@@ } -- + - username - - @@ -48,15 +45,15 @@ }↲ -•• - -- + { if (this.props.username) { return ''; } - } - -- + }↲ + componentDidMount() { if (this.props.username) { return ''; @@ -71,11 +68,10 @@ - } }↲ - -- + class HomePage { componentDidMount() { - if (this.props.username) { -@@= skipped -59, +31 lines =@@ +@@= skipped -58, +34 lines =@@ } } @@ -90,9 +86,9 @@ -••••••return '';↲ -•••• - -- + '' ↲ + return '';↲ + if (this.props.username) { - return ''; - } @@ -104,15 +100,15 @@ }↲ -•• - -- + { if (this.props.username) { return ''; } - } - -- + }↲ + componentDidMount() { if (this.props.username) { return ''; @@ -127,7 +123,6 @@ - } }↲ - -- + class HomePage { - componentDidMount() { - if (this.props.username) { \ No newline at end of file + componentDidMount() { \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_function1.baseline b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_function1.baseline index 2a50431eef..6344b9c647 100644 --- a/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_function1.baseline +++ b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_function1.baseline @@ -3,12 +3,15 @@ const f1 = () => { /**/ }; + { } + () => { } + const f1 = () => { }; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_function1.baseline.diff b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_function1.baseline.diff deleted file mode 100644 index a3efa8b753..0000000000 --- a/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_function1.baseline.diff +++ /dev/null @@ -1,18 +0,0 @@ ---- old.smartSelection_function1.baseline -+++ new.smartSelection_function1.baseline -@@= skipped -2, +2 lines =@@ - /**/ - }; - -- - { - - } -- - () => { - - } -- - const f1 = () => { - - }; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_function2.baseline b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_function2.baseline index def3bc1703..1b4f84b37c 100644 --- a/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_function2.baseline +++ b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_function2.baseline @@ -3,9 +3,11 @@ function f2() { /**/ } + { } + function f2() { } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_function2.baseline.diff b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_function2.baseline.diff deleted file mode 100644 index a18698b35d..0000000000 --- a/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_function2.baseline.diff +++ /dev/null @@ -1,14 +0,0 @@ ---- old.smartSelection_function2.baseline -+++ new.smartSelection_function2.baseline -@@= skipped -2, +2 lines =@@ - /**/ - } - -- - { - - } -- - function f2() { - - } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_function3.baseline b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_function3.baseline index ca8a14e884..afd3e7948c 100644 --- a/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_function3.baseline +++ b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_function3.baseline @@ -3,12 +3,15 @@ const f3 = function () { /**/ } + { } + function () { } + const f3 = function () { } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_function3.baseline.diff b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_function3.baseline.diff deleted file mode 100644 index eeb1265fb5..0000000000 --- a/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_function3.baseline.diff +++ /dev/null @@ -1,18 +0,0 @@ ---- old.smartSelection_function3.baseline -+++ new.smartSelection_function3.baseline -@@= skipped -2, +2 lines =@@ - /**/ - } - -- - { - - } -- - function () { - - } -- - const f3 = function () { - - } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_functionParams2.baseline b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_functionParams2.baseline index 130a434904..f9c497907a 100644 --- a/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_functionParams2.baseline +++ b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_functionParams2.baseline @@ -5,8 +5,10 @@ function f( ) {} b↲ + a, b↲ + function f( a, b diff --git a/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_functionParams2.baseline.diff b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_functionParams2.baseline.diff index bf421d0628..669d9d0f32 100644 --- a/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_functionParams2.baseline.diff +++ b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_functionParams2.baseline.diff @@ -12,10 +12,10 @@ -••a, - b↲ - -- + b↲ ++ + a, + b↲ + function f( - a, - b \ No newline at end of file + a, \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_imports.baseline b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_imports.baseline index 22f95170ab..f1208f23a3 100644 --- a/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_imports.baseline +++ b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_imports.baseline @@ -9,6 +9,7 @@ console.log(1); x as y, z ↲ { x as y, z } ↲ import { x as y, z } from './z';↲ + import { x as y, z } from './z'; import { b } from './'; console.log(1); \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_imports.baseline.diff b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_imports.baseline.diff index ed989358fb..f0ecf62be0 100644 --- a/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_imports.baseline.diff +++ b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_imports.baseline.diff @@ -32,6 +32,7 @@ + x as y, z ↲ + { x as y, z } ↲ +import { x as y, z } from './z';↲ ++ +import { x as y, z } from './z'; +import { b } from './'; console.log(1); \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_objectTypes.baseline b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_objectTypes.baseline index 1a5c16bd35..2cd2a914e1 100644 --- a/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_objectTypes.baseline +++ b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_objectTypes.baseline @@ -7,14 +7,17 @@ type X = { foo ↲ foo?: string;↲ + foo?: string; readonly bar: { x: number }; meh↲ + { foo?: string; readonly bar: { x: number }; meh } + type X = { foo?: string; readonly bar: { x: number }; @@ -31,14 +34,17 @@ type X = { readonly ↲ readonly bar: { x: number };↲ + foo?: string; readonly bar: { x: number }; meh↲ + { foo?: string; readonly bar: { x: number }; meh } + type X = { foo?: string; readonly bar: { x: number }; @@ -55,14 +61,17 @@ type X = { bar ↲ readonly bar: { x: number };↲ + foo?: string; readonly bar: { x: number }; meh↲ + { foo?: string; readonly bar: { x: number }; meh } + type X = { foo?: string; readonly bar: { x: number }; @@ -81,14 +90,17 @@ type X = { x: number ↲ { x: number } ↲ readonly bar: { x: number };↲ + foo?: string; readonly bar: { x: number }; meh↲ + { foo?: string; readonly bar: { x: number }; meh } + type X = { foo?: string; readonly bar: { x: number }; @@ -104,14 +116,17 @@ type X = { } meh↲ + foo?: string; readonly bar: { x: number }; meh↲ + { foo?: string; readonly bar: { x: number }; meh } + type X = { foo?: string; readonly bar: { x: number }; diff --git a/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_objectTypes.baseline.diff b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_objectTypes.baseline.diff index 178233ca12..66f80dbaef 100644 --- a/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_objectTypes.baseline.diff +++ b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_objectTypes.baseline.diff @@ -10,9 +10,9 @@ - - foo? - -- + foo ↲ + foo?: string;↲ + foo?: string; - - @@ -21,17 +21,10 @@ readonly bar: { x: number }; meh↲ - -- + { foo?: string; - readonly bar: { x: number }; - meh - } -- - type X = { - foo?: string; - readonly bar: { x: number }; -@@= skipped -36, +24 lines =@@ +@@= skipped -36, +27 lines =@@ meh } @@ -49,21 +42,15 @@ -••foo?: string; + readonly ↲ + readonly bar: { x: number };↲ ++ + foo?: string; readonly bar: { x: number }; meh↲ - -- + { foo?: string; - readonly bar: { x: number }; - meh - } -- - type X = { - foo?: string; - readonly bar: { x: number }; -@@= skipped -36, +24 lines =@@ +@@= skipped -36, +27 lines =@@ meh } @@ -81,21 +68,15 @@ -••foo?: string; + bar ↲ + readonly bar: { x: number };↲ ++ + foo?: string; readonly bar: { x: number }; meh↲ - -- + { foo?: string; - readonly bar: { x: number }; - meh - } -- - type X = { - foo?: string; - readonly bar: { x: number }; -@@= skipped -36, +24 lines =@@ +@@= skipped -36, +27 lines =@@ meh } @@ -118,21 +99,15 @@ + x: number ↲ + { x: number } ↲ + readonly bar: { x: number };↲ ++ + foo?: string; readonly bar: { x: number }; meh↲ - -- + { foo?: string; - readonly bar: { x: number }; - meh - } -- - type X = { - foo?: string; - readonly bar: { x: number }; -@@= skipped -39, +26 lines =@@ +@@= skipped -39, +29 lines =@@ /**/meh } @@ -143,17 +118,11 @@ - ↲ -••foo?: string; + meh↲ ++ + foo?: string; readonly bar: { x: number }; meh↲ - -- + { - foo?: string; - readonly bar: { x: number }; - meh - } -- - type X = { - foo?: string; - readonly bar: { x: number }; \ No newline at end of file + foo?: string; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_simple1.baseline b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_simple1.baseline index 44b3b90605..8027901532 100644 --- a/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_simple1.baseline +++ b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_simple1.baseline @@ -10,25 +10,30 @@ class Foo { a ↲ a === b ↲ + if (a === b) { return true; }↲ + if (a === b) { return true; } return false;↲ + { if (a === b) { return true; } return false; }↲ + bar(a, b) { if (a === b) { return true; } return false; }↲ + class Foo { bar(a, b) { if (a === b) { @@ -51,25 +56,30 @@ class Foo { true ↲ return true;↲ + if (a === b) { return true; }↲ + if (a === b) { return true; } return false;↲ + { if (a === b) { return true; } return false; }↲ + bar(a, b) { if (a === b) { return true; } return false; }↲ + class Foo { bar(a, b) { if (a === b) { diff --git a/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_simple1.baseline.diff b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_simple1.baseline.diff index 8780f9a027..3dca3d25ec 100644 --- a/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_simple1.baseline.diff +++ b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_simple1.baseline.diff @@ -10,9 +10,9 @@ - - a === b - -- + a ↲ + a === b ↲ + if (a === b) { return true; - } @@ -21,13 +21,14 @@ - ↲ -••••••if (a === b) { + }↲ ++ + if (a === b) { return true; } return false;↲ -•• - -- + { if (a === b) { return true; @@ -35,8 +36,8 @@ return false; - } - -- + }↲ + bar(a, b) { if (a === b) { return true; @@ -53,11 +54,10 @@ - return false; }↲ - -- + class Foo { bar(a, b) { - if (a === b) { -@@= skipped -65, +41 lines =@@ +@@= skipped -65, +46 lines =@@ } } @@ -82,16 +82,18 @@ -••••••if (a === b) { + true ↲ + return true;↲ ++ + if (a === b) { + return true; + }↲ ++ + if (a === b) { return true; } return false;↲ -•• - -- + { if (a === b) { return true; @@ -99,8 +101,8 @@ return false; - } - -- + }↲ + bar(a, b) { if (a === b) { return true; @@ -117,7 +119,6 @@ - return false; }↲ - -- + class Foo { - bar(a, b) { - if (a === b) { \ No newline at end of file + bar(a, b) { \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_simple2.baseline b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_simple2.baseline index 46a124d294..34d63f7949 100644 --- a/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_simple2.baseline +++ b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_simple2.baseline @@ -10,9 +10,11 @@ export interface IService { host: number ↲ host: number, data: any ↲ open(host: number, data: any): Promise;↲ + _serviceBrand: any; open(host: number, data: any): Promise; bar(): void↲ + export interface IService { _serviceBrand: any; open(host: number, data: any): Promise; @@ -28,6 +30,7 @@ export interface IService { bar(): void/**/ } + export interface IService { _serviceBrand: any; open(host: number, data: any): Promise; diff --git a/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_simple2.baseline.diff b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_simple2.baseline.diff index cef4947937..ca0b9e1cd8 100644 --- a/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_simple2.baseline.diff +++ b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_simple2.baseline.diff @@ -24,10 +24,11 @@ + host: number ↲ + host: number, data: any ↲ + open(host: number, data: any): Promise;↲ ++ + _serviceBrand: any; open(host: number, data: any): Promise; bar(): void↲ -- + - export interface IService { _serviceBrand: any; @@ -35,11 +36,10 @@ open(host: number, data: any): Promise; bar(): void } -@@= skipped -36, +22 lines =@@ - bar(): void/**/ +@@= skipped -37, +25 lines =@@ } -- + - void - - diff --git a/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_stringLiteral.baseline b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_stringLiteral.baseline index 2024479638..883f9f5ab3 100644 --- a/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_stringLiteral.baseline +++ b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_stringLiteral.baseline @@ -4,5 +4,6 @@ const b = /**/'b'; 'b' const b = 'b'; + const a = 'a'; const b = 'b'; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_stringLiteral.baseline.diff b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_stringLiteral.baseline.diff index 8709b33c41..0bde7503b4 100644 --- a/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_stringLiteral.baseline.diff +++ b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_stringLiteral.baseline.diff @@ -8,6 +8,5 @@ 'b' - const b = 'b'; -- - const a = 'a'; - const b = 'b'; \ No newline at end of file + + const a = 'a'; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_templateStrings.baseline b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_templateStrings.baseline index 0e33fa815f..ada0f0c185 100644 --- a/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_templateStrings.baseline +++ b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_templateStrings.baseline @@ -3,6 +3,7 @@ 'c' } d` + `a b ${ 'c' } d` @@ -14,8 +15,10 @@ } d` 'c'↲ + 'c' } d` + `a b ${ 'c' } d` \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_templateStrings.baseline.diff b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_templateStrings.baseline.diff index f5418277fe..ad54e4e730 100644 --- a/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_templateStrings.baseline.diff +++ b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_templateStrings.baseline.diff @@ -1,10 +1,9 @@ --- old.smartSelection_templateStrings.baseline +++ new.smartSelection_templateStrings.baseline -@@= skipped -2, +2 lines =@@ - 'c' +@@= skipped -3, +3 lines =@@ } d` -- + - a b ${ - 'c' -} d @@ -12,7 +11,7 @@ `a b ${ 'c' } d` -@@= skipped -15, +10 lines =@@ +@@= skipped -14, +10 lines =@@ '/**/c' } d` @@ -30,10 +29,10 @@ - a b ${ - 'c' -} d -- + 'c'↲ ++ + 'c' +} d` + `a b ${ - 'c' - } d` \ No newline at end of file + 'c' \ No newline at end of file From e58923e3524495165958c6da76672012481ad209 Mon Sep 17 00:00:00 2001 From: Jake Bailey <5341706+jakebailey@users.noreply.github.com> Date: Thu, 23 Oct 2025 11:22:57 -0700 Subject: [PATCH 8/9] Walk into JSDoc --- internal/ls/selectionranges.go | 7 +++ .../smartSelection_JSDocTags1.baseline | 11 ++++ .../smartSelection_JSDocTags1.baseline.diff | 26 ++++++---- .../smartSelection_JSDocTags10.baseline | 11 ++++ .../smartSelection_JSDocTags10.baseline.diff | 25 +++++---- .../smartSelection_JSDocTags2.baseline | 8 +++ .../smartSelection_JSDocTags2.baseline.diff | 23 ++++---- .../smartSelection_JSDocTags3.baseline | 8 +++ .../smartSelection_JSDocTags3.baseline.diff | 21 +++++--- .../smartSelection_JSDocTags4.baseline | 17 ++++++ .../smartSelection_JSDocTags4.baseline.diff | 23 +++++++- .../smartSelection_JSDocTags5.baseline | 21 ++++++++ .../smartSelection_JSDocTags5.baseline.diff | 29 +++++++++-- .../smartSelection_JSDocTags6.baseline | 15 ++++++ .../smartSelection_JSDocTags6.baseline.diff | 33 +++++++----- .../smartSelection_JSDocTags7.baseline | 13 +++++ .../smartSelection_JSDocTags7.baseline.diff | 27 ++++++---- .../smartSelection_JSDocTags8.baseline | 26 ++++++++++ .../smartSelection_JSDocTags8.baseline.diff | 52 +++++++++++++------ .../smartSelection_JSDocTags9.baseline | 3 ++ .../smartSelection_JSDocTags9.baseline.diff | 13 +++-- 21 files changed, 325 insertions(+), 87 deletions(-) diff --git a/internal/ls/selectionranges.go b/internal/ls/selectionranges.go index a93e473e6c..823730282d 100644 --- a/internal/ls/selectionranges.go +++ b/internal/ls/selectionranges.go @@ -170,6 +170,13 @@ func getSmartSelectionRange(l *LanguageService, sourceFile *ast.SourceFile, pos return v.VisitNodes(nodes) } + // Visit JSDoc nodes first if they exist + if current.Flags&ast.NodeFlagsHasJSDoc != 0 { + for _, jsdoc := range current.JSDoc(sourceFile) { + visit(jsdoc) + } + } + tempVisitor := ast.NewNodeVisitor(visit, nil, ast.NodeVisitorHooks{ VisitNodes: visitNodes, }) diff --git a/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags1.baseline b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags1.baseline index 97057c429b..dc05be2dfe 100644 --- a/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags1.baseline +++ b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags1.baseline @@ -4,6 +4,17 @@ */ function foo() { return [] } + string ↲ + value: string ↲ + { value: string } ↲ + Array<{ value: string }> ↲ + + @returns {Array<{ value: string }>}↲ +• ↲ + +/** + * @returns {Array<{ value: string }>} + */↲ /** * @returns {Array<{ value: string }>} diff --git a/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags1.baseline.diff b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags1.baseline.diff index b2b343c511..feb6ca51ef 100644 --- a/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags1.baseline.diff +++ b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags1.baseline.diff @@ -1,9 +1,10 @@ --- old.smartSelection_JSDocTags1.baseline +++ new.smartSelection_JSDocTags1.baseline -@@= skipped -4, +4 lines =@@ +@@= skipped -3, +3 lines =@@ + */ function foo() { return [] } - +- - string - - @@ -15,16 +16,21 @@ - - Array<{ value: string }> - -- -- @returns {Array<{ value: string }>}↲ ++ string ↲ ++ value: string ↲ ++ { value: string } ↲ ++ Array<{ value: string }> ↲ + + @returns {Array<{ value: string }>}↲ -• - -- --/** -- * @returns {Array<{ value: string }>} ++• ↲ + + /** + * @returns {Array<{ value: string }>} - */ - -- ++ */↲ + /** - * @returns {Array<{ value: string }>} - */ \ No newline at end of file + * @returns {Array<{ value: string }>} \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags10.baseline b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags10.baseline index 3b002e2f42..8a3eba07c9 100644 --- a/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags10.baseline +++ b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags10.baseline @@ -6,6 +6,17 @@ class A extends B { } + Set ↲ + Set ↲ + @extends {Set}↲ + + @template T + * @extends {Set}↲ + +/** + * @template T + * @extends {Set} + */↲ /** * @template T diff --git a/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags10.baseline.diff b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags10.baseline.diff index 862f9aa746..414ab264a0 100644 --- a/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags10.baseline.diff +++ b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags10.baseline.diff @@ -1,9 +1,10 @@ --- old.smartSelection_JSDocTags10.baseline +++ new.smartSelection_JSDocTags10.baseline -@@= skipped -6, +6 lines =@@ +@@= skipped -5, +5 lines =@@ + class A extends B { } - +- - Set - - @@ -12,13 +13,19 @@ - - @extends {Set} - -- --/** -- * @template T -- * @extends {Set} ++ Set ↲ ++ Set ↲ ++ @extends {Set}↲ ++ ++ @template T ++ * @extends {Set}↲ + + /** + * @template T + * @extends {Set} - */ - -- ++ */↲ + /** - * @template T - * @extends {Set} \ No newline at end of file + * @template T \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags2.baseline b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags2.baseline index 7e9f37d62b..9096e04a80 100644 --- a/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags2.baseline +++ b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags2.baseline @@ -4,6 +4,14 @@ */ const foo; + string ↲ + + @type {string}↲ +• ↲ + +/** + * @type {string} + */↲ /** * @type {string} diff --git a/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags2.baseline.diff b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags2.baseline.diff index 445190e48d..39de1ed1bc 100644 --- a/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags2.baseline.diff +++ b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags2.baseline.diff @@ -1,21 +1,24 @@ --- old.smartSelection_JSDocTags2.baseline +++ new.smartSelection_JSDocTags2.baseline -@@= skipped -4, +4 lines =@@ +@@= skipped -3, +3 lines =@@ + */ const foo; - -- string - +- string - -- @type {string}↲ ++ string ↲ + + @type {string}↲ -• - -- --/** -- * @type {string} ++• ↲ + + /** + * @type {string} - */ - -- ++ */↲ + /** - * @type {string} - */ \ No newline at end of file + * @type {string} \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags3.baseline b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags3.baseline index 9f447cef5f..11c5873726 100644 --- a/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags3.baseline +++ b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags3.baseline @@ -4,6 +4,14 @@ */ function foo(x) {} + string ↲ + + @param {string} x↲ +• ↲ + +/** + * @param {string} x + */↲ /** * @param {string} x diff --git a/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags3.baseline.diff b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags3.baseline.diff index 39b7fd4745..ab5625443c 100644 --- a/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags3.baseline.diff +++ b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags3.baseline.diff @@ -1,20 +1,25 @@ --- old.smartSelection_JSDocTags3.baseline +++ new.smartSelection_JSDocTags3.baseline -@@= skipped -4, +4 lines =@@ +@@= skipped -3, +3 lines =@@ + */ function foo(x) {} - +- - string - - - @param {string} x - -- --/** -- * @param {string} x ++ string ↲ ++ ++ @param {string} x↲ ++• ↲ + + /** + * @param {string} x - */ - -- ++ */↲ + /** - * @param {string} x - */ \ No newline at end of file + * @param {string} x \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags4.baseline b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags4.baseline index cc40a448f6..5501c65dcb 100644 --- a/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags4.baseline +++ b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags4.baseline @@ -9,6 +9,23 @@ /** @type {Foo} */ const foo; + number ↲ + + @property {number} c↲ +• ↲ + + @typedef {object} Foo + * @property {string} a + * @property {number} b + * @property {number} c↲ +• ↲ + +/** + * @typedef {object} Foo + * @property {string} a + * @property {number} b + * @property {number} c + */↲ /** * @typedef {object} Foo diff --git a/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags4.baseline.diff b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags4.baseline.diff index f15502d303..f17991ca59 100644 --- a/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags4.baseline.diff +++ b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags4.baseline.diff @@ -1,9 +1,10 @@ --- old.smartSelection_JSDocTags4.baseline +++ new.smartSelection_JSDocTags4.baseline -@@= skipped -9, +9 lines =@@ +@@= skipped -8, +8 lines =@@ + /** @type {Foo} */ const foo; - +- - number - - @@ -25,6 +26,24 @@ - * @property {number} c - */ - ++ number ↲ ++ ++ @property {number} c↲ ++• ↲ ++ ++ @typedef {object} Foo ++ * @property {string} a ++ * @property {number} b ++ * @property {number} c↲ ++• ↲ ++ ++/** ++ * @typedef {object} Foo ++ * @property {string} a ++ * @property {number} b ++ * @property {number} c ++ */↲ ++ +/** + * @typedef {object} Foo + * @property {string} a diff --git a/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags5.baseline b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags5.baseline index 8e06d293a0..30c03e037b 100644 --- a/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags5.baseline +++ b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags5.baseline @@ -9,6 +9,27 @@ /** @type {Foo} */ const foo = s => !(s.length % 2); + number ↲ + + @param {number} [index] - comment + *• ↲ + + @param {string} data + * @param {number} [index] - comment + *• ↲ + + @callback Foo + * @param {string} data + * @param {number} [index] - comment + * @return {boolean}↲ +• ↲ + +/** + * @callback Foo + * @param {string} data + * @param {number} [index] - comment + * @return {boolean} + */↲ /** * @callback Foo diff --git a/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags5.baseline.diff b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags5.baseline.diff index 59d1b1a933..3403d78084 100644 --- a/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags5.baseline.diff +++ b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags5.baseline.diff @@ -1,13 +1,15 @@ --- old.smartSelection_JSDocTags5.baseline +++ new.smartSelection_JSDocTags5.baseline -@@= skipped -9, +9 lines =@@ +@@= skipped -8, +8 lines =@@ + /** @type {Foo} */ const foo = s => !(s.length % 2); - -- number - +- number - -- @param {number} [index] - comment ++ number ↲ + + @param {number} [index] - comment - - -/** @@ -25,6 +27,25 @@ - * @return {boolean} - */ - ++ *• ↲ ++ ++ @param {string} data ++ * @param {number} [index] - comment ++ *• ↲ ++ ++ @callback Foo ++ * @param {string} data ++ * @param {number} [index] - comment ++ * @return {boolean}↲ ++• ↲ ++ ++/** ++ * @callback Foo ++ * @param {string} data ++ * @param {number} [index] - comment ++ * @return {boolean} ++ */↲ ++ +/** + * @callback Foo + * @param {string} data diff --git a/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags6.baseline b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags6.baseline index 47bbf2c4f9..e61baed7c5 100644 --- a/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags6.baseline +++ b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags6.baseline @@ -8,6 +8,21 @@ function foo(x) { return x; } + T ↲ + + @param {T} x + *• ↲ + + @template T + * @param {T} x + * @return {T}↲ +• ↲ + +/** + * @template T + * @param {T} x + * @return {T} + */↲ /** * @template T diff --git a/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags6.baseline.diff b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags6.baseline.diff index 81f41814af..866cc3980a 100644 --- a/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags6.baseline.diff +++ b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags6.baseline.diff @@ -1,22 +1,29 @@ --- old.smartSelection_JSDocTags6.baseline +++ new.smartSelection_JSDocTags6.baseline -@@= skipped -8, +8 lines =@@ +@@= skipped -7, +7 lines =@@ + return x; } - -- T -- -- -- @param {T} x - +- T - --/** -- * @template T -- * @param {T} x -- * @return {T} ++ T ↲ + + @param {T} x ++ *• ↲ + ++ @template T ++ * @param {T} x ++ * @return {T}↲ ++• ↲ + + /** + * @template T + * @param {T} x + * @return {T} - */ - -- ++ */↲ + /** - * @template T - * @param {T} x \ No newline at end of file + * @template T \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags7.baseline b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags7.baseline index af95be534e..f11d6a5ef2 100644 --- a/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags7.baseline +++ b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags7.baseline @@ -6,6 +6,19 @@ function Foo(data) { } + number ↲ + + @param {number} data↲ +• ↲ + + @constructor + * @param {number} data↲ +• ↲ + +/** + * @constructor + * @param {number} data + */↲ /** * @constructor diff --git a/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags7.baseline.diff b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags7.baseline.diff index e2871c80eb..7192c0ba73 100644 --- a/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags7.baseline.diff +++ b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags7.baseline.diff @@ -1,21 +1,30 @@ --- old.smartSelection_JSDocTags7.baseline +++ new.smartSelection_JSDocTags7.baseline -@@= skipped -6, +6 lines =@@ +@@= skipped -5, +5 lines =@@ + function Foo(data) { } - +- - number - - - @param {number} data - -- --/** -- * @constructor -- * @param {number} data ++ number ↲ ++ ++ @param {number} data↲ ++• ↲ ++ ++ @constructor ++ * @param {number} data↲ ++• ↲ + + /** + * @constructor + * @param {number} data - */ - -- ++ */↲ + /** - * @constructor - * @param {number} data \ No newline at end of file + * @constructor \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags8.baseline b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags8.baseline index 4b0fe1916c..a75ccd40a2 100644 --- a/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags8.baseline +++ b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags8.baseline @@ -6,6 +6,19 @@ function callback(e) { } + Foo ↲ + + @this {Foo} + *• ↲ + + @this {Foo} + * @param {*} e↲ +• ↲ + +/** + * @this {Foo} + * @param {*} e + */↲ /** * @this {Foo} @@ -23,6 +36,19 @@ function callback(e) { function callback(e) { } + * ↲ + + @param {*} e↲ +• ↲ + + @this {Foo} + * @param {*} e↲ +• ↲ + +/** + * @this {Foo} + * @param {*} e + */↲ /** * @this {Foo} diff --git a/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags8.baseline.diff b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags8.baseline.diff index 0554a3c481..d193bd94bf 100644 --- a/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags8.baseline.diff +++ b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags8.baseline.diff @@ -1,40 +1,58 @@ --- old.smartSelection_JSDocTags8.baseline +++ new.smartSelection_JSDocTags8.baseline -@@= skipped -6, +6 lines =@@ +@@= skipped -5, +5 lines =@@ + function callback(e) { } - +- - Foo - - - @this {Foo} - -- --/** -- * @this {Foo} -- * @param {*} e ++ Foo ↲ ++ ++ @this {Foo} ++ *• ↲ ++ ++ @this {Foo} ++ * @param {*} e↲ ++• ↲ + + /** + * @this {Foo} + * @param {*} e - */ - -- ++ */↲ + /** * @this {Foo} - * @param {*} e -@@= skipped -27, +15 lines =@@ - */ +@@= skipped -29, +30 lines =@@ function callback(e) { } -- + - - * - - - @param {*} e - -- --/** -- * @this {Foo} -- * @param {*} e -- */ ++ * ↲ ++ ++ @param {*} e↲ ++• ↲ ++ ++ @this {Foo} ++ * @param {*} e↲ ++• ↲ + /** + * @this {Foo} + * @param {*} e +- */ +- ++ */↲ - /** \ No newline at end of file + /** + * @this {Foo} \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags9.baseline b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags9.baseline index 36d1c173c7..02e046a1ae 100644 --- a/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags9.baseline +++ b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags9.baseline @@ -5,6 +5,9 @@ const Foo = { y: 1, }; + {number}• ↲ + @enum {number}• ↲ +/** @enum {number} */↲ /** @enum {number} */ const Foo = { diff --git a/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags9.baseline.diff b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags9.baseline.diff index a85e3aef9d..755605b141 100644 --- a/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags9.baseline.diff +++ b/testdata/baselines/reference/submodule/fourslash/smartSelection/smartSelection_JSDocTags9.baseline.diff @@ -1,9 +1,10 @@ --- old.smartSelection_JSDocTags9.baseline +++ new.smartSelection_JSDocTags9.baseline -@@= skipped -5, +5 lines =@@ +@@= skipped -4, +4 lines =@@ + y: 1, }; - +- - number - - @@ -12,7 +13,9 @@ - -/** @enum {number} */ - -- ++ {number}• ↲ ++ @enum {number}• ↲ ++/** @enum {number} */↲ + /** @enum {number} */ - const Foo = { - x: 0, \ No newline at end of file + const Foo = { \ No newline at end of file From d02265494995e0a277a737739922c2096e12a637 Mon Sep 17 00:00:00 2001 From: Jake Bailey <5341706+jakebailey@users.noreply.github.com> Date: Thu, 23 Oct 2025 11:41:11 -0700 Subject: [PATCH 9/9] Feedback --- internal/fourslash/_scripts/convertFourslash.mts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/internal/fourslash/_scripts/convertFourslash.mts b/internal/fourslash/_scripts/convertFourslash.mts index 687b3fe4ff..5d47f7a836 100644 --- a/internal/fourslash/_scripts/convertFourslash.mts +++ b/internal/fourslash/_scripts/convertFourslash.mts @@ -1427,7 +1427,7 @@ function parseBaselineSignatureHelp(args: ts.NodeArray): Cmd { function parseBaselineSmartSelection(args: ts.NodeArray): Cmd { if (args.length !== 0) { // All calls are currently empty! - throw new Error("Expected no arguments in verify.baselineSignatureHelp"); + throw new Error("Expected no arguments in verify.baselineSmartSelection"); } return { kind: "verifyBaselineSmartSelection", @@ -1789,7 +1789,6 @@ function generateCmd(cmd: Cmd): string { return `f.VerifyRenameSucceeded(t, ${cmd.preferences})`; case "renameInfoFailed": return `f.VerifyRenameFailed(t, ${cmd.preferences})`; - default: let neverCommand: never = cmd; throw new Error(`Unknown command kind: ${neverCommand as Cmd["kind"]}`);