Skip to content

Commit

Permalink
Merge pull request #447 from tgodzik/add-implicit-conversions-opt
Browse files Browse the repository at this point in the history
Add option to show implicit methods and classes
  • Loading branch information
tgodzik authored Nov 20, 2020
2 parents 1ccdeac + 270cdf3 commit 2ab2c22
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 0 deletions.
31 changes: 31 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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."
Expand Down Expand Up @@ -300,6 +304,21 @@
"command": "metals.ammonite-stop",
"category": "Metals",
"title": "Stop Ammonite build server"
},
{
"command": "metals.toggle-implicit-conversions-and-classes",
"category": "Metals",
"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": {
Expand All @@ -315,6 +334,18 @@
"command": "metals.reveal-active-file",
"when": "metals:enabled"
},
{
"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"
},
{
"command": "metals.restartServer",
"when": "metals:enabled"
Expand Down
19 changes: 19 additions & 0 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -656,6 +656,18 @@ function launchMetals(
});
});

registerCommand("metals.toggle-implicit-conversions-and-classes", () => {
toggleBooleanWorkspaceSetting("showImplicitConversionsAndClasses");
});

registerCommand("metals.toggle-implicit-parameters", () => {
toggleBooleanWorkspaceSetting("showImplicitArguments");
});

registerCommand("metals.toggle-show-inferred-type", () => {
toggleBooleanWorkspaceSetting("showInferredType");
});

registerCommand(
`metals.${ServerCommands.NewScalaFile}`,
async (directory: Uri) => {
Expand Down Expand Up @@ -1027,3 +1039,10 @@ function configureSettingsDefaults() {
ConfigurationTarget.Workspace
);
}

function toggleBooleanWorkspaceSetting(setting: string) {
const config = workspace.getConfiguration("metals");
const configProperty = config.inspect<boolean>(setting);
const currentValues = configProperty?.workspaceValue ?? false;
config.update(setting, !currentValues, ConfigurationTarget.Workspace);
}

0 comments on commit 2ab2c22

Please sign in to comment.