Skip to content

Modernize to Java 17 switch expression. #2816

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

deepika-u
Copy link
Contributor

Update legacy switch block with Java 17 switch expression in org.eclipse.ui.workbench.texteditor package.

case BEFORE -> true;
default -> {
childHelper.fail(RulerColumnMessages.RulerColumnPlacement_illegal_child_msg);
yield false; // Required because default must return a value.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks wrong. Is this autogenerated or manually changed?
Original code would continue for loop without adding anything to constraints.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had a doubt only in this context. So here it cannot be written in newer syntax does it mean?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No idea, have no time for this.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can this loop be like this to achieve the loop?

boolean before = switch (name) {
    case AFTER -> false;
    case BEFORE -> true;
    default -> {
        childHelper.fail(RulerColumnMessages.RulerColumnPlacement_illegal_child_msg);
        yield false;
    }
};
continue;

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let me check on it further.

Copy link
Contributor Author

@deepika-u deepika-u Feb 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reverting this to original switch, thanks for the suggestion.

@iloveeclipse
Copy link
Member

I'm not sure the change improves readability.
Is this PR manually crafted of is the result of automated quick fix?

@deepika-u
Copy link
Contributor Author

I'm not sure the change improves readability. Is this PR manually crafted of is the result of automated quick fix?

I have did it manually.

@iloveeclipse
Copy link
Member

I have did it manually

Why not with a cleanup? Or there is nothing available?

@deepika-u
Copy link
Contributor Author

I have did it manually

Why not with a cleanup? Or there is nothing available?

Any specific context of "cleanup" in this code are you referring to?

Copy link
Member

@iloveeclipse iloveeclipse left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can perform changes via Source->Cleanup... and the cleanup of your choice.
image

The proposed change breaks code.

case BEFORE -> true;
default -> {
childHelper.fail(RulerColumnMessages.RulerColumnPlacement_illegal_child_msg);
yield false; // Required because default must return a value.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No!

Copy link
Contributor

github-actions bot commented Feb 25, 2025

Test Results

 1 821 files  ±0   1 821 suites  ±0   1h 34m 22s ⏱️ + 3m 5s
 7 900 tests ±0   7 671 ✅  - 1  228 💤 ±0  1 ❌ +1 
23 787 runs  ±0  23 038 ✅  - 1  748 💤 ±0  1 ❌ +1 

For more details on these failures, see this check.

Results for commit 78f65c3. ± Comparison against base commit 60b8674.

♻️ This comment has been updated with latest results.

@deepika-u deepika-u force-pushed the Modernize_with_java17_switch_expression branch from 4773319 to ef4610d Compare February 26, 2025 08:06
@deepika-u
Copy link
Contributor Author

deepika-u commented Feb 26, 2025

You can perform changes via Source->Cleanup... and the cleanup of your choice.

Thanks for the suggestion, even via this that file is not getting picked and updated. So i have reverted that file change(switch to original code).
Can you review now please?

@iloveeclipse
Copy link
Member

even via this that file is not getting picked and updated

That is the sign that the quick fix doesn't have an automated solution for conversion (yet).

Can you review now please?

The new change shows some new warning, shows files with whitespace only changes. That shouldn't happen.

I only briefly checked original PR whether the proposed change make sense, found immediately a problem and beside the problem nothing interesting in the change itself. Approving a PR means I agree with the change, which is not the case here.

I would propose to close this PR, and if you are eager to apply this particular refactoring on this particular bundle, do this with the automated cleanup and only with that.

For the new PR please find someone who is interested in such kind of reviews and let review it. I'm definitely not interested in this particular change.

@deepika-u deepika-u force-pushed the Modernize_with_java17_switch_expression branch from ef4610d to 8bb2889 Compare February 27, 2025 09:40
@akurtakov akurtakov force-pushed the Modernize_with_java17_switch_expression branch from 8bb2889 to 2411bcb Compare March 6, 2025 15:25
@eclipse-platform-bot
Copy link
Contributor

This pull request changes some projects for the first time in this development cycle.
Therefore the following files need a version increment:

bundles/org.eclipse.ui.workbench.texteditor/META-INF/MANIFEST.MF

An additional commit containing all the necessary changes was pushed to the top of this PR's branch. To obtain these changes (for example if you want to push more changes) either fetch from your fork or apply the git patch.

Git patch
From 30eecdfa074bfd90c87cf2ae676f84d44a636f92 Mon Sep 17 00:00:00 2001
From: Eclipse Platform Bot <[email protected]>
Date: Thu, 6 Mar 2025 15:30:01 +0000
Subject: [PATCH] Version bump(s) for 4.36 stream


diff --git a/bundles/org.eclipse.ui.workbench.texteditor/META-INF/MANIFEST.MF b/bundles/org.eclipse.ui.workbench.texteditor/META-INF/MANIFEST.MF
index 2e7b7c5380..1115872cdf 100644
--- a/bundles/org.eclipse.ui.workbench.texteditor/META-INF/MANIFEST.MF
+++ b/bundles/org.eclipse.ui.workbench.texteditor/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
 Bundle-ManifestVersion: 2
 Bundle-Name: %pluginName
 Bundle-SymbolicName: org.eclipse.ui.workbench.texteditor; singleton:=true
-Bundle-Version: 3.19.100.qualifier
+Bundle-Version: 3.19.200.qualifier
 Bundle-Activator: org.eclipse.ui.internal.texteditor.TextEditorPlugin
 Bundle-ActivationPolicy: lazy
 Bundle-Vendor: %providerName
-- 
2.48.1

Further information are available in Common Build Issues - Missing version increments.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants