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
dogfooding batch: cleanup Java 5: Convert to enhanced 'for' loops #2097
Conversation
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) { |
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.
Shouldn't this iterate directly over set, without extra array?
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.
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?
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.
I would expect extra commit for all non-automated changes.
...se.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/OperatorExpression.java
Outdated
Show resolved
Hide resolved
819f251
to
44d06e3
Compare
@@ -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) { |
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.
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) { |
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.
and this one
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. |
/* 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. ..." | ||
*/ |
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.
someone is stealing comments.
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.
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; |
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.
Someone steals imports they just recently added (for good reason).
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.
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 |
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.
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?
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.
yes that's the purpose. 2 reviewers who did not see it. 6 eyes see more then 4 :-)
org.eclipse.jdt.core.compiler.batch