Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » Java Development Tools (JDT) » Automating Comments after closing bracket
Automating Comments after closing bracket [message #658005] Fri, 04 March 2011 22:36 Go to next message
Missing name Mising name is currently offline Missing name Mising nameFriend
Messages: 3
Registered: March 2011
Junior Member
Eclipse is quite an incredible tool! I'm amazed at how advanced it's automatic formatting is. BUT, there is one thing I would like to automate that I cant figure out how to do (or IF it can do it)

When coding in java, I prefer that the closing brackets for each method and class be double slash commented with the name of the method or class.

For example

  public void myMethod()
    {
    do lots of java stuff
    }//myMethod


Is there any way to automate this in the Eclipse Code Style formatter?

Thanks in advance for any help anyone can provide!
Re: Automating Comments after closing bracket [message #658020 is a reply to message #658005] Sat, 05 March 2011 04:43 Go to previous messageGo to next message
Deepak Azad is currently offline Deepak AzadFriend
Messages: 543
Registered: July 2009
Senior Member
On 3/5/2011 4:06 AM, bugzilla-dch00@sneakemail.com wrote:
> Eclipse is quite an incredible tool! I'm amazed at how advanced it's
> automatic formatting is. BUT, there is one thing I would like to
> automate that I cant figure out how to do (or IF it can do it)
>
> When coding in java, I prefer that the closing brackets for each method
> and class be double slash commented with the name of the method or class.
>
> For example
>
>
> public void myMethod()
> {
> do lots of java stuff
> }//myMethod
>
>
> Is there any way to automate this in the Eclipse Code Style formatter?
>
> Thanks in advance for any help anyone can provide!

A formatter setting is not available for this. But you can create a
template to help you with this.

- Go to Window > Preferences > Java > Editor > Templates
- Create a new template in 'Java' context, name it something like
'methodNameComment', and give the pattern as "//${enclosing_method}"

In the Java editor
- place the caret after the closing brace of a method
- type 'me'
- press 'Ctrl+Space' to invoke content assist
- this newly created template should be the first proposal. Press enter
to accept it.

Hope this helps.
Re: Automating Comments after closing bracket [message #658844 is a reply to message #658020] Thu, 10 March 2011 02:07 Go to previous messageGo to next message
Missing name Mising name is currently offline Missing name Mising nameFriend
Messages: 3
Registered: March 2011
Junior Member
yes! Thank you! That works quite wonderfully!
I'm going to need to explore the possibilities in these templates.

Thank you very much!
Re: Automating Comments after closing bracket [message #658848 is a reply to message #658844] Thu, 10 March 2011 03:56 Go to previous messageGo to next message
Deepak Azad is currently offline Deepak AzadFriend
Messages: 543
Registered: July 2009
Senior Member
On 3/10/2011 7:37 AM, bugzilla-dch00@sneakemail.com wrote:
> yes! Thank you! That works quite wonderfully!
> I'm going to need to explore the possibilities in these templates.
> Thank you very much!
To learn more about templates, especially about pre-existing variables,
search in Eclipse help for 'Template variables'.
Re: Automating Comments after closing bracket [message #658854 is a reply to message #658848] Thu, 10 March 2011 05:05 Go to previous message
Missing name Mising name is currently offline Missing name Mising nameFriend
Messages: 3
Registered: March 2011
Junior Member
>To learn more about templates, especially about pre-existing variables,
>search in Eclipse help for 'Template variables'.

Thats what I've been doing all evening! Smile

I've rewritten many of the existing code templates and added a few new ones that fit my needs. This is fantastic. The code templates, formatting style, automated coding of getters/setters, instant importing, I'm in love with Eclipse!

Eclipse is really allowing me to concentrate on the actual coding while it takes care of all the busy work.

Again, thank you very much!
Previous Topic:Eclipse 3.6.2 does not work on RHEL6
Next Topic:Java source formatter doesn't run
Goto Forum:
  


Current Time: Fri Apr 26 15:59:46 GMT 2024

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

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

Back to the top