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

Bug 357285

Summary: [getter setter] Generate Getters and Setters spacing
Product: [Eclipse Project] JDT Reporter: Tiberiu Rogojan <tiberiu.rogojan>
Component: TextAssignee: JDT-Text-Inbox <jdt-text-inbox>
Status: RESOLVED WORKSFORME QA Contact:
Severity: minor    
Priority: P3 CC: daniel_megert
Version: 3.8Keywords: needinfo
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   
Whiteboard:

Description Tiberiu Rogojan CLA 2011-09-09 16:20:06 EDT
Build Identifier: 20100917-0705

Let's take the following class for instance:

.....
public MessagePacket(SocketAddress from, SocketAddress to, Calendar timestamp, String message) {
		this.from = from;
		this.to = to;
		this.timestamp = timestamp;
		this.message = message;
	}
	
	// HERE YOU HAVE 5 NEW LINES!
	
	
	
	@Override
	public int hashCode() {
          // hashCode method....
        }
.....

If you chose to generate setters and getters and place them before the hashcode method, and your cursor position is let's say 4 LINES above hashcode method, then all the generated setters and getters will end up having 4 LINES between them.
The code generation code, shouldn't use the lines between cursor position and the next statement in order to compute the lines that it should use between getter and setter methods that are about to be generated. It should solely be based on a template that let's say uses one new line.

Reproducible: Always

Steps to Reproduce:
Leave N LINES between cursor position and a statement (method or whatever).
Alt + Shift + S -> generate getters and setters.
Select either getters, either setters, or both and hit OK
The generated setXXX getXXX methods have N Lines of new line between them!
Comment 1 Dani Megert CLA 2011-09-13 03:30:48 EDT
I cannot reproduce this using 3.6.2 or 3.8 M1 from here:
http://download.eclipse.org/eclipse/downloads/eclipse3x.php
with a new workspace.

Please try with those builds and if you still see the issue, provide more detailed steps and reopen this bug.
Comment 2 Tiberiu Rogojan CLA 2011-09-17 14:47:41 EDT
Hi,

I've tried with the builds that you pointed out and you're right. The bug doesn't reproduce with that build.
I've looked at my build number and it's 3.6.1.
I've made a new project and tried to reproduce it again with my version 3.6.1, but couldn't.

I remember that this bug happened several times. I'm not quite sure what I'm doing that makes eclipse behave like this, but if stumble on it again, I will try to give the steps to reproduce it.

Sorry for the false alarm, and thank you!

Regards,
Tiberiu


> I cannot reproduce this using 3.6.2 or 3.8 M1 from here:
> http://download.eclipse.org/eclipse/downloads/eclipse3x.php
> with a new workspace.
> 
> Please try with those builds and if you still see the issue, provide more
> detailed steps and reopen this bug.