Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 330415

Summary: [inline] Refactor > Inline fails to parenthesize replaced arguments
Product: [Eclipse Project] JDT Reporter: Missing name <cub1975>
Component: UIAssignee: Deepak Azad <deepakazad>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: deepakazad, remy.suen
Version: 3.5.2   
Target Milestone: 3.7 M4   
Hardware: All   
OS: All   
Whiteboard:
Attachments:
Description Flags
This is a test case to demonstrate the bug (requires manual steps; see file).
none
fix + tests none

Description Missing name CLA 2010-11-16 19:07:25 EST
Build Identifier: M20100211-1343

Inlining a subtracted expression produces the wrong result because the refactoring tool fails to parenthesize the arguments.

Example: instead of x - (y + z), you can end up with x - y + z.

(See attached test case).

Reproducible: Always

Steps to Reproduce:
1. Run the test case as-is.
2. Inline each of the functions in main().
3. Run the test case again and observe the difference.
Comment 1 Missing name CLA 2010-11-16 19:08:49 EST
Created attachment 183272 [details]
This is a test case to demonstrate the bug (requires manual steps; see file).
Comment 2 Remy Suen CLA 2010-11-16 19:25:26 EST
Issues with Eclipse's Java tooling goes to JDT.
Comment 3 Deepak Azad CLA 2010-11-17 00:30:14 EST
Created attachment 183275 [details]
fix + tests

It is better to add extra parenthesis in some cases e.g. x + (y + z) , than change the semantics on inlining.
Comment 4 Deepak Azad CLA 2010-11-17 00:30:47 EST
Fixed in HEAD.