Skip to content

Commit c05c379

Browse files
authored
Support inferSeletion when extract variable (#1717)
Signed-off-by: Shi Chen <[email protected]>
1 parent 5514f22 commit c05c379

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

src/extension.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ export function activate(context: ExtensionContext): Promise<ExtensionAPI> {
174174
generateConstructorsPromptSupport: true,
175175
generateDelegateMethodsPromptSupport: true,
176176
advancedExtractRefactoringSupport: true,
177-
inferSelectionSupport: ["extractMethod"],
177+
inferSelectionSupport: ["extractMethod", "extractVariable"],
178178
moveRefactoringSupport: true,
179179
clientHoverProvider: true,
180180
clientDocumentSymbolProvider: true,

src/refactorAction.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,10 @@ function registerApplyRefactorCommand(languageClient: LanguageClient, context: E
7070

7171
commandArguments.push(initializeIn);
7272
}
73-
} else if (command === 'extractMethod') {
73+
} else if (command === 'extractMethod'
74+
|| command === 'extractVariableAllOccurrence'
75+
|| command === 'extractVariable'
76+
|| command === 'extractConstant') {
7477
if (!params || !params.range) {
7578
return;
7679
}
@@ -81,12 +84,12 @@ function registerApplyRefactorCommand(languageClient: LanguageClient, context: E
8184
});
8285
const options: IExpressionItem[] = [];
8386
for (const expression of expressions) {
84-
const extractMethodItem: IExpressionItem = {
87+
const extractItem: IExpressionItem = {
8588
label: expression.name,
8689
length: expression.length,
8790
offset: expression.offset,
8891
};
89-
options.push(extractMethodItem);
92+
options.push(extractItem);
9093
}
9194
let resultItem: IExpressionItem;
9295
if (options.length === 1) {

0 commit comments

Comments
 (0)