Skip to content
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

dogfooding batch: cleanup Java 5: Convert to enhanced 'for' loops #2097

Conversation

jukzi
Copy link
Contributor

@jukzi jukzi commented Mar 5, 2024

org.eclipse.jdt.core.compiler.batch

@@ -245,8 +245,8 @@ protected Commandline setupJavacCommand() throws BuildException {
if (this.attributes.getNowarn()) {
// disable all warnings
Object[] entries = this.customDefaultOptions.entrySet().toArray();
for (int i = 0, max = entries.length; i < max; i++) {
Map.Entry entry = (Map.Entry) entries[i];
for (Object entry2 : entries) {
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't this iterate directly over set, without extra array?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yea that would be better, i have also seen other odds. For example ParameterizedQualifiedTypeReference needs the refactoring twice.
Should i squash manual changes or add another commit?

Copy link
Member

Choose a reason for hiding this comment

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

I would expect extra commit for all non-automated changes.

@jukzi jukzi force-pushed the forEach_org.eclipse.jdt.core.compiler.batch branch from 819f251 to 44d06e3 Compare March 5, 2024 16:37
@@ -3294,8 +3288,7 @@ protected void enableAll(int severity) {
break;
}
Map.Entry<String, String>[] entries = this.options.entrySet().toArray(new Map.Entry[this.options.size()]);
for (int i = 0, max = entries.length; i < max; i++) {
Map.Entry<String, String> entry = entries[i];
for (Entry<String, String> entry : entries) {
Copy link
Member

Choose a reason for hiding this comment

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

Can you please check this one?

@@ -3571,8 +3564,8 @@ protected ArrayList<FileSystem.Classpath> handleModuleSourcepath(String arg) {
}
String[] paths = new String[modulePaths.size()];
modulePaths.toArray(paths);
for (int i = 0; i < paths.length; i++) {
File dir = new File(paths[i]);
for (String path : paths) {
Copy link
Member

Choose a reason for hiding this comment

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

and this one

@iloveeclipse
Copy link
Member

I've scanned through the patch, looks OK, only two places in Main could be improved further, but I would prefer this monster to be merged early, there are few pending PR's that would be merged soon, if we don't merge yet, we will see merge problems later on.

@iloveeclipse iloveeclipse merged commit b8055d6 into eclipse-jdt:master Mar 5, 2024
9 checks passed
Comment on lines -648 to -651
/* TODO: are we sure this will always terminate? Cf. e.g. (Discussion in 18.3):
*
* "The assertion that incorporation reaches a fixed point oversimplifies the matter slightly. ..."
*/
Copy link
Contributor

Choose a reason for hiding this comment

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

someone is stealing comments.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Someone called "cleanup Java 5: Convert to enhanced 'for' loops". Nice finding. Consider opening a bug on jdt.ui

@@ -57,7 +56,6 @@
import org.eclipse.jdt.internal.compiler.ASTVisitor;
import org.eclipse.jdt.internal.compiler.CompilationResult;
import org.eclipse.jdt.internal.compiler.ast.*;
import org.eclipse.jdt.internal.compiler.ast.StringTemplate;
Copy link
Contributor

Choose a reason for hiding this comment

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

Someone steals imports they just recently added (for good reason).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Probably because BREE is not set to 21, but 17 where it does not matter. Consider mentioning in eclipse-platform/.github#188

@@ -13120,9 +13115,7 @@ public boolean visit(TypeDeclaration memberTypeDeclaration, ClassScope scope) {
}
boolean containsInitializers = false;
TypeDeclaration typeDeclaration = null;
for (int i = 0, max = result.length; i < max; i++) {
// parse each class or record body declaration
Copy link
Contributor

Choose a reason for hiding this comment

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

apparently the refactoring is not safe wrt comments.
If dogfooding should help improve the tool, than such flaws should be detected, reported and fixed, 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.

yes that's the purpose. 2 reviewers who did not see it. 6 eyes see more then 4 :-)

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.

None yet

4 participants