if (startsWithClosingBrace(pastedText)) { int outsideBlockIndentSize= blockIndent == null ? 0 : calculateDisplayedWidth(blockIndent, getTabWidth()); newIndentSize = outsideBlockIndentSize; }   int offset= command.offset; int line= document.getLineOfOffset(offset); int lineOffset= document.getLineOffset(line); String prefix= document.get(lineOffset, offset - lineOffset);  boolean formatFirstLine= prefix.trim().length() == 0;  String formattedParagraph= format(pastedText, newIndentSize, lineDelimiter, formatFirstLine);   if (formatFirstLine) { int end= command.offset + command.length; command.offset= lineOffset; command.length= end - command.offset; } command.text= formattedParagraph;
command.text= temp.get(prefix.length(), temp.getLength() - prefix.length() - afterContent.length());
	private void smartPaste(IDocument document, DocumentCommand command) {		String lineDelimiter= getLineDelimiter(document);		try {			String pastedText= command.text;			Assert.isNotNull(pastedText);			Assert.isTrue(pastedText.length() > 1);						// extend selection begin if only whitespaces			int selectionStart= command.offset;			IRegion region= document.getLineInformationOfOffset(selectionStart);			String notSelected= document.get(region.getOffset(), selectionStart - region.getOffset());			String selected= document.get(selectionStart, region.getOffset() + region.getLength() - selectionStart);			if (notSelected.trim().length() == 0 && selected.trim().length() != 0) {				pastedText= notSelected + pastedText;				command.length += notSelected.length();				command.offset= region.getOffset();			}						// choose smaller indent of block and preceeding non-empty line 			String blockIndent= getBlockIndent(document, command);			String insideBlockIndent= blockIndent == null ? "" : blockIndent + createIndent(1, useSpaces()); //$NON-NLS-1$ // add one indent level			int insideBlockIndentSize= calculateDisplayedWidth(insideBlockIndent, getTabWidth());			int previousIndentSize= getIndentSize(document, command);			int newIndentSize= insideBlockIndentSize < previousIndentSize ? insideBlockIndentSize : previousIndentSize;			// indent is different if block starts with '}'							if (startsWithClosingBrace(pastedText)) {				int outsideBlockIndentSize= blockIndent == null ? 0 : calculateDisplayedWidth(blockIndent, getTabWidth());				newIndentSize = outsideBlockIndentSize;							}			// check selection			int offset= command.offset;			int line= document.getLineOfOffset(offset);			int lineOffset= document.getLineOffset(line);			String prefix= document.get(lineOffset, offset - lineOffset);			boolean formatFirstLine= prefix.trim().length() == 0;			String formattedParagraph= format(pastedText, newIndentSize, lineDelimiter, formatFirstLine);			// paste			if (formatFirstLine) {				int end= command.offset + command.length;				command.offset= lineOffset;				command.length= end - command.offset;			}			command.text= formattedParagraph;		} catch (BadLocationException e) {			JavaPlugin.log(e);		}	}