Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 25 additions & 3 deletions tsc/internal/fourslash/fourslash.go
Original file line number Diff line number Diff line change
Expand Up @@ -1990,7 +1990,7 @@ func (f *FourslashTest) VerifySourceFixAll(t *testing.T, expectedContent string)

var selected *lsproto.CodeAction
for _, item := range *result.CommandOrCodeActionArray {
if item.CodeAction == nil || item.CodeAction.Kind == nil || *item.CodeAction.Kind != lsproto.CodeActionKindSourceFixAll {
if item.CodeAction == nil || item.CodeAction.Kind == nil || *item.CodeAction.Kind != lsproto.CodeActionKindSourceFixAllTs {
continue
}
selected = item.CodeAction
Expand Down Expand Up @@ -2129,6 +2129,28 @@ func (f *FourslashTest) applyEditsToContent(content string, edits []*lsproto.Tex

func (f *FourslashTest) VerifyOrganizeImports(t *testing.T, expectedContent string, codeActionKind lsproto.CodeActionKind, preferences *lsutil.UserPreferences) {
t.Helper()
f.verifyOrganizeImports(t, expectedContent, codeActionKind, codeActionKind, preferences)
}

func (f *FourslashTest) VerifyOrganizeImportsWithRequestKind(
t *testing.T,
expectedContent string,
requestedKind lsproto.CodeActionKind,
expectedKind lsproto.CodeActionKind,
preferences *lsutil.UserPreferences,
) {
t.Helper()
f.verifyOrganizeImports(t, expectedContent, requestedKind, expectedKind, preferences)
}

func (f *FourslashTest) verifyOrganizeImports(
t *testing.T,
expectedContent string,
requestedKind lsproto.CodeActionKind,
expectedKind lsproto.CodeActionKind,
preferences *lsutil.UserPreferences,
) {
t.Helper()

if preferences != nil {
reset := f.ConfigureWithReset(t, *preferences)
Expand All @@ -2144,7 +2166,7 @@ func (f *FourslashTest) VerifyOrganizeImports(t *testing.T, expectedContent stri
End: f.converters.PositionToLineAndCharacter(f.getScriptInfo(f.activeFilename), core.TextPos(len(f.getScriptInfo(f.activeFilename).content))),
},
Context: &lsproto.CodeActionContext{
Only: &[]lsproto.CodeActionKind{codeActionKind},
Only: &[]lsproto.CodeActionKind{requestedKind},
},
}

Expand All @@ -2156,7 +2178,7 @@ func (f *FourslashTest) VerifyOrganizeImports(t *testing.T, expectedContent stri

var organizeAction *lsproto.CodeAction
for _, item := range *result.CommandOrCodeActionArray {
if item.CodeAction != nil && item.CodeAction.Kind != nil && *item.CodeAction.Kind == codeActionKind {
if item.CodeAction != nil && item.CodeAction.Kind != nil && *item.CodeAction.Kind == expectedKind {
organizeAction = item.CodeAction
break
}
Expand Down
2 changes: 1 addition & 1 deletion tsc/internal/fourslash/tests/organizeImports10_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export function fun() { /* ... */ }

/** Intended to be used in combination with {@link ZodType} */
export function fun() { /* ... */ }`,
lsproto.CodeActionKindSourceOrganizeImports,
lsproto.CodeActionKindSourceOrganizeImportsTs,
nil,
)
}
2 changes: 1 addition & 1 deletion tsc/internal/fourslash/tests/organizeImports11_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ export class MyClass {
someFunction();
}
}`,
lsproto.CodeActionKindSourceOrganizeImports,
lsproto.CodeActionKindSourceOrganizeImportsTs,
nil,
)
}
2 changes: 1 addition & 1 deletion tsc/internal/fourslash/tests/organizeImports12_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ declare export * from "foo";`
declare export * from "foo";
declare export { a, b };
`,
lsproto.CodeActionKindSourceOrganizeImports,
lsproto.CodeActionKindSourceOrganizeImportsTs,
nil,
)
}
4 changes: 2 additions & 2 deletions tsc/internal/fourslash/tests/organizeImports13_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ console.log(func1, func2, func3, func4, func5, func6, func7, func8, func9);`
} from "foo";
interface Use extends Type1, Type2, Type3, Type4, Type5, Type6, Type7, Type8, Type9 {}
console.log(func1, func2, func3, func4, func5, func6, func7, func8, func9);`,
lsproto.CodeActionKindSourceOrganizeImports,
lsproto.CodeActionKindSourceOrganizeImportsTs,
nil,
)
f.VerifyOrganizeImports(t,
Expand All @@ -86,7 +86,7 @@ console.log(func1, func2, func3, func4, func5, func6, func7, func8, func9);`,
} from "foo";
interface Use extends Type1, Type2, Type3, Type4, Type5, Type6, Type7, Type8, Type9 {}
console.log(func1, func2, func3, func4, func5, func6, func7, func8, func9);`,
lsproto.CodeActionKindSourceOrganizeImports,
lsproto.CodeActionKindSourceOrganizeImportsTs,
&lsutil.UserPreferences{
OrganizeImportsIgnoreCase: core.TSTrue,
},
Expand Down
2 changes: 1 addition & 1 deletion tsc/internal/fourslash/tests/organizeImports14_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ import { foo } from "./a";`
// comment 2

`,
lsproto.CodeActionKindSourceOrganizeImports,
lsproto.CodeActionKindSourceOrganizeImportsTs,
nil,
)
}
2 changes: 1 addition & 1 deletion tsc/internal/fourslash/tests/organizeImports15_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ import { foo } from "./a";`
// comment 2

`,
lsproto.CodeActionKindSourceOrganizeImports,
lsproto.CodeActionKindSourceOrganizeImportsTs,
nil,
)
}
8 changes: 4 additions & 4 deletions tsc/internal/fourslash/tests/organizeImports16_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@ console.log(a, b);`
`import { a, A, b } from "foo";
interface Use extends A {}
console.log(a, b);`,
lsproto.CodeActionKindSourceOrganizeImports,
lsproto.CodeActionKindSourceOrganizeImportsTs,
nil,
)
f.ReplaceLine(t, 0, "import { a, A, b } from \"foo1\";")
f.VerifyOrganizeImports(t,
`import { a, A, b } from "foo1";
interface Use extends A {}
console.log(a, b);`,
lsproto.CodeActionKindSourceOrganizeImports,
lsproto.CodeActionKindSourceOrganizeImportsTs,
&lsutil.UserPreferences{
OrganizeImportsIgnoreCase: core.TSUnknown,
},
Expand All @@ -40,7 +40,7 @@ console.log(a, b);`,
`import { a, A, b } from "foo2";
interface Use extends A {}
console.log(a, b);`,
lsproto.CodeActionKindSourceOrganizeImports,
lsproto.CodeActionKindSourceOrganizeImportsTs,
&lsutil.UserPreferences{
OrganizeImportsIgnoreCase: core.TSTrue,
},
Expand All @@ -50,7 +50,7 @@ console.log(a, b);`,
`import { A, a, b } from "foo3";
interface Use extends A {}
console.log(a, b);`,
lsproto.CodeActionKindSourceOrganizeImports,
lsproto.CodeActionKindSourceOrganizeImportsTs,
&lsutil.UserPreferences{
OrganizeImportsIgnoreCase: core.TSFalse,
},
Expand Down
2 changes: 1 addition & 1 deletion tsc/internal/fourslash/tests/organizeImports17_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import { aa, CaseInsensitively, sorted } from "aardvark";`
`import { aa, CaseInsensitively, sorted } from "aardvark";
import { Both } from "module-specifiers-unsorted";
`,
lsproto.CodeActionKindSourceSortImports,
lsproto.CodeActionKindSourceSortImportsTs,
&lsutil.UserPreferences{
OrganizeImportsIgnoreCase: core.TSUnknown,
},
Expand Down
2 changes: 1 addition & 1 deletion tsc/internal/fourslash/tests/organizeImports18_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export { bFuncA } from "./A";
export { bFuncB } from "./B";
export { bFuncC } from "./C";
`,
lsproto.CodeActionKindSourceOrganizeImports,
lsproto.CodeActionKindSourceOrganizeImportsTs,
nil,
)
}
2 changes: 1 addition & 1 deletion tsc/internal/fourslash/tests/organizeImports19_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export { b };
const c = 1;
export { c };
`,
lsproto.CodeActionKindSourceOrganizeImports,
lsproto.CodeActionKindSourceOrganizeImportsTs,
nil,
)
}
5 changes: 3 additions & 2 deletions tsc/internal/fourslash/tests/organizeImports1_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ console.log(a, B, b, c, C, d, D);
console.log(e, f, F, g, G, H, h);`
f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content)
defer done()
f.VerifyOrganizeImports(t,
f.VerifyOrganizeImportsWithRequestKind(t,
`import {
a,
b,
Expand All @@ -49,6 +49,7 @@ console.log(e, f, F, g, G, H, h);`
console.log(a, B, b, c, C, d, D);
console.log(e, f, F, g, G, H, h);`,
lsproto.CodeActionKindSourceOrganizeImports,
lsproto.CodeActionKindSourceOrganizeImportsTs,
&lsutil.UserPreferences{
OrganizeImportsIgnoreCase: core.TSTrue,
},
Expand All @@ -73,7 +74,7 @@ console.log(e, f, F, g, G, H, h);`,

console.log(a, B, b, c, C, d, D);
console.log(e, f, F, g, G, H, h);`,
lsproto.CodeActionKindSourceOrganizeImports,
lsproto.CodeActionKindSourceOrganizeImportsTs,
&lsutil.UserPreferences{
OrganizeImportsIgnoreCase: core.TSFalse,
},
Expand Down
2 changes: 1 addition & 1 deletion tsc/internal/fourslash/tests/organizeImports20_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export { b };`
const b = 1;
export { a, b };
`,
lsproto.CodeActionKindSourceOrganizeImports,
lsproto.CodeActionKindSourceOrganizeImportsTs,
nil,
)
}
2 changes: 1 addition & 1 deletion tsc/internal/fourslash/tests/organizeImports21_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export {
PersonDefinitions
} from './a';
`,
lsproto.CodeActionKindSourceOrganizeImports,
lsproto.CodeActionKindSourceOrganizeImportsTs,
nil,
)
}
4 changes: 2 additions & 2 deletions tsc/internal/fourslash/tests/organizeImports22_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ console.log(abc, Abc, bc, Bc, I, R, M);`
} from 'a';
import { abc, Abc, bc, Bc } from 'b';
console.log(abc, Abc, bc, Bc, I, R, M);`,
lsproto.CodeActionKindSourceOrganizeImports,
lsproto.CodeActionKindSourceOrganizeImportsTs,
nil,
)
f.VerifyOrganizeImports(t,
Expand All @@ -39,7 +39,7 @@ console.log(abc, Abc, bc, Bc, I, R, M);`,
} from 'a';
import { abc, Abc, bc, Bc } from 'b';
console.log(abc, Abc, bc, Bc, I, R, M);`,
lsproto.CodeActionKindSourceOrganizeImports,
lsproto.CodeActionKindSourceOrganizeImportsTs,
nil,
)
}
4 changes: 2 additions & 2 deletions tsc/internal/fourslash/tests/organizeImports23_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ console.log(abc, Abc, I, R, M);`
import { abc, Abc, type bc, type Bc } from 'b';
type x = bc | Bc;
console.log(abc, Abc, I, R, M);`,
lsproto.CodeActionKindSourceOrganizeImports,
lsproto.CodeActionKindSourceOrganizeImportsTs,
nil,
)
f.VerifyOrganizeImports(t,
Expand All @@ -42,7 +42,7 @@ console.log(abc, Abc, I, R, M);`,
import { abc, Abc, type bc, type Bc } from 'b';
type x = bc | Bc;
console.log(abc, Abc, I, R, M);`,
lsproto.CodeActionKindSourceOrganizeImports,
lsproto.CodeActionKindSourceOrganizeImportsTs,
nil,
)
}
2 changes: 1 addition & 1 deletion tsc/internal/fourslash/tests/organizeImports2_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ console.log(Foo, Bar);`
} from "foo";

