Bug 47674 Formatting problem with paste
M5: - create class Bar with this code: public class Bar { void foo() { int i= 1; if (i == 2) { i= 1; } i= 2; } } - select full line "i= 2" and cut to clipboard - paste line inside if-statement Observe: the closing bracket is indented public class Bar { void foo() { int i= 1; if (i == 2) { i= 1; i= 2; } } }
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/JavaAutoIndentStrategy.java
if (scanTo == -1)
			scanTo= length;
			
		int closingParen= findClosingParenToLeft(scanner, pos) - 1;
		while (true) {
			int startScan= closingParen + 1;
			closingParen= scanner.scanForward(startScan, scanTo, ')');
			if (closingParen == -1)
				break;
			int openingParen= scanner.findOpeningPeer(closingParen - 1, '(', ')');
			
			if (openingParen < 1)
				break;
			
			if (openingParen > pos)
				continue;
			if (looksLikeAnonymousClassDef(document, partitioning, scanner, openingParen - 1))
				return closingParen + 1;
		}
		return -1;
	}
	/**
	 * Finds a closing parenthesis to the left of <code>position</code> in document, where that parenthesis is only
	 * separated by whitespace from <code>position</code>. If no such parenthesis can be found, <code>position</code> is returned.
	 * 
	 * @param document the document being modified
	 * @param position the first character position in <code>document</code> to be considered
	 * @param partitioning the document partitioning
	 * @return the position of a closing parenthesis left to <code>position</code> separated only by whitespace, or <code>position</code> if no parenthesis can be found
	 */