Bug 538663 - Correct Indentation fails with Brace-less if-clause before
Summary: Correct Indentation fails with Brace-less if-clause before
Status: NEW
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 4.5   Edit
Hardware: PC Windows 8
: P3 minor (vote)
Target Milestone: ---   Edit
Assignee: JDT-Core-Inbox CLA
QA Contact:
URL:
Whiteboard: stalebug
Keywords:
Depends on:
Blocks:
 
Reported: 2018-09-05 13:03 EDT by Michael Hochmuth CLA
Modified: 2023-04-01 12:19 EDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Michael Hochmuth CLA 2018-09-05 13:03:26 EDT
After an assignment in a brace-less if-clause, that assigns a conditional expression to a boolean variable, the indentation-level doesn't revert to normal. This can be fixed by sourrounding the conditional expression with braces, but java-syntax doesn't impose this restriction.

Here it fails:

boolean test;
	if(true) 
		test = 4>0;
		int x = 4;
		x+=4;
		System.out.println("lol");

Here it works:

boolean test;
	if(true) 
		test = (4>0);
	int x = 4;
	x+=4;
	System.out.println("lol");

-- Configuration Details --
Product: Eclipse 4.7.3.20180405-1200 (org.eclipse.epp.package.java.product)Installed Features:
 org.eclipse.jdt 3.13.4.v20180330-0919
Versioning Plugin:
 org.eclipse.platform 4.7.3.v20180330-0640
Comment 1 Ed Willink CLA 2019-03-18 04:18:50 EDT
I see the same thing, but the problem seems to also need a constant expression for a switch case:

public class Bug {
	public void eInverseAdd(Object otherEnd, int featureID, Object msgs) {
		switch (featureID) {
			case 57 + 1:
				if (otherEnd != null)
					msgs = null;
			return;     // This should be indented to match if.
		}
		return;
	}

}
Comment 2 Eclipse Genie CLA 2021-03-08 13:46:04 EST
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.
Comment 3 Ed Willink CLA 2021-03-09 02:59:06 EST
Cannot be stale under a relevant committer has triaged.
Comment 4 Eclipse Genie CLA 2023-04-01 12:19:02 EDT
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.