From d7aab2931b6083c9ef793b5f5b63b63d8f596d2a Mon Sep 17 00:00:00 2001 From: Hope Hadfield Date: Tue, 10 Dec 2024 17:55:20 -0500 Subject: [PATCH] remove additional setting and add check for previous setting --- README.md | 3 +-- package.json | 43 ++++++++++++++++++++++++------------------- src/utils.ts | 8 ++++++++ 3 files changed, 33 insertions(+), 21 deletions(-) diff --git a/README.md b/README.md index e220ca6c8..720de59d4 100644 --- a/README.md +++ b/README.md @@ -123,8 +123,7 @@ The following settings are supported: * `java.configuration.maven.userSettings` : Path to Maven's user settings.xml. * `java.configuration.checkProjectSettingsExclusions`: **Deprecated, please use 'java.import.generatesMetadataFilesAtProjectRoot' to control whether to generate the project metadata files at the project root. And use 'files.exclude' to control whether to hide the project metadata files from the file explorer.** Controls whether to exclude extension-generated project settings files (`.project`, `.classpath`, `.factorypath`, `.settings/`) from the file explorer. Defaults to `false`. * `java.referencesCodeLens.enabled` : Enable/disable the references code lenses. -* `java.implementationsCodeLens.enabled` : Enable/disable the implementations code lenses. -* `java.methodImplementationsCodeLens.enabled` : Enable/disable the method implementations code lenses. +* `java.implementationCodeLens` : Enable/disable the implementations code lens for the provided categories. * `java.signatureHelp.enabled` : Enable/disable signature help support (triggered on `(`). * `java.signatureHelp.description.enabled` : Enable/disable to show the description in signature help. Defaults to `false`. * `java.contentProvider.preferred` : Preferred content provider (see 3rd party decompilers available in [vscode-java-decompiler](https://github.com/dgileadi/vscode-java-decompiler)). diff --git a/package.json b/package.json index 7715830aa..1f878f551 100644 --- a/package.json +++ b/package.json @@ -1409,54 +1409,59 @@ "scope": "window", "order": 10 }, - "java.implementationsCodeLens.enabled": { - "type": "boolean", - "default": false, - "description": "Enable/disable the implementations code lens.", + "java.implementationCodeLens": { + "type": "string", + "enum": [ + "none", + "types", + "methods", + "all" + ], + "enumDescriptions": [ + "Disable the implementations code lens", + "Enable the implementations code lens only for types", + "Enable the implementations code lens only for methods", + "Enable the implementations code lens for types and methods" + ], + "default": "none", + "description": "Enable/disable the implementations code lens for the provided categories.", "scope": "window", "order": 20 }, - "java.methodImplementationsCodeLens.enabled": { - "type": "boolean", - "default": false, - "description": "Enable/disable the method implementations code lens.", - "scope": "window", - "order": 30 - }, "java.references.includeAccessors": { "type": "boolean", "default": true, "description": "Include getter, setter and builder/constructor when finding references.", "scope": "window", - "order": 40 + "order": 30 }, "java.references.includeDeclarations": { "type": "boolean", "default": true, "description": "Include declarations when finding references.", "scope": "window", - "order": 50 + "order": 40 }, "java.references.includeDecompiledSources": { "type": "boolean", "default": true, "description": "Include the decompiled sources when finding references.", "scope": "window", - "order": 60 + "order": 50 }, "java.symbols.includeSourceMethodDeclarations": { "type": "boolean", "markdownDescription": "Include method declarations from source files in symbol search.", "default": false, "scope": "window", - "order": 70 + "order": 60 }, "java.typeHierarchy.lazyLoad": { "type": "boolean", "default": false, "description": "Enable/disable lazy loading the content in type hierarchy. Lazy loading could save a lot of loading time but every type should be expanded manually to load its content.", "scope": "window", - "order": 80 + "order": 70 }, "java.inlayHints.parameterNames.enabled": { "type": "string", @@ -1473,7 +1478,7 @@ "default": "literals", "markdownDescription": "Enable/disable inlay hints for parameter names:\n```java\n\nInteger.valueOf(/* s: */ '123', /* radix: */ 10)\n \n```\n `#java.inlayHints.parameterNames.exclusions#` can be used to disable the inlay hints for methods.", "scope": "window", - "order": 90 + "order": 80 }, "java.inlayHints.parameterNames.exclusions": { "type": "array", @@ -1483,7 +1488,7 @@ "default": [], "markdownDescription": "The patterns for the methods that will be disabled to show the inlay hints. Supported pattern examples:\n - `java.lang.Math.*` - All the methods from java.lang.Math.\n - `*.Arrays.asList` - Methods named as 'asList' in the types named as 'Arrays'.\n - `*.println(*)` - Methods named as 'println'.\n - `(from, to)` - Methods with two parameters named as 'from' and 'to'.\n - `(arg*)` - Methods with one parameter whose name starts with 'arg'.", "scope": "window", - "order": 100 + "order": 90 }, "java.search.scope": { "type": "string", @@ -1498,7 +1503,7 @@ "default": "all", "markdownDescription": "Specifies the scope which must be used for search operation like \n - Find Reference\n - Call Hierarchy\n - Workspace Symbols", "scope": "window", - "order": 110 + "order": 100 } } }, diff --git a/src/utils.ts b/src/utils.ts index 38bf67654..0a06f4597 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -272,6 +272,14 @@ export async function getJavaConfig(javaHome: string) { const userConfiguredJREs: any[] = javaConfig.configuration.runtimes; javaConfig.configuration.runtimes = await addAutoDetectedJdks(userConfiguredJREs); } + + if (!isPreferenceOverridden("java.implementationCodeLens") && javaConfig.implementationsCodeLens){ + const deprecatedImplementations: boolean | undefined = javaConfig.implementationsCodeLens.enabled; + if (deprecatedImplementations !== undefined){ + javaConfig.implementationCodeLens = deprecatedImplementations ? "types" : "none"; + } + } + return javaConfig; }