Skip to content

Commit 8c75f07

Browse files
committed
Always require getCodeActions.trigger
1 parent 7b095ea commit 8c75f07

4 files changed

Lines changed: 17 additions & 25 deletions

File tree

src/tsconfig.strictNullChecks.json

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,19 @@
66
},
77
"include": [
88
"./typings",
9+
"./vs/base/browser/**/*.ts",
910
"./vs/base/common/**/*.ts",
1011
"./vs/base/node/**/*.ts",
11-
"./vs/base/browser/**/*.ts",
12-
"./vs/editor/common/**/*.ts",
1312
"./vs/editor/browser/**/*.ts",
14-
"./vs/editor/test/**/*.ts",
15-
"./vs/editor/contrib/smartSelect/**/*.ts",
13+
"./vs/editor/common/**/*.ts",
14+
"./vs/editor/contrib/codeAction/**/*.ts",
1615
"./vs/editor/contrib/format/**/*.ts",
1716
"./vs/editor/contrib/gotoError/**/*.ts",
1817
"./vs/editor/contrib/inPlaceReplace/**/*.ts",
18+
"./vs/editor/contrib/smartSelect/**/*.ts",
19+
"./vs/editor/contrib/snippet/**/*.ts",
1920
"./vs/editor/contrib/suggest/**/*.ts",
20-
"./vs/editor/contrib/snippet/**/*.ts"
21+
"./vs/editor/test/**/*.ts",
2122
],
2223
"files": [
2324
"./vs/base/parts/contextmenu/common/contextmenu.ts",
@@ -156,15 +157,6 @@
156157
"./vs/editor/contrib/caretOperations/test/moveCarretCommand.test.ts",
157158
"./vs/editor/contrib/caretOperations/transpose.ts",
158159
"./vs/editor/contrib/clipboard/clipboard.ts",
159-
"./vs/editor/contrib/codeAction/codeAction.ts",
160-
"./vs/editor/contrib/codeAction/codeActionCommands.ts",
161-
"./vs/editor/contrib/codeAction/codeActionContributions.ts",
162-
"./vs/editor/contrib/codeAction/codeActionModel.ts",
163-
"./vs/editor/contrib/codeAction/codeActionTrigger.ts",
164-
"./vs/editor/contrib/codeAction/codeActionWidget.ts",
165-
"./vs/editor/contrib/codeAction/lightBulbWidget.ts",
166-
"./vs/editor/contrib/codeAction/test/codeAction.test.ts",
167-
"./vs/editor/contrib/codeAction/test/codeActionModel.test.ts",
168160
"./vs/editor/contrib/codelens/codelens.ts",
169161
"./vs/editor/contrib/codelens/codelensController.ts",
170162
"./vs/editor/contrib/codelens/codelensWidget.ts",

src/vs/editor/contrib/codeAction/codeAction.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@ import { CodeActionFilter, CodeActionKind, CodeActionTrigger } from './codeActio
1818
export function getCodeActions(
1919
model: ITextModel,
2020
rangeOrSelection: Range | Selection,
21-
trigger: CodeActionTrigger | undefined,
21+
trigger: CodeActionTrigger,
2222
token: CancellationToken
2323
): Promise<CodeAction[]> {
2424
const codeActionContext: CodeActionContext = {
25-
only: trigger && trigger.filter && trigger.filter.kind ? trigger.filter.kind.value : undefined,
26-
trigger: trigger && trigger.type === 'manual' ? CodeActionTriggerKind.Manual : CodeActionTriggerKind.Automatic
25+
only: trigger.filter && trigger.filter.kind ? trigger.filter.kind.value : undefined,
26+
trigger: trigger.type === 'manual' ? CodeActionTriggerKind.Manual : CodeActionTriggerKind.Automatic
2727
};
2828

2929
const promises = CodeActionProviderRegistry.all(model)
@@ -36,12 +36,12 @@ export function getCodeActions(
3636
return provider.providedCodeActionKinds.some(providedKind => {
3737
// Filter out actions by kind
3838
// The provided kind can be either a subset of a superset of the filtered kind
39-
if (trigger && trigger.filter && trigger.filter.kind && !(trigger.filter.kind.contains(providedKind) || new CodeActionKind(providedKind).contains(trigger.filter.kind.value))) {
39+
if (trigger.filter && trigger.filter.kind && !(trigger.filter.kind.contains(providedKind) || new CodeActionKind(providedKind).contains(trigger.filter.kind.value))) {
4040
return false;
4141
}
4242

4343
// Don't return source actions unless they are explicitly requested
44-
if (trigger && CodeActionKind.Source.contains(providedKind) && (!trigger.filter || !trigger.filter.includeSourceActions)) {
44+
if (CodeActionKind.Source.contains(providedKind) && (!trigger.filter || !trigger.filter.includeSourceActions)) {
4545
return false;
4646
}
4747

@@ -53,7 +53,7 @@ export function getCodeActions(
5353
if (!Array.isArray(providedCodeActions)) {
5454
return [];
5555
}
56-
return providedCodeActions.filter(action => isValidAction(trigger && trigger.filter, action));
56+
return providedCodeActions.filter(action => isValidAction(trigger.filter, action));
5757
}, (err): CodeAction[] => {
5858
if (isPromiseCanceledError(err)) {
5959
throw err;

src/vs/editor/contrib/codeAction/test/codeAction.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ suite('CodeAction', () => {
116116
testData.tsLint.abc
117117
];
118118

119-
const actions = await getCodeActions(model, new Range(1, 1, 2, 1), undefined, CancellationToken.None);
119+
const actions = await getCodeActions(model, new Range(1, 1, 2, 1), { type: 'manual' }, CancellationToken.None);
120120
assert.equal(actions.length, 6);
121121
assert.deepEqual(actions, expected);
122122
});

src/vs/workbench/test/electron-browser/api/extHostLanguageFeatures.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -670,7 +670,7 @@ suite('ExtHostLanguageFeatures', function () {
670670
}));
671671

672672
return rpcProtocol.sync().then(() => {
673-
return getCodeActions(model, model.getFullModelRange(), undefined, CancellationToken.None).then(value => {
673+
return getCodeActions(model, model.getFullModelRange(), { type: 'manual' }, CancellationToken.None).then(value => {
674674
assert.equal(value.length, 2);
675675

676676
const [first, second] = value;
@@ -697,7 +697,7 @@ suite('ExtHostLanguageFeatures', function () {
697697
}));
698698

699699
return rpcProtocol.sync().then(() => {
700-
return getCodeActions(model, model.getFullModelRange(), undefined, CancellationToken.None).then(value => {
700+
return getCodeActions(model, model.getFullModelRange(), { type: 'manual' }, CancellationToken.None).then(value => {
701701
assert.equal(value.length, 1);
702702

703703
const [first] = value;
@@ -723,7 +723,7 @@ suite('ExtHostLanguageFeatures', function () {
723723
}));
724724

725725
return rpcProtocol.sync().then(() => {
726-
return getCodeActions(model, model.getFullModelRange(), undefined, CancellationToken.None).then(value => {
726+
return getCodeActions(model, model.getFullModelRange(), { type: 'manual' }, CancellationToken.None).then(value => {
727727
assert.equal(value.length, 1);
728728
});
729729
});
@@ -743,7 +743,7 @@ suite('ExtHostLanguageFeatures', function () {
743743
}));
744744

745745
return rpcProtocol.sync().then(() => {
746-
return getCodeActions(model, model.getFullModelRange(), undefined, CancellationToken.None).then(value => {
746+
return getCodeActions(model, model.getFullModelRange(), { type: 'manual' }, CancellationToken.None).then(value => {
747747
assert.equal(value.length, 1);
748748
});
749749
});

0 commit comments

Comments
 (0)