From 8db7740804dd28506e19f813fc78a66fb022abc8 Mon Sep 17 00:00:00 2001 From: Tomasz Godzik Date: Mon, 16 Nov 2020 16:56:47 +0100 Subject: [PATCH 1/3] Add option to show implicit methods and classes --- package.json | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/package.json b/package.json index 6b56621a2..274fb493f 100644 --- a/package.json +++ b/package.json @@ -131,6 +131,10 @@ "type": "boolean", "markdownDescription": "When this option is enabled, for each method that has implicit arguments they are displayed as additional decorations." }, + "metals.showImplicitConversionsAndClasses": { + "type": "boolean", + "markdownDescription": "When this option is enabled, each implicit method and class is displayed as additional decorations at the usage site." + }, "metals.javaHome": { "type": "string", "markdownDescription": "Optional path to the Java home directory. Requires reloading the window.\n\nDefaults to the most recent Java version between 8 and 11 (inclusive) computed by the `locate-java-home` npm package." From 5a3bb80267d306c0213c4df0cbb0a1da29c90124 Mon Sep 17 00:00:00 2001 From: tgodzik Date: Wed, 18 Nov 2020 23:39:54 +0100 Subject: [PATCH 2/3] Add option to toggle implicit conversions on and off --- package.json | 9 +++++++++ src/extension.ts | 8 ++++++++ 2 files changed, 17 insertions(+) diff --git a/package.json b/package.json index 274fb493f..2987684fd 100644 --- a/package.json +++ b/package.json @@ -304,6 +304,11 @@ "command": "metals.ammonite-stop", "category": "Metals", "title": "Stop Ammonite build server" + }, + { + "command": "metals.toggle-implicit-conversions-and-classes", + "category": "Metals", + "title": "Toggle implicit conversions and classes" } ], "menus": { @@ -319,6 +324,10 @@ "command": "metals.reveal-active-file", "when": "metals:enabled" }, + { + "command": "metals.toggle-implicits", + "when": "metals:enabled" + }, { "command": "metals.restartServer", "when": "metals:enabled" diff --git a/src/extension.ts b/src/extension.ts index 66d61903e..fa30d68db 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -656,6 +656,14 @@ function launchMetals( }); }); + registerCommand("metals.toggle-implicit-conversions-and-classes", () => { + const setting = "showImplicitConversionsAndClasses"; + const config = workspace.getConfiguration("metals"); + const configProperty = config.inspect(setting); + const currentValues = configProperty?.workspaceValue ?? false; + config.update(setting, !currentValues, ConfigurationTarget.Workspace); + }); + registerCommand( `metals.${ServerCommands.NewScalaFile}`, async (directory: Uri) => { From 270cdf336a922ec532b3a5761b5cd0ac192260ba Mon Sep 17 00:00:00 2001 From: Tomasz Godzik Date: Thu, 19 Nov 2020 11:47:08 +0100 Subject: [PATCH 3/3] Add commands to toggle each synthetic decoration option --- package.json | 22 ++++++++++++++++++++-- src/extension.ts | 21 ++++++++++++++++----- 2 files changed, 36 insertions(+), 7 deletions(-) diff --git a/package.json b/package.json index 2987684fd..f772c0c08 100644 --- a/package.json +++ b/package.json @@ -308,7 +308,17 @@ { "command": "metals.toggle-implicit-conversions-and-classes", "category": "Metals", - "title": "Toggle implicit conversions and classes" + "title": "Toggle showing implicit conversions and classes" + }, + { + "command": "metals.toggle-implicit-parameters", + "category": "Metals", + "title": "Toggle showing implicit parameters" + }, + { + "command": "metals.toggle-show-inferred-type", + "category": "Metals", + "title": "Toggle showing inferred type" } ], "menus": { @@ -325,7 +335,15 @@ "when": "metals:enabled" }, { - "command": "metals.toggle-implicits", + "command": "metals.toggle-implicit-conversions-and-classes", + "when": "metals:enabled" + }, + { + "command": "metals.toggle-implicit-parameters", + "when": "metals:enabled" + }, + { + "command": "metals.toggle-show-inferred-type", "when": "metals:enabled" }, { diff --git a/src/extension.ts b/src/extension.ts index fa30d68db..33bb6f815 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -657,11 +657,15 @@ function launchMetals( }); registerCommand("metals.toggle-implicit-conversions-and-classes", () => { - const setting = "showImplicitConversionsAndClasses"; - const config = workspace.getConfiguration("metals"); - const configProperty = config.inspect(setting); - const currentValues = configProperty?.workspaceValue ?? false; - config.update(setting, !currentValues, ConfigurationTarget.Workspace); + toggleBooleanWorkspaceSetting("showImplicitConversionsAndClasses"); + }); + + registerCommand("metals.toggle-implicit-parameters", () => { + toggleBooleanWorkspaceSetting("showImplicitArguments"); + }); + + registerCommand("metals.toggle-show-inferred-type", () => { + toggleBooleanWorkspaceSetting("showInferredType"); }); registerCommand( @@ -1035,3 +1039,10 @@ function configureSettingsDefaults() { ConfigurationTarget.Workspace ); } + +function toggleBooleanWorkspaceSetting(setting: string) { + const config = workspace.getConfiguration("metals"); + const configProperty = config.inspect(setting); + const currentValues = configProperty?.workspaceValue ?? false; + config.update(setting, !currentValues, ConfigurationTarget.Workspace); +}