diff --git a/package.json b/package.json index 4e9ff928..2cfc0b81 100644 --- a/package.json +++ b/package.json @@ -198,6 +198,16 @@ "command": "sourcery.rule.create", "title": "Create custom rule", "category": "Sourcery" + }, + { + "command": "sourcery.effects.enable", + "title": "Show Effects", + "category": "Sourcery" + }, + { + "command": "sourcery.effects.disable", + "title": "Hide Effects", + "category": "Sourcery" } ], "submenus": [ @@ -289,6 +299,14 @@ { "command": "sourcery.rule.create", "when": "false" + }, + { + "command": "sourcery.effects.enable", + "when": "sourcery.features.code_understanding && !sourcery.effects.enabled" + }, + { + "command": "sourcery.effects.disable", + "when": "sourcery.features.code_understanding && sourcery.effects.enabled" } ] }, diff --git a/src/extension.ts b/src/extension.ts index 59d0908f..6bbbe24b 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -171,6 +171,22 @@ function registerCommands(context: ExtensionContext, riProvider: RuleInputProvid })); + // Enable/disable effects + context.subscriptions.push( + commands.registerCommand('sourcery.effects.enable', () => effects_set_enabled(true)) + ); + context.subscriptions.push( + commands.registerCommand('sourcery.effects.disable', () => effects_set_enabled(false)) + ); + function effects_set_enabled(enabled: boolean) { + vscode.commands.executeCommand('setContext', 'sourcery.effects.enabled', enabled); + let request: ExecuteCommandParams = { + command: 'sourcery.effects.set_enabled', + arguments: [enabled] + }; + languageClient.sendRequest(ExecuteCommandRequest.type, request); + } + context.subscriptions.push(commands.registerCommand('sourcery.scan.applyRule', (entry) => { workspace.openTextDocument(entry.resourceUri).then(doc => { window.showTextDocument(doc).then(e => { diff --git a/src/rule-search-results.ts b/src/rule-search-results.ts index 5f3981e6..d273b24d 100644 --- a/src/rule-search-results.ts +++ b/src/rule-search-results.ts @@ -85,4 +85,4 @@ export class ScanResultProvider implements vscode.TreeDataProvider this.data = []; this._onDidChangeTreeData.fire(); } - } \ No newline at end of file + }