Bug 30468 enhanced smart pasting
consider the following file: public class Test { public void method() { String x = "hello"; } public class C { } } ------------------- if you select the method starting the 'p' in "public void method()" and paste it just below with smart pasting enabled you get the following: public class Test { public void method() { String x = "hello"; } public void method() { String x = "hello"; } public class C { } } If you then paste it as part of class C you get the following: public class Test { public void method() { String x = "hello"; } public void method() { String x = "hello"; } public class C { public void method() { String x = "hello"; } } } It would be nice if the brackets line up with the method. This can probably be achieved if you treat the first line of the pasted text as different to the other lines because you cannot guarentee that text selection will always start from the beginning of the line with the correct ammount of tabs/spaces in the first line of a selection.
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/JavaAutoIndentStrategy.java
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
	 */
	private static int findClosingParenToLeft(JavaHeuristicScanner scanner, int position) {
		if (position < 1)
			return position;
		if (scanner.previousToken(position - 1, JavaHeuristicScanner.UNBOUND) == Symbols.TokenRPAREN)