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

Bug 563492

Summary: Enhanced for loop without brackets has no code assist
Product: [Eclipse Project] JDT Reporter: Wojtek Bok <bigguy>
Component: CoreAssignee: Stephan Herrmann <stephan.herrmann>
Status: CLOSED WORKSFORME QA Contact:
Severity: normal    
Priority: P3 CC: stephan.herrmann
Version: 4.8   
Target Milestone: 4.16 RC1   
Hardware: PC   
OS: Windows 7   
Whiteboard:

Description Wojtek Bok CLA 2020-05-22 14:51:17 EDT
For the following code:
---------------------------- 
String[] stuff = new String[2];

// case 1
for ( String s : stuff )
{
  s.<press CTRL-SPACE>
}

// cased 2
for ( String s : stuff )
  s.<press CTRL-SPACE> 
----------------------------

Pressing CTRL-SPACE in case 1 brings up code assist for a String. However for case 2 no code assist is shown. The only difference is that case 2 does not have brackets defining the for loop body.

Hovering over "s" in case 2 also does not work.

Eclipse About shows Photon release 4.8.0 build 20180619-1200
Comment 1 Stephan Herrmann CLA 2020-05-22 15:38:13 EDT
(In reply to Wojtek Bok from comment #0)
> Eclipse About shows Photon release 4.8.0 build 20180619-1200

That's quite dated. Please try a newer version. Latest release is 4.15 (2020-03).
Comment 2 Wojtek Bok CLA 2020-05-22 16:23:36 EDT
Alright I can be big about this :-)

Yes, the latest version does work correctly.

As an aside, I am always a bit leery of changing my tools in the middle of a project, as unexpected things can happen. As it is, I had to re-install WindowBuilder as I am writing a GUI application. However the installer DID find my preferences, so that was really good.

Thanks, and sorry about the bug report
Comment 3 Stephan Herrmann CLA 2020-05-22 19:23:37 EDT
(In reply to Wojtek Bok from comment #2)
> Alright I can be big about this :-)
> 
> Yes, the latest version does work correctly.

thanks for confirming.

I'll skip the hunt for the commit which fixed this, hence saying just WORKSFORME :) - because FIXED implies there is a change booked on this bug.