View | Details | Raw Unified | Return to bug 430818 | Differences between
and this patch

Collapse All | Expand All

(-)a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/LocalCorrectionsSubProcessor.java (-1 / +7 lines)
Lines 10-15 Link Here
10
 *     Renaud Waldura <renaud+eclipse@waldura.com> - Access to static proposal
10
 *     Renaud Waldura <renaud+eclipse@waldura.com> - Access to static proposal
11
 *     Benjamin Muskalla <bmuskalla@innoopract.com> - [quick fix] Shouldn't offer "Add throws declaration" quickfix for overriding signature if result would conflict with overridden signature
11
 *     Benjamin Muskalla <bmuskalla@innoopract.com> - [quick fix] Shouldn't offer "Add throws declaration" quickfix for overriding signature if result would conflict with overridden signature
12
 *     Lukas Hanke <hanke@yatta.de> - Bug 241696 [quick fix] quickfix to iterate over a collection - https://bugs.eclipse.org/bugs/show_bug.cgi?id=241696
12
 *     Lukas Hanke <hanke@yatta.de> - Bug 241696 [quick fix] quickfix to iterate over a collection - https://bugs.eclipse.org/bugs/show_bug.cgi?id=241696
13
 *     Lukas Hanke <hanke@yatta.de> - Bug 430818 [1.8][quick fix] Quick fix for "for loop" is not shown for bare local variable/argument/field - https://bugs.eclipse.org/bugs/show_bug.cgi?id=430818
13
 *******************************************************************************/
14
 *******************************************************************************/
14
package org.eclipse.jdt.internal.ui.text.correction;
15
package org.eclipse.jdt.internal.ui.text.correction;
15
16
Lines 1857-1863 Link Here
1857
	public static void getGenerateForLoopProposals(IInvocationContext context, IProblemLocation problem, Collection<ICommandAccess> proposals) {
1858
	public static void getGenerateForLoopProposals(IInvocationContext context, IProblemLocation problem, Collection<ICommandAccess> proposals) {
1858
		ASTNode coveringNode= problem.getCoveringNode(context.getASTRoot());
1859
		ASTNode coveringNode= problem.getCoveringNode(context.getASTRoot());
1859
		if (coveringNode != null) {
1860
		if (coveringNode != null) {
1860
			QuickAssistProcessor.getGenerateForLoopProposals(context, coveringNode, null, proposals);
1861
			Statement statement= ASTResolving.findParentStatement(coveringNode);
1862
			// because hovering and clicking on the error marker generate different error signatures, this avoids the assist to be added twice
1863
			if ((problem.getProblemId() == IProblem.ParsingErrorInsertToComplete && statement instanceof ExpressionStatement) ||
1864
					(problem.getProblemId() == IProblem.UndefinedType)) {
1865
				QuickAssistProcessor.getGenerateForLoopProposals(context, coveringNode, null, proposals);
1866
			}
1861
		}
1867
		}
1862
	}
1868
	}
1863
1869
(-)a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/QuickAssistProcessor.java (-2 / +2 lines)
Lines 2743-2750 Link Here
2743
	}
2743
	}
