Allow cancellation during extract method's symbol walking

This commit is contained in:
Andrew Casey
2017-08-29 13:24:13 -07:00
parent ea4fdc5a99
commit 19c3a150e7

View File

@@ -531,7 +531,8 @@ namespace ts.refactor.extractMethod {
scopes,
enclosingTextRange,
sourceFile,
context.program.getTypeChecker());
context.program.getTypeChecker(),
context.cancellationToken);
context.cancellationToken.throwIfCancellationRequested();
@@ -932,7 +933,8 @@ namespace ts.refactor.extractMethod {
scopes: Scope[],
enclosingTextRange: TextRange,
sourceFile: SourceFile,
checker: TypeChecker) {
checker: TypeChecker,
cancellationToken: CancellationToken) {
const allTypeParameterUsages = createMap<TypeParameter>(); // Key is type ID
const usagesPerScope: ScopeUsages[] = [];
@@ -1045,7 +1047,7 @@ namespace ts.refactor.extractMethod {
// PERF: This is potentially very expensive. `type` could be a library type with
// a lot of properties, each of which the walker will visit. Unfortunately, the
// solution isn't as trivial as filtering to user types because of (e.g.) Array.
const symbolWalker = checker.getSymbolWalker();
const symbolWalker = checker.getSymbolWalker(() => (cancellationToken.throwIfCancellationRequested(), true));
const {visitedTypes} = symbolWalker.walkType(type);
for (const visitedType of visitedTypes) {