Skip to main content



      Home
Home » Language IDEs » Java Development Tools (JDT) » issues with Code Generation in 2.1
issues with Code Generation in 2.1 [message #100319] Wed, 01 October 2003 12:30 Go to next message
Eclipse UserFriend
With Eclipse 2.1, using the facility provided by:
preferences->java->code generation "code and comments" tab

I set the text for "New Java files" to:

---snip start----------------

${package_declaration}

import org.apache.log4j.Logger;

${type_declaration}
private static final Logger log = Logger.getLogger(${type_name}.class);

---snip end----------------

which generates the following code for test.TestClass

---snip start----------------

package test;

public class TestClass {

}

private static final Logger log = Logger.getLogger(TestClass.class);

---snip end----------------

So, my questions are:
1- what happened to the explicit import statement ? how can get that to
work ?
2- is there a way to include the static Logger declaration within the
type declaration ?

This isn't a personal showstopper, but it'd be nice.. I'm reticent to
move to 3.0 but having these issues fixed would definitely be an
incentive to move up.
Re: issues with Code Generation in 2.1 [message #100332 is a reply to message #100319] Wed, 01 October 2003 17:35 Go to previous messageGo to next message
Eclipse UserFriend
I simply use code completion with the template below.

/**
* Responsible for logging.
*/
private static final Logger log = Logger.getLogger(
${enclosing_type}.class);
${cursor}


Then type log <ctrl>+space followed by <Ctrl><shift>+O to get the
import.



On Wed, 01 Oct 2003 09:30:22 -0700, Ivar Vasara
<ivar-eclipse@oobik.com> wrote:

>
>With Eclipse 2.1, using the facility provided by:
>preferences->java->code generation "code and comments" tab
>
>I set the text for "New Java files" to:
>
>---snip start----------------
>
>${package_declaration}
>
>import org.apache.log4j.Logger;
>
>${type_declaration}
>private static final Logger log = Logger.getLogger(${type_name}.class);
>
>---snip end----------------
>
>which generates the following code for test.TestClass
>
>---snip start----------------
>
>package test;
>
>public class TestClass {
>
>}
>
>private static final Logger log = Logger.getLogger(TestClass.class);
>
>---snip end----------------
>
>So, my questions are:
>1- what happened to the explicit import statement ? how can get that to
>work ?
>2- is there a way to include the static Logger declaration within the
>type declaration ?
>
>This isn't a personal showstopper, but it'd be nice.. I'm reticent to
>move to 3.0 but having these issues fixed would definitely be an
>incentive to move up.
Re: issues with Code Generation in 2.1 [message #101608 is a reply to message #100319] Mon, 06 October 2003 10:48 Go to previous message
Eclipse UserFriend
That's a bug, you're right. I fixed it for M5.

Please file a bug using buzilla in such cases. It was a coincidence that
I read this.

Martin

Ivar Vasara wrote:
>
> With Eclipse 2.1, using the facility provided by:
> preferences->java->code generation "code and comments" tab
>
> I set the text for "New Java files" to:
>
> ---snip start----------------
>
> ${package_declaration}
>
> import org.apache.log4j.Logger;
>
> ${type_declaration}
> private static final Logger log = Logger.getLogger(${type_name}.class);
>
> ---snip end----------------
>
> which generates the following code for test.TestClass
>
> ---snip start----------------
>
> package test;
>
> public class TestClass {
>
> }
>
> private static final Logger log = Logger.getLogger(TestClass.class);
>
> ---snip end----------------
>
> So, my questions are:
> 1- what happened to the explicit import statement ? how can get that to
> work ?
> 2- is there a way to include the static Logger declaration within the
> type declaration ?
>
> This isn't a personal showstopper, but it'd be nice.. I'm reticent to
> move to 3.0 but having these issues fixed would definitely be an
> incentive to move up.
>
Previous Topic:Accessor javadoc
Next Topic:Completing TODO tasks?
Goto Forum:
  


Current Time: Tue Jul 22 00:44:42 EDT 2025

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

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

Back to the top