2744
2744
2745
	public static boolean getGenerateForLoopProposals(IInvocationContext context, ASTNode coveringNode, IProblemLocation[] locations, Collection<ICommandAccess> resultingCollections) {
2745
	public static boolean getGenerateForLoopProposals(IInvocationContext context, ASTNode coveringNode, IProblemLocation[] locations, Collection<ICommandAccess> resultingCollections) {
2746
//		if (containsMatchingProblem(locations, IProblem.ParsingErrorInsertToComplete))
2746
		if (containsMatchingProblem(locations, IProblem.ParsingErrorInsertToComplete))
2747
//			return false;
2747
			return false;
2748
2748
2749
		Statement statement= ASTResolving.findParentStatement(coveringNode);
2749
		Statement statement= ASTResolving.findParentStatement(coveringNode);
2750
		ICompilationUnit cu= context.getCompilationUnit();
2750
		ICompilationUnit cu= context.getCompilationUnit();
(-)a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/QuickFixProcessor.java (+7 lines)
Lines 14-19 Link Here
14
 *								[quick fix] don't propose null annotations when those are disabled - https://bugs.eclipse.org/405086
14
 *								[quick fix] don't propose null annotations when those are disabled - https://bugs.eclipse.org/405086
15
 *								[quickfix] Update null annotation quick fixes for bug 388281 - https://bugs.eclipse.org/395555
15
 *								[quickfix] Update null annotation quick fixes for bug 388281 - https://bugs.eclipse.org/395555
16
 *     Lukas Hanke <hanke@yatta.de> - Bug 241696 [quick fix] quickfix to iterate over a collection - https://bugs.eclipse.org/bugs/show_bug.cgi?id=241696
16
 *     Lukas Hanke <hanke@yatta.de> - Bug 241696 [quick fix] quickfix to iterate over a collection - https://bugs.eclipse.org/bugs/show_bug.cgi?id=241696
17
 *     Lukas Hanke <hanke@yatta.de> - Bug 430818 [1.8][quick fix] Quick fix for "for loop" is not shown for bare local variable/argument/field - https://bugs.eclipse.org/bugs/show_bug.cgi?id=430818
17
 *******************************************************************************/
18
 *******************************************************************************/
18
package org.eclipse.jdt.internal.ui.text.correction;
19
package org.eclipse.jdt.internal.ui.text.correction;
19
20
Lines 273-278 Link Here
273
			case IProblem.ConstructorReferenceNotBelow18:
274
			case IProblem.ConstructorReferenceNotBelow18:
274
			case IProblem.IntersectionCastNotBelow18:
275
			case IProblem.IntersectionCastNotBelow18:
275
			case IProblem.InvalidUsageOfTypeAnnotations:
276
			case IProblem.InvalidUsageOfTypeAnnotations:
277
			case IProblem.ParsingErrorInsertToComplete:
276
				return true;
278
				return true;
277
			default:
279
			default:
278
				return SuppressWarningsSubProcessor.hasSuppressWarningsProposal(cu.getJavaProject(), problemId);
280
				return SuppressWarningsSubProcessor.hasSuppressWarningsProposal(cu.getJavaProject(), problemId);
Lines 367-372 Link Here
367
				ReorgCorrectionsSubProcessor.getWrongPackageDeclNameProposals(context, problem, proposals);
369
				ReorgCorrectionsSubProcessor.getWrongPackageDeclNameProposals(context, problem, proposals);
368
				break;
370
				break;
369
			case IProblem.UndefinedType:
371
			case IProblem.UndefinedType:
372
				LocalCorrectionsSubProcessor.getGenerateForLoopProposals(context, problem, proposals);
373
				//$FALL-THROUGH$
370
			case IProblem.JavadocUndefinedType:
374
			case IProblem.JavadocUndefinedType:
371
				UnresolvedElementsSubProcessor.getTypeProposals(context, problem, proposals);
375
				UnresolvedElementsSubProcessor.getTypeProposals(context, problem, proposals);
372
				break;
376
				break;
Lines 760-765 Link Here
760
				NullAnnotationsCorrectionProcessor.addReturnAndArgumentTypeProposal(context, problem, ChangeKind.LOCAL, proposals);
764
				NullAnnotationsCorrectionProcessor.addReturnAndArgumentTypeProposal(context, problem, ChangeKind.LOCAL, proposals);
761
				NullAnnotationsCorrectionProcessor.addReturnAndArgumentTypeProposal(context, problem, ChangeKind.INVERSE, proposals);
765
				NullAnnotationsCorrectionProcessor.addReturnAndArgumentTypeProposal(context, problem, ChangeKind.INVERSE, proposals);
762
				break;
766
				break;
767
			case IProblem.ParsingErrorInsertToComplete:
768
				LocalCorrectionsSubProcessor.getGenerateForLoopProposals(context, problem, proposals);
769
				break;
763
			default:
770
			default:
764
		}
771
		}
765
		if (JavaModelUtil.is50OrHigher(context.getCompilationUnit().getJavaProject())) {
772
		if (JavaModelUtil.is50OrHigher(context.getCompilationUnit().getJavaProject())) {

Return to bug 430818