Bug 463477

Summary: [inline] Inline local variable adds extra parenthesis with ArrayCreation having initializer
Product: [Eclipse Project] JDT Reporter: Noopur Gupta <noopur_gupta>
Component: UIAssignee: JDT-UI-Inbox <jdt-ui-inbox>
Status: ASSIGNED --- QA Contact:
Severity: normal    
Priority: P3 CC: daniel_megert
Version: 4.5   
Target Milestone: ---   
Hardware: All   
OS: All   
See Also: https://bugs.eclipse.org/bugs/show_bug.cgi?id=394721
Whiteboard: stalebug

Description Noopur Gupta CLA 2015-03-30 11:12:53 EDT
Example:

class T {
	static final int[][] f1 = new int[][] {{0}};
	{
		f1[0][0] = 0;
		
		int[][] m1 = new int[][] {{0}};
		m1[0][0] = 0;		
	}
}

Inlining "m1" adds extra parentheses and results in:
(new int[][] {{0}})[0][0] = 0;

Inlining the constant "f1" doesn't add extra parentheses.

This is because InlineTempRefactoring#getInitializerSource invokes NecessaryParenthesesChecker#needsParentheses with a copy node which checks for the node's initializer value, and that is null for the copied node.
Comment 1 Eclipse Genie CLA 2019-04-01 14:06:23 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.
Comment 2 Dani Megert CLA 2019-04-02 10:01:17 EDT
Still an issue in 4.11.
Comment 3 Eclipse Genie CLA 2021-03-24 09:08:59 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.
Comment 4 Eclipse Genie CLA 2023-04-11 17:57:21 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.