console.log(Foo, Bar);`,
lsproto.CodeActionKindSourceOrganizeImports,
lsproto.CodeActionKindSourceOrganizeImportsTs,
nil,
)
}
2 changes: 1 addition & 1 deletion tsc/internal/fourslash/tests/organizeImports3_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ console.log(Foo, Bar);`
} from "foo";

console.log(Foo, Bar);`,
lsproto.CodeActionKindSourceOrganizeImports,
lsproto.CodeActionKindSourceOrganizeImportsTs,
nil,
)
}
2 changes: 1 addition & 1 deletion tsc/internal/fourslash/tests/organizeImports4_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import * as AnotherThingElse from "someotherpath";`
defer done()
f.VerifyOrganizeImports(t,
``,
lsproto.CodeActionKindSourceOrganizeImports,
lsproto.CodeActionKindSourceOrganizeImportsTs,
nil,
)
}
2 changes: 1 addition & 1 deletion tsc/internal/fourslash/tests/organizeImports5_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import * as AnotherThingElse from "someotherpath";`
defer done()
f.VerifyOrganizeImports(t,
``,
lsproto.CodeActionKindSourceOrganizeImports,
lsproto.CodeActionKindSourceOrganizeImportsTs,
nil,
)
}
2 changes: 1 addition & 1 deletion tsc/internal/fourslash/tests/organizeImports6_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ import * as anotherThing from "someopath"; /* small comment */ // single line on
*/

anotherThing;`,
lsproto.CodeActionKindSourceOrganizeImports,
lsproto.CodeActionKindSourceOrganizeImportsTs,
nil,
)
}
2 changes: 1 addition & 1 deletion tsc/internal/fourslash/tests/organizeImports7_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import * as something from "path"; /**

something;
somethingElse;`,
lsproto.CodeActionKindSourceOrganizeImports,
lsproto.CodeActionKindSourceOrganizeImportsTs,
nil,
)
}
2 changes: 1 addition & 1 deletion tsc/internal/fourslash/tests/organizeImports8_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ foo;`
f.VerifyOrganizeImports(t,
`import { foo } from "foo";
foo;`,
lsproto.CodeActionKindSourceOrganizeImports,
lsproto.CodeActionKindSourceOrganizeImportsTs,
nil,
)
}
2 changes: 1 addition & 1 deletion tsc/internal/fourslash/tests/organizeImports9_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ a(b, d);`
f.VerifyOrganizeImports(t,
`import { a, b, d } from "foo";
a(b, d);`,
lsproto.CodeActionKindSourceOrganizeImports,
lsproto.CodeActionKindSourceOrganizeImportsTs,
nil,
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import { A as D } from "./a" with { type: "b" };
import { Z } from "./z";

export type G = A | B | C | D | E | F | Z;`,
lsproto.CodeActionKindSourceOrganizeImports,
lsproto.CodeActionKindSourceOrganizeImportsTs,
nil,
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import { A as D, Y } from "./a" with { type: "b" };
import { Z } from "./z";

export type G = A | B | C | D | E | F | Y | Z;`,
lsproto.CodeActionKindSourceOrganizeImports,
lsproto.CodeActionKindSourceOrganizeImportsTs,
nil,
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import { F, Z } from "./a" with { foo: "42" };
import { Y } from "./a" with { foo: 42 };

export type G = A | B | C | D | E | F | Y | Z;`,
lsproto.CodeActionKindSourceOrganizeImports,
lsproto.CodeActionKindSourceOrganizeImportsTs,
nil,
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import { C, E } from "./file" with { type: "a" };
import { A as D, A as F } from "./file" with { type: "b" };

type G = A | B | C | D | E | F;`,
lsproto.CodeActionKindSourceOrganizeImports,
lsproto.CodeActionKindSourceOrganizeImportsTs,
nil,
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import b from "B";
import d from "D";

console.log(a, b, c, d)`,
lsproto.CodeActionKindSourceOrganizeImports,
lsproto.CodeActionKindSourceOrganizeImportsTs,
nil,
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import b from "B";
import d from "D";

console.log(a, b, c, d)`,
lsproto.CodeActionKindSourceOrganizeImports,
lsproto.CodeActionKindSourceOrganizeImportsTs,
nil,
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import b from "B";
import d from "D";

console.log(a, b, c, d)`,
lsproto.CodeActionKindSourceOrganizeImports,
lsproto.CodeActionKindSourceOrganizeImportsTs,
nil,
)
}
Loading
Loading