mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
getApplicableRefactors: Don't return undefined response (#16773)
This commit is contained in:
@@ -33,22 +33,9 @@ namespace ts {
|
||||
refactors.set(refactor.name, refactor);
|
||||
}
|
||||
|
||||
export function getApplicableRefactors(context: RefactorContext): ApplicableRefactorInfo[] | undefined {
|
||||
let results: ApplicableRefactorInfo[];
|
||||
const refactorList: Refactor[] = [];
|
||||
refactors.forEach(refactor => {
|
||||
refactorList.push(refactor);
|
||||
});
|
||||
for (const refactor of refactorList) {
|
||||
if (context.cancellationToken && context.cancellationToken.isCancellationRequested()) {
|
||||
return results;
|
||||
}
|
||||
const infos = refactor.getAvailableActions(context);
|
||||
if (infos && infos.length) {
|
||||
(results || (results = [])).push(...infos);
|
||||
}
|
||||
}
|
||||
return results;
|
||||
export function getApplicableRefactors(context: RefactorContext): ApplicableRefactorInfo[] {
|
||||
return flatMapIter(refactors.values(), refactor =>
|
||||
context.cancellationToken && context.cancellationToken.isCancellationRequested() ? [] : refactor.getAvailableActions(context));
|
||||
}
|
||||
|
||||
export function getEditsForRefactor(context: RefactorContext, refactorName: string, actionName: string): RefactorEditInfo | undefined {
|
||||
|
||||
Reference in New Issue
Block a user