Bug 128422 - [ast rewrite] Add paranoiac paranthesis does not detect comments
Summary: [ast rewrite] Add paranoiac paranthesis does not detect comments
Status: RESOLVED DUPLICATE of bug 143026
Alias: None
Product: JDT
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.2   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Martin Aeschlimann CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 149433 (view as bug list)
Depends on:
Blocks:
 
Reported: 2006-02-17 10:30 EST by Benno Baumgartner CLA
Modified: 2007-05-15 05:09 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 Benno Baumgartner CLA 2006-02-17 10:30:19 EST
Version: 3.2.0
Build id: I20060216-2000

Given:
if (i != 0 //I don't like 0
		&& i != 10)
	System.out.println(i);

1. Select:
(i != 0 //I don't like 0
		&& i != 10)
2. Ctrl-1
3. Add paranoiac paranthesis
Result:
if ((i != 0 //I don't like 0)
		&& (i != 10))
	System.out.println(i);

Expected:
if ((i != 0) //I don't like 0
		&& (i != 10))
	System.out.println(i);

(the ')' is inserted at end of comment)

Looks like a bug in AST rewrite. The code to add parenthesis is rather simple:

ParenthesizedExpression parenthesizedExpression=
      ast.newParenthesizedExpression();
parenthesizedExpression.setExpression(
      (Expression) rewrite.createCopyTarget(expression));
rewrite.replace(expression, parenthesizedExpression, group);
Comment 1 Benno Baumgartner CLA 2006-02-21 11:17:09 EST
See also Bug 128818 which may be a dup?
Comment 2 Martin Aeschlimann CLA 2006-04-26 14:37:02 EDT

*** This bug has been marked as a duplicate of 95839 ***
Comment 3 Martin Aeschlimann CLA 2006-07-04 10:43:21 EDT
reopen. fix for bug 95839 did not cover this bug releated to copy.
Comment 4 Martin Aeschlimann CLA 2006-07-04 10:43:52 EDT
*** Bug 149433 has been marked as a duplicate of this bug. ***
Comment 5 Martin Aeschlimann CLA 2007-05-11 10:44:38 EDT

*** This bug has been marked as a duplicate of bug 143026 ***
Comment 6 Eric Jodet CLA 2007-05-15 05:09:59 EDT
Verified for 3.3 RC1 using I20070515-0010