-
Notifications
You must be signed in to change notification settings - Fork 440
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add setting to support method implementation code lens #3876
Add setting to support method implementation code lens #3876
Conversation
@rgrunber I wasn't sure if there should be some dependency between the new setting and the |
Options are either :
I'm inclined towards (2). The thing with this, is it'd be ideal to add some code that still respects the old setting and it's values ( |
Sounds good to me. I'll implement that second option with support for the old setting. |
@rgrunber my one concern with this approach is if users are unaware of the old setting in their configuration and intend to use the new one, then updates to the new setting won't be reflected accurately (i.e. if the old setting is true, but the user intends for the setting to be "none", then mapping the old setting to "types" and using this value for the new setting would give undesired behaviour). Another alternative would be to keep the same name for the setting ( |
The problem with keeping it the same is that Have a look at |
Yes that would definitely work, I didn't know if we could check that the default had been intentionally set or not. I can't find |
Line 14 in 309c705
|
Ah, I was looking to do the check on the server-side. I tried using |
I forgot that we might have to do the same on the server side for other clients 😐 . I guess we can look at that later. I feel like we made this decision once before on another PR.
This seems more like a quirk of VS Code. When a value is set to match the default through the Settings UI, VS Code removes the setting from the underlying However, I don't think we have to worry about that because when the updated extension is installed, there will be no "boolean" checkbox for Let me know if that makes sense. |
Sorry for the delay, got swamped with studying for exams. I updated the setting, though please note that I named it Please let me know if this update works. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall, look good and mostly ready to merge. Just a minor logic issue.
I've played with this and it seems to work well in supporting the deprecated option.
src/utils.ts
Outdated
@@ -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){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is probably good enough. Did you see this approach somewhere in the code ? What do you think of :
const deprecatedImplementations = typeof javaConfig.implementationsCodeLens?.enabled === 'boolean';
Then you won't need that undefined
check or the risk that javaConfig.implementationsCodeLens.enabled
might be something other than a boolean
that gets converted to a boolean
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't this expression just evaluating if javaConfig.implementationsCodeLens.enabled
is a boolean or not? If enabled is false, this would return true.
What about
if (!isPreferenceOverridden("java.implementationCodeLens") && typeof javaConfig.implementationsCodeLens?.enabled === 'boolean'){
const deprecatedImplementations = javaConfig.implementationsCodeLens.enabled;
javaConfig.implementationCodeLens = deprecatedImplementations ? "types" : "none";
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 Yeah I think we agree. I just wasn't specific. You'd just have 2 different values. One for whether the property is a boolean, and one for the actual boolean value. Here's what I had :
diff --git a/src/utils.ts b/src/utils.ts
index 0a06f45..58f8c22 100644
--- a/src/utils.ts
+++ b/src/utils.ts
@@ -273,11 +273,9 @@ export async function getJavaConfig(javaHome: string) {
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";
- }
+ const deprecatedImplementations = typeof javaConfig.implementationsCodeLens.enabled === 'boolean';
+ if (!isPreferenceOverridden("java.implementationCodeLens") && deprecatedImplementations){
+ javaConfig.implementationCodeLens = javaConfig.implementationsCodeLens.enabled ? "types" : "none";
}
return javaConfig;
I think either is fine.
Signed-off-by: Hope Hadfield <[email protected]>
d7aab29
to
a450004
Compare
Thanks for the advice and review! 😄 @rgrunber |
Fixes #3813
Requires eclipse-jdtls/eclipse.jdt.ls#3333
Applies to abstract and interface methods, and protected by the
java.methodImplementationsCodeLens.enabled
setting (false by default).