eclipse-jdt / eclipse.jdt.ui

Eclipse Public License 2.0
36 stars 86 forks source link

Adapt ConvertForLoopOperation to work with Javac generated AST #1617

Closed jjohnstn closed 1 week ago

jjohnstn commented 2 weeks ago

From: https://github.com/eclipse-jdtls/eclipse-jdt-core-incubator/issues/748

ConvertForLoopOperation uses the type of .size() method on collections to determine the type. While it's fine with JDT, Javac does not consider the type argument in the .size() method, simply because the method is always the same, so it doesn't make sense to create such separation. The ConvertForLoopOperation could instead of this untyped size method check the type of the expression on which size() is called, and check a type method such as add to find the actual element type.