Bug 115513 [quick assist] Surround with template
Version: 3.2.0 Build id: I20051102-1600 Surround with template is an enhancement of surround with runnable. It adds logic to the 'surround with' templates. Users can define there own templates to surround code with (i.e. 'surround with ISafeRunnable').
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/QuickAssistProcessor.java
final ICompilationUnit cu= context.getCompilationUnit();
		final ExtractTempRefactoring refactoring= ExtractTempRefactoring.create(cu, expression.getStartPosition(), expression.getLength());
		if (refactoring.checkActivationBasics(context.getASTRoot(), new NullProgressMonitor()).isOK()) {
			String label= CorrectionMessages.QuickAssistProcessor_extract_to_local_description;
			Image image= JavaPluginImages.get(JavaPluginImages.IMG_CORRECTION_LOCAL);
			CUCorrectionProposal proposal= new CUCorrectionProposal(label, cu, 5, image) {
				protected TextChange createTextChange() throws CoreException {
					refactoring.setTempName(refactoring.guessTempName());
					if (!refactoring.checkFinalConditions(new NullProgressMonitor()).hasFatalError()) {
						return (TextChange) refactoring.createChange(new NullProgressMonitor());
					} else {
						Document document= new Document(""); 
						document.setInitialLineDelimiter(StubUtility.getLineDelimiterUsed(cu));
						return new DocumentChange(getDisplayString(), document);
					}
				}
			};
			proposals.add(proposal);
		}
		return false;
	}
	private static boolean getJoinVariableProposals(IInvocationContext context, ASTNode node, Collection resultingCollections) {
		ASTNode parent= node.getParent();
		
		VariableDeclarationFragment fragment= null;
		boolean onFirstAccess= false;
		if (node instanceof SimpleName && node.getLocationInParent() == Assignment.LEFT_HAND_SIDE_PROPERTY) {
			onFirstAccess= true;
			SimpleName name= (SimpleName) node;
			IBinding binding= name.resolveBinding();