Skip to content

Commit 19c3a15

Browse files
committed
Allow cancellation during extract method's symbol walking
1 parent ea4fdc5 commit 19c3a15

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/services/refactors/extractMethod.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -531,7 +531,8 @@ namespace ts.refactor.extractMethod {
531531
scopes,
532532
enclosingTextRange,
533533
sourceFile,
534-
context.program.getTypeChecker());
534+
context.program.getTypeChecker(),
535+
context.cancellationToken);
535536

536537
context.cancellationToken.throwIfCancellationRequested();
537538

@@ -932,7 +933,8 @@ namespace ts.refactor.extractMethod {
932933
scopes: Scope[],
933934
enclosingTextRange: TextRange,
934935
sourceFile: SourceFile,
935-
checker: TypeChecker) {
936+
checker: TypeChecker,
937+
cancellationToken: CancellationToken) {
936938

937939
const allTypeParameterUsages = createMap<TypeParameter>(); // Key is type ID
938940
const usagesPerScope: ScopeUsages[] = [];
@@ -1045,7 +1047,7 @@ namespace ts.refactor.extractMethod {
10451047
// PERF: This is potentially very expensive. `type` could be a library type with
10461048
// a lot of properties, each of which the walker will visit. Unfortunately, the
10471049
// solution isn't as trivial as filtering to user types because of (e.g.) Array.
1048-
const symbolWalker = checker.getSymbolWalker();
1050+
const symbolWalker = checker.getSymbolWalker(() => (cancellationToken.throwIfCancellationRequested(), true));
10491051
const {visitedTypes} = symbolWalker.walkType(type);
10501052

10511053
for (const visitedType of visitedTypes) {

0 commit comments

Comments
 (0)