Skip to content

Commit 7e6d247

Browse files
authored
Fix quick fix for missing type in enhanced for loop (eclipse-jdt#2181)
- modify NewVariableCorrectionProposalCore.getDominantNode() to also look for parent being enhanced for statement - add new test to UnresolvedTypesQuickFixTest - fixes eclipse-jdt#2180
1 parent 0e5e812 commit 7e6d247

File tree

2 files changed

+149
-108
lines changed

2 files changed

+149
-108
lines changed

org.eclipse.jdt.core.manipulation/proposals/org/eclipse/jdt/internal/ui/text/correction/proposals/NewVariableCorrectionProposalCore.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -416,7 +416,7 @@ private ASTNode getDominantNode(SimpleName[] names) {
416416
}
417417
}
418418
int parentKind= dominator.getParent().getNodeType();
419-
if (parentKind != ASTNode.BLOCK && parentKind != ASTNode.FOR_STATEMENT) {
419+
if (parentKind != ASTNode.BLOCK && parentKind != ASTNode.FOR_STATEMENT && parentKind != ASTNode.ENHANCED_FOR_STATEMENT) {
420420
return dominator.getParent();
421421
}
422422
return dominator;

0 commit comments

Comments
 (0)