Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 331028 - [typing] Indentation broken in enhanced for loop
Summary: [typing] Indentation broken in enhanced for loop
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Text (show other bugs)
Version: 3.7   Edit
Hardware: PC Windows 7
: P2 major (vote)
Target Milestone: 3.7 M4   Edit
Assignee: Dani Megert CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-11-24 10:05 EST by Markus Keller CLA
Modified: 2011-06-03 07:24 EDT (History)
4 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Markus Keller CLA 2010-11-24 10:05:40 EST
Broken in M3, HEAD, and in HEAD with patch from bug 330556 comment 8
OK up to at least 3.7 M1.

Auto-indentation is broken when copying lines with Ctrl+Alt+ArrowDown.

Example (using default code formatter):

package p;

import java.util.List;

class A {
	void x() {
		List<? extends Number> nums = getNums();
		for (Number n : nums) {
			Number n2 = (Number) n; // copy with Ctrl+Alt+ArrowDown
			System.out.println(n);
		}
	}

	private List getNums() {
		return null;
	}
}

=> Copied line indented too much:

		for (Number n : nums) {
			Number n2 = (Number) n;
				Number n2 = (Number) n;
Comment 1 Markus Keller CLA 2010-11-24 10:21:55 EST
The copying is not necessary to reproduce. Ctrl+I also indents wrongly:

		for (Number n : nums) {
			Number n2 = (Number) n;
				Number n2 = (Number) n;
				System.out.println(n);
		}
Comment 2 Dani Megert CLA 2010-12-03 03:08:54 EST
I've reverted all recently made indent fixes.
Comment 3 Deepak Azad CLA 2010-12-07 08:19:10 EST
Verified for 3.7M4 with I20101206-1800.
Comment 4 Ulrich Hobelmann CLA 2011-06-03 07:21:24 EDT
The problem also affects for-loops with a single statement instead of a block:

for (Integer id : ids)
    process(id);
        int nextLine;

Using 3.7RC2 here (20110526-1053).

(Does that mean reopen, since it's supposed to be fixed in M4?)
Comment 5 Dani Megert CLA 2011-06-03 07:24:32 EDT
(In reply to comment #4)
> The problem also affects for-loops with a single statement instead of a block:
> 
> for (Integer id : ids)
>     process(id);
>         int nextLine;
> 
> Using 3.7RC2 here (20110526-1053).
> 
> (Does that mean reopen, since it's supposed to be fixed in M4?)

Please file a new bug.