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

Bug 511431

Summary: Nested parentheses during function completion
Product: [Eclipse Project] JDT Reporter: Nathan Ridge <zeratul976>
Component: TextAssignee: JDT-Text-Inbox <jdt-text-inbox>
Status: CLOSED DUPLICATE QA Contact:
Severity: normal    
Priority: P3 CC: noopur_gupta
Version: 4.7   
Target Milestone: ---   
Hardware: All   
OS: All   
Whiteboard:

Description Nathan Ridge CLA 2017-01-31 20:41:35 EST
Steps to reproduce:

 1) Enter the following code into an editor:

	public abstract class Test {
		interface A {}
		interface B {}
	
		void foo(A a) {}
		abstract B bar();
		
		void caller() {
			B b = bar();
			fo/*cursor*/
		}
	}

 2) Invoke content assist at the indicated location.
 3) Select the completion proposal for foo().
 4) Start typing the argument expression "(A) b" (without quotes).

Expected results:

  When you type the closing parenthesis in the (A), the cursor
  does not move.

Actual results:

  When you type the closing parenthesis in the (A), the cursor
  jumps to the end of the statement, leaving you will the following
  incomplete statement:

		foo((A);/*cursor*/

JDT should be keeping track of the fact that I typed an opening parenthesis as part of the argument expression, and that therefore the closing parenthesis is just closing that, rather than the entire function call expression.
Comment 1 Nathan Ridge CLA 2017-01-31 20:43:50 EST
Bug 473574 is related, except in that case, the parenthesis is inside a string literal.
Comment 2 Nathan Ridge CLA 2017-01-31 20:45:42 EST
I run into this very frequently while working on Eclipse projects (such as CDT), because the prevailing coding style involves frequent casting, so argument expressions of the form "(Interface) variable" are very common.
Comment 3 Noopur Gupta CLA 2017-02-01 00:38:26 EST

*** This bug has been marked as a duplicate of bug 477615 ***