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/JavaIndenter.java
private int fPreviousPos;
	
	private int fToken;
	/** 
	 * The scanner we will use to scan the document. It has to be installed on the same document
	 * as the one we get.
	 */
	private JavaHeuristicScanner fScanner;
	
	/**
	 * Creates a new instance.
	 * 
	 * @param document the document to scan
	 */
	public JavaIndenter(IDocument document, JavaHeuristicScanner scanner) {
		Assert.isNotNull(document);
		Assert.isNotNull(scanner);
		fDocument= document;
		fScanner= scanner;
	}
	
	/**
	 * Computes the indentation at the reference point of <code>position</code>.
	 * 
	 * @param position the position in the document, either at the beginning of a line or in the 
	 * whitespace at the beginning of a line
	 * @return a String which reflects the indentation at the line in which the reference position
	 * to <code>position</code> resides, or <code>null</code> if it cannot be determined.
	 */