Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 337077 - [move member type] Move Type to New File ignores code template when inner class has class level comments
Summary: [move member type] Move Type to New File ignores code template when inner cla...
Status: RESOLVED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.7   Edit
Hardware: All All
: P3 minor (vote)
Target Milestone: 3.7 M6   Edit
Assignee: Markus Keller CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-02-13 14:58 EST by Troy CLA
Modified: 2011-02-14 11:26 EST (History)
2 users (show)

See Also:


Attachments
Fix & tests (6.44 KB, patch)
2011-02-14 11:24 EST, Markus Keller CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Troy CLA 2011-02-13 14:58:09 EST
Build Identifier: Build id: 20100917-0705

If I have an inner-class and it has javadoc in it. I select the inner class, go to Refactor, Move Type to New File, and the new file is created. Looking at the new file though, you'll see that the code template for Comments -> Files is ignored, and my document starts immediately with the package declaration

Reproducible: Always

Steps to Reproduce:
1. Go to Window | Preferences, Java\Code Style\Code Templates.
2. Define a pattern for Comments\Files
3. Create a class containing an inner class. Be sure to create a comment at the class level for the inner class.
E.g.

/**
 * Hello World
 *
 */
public class Foo
{
  /**
   * Goodbye World
   */
  public static class Bar
  {
  }
}

4. Select the inner class element, and go to Refactor | Move Type to New File. Have a look at the new file. It's missing your file comment at the beginning of the file prior to package declaration.
5. Undo your refactor
6. Remove the comment for Bar. Try refactoring again. This time Bar will have the proper file level comment prior to the package declaration.

I haven't gone as far as checking other code template stuff, but perhaps there's problems with other templates too?
Comment 1 Olivier Thomann CLA 2011-02-13 15:49:15 EST
Move to JDT/UI
Comment 2 Deepak Azad CLA 2011-02-13 22:57:03 EST
To reproduce, make sure to enable "Automatically add comments for new methods and types" on the code template preference page.
Comment 3 Markus Keller CLA 2011-02-14 11:24:46 EST
Created attachment 188910 [details]
Fix & tests
Comment 4 Markus Keller CLA 2011-02-14 11:26:49 EST
Fixed in HEAD.