Bug 357285 - [getter setter] Generate Getters and Setters spacing
Summary: [getter setter] Generate Getters and Setters spacing
Status: RESOLVED WORKSFORME
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Text (show other bugs)
Version: 3.8   Edit
Hardware: PC Windows XP
: P3 minor (vote)
Target Milestone: ---   Edit
Assignee: JDT-Text-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords: needinfo
Depends on:
Blocks:
 
Reported: 2011-09-09 16:20 EDT by Tiberiu Rogojan CLA
Modified: 2011-09-17 14:47 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 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.