Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 64954 - Extract constant: source not formatted corretly [refactoring]
Summary: Extract constant: source not formatted corretly [refactoring]
Status: RESOLVED DUPLICATE of bug 85839
Alias: None
Product: JDT
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.0   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Markus Keller CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-06-01 10:11 EDT by Dirk Baeumer CLA
Modified: 2005-02-18 12:55 EST (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Dirk Baeumer CLA 2004-06-01 10:11:33 EDT
RC1:

Test Case:
package p;

import java.util.ArrayList;
import java.util.List;

import junit.framework.TestCase;

public class Dummy extends TestCase {

private String fValue = "Eclipse";

public void testOne() throws Exception
{
	List l = new ArrayList();
}
}

- select new ArrayList()
- extract constant

You get:

package p;

import java.util.ArrayList;
import java.util.List;

import junit.framework.TestCase;

public class Dummy extends TestCase {


private static final ArrayList EEE = new ArrayList();
private String fValue = "Eclipse";

public void testOne() throws Exception
{
	List l = EEE;
}
}

Expected result is to have a blank line between the constant and the field. 
That's how my formatter is configured.

Problem seems to be that extract constant isn't using AST rewriter.
Comment 1 Sean McRae CLA 2004-06-22 16:48:01 EDT
Also the JavaDoc is not generated for the new constant. I would expect that 
the "Fields" JavaDoc template would be employed for the new constant.
Comment 2 Markus Keller CLA 2005-02-18 12:55:02 EST
Fixed in HEAD.

- Added javadoc generation if the option is enabled in the "Code Templates"
settings.
- Rewrote code to use ASTRewrite. Bug 85839 deals with remaining formatting
problems of the inserted field declaration.

*** This bug has been marked as a duplicate of 85839 ***