Skip to main content



      Home
Home » Eclipse Projects » Eclipse Platform » Changing template for creation of methods and variables
Changing template for creation of methods and variables [message #218101] Tue, 30 March 2004 07:24 Go to next message
Eclipse UserFriend
Hi,

I have a coding convention that requires me to do something like:

//******************************
// Method: method()
// ----------------
/**
* Javadoc goes here
*/
//******************************
void method() {
// stuff here
} //method()

Where do I go to tell Eclipse to generate new methods in this manner?

Also, the coding convention wants variables that use different prefixes,
depending on the type, whether it's a class variable or an instance
variable, etc. Is there a way to customize this also? And then tell
Eclipse that generating getters and setters should not use those prefixes?

For example:

class Foo {
int m_iFooVar;

int getFooVar() {
return m_iFooVar;
}

int setFooVar(int p_iFooVar) {
m_iFooVar = p_iFooVar;
}
}

I don't expect this to be possible, but you can't know unless you ask,
right? :-)

L
Re: Changing template for creation of methods and variables [message #218111 is a reply to message #218101] Tue, 30 March 2004 07:27 Go to previous messageGo to next message
Eclipse UserFriend
On Tue, 30 Mar 2004 07:24:33 -0500, Laurent Duperval wrote:

> Hi,
>
> I have a coding convention that requires me to do something like:
>

On M8. SOrry 'bout that.

L
Re: Changing template for creation of methods and variables [message #218406 is a reply to message #218101] Tue, 30 March 2004 12:02 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: martinek.fit.vutbr.cz

Laurent Duperval:
> Hi,
>
> I have a coding convention that requires me to do something like:
>
> //******************************
> // Method: method()
> // ----------------
> /**
> * Javadoc goes here
> */
> //******************************
> void method() {
> // stuff here
> } //method()
>
> Where do I go to tell Eclipse to generate new methods in this manner?

Window->Preferences->Java->Editor->Templates - you can create your own
templates.

>
> Also, the coding convention wants variables that use different prefixes,
> depending on the type, whether it's a class variable or an instance
> variable, etc. Is there a way to customize this also? And then tell
> Eclipse that generating getters and setters should not use those prefixes?
>
> For example:
>
> class Foo {
> int m_iFooVar;
>
> int getFooVar() {
> return m_iFooVar;
> }
>
> int setFooVar(int p_iFooVar) {
> m_iFooVar = p_iFooVar;
> }
> }
>
> I don't expect this to be possible, but you can't know unless you ask,
> right? :-)
>
> L
>

Preferences->Java->Code Generation but I'm not sure if it can do exactly
what you want. I'm using this convention

this.iFooVar = iFooVar;

instead of prefixes.

David
Re: Changing template for creation of methods and variables [message #218550 is a reply to message #218406] Tue, 30 March 2004 14:22 Go to previous messageGo to next message
Eclipse UserFriend
On Tue, 30 Mar 2004 19:02:12 +0200, David Martinek wrote:
> Window->Preferences->Java->Editor->Templates - you can create your own
> templates.
>

Thanks, I almost have it working like I want. The one part I can't get
working is the comment at the closing brace of the method. So now, I can
generate this:

//******************************
// Method: method()
// ----------------
/**
* Javadoc goes here
*/
//******************************
void method() {
// stuff here
}

but the last line should say

} method()

Maybe I'm blinded bu the light but I'm not sure where to confifure this.
I thought maybe it was in the Code Templates section but I made a
modification there and it doesn't show up.

Also, for new class files, I've set my template to look like this:

${package_declaration}

//Class: ${type_name}}
//---------------------
${typecomment}
${type_declaration} // ${type_name}


When I generate the code, it looks like this:

class Foo {
}
// Foo

It looks like ${type_declaration} automatically adds a new line. Is it
possible to tell it not to?

Maybe all this is glaringly obvious but I'm just now getting to know the
more fancy features of Eclipse.

Thanks again,

L
Re: Changing template for creation of methods and variables [message #218993 is a reply to message #218550] Wed, 31 March 2004 03:57 Go to previous message
Eclipse UserFriend
Laurent Duperval wrote:
> When I generate the code, it looks like this:
>
> class Foo {
> }
> // Foo
>
> It looks like ${type_declaration} automatically adds a new line. Is it
> possible to tell it not to?

No.

-tom
Previous Topic:Enabling Java Menus in my perspective
Next Topic:eclipse 2.1.2, upload exclude certain directories (.svn)
Goto Forum:
  


Current Time: Sat Jun 07 14:22:56 EDT 2025

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

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

Back to the top