Bug 55347 Surround with try/catch QF corrupts code
I20040318 With this code: import java.io.*; public class EF { public static void foo() throws IOException { InputStream is= null; if (is != null) { is.close(); } } } - select the full line containing the "close" - press Command-1 for QF - select surround with try/catch Observe: corrupted code import java.io.*; public class EF { public static void foo() throws IOException { InputStream is= null; if (is != null) { try { is.close(); } } catch (Exception e) { // TODO: handle exception } } }
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/QuickTemplateProcessor.java
return new IJavaCompletionProposal[0];
		}
		
		try {
			ICompilationUnit cu= context.getCompilationUnit();
			IDocument document= getDocument(cu);
			
			int offset= context.getSelectionOffset();
			int length= context.getSelectionLength();
			
			int startLine= document.getLineOfOffset(offset);
			int endLine= document.getLineOfOffset(offset + length);
			IRegion endLineRegion= document.getLineInformation(endLine);
			if (startLine  == endLine) {
				if (length == 0 || offset != endLineRegion.getOffset() || length != endLineRegion.getLength()) {
					return null;
				}
			} else {
				
				offset= document.getLineOffset(startLine);
				length= endLineRegion.getOffset() + endLineRegion.getLength() - offset;
			}
			ArrayList resultingCollections= new ArrayList();
			collectSurroundTemplates(document, cu, offset, length, resultingCollections);
			return (IJavaCompletionProposal[]) resultingCollections.toArray(new IJavaCompletionProposal[resultingCollections.size()]);
		} catch (BadLocationException e) {
			throw new CoreException(JavaUIStatus.createError(IStatus.ERROR, "", e)); 
		}
	}
	private IDocument getDocument(ICompilationUnit cu) throws JavaModelException {