Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » Java Development Tools (JDT) » this. in getter and setter methods
this. in getter and setter methods [message #122330] Wed, 26 November 2003 13:59 Go to next message
Eclipse UserFriend
Originally posted by: kl.itec.uni-klu.ac.at

Hi,

is it possible to customize the "Generate Getter and Setter" functionality
by adding a "this." before the attribute to set/get?

Example:
What Eclipse does:
public void setSomething(int i) {
something = i;
}

What I want:
public void setSomething(int i) {
this.something = i;
}

Thanks in advance,
Klaus
Re: this. in getter and setter methods [message #122378 is a reply to message #122330] Wed, 26 November 2003 14:36 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: eclipse.tkilla.ch

Klaus Leopold wrote:
> Hi,
>
> is it possible to customize the "Generate Getter and Setter" functionality
> by adding a "this." before the attribute to set/get?
>
> Example:
> What Eclipse does:
> public void setSomething(int i) {
> something = i;
> }
>
> What I want:
> public void setSomething(int i) {
> this.something = i;
> }

In the preferences, go to Java->Code Generation->Code and Comments tab
and modify the getter and setter bodies.

-tom
Re: this. in getter and setter methods [message #122387 is a reply to message #122378] Wed, 26 November 2003 14:44 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: kl.itec.uni-klu.ac.at

That was the first place where I looked for it but I couldn't find these
settings. I just have following entries:

Comments:
Constructors
Types
Methods
Overriding methods
Code:
New Java files
Catch block body
Method body
Constructor body

No getter and setter stuff here :(

Klaus


Tom Eicher wrote:

> Klaus Leopold wrote:
>> Hi,
>>
>> is it possible to customize the "Generate Getter and Setter"
>> functionality by adding a "this." before the attribute to set/get?
>>
>> Example:
>> What Eclipse does:
>> public void setSomething(int i) {
>> something = i;
>> }
>>
>> What I want:
>> public void setSomething(int i) {
>> this.something = i;
>> }
>
> In the preferences, go to Java->Code Generation->Code and Comments tab
> and modify the getter and setter bodies.
>
> -tom
Re: this. in getter and setter methods [message #122398 is a reply to message #122387] Wed, 26 November 2003 15:06 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: eclipse.tkilla.ch

Klaus Leopold wrote:
> That was the first place where I looked for it but I couldn't find these
> settings. I just have following entries:
>
> Comments:
> Constructors
> Types
> Methods
> Overriding methods
> Code:
> New Java files
> Catch block body
> Method body
> Constructor body
>
> No getter and setter stuff here :(

What build are you on? AFAIR, this has been added around M3 or M4.
-tom
Re: this. in getter and setter methods [message #122409 is a reply to message #122398] Wed, 26 November 2003 15:14 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: kl.itec.uni-klu.ac.at

My about says:

Version: 2.1.2
Build id: 200311030802

So, I'll have to update?

Klaus

Tom Eicher wrote:

> Klaus Leopold wrote:
>> That was the first place where I looked for it but I couldn't find these
>> settings. I just have following entries:
>>
>> Comments:
>> Constructors
>> Types
>> Methods
>> Overriding methods
>> Code:
>> New Java files
>> Catch block body
>> Method body
>> Constructor body
>>
>> No getter and setter stuff here :(
>
> What build are you on? AFAIR, this has been added around M3 or M4.
> -tom
Re: this. in getter and setter methods [message #122429 is a reply to message #122398] Wed, 26 November 2003 15:19 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: mlegart.dk.tiscali.com

On Wed, 26 Nov 2003 16:06:48 +0100, Tom Eicher <eclipse@tkilla.ch> wrote:
>> No getter and setter stuff here :(
>
> What build are you on? AFAIR, this has been added around M3 or M4.
> -tom

Is it just me or is this broken in M5? When I choose "Generate
Getters and Setters" nothing happends. No dialig appears and
no errormessage. Any ideas?

Thanks
Michael
Re: this. in getter and setter methods [message #122478 is a reply to message #122409] Wed, 26 November 2003 16:36 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: akiezun.to.reply.remove.whats.unneeded.mit.edu

> Version: 2.1.2
> Build id: 200311030802
>
> So, I'll have to update?


big time
you're sitting on some old stuff
get M4 or M5
a.
Re: this. in getter and setter methods [message #122526 is a reply to message #122429] Wed, 26 November 2003 17:05 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: eclipse.tkilla.ch

Michael Legart wrote:
> Is it just me or is this broken in M5? When I choose "Generate
> Getters and Setters" nothing happends. No dialig appears and
> no errormessage. Any ideas?

Works fine for me
-tom
Re: this. in getter and setter methods [message #122560 is a reply to message #122478] Wed, 26 November 2003 19:18 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: kl.itec.uni-klu.ac.at

With 3.0M5 it works perfekt!
Thanks,
Klaus

Adam Kiezun wrote:

>> Version: 2.1.2
>> Build id: 200311030802
>>
>> So, I'll have to update?
>
>
> big time
> you're sitting on some old stuff
> get M4 or M5
> a.
Re: this. in getter and setter methods [message #122714 is a reply to message #122429] Thu, 27 November 2003 15:06 Go to previous messageGo to next message
Colin Sampaleanu is currently offline Colin SampaleanuFriend
Messages: 22
Registered: July 2009
Junior Member
Michael Legart wrote:
> On Wed, 26 Nov 2003 16:06:48 +0100, Tom Eicher <eclipse@tkilla.ch> wrote:
>
>>>No getter and setter stuff here :(
>>
>>What build are you on? AFAIR, this has been added around M3 or M4.
>>-tom
>
>
> Is it just me or is this broken in M5? When I choose "Generate
> Getters and Setters" nothing happends. No dialig appears and
> no errormessage. Any ideas?

This appears to be 'half' broken in M5. If I right click on a field
variable and do 'Source|Generate Getters and Setters', then it works
absolutely ok. On the other hand, if I right click on some empty space
in the class and do the same thing, or if I try to use the Eclipse menu
option for this, I get no visible results, and some errors appear in the
Error Log, as follows:

!ENTRY org.eclipse.ui 4 4 Nov 27, 2003 10:01:47.980
!MESSAGE Unhandled event loop exception
!ENTRY org.eclipse.ui 4 0 Nov 27, 2003 10:01:47.980
!MESSAGE null argument;
!STACK 0
org.eclipse.jface.util.Assert$AssertionFailedException: null argument;
at org.eclipse.jface.util.Assert.isNotNull(Assert.java:139)
at org.eclipse.jface.util.Assert.isNotNull(Assert.java:116)
at
org.eclipse.jface.viewers.AbstractTreeViewer.reveal(Abstract TreeViewer.java:1233)
at
org.eclipse.jdt.ui.actions.AddGetterSetterAction$GetterSette rTreeSelectionDialog.createDialogArea(AddGetterSetterAction. java:972)
at org.eclipse.jface.dialogs.Dialog.createContents(Dialog.java: 573)
at org.eclipse.jface.window.Window.create(Window.java:305)
at org.eclipse.jface.dialogs.Dialog.create(Dialog.java:883)
at
org.eclipse.ui.dialogs.SelectionStatusDialog.create(Selectio nStatusDialog.java:143)
at
org.eclipse.ui.dialogs.CheckedTreeSelectionDialog.access$sup erCreate(CheckedTreeSelectionDialog.java:215)
at
org.eclipse.ui.dialogs.CheckedTreeSelectionDialog.access$0(C heckedTreeSelectionDialog.java:214)
at
org.eclipse.ui.dialogs.CheckedTreeSelectionDialog$1.run(Chec kedTreeSelectionDialog.java:240)
at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator .java:84)
at
org.eclipse.ui.dialogs.CheckedTreeSelectionDialog.create(Che ckedTreeSelectionDialog.java:238)
at org.eclipse.jface.window.Window.open(Window.java:555)
at
org.eclipse.ui.dialogs.CheckedTreeSelectionDialog.open(Check edTreeSelectionDialog.java:209)
at
org.eclipse.jdt.ui.actions.AddGetterSetterAction.run(AddGett erSetterAction.java:255)
at
org.eclipse.jdt.ui.actions.AddGetterSetterAction.run(AddGett erSetterAction.java:505)
at
org.eclipse.jdt.ui.actions.SelectionDispatchAction.dispatchR un(SelectionDispatchAction.java:196)
at
org.eclipse.jdt.ui.actions.SelectionDispatchAction.run(Selec tionDispatchAction.java:172)
at org.eclipse.jface.action.Action.runWithEvent(Action.java:842 )
at
org.eclipse.jface.action.ActionContributionItem.handleWidget Selection(ActionContributionItem.java:542)
at
org.eclipse.jface.action.ActionContributionItem.access$4(Act ionContributionItem.java:494)
at
org.eclipse.jface.action.ActionContributionItem$6.handleEven t(ActionContributionItem.java:466)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java :82)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:847)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.ja va:2187)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java :1877)
at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.jav a:1405)
at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1381)
at
org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Work bench.java:237)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.j ava:139)
at org.eclipse.ui.internal.ide.IDEApplication.run(IDEApplicatio n.java:47)
at
org.eclipse.core.internal.boot.InternalBootLoader.run(Intern alBootLoader.java:858)
at org.eclipse.core.boot.BootLoader.run(BootLoader.java:461)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.eclipse.core.launcher.Main.basicRun(Main.java:299)
at org.eclipse.core.launcher.Main.run(Main.java:767)
at org.eclipse.core.launcher.Main.main(Main.java:601)
Re: this. in getter and setter methods [message #122723 is a reply to message #122714] Thu, 27 November 2003 15:34 Go to previous message
Eclipse UserFriend
Originally posted by: eclipse.tkilla.ch

Please file a bug report agains jdt ui.

-tom

Colin Sampaleanu wrote:
> Michael Legart wrote:
> This appears to be 'half' broken in M5. If I right click on a field
> variable and do 'Source|Generate Getters and Setters', then it works
> absolutely ok. On the other hand, if I right click on some empty space
> in the class and do the same thing, or if I try to use the Eclipse menu
> option for this, I get no visible results, and some errors appear in the
> Error Log, as follows:
>
> !ENTRY org.eclipse.ui 4 4 Nov 27, 2003 10:01:47.980
> !MESSAGE Unhandled event loop exception
> !ENTRY org.eclipse.ui 4 0 Nov 27, 2003 10:01:47.980
> !MESSAGE null argument;
> !STACK 0
> org.eclipse.jface.util.Assert$AssertionFailedException: null argument;
> at org.eclipse.jface.util.Assert.isNotNull(Assert.java:139)
> at org.eclipse.jface.util.Assert.isNotNull(Assert.java:116)
> at
> org.eclipse.jface.viewers.AbstractTreeViewer.reveal(Abstract TreeViewer.java:1233)
>
> at
> org.eclipse.jdt.ui.actions.AddGetterSetterAction$GetterSette rTreeSelectionDialog.createDialogArea(AddGetterSetterAction. java:972)
>
> at org.eclipse.jface.dialogs.Dialog.createContents(Dialog.java: 573)
> at org.eclipse.jface.window.Window.create(Window.java:305)
> at org.eclipse.jface.dialogs.Dialog.create(Dialog.java:883)
> at
> org.eclipse.ui.dialogs.SelectionStatusDialog.create(Selectio nStatusDialog.java:143)
>
> at
> org.eclipse.ui.dialogs.CheckedTreeSelectionDialog.access$sup erCreate(CheckedTreeSelectionDialog.java:215)
>
> at
> org.eclipse.ui.dialogs.CheckedTreeSelectionDialog.access$0(C heckedTreeSelectionDialog.java:214)
>
> at
> org.eclipse.ui.dialogs.CheckedTreeSelectionDialog$1.run(Chec kedTreeSelectionDialog.java:240)
>
> at
> org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator .java:84)
> at
> org.eclipse.ui.dialogs.CheckedTreeSelectionDialog.create(Che ckedTreeSelectionDialog.java:238)
>
> at org.eclipse.jface.window.Window.open(Window.java:555)
> at
> org.eclipse.ui.dialogs.CheckedTreeSelectionDialog.open(Check edTreeSelectionDialog.java:209)
>
> at
> org.eclipse.jdt.ui.actions.AddGetterSetterAction.run(AddGett erSetterAction.java:255)
>
> at
> org.eclipse.jdt.ui.actions.AddGetterSetterAction.run(AddGett erSetterAction.java:505)
>
> at
> org.eclipse.jdt.ui.actions.SelectionDispatchAction.dispatchR un(SelectionDispatchAction.java:196)
>
> at
> org.eclipse.jdt.ui.actions.SelectionDispatchAction.run(Selec tionDispatchAction.java:172)
>
> at org.eclipse.jface.action.Action.runWithEvent(Action.java:842 )
> at
> org.eclipse.jface.action.ActionContributionItem.handleWidget Selection(ActionContributionItem.java:542)
>
> at
> org.eclipse.jface.action.ActionContributionItem.access$4(Act ionContributionItem.java:494)
>
> at
> org.eclipse.jface.action.ActionContributionItem$6.handleEven t(ActionContributionItem.java:466)
>
> at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java :82)
> at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:847)
> at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.ja va:2187)
> at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java :1877)
> at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.jav a:1405)
> at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1381)
> at
> org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Work bench.java:237)
> at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.j ava:139)
> at
> org.eclipse.ui.internal.ide.IDEApplication.run(IDEApplicatio n.java:47)
> at
> org.eclipse.core.internal.boot.InternalBootLoader.run(Intern alBootLoader.java:858)
>
> at org.eclipse.core.boot.BootLoader.run(BootLoader.java:461)
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
> at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
> at java.lang.reflect.Method.invoke(Unknown Source)
> at org.eclipse.core.launcher.Main.basicRun(Main.java:299)
> at org.eclipse.core.launcher.Main.run(Main.java:767)
> at org.eclipse.core.launcher.Main.main(Main.java:601)
>
Previous Topic:import master build.xml from legacy java project
Next Topic:Java Project Properties no longer shows Build Path
Goto Forum:
  


Current Time: Tue Jul 16 12:25:10 GMT 2024

Powered by FUDForum. Page generated in 0.04713 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top