Bug 109730 Surround with runnable quick assist
Version: 3.1.0 Build id: I20050906-1200 Until now surround with runnable was only a text templat. This patches add a quick assist for surround with runnable. Variable declarations are made final and initializers are split off if required. Surround with runnable does not guarantee to generate syntactically correct code in every situation. i.e.: int i = 10, j = i; System.out.println(i); System.out.println(j); Applying surround with runnable on System.out.println(i); results in final int i = 10; int j = i; Runnable runnable = new Runnable() { public void run() { System.out.println(i); } } System.out.println(j);
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/QuickAssistProcessor.java
String label= Messages.format(CorrectionMessages.QuickAssistProcessor_createmethodinsuper_description, curr.getName());
						resultingCollections.add(new NewDefiningMethodProposal(label, targetCU, astRoot, typeDecl, binding, paramNames, 6));
					}
				}
			}
		}
		return true;
	}
	private static boolean getConvertForLoopProposal(IInvocationContext context, ASTNode node, ArrayList resultingCollections) throws CoreException {
		ForStatement forStatement= getEnclosingForStatementHeader(node);
		if (forStatement == null)
			return false;
		if (resultingCollections == null)
			return true;
		ConvertForLoopProposal convertForLoopProposal= new ConvertForLoopProposal(
				CorrectionMessages.QuickAssistProcessor_forLoop_description,
				context.getCompilationUnit(),
				forStatement, 1,
				JavaPluginImages.get(JavaPluginImages.IMG_CORRECTION_CHANGE));
		if (!convertForLoopProposal.satisfiesPreconditions())
		    return false;
		resultingCollections.add(convertForLoopProposal);
		return true;
	}
	private static boolean getConvertIterableLoopProposal(IInvocationContext context, ASTNode node, ArrayList resultingCollections) throws CoreException {
		ForStatement forStatement= getEnclosingForStatementHeader(node);
		if (forStatement == null)
			return false;
		if (resultingCollections == null)
			return true;