This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.
Summary: | [Inline] Inline looses all formatting and comments | ||
---|---|---|---|
Product: | java | Reporter: | tomzi <tomzi> |
Component: | Refactoring | Assignee: | Ralph Ruijs <ralphbenjamin> |
Status: | RESOLVED FIXED | ||
Severity: | normal | CC: | markiewb |
Priority: | P3 | ||
Version: | 7.4 | ||
Hardware: | PC | ||
OS: | Linux | ||
Issue Type: | DEFECT | Exception Reporter: | |
Attachments: |
Shows the issue
Proposed patch |
Description
tomzi
2013-09-27 08:38:49 UTC
Created attachment 145154 [details]
Shows the issue
Another example:
* Take the following code
package com;
public class Main
{
private void bar()
{
//TODO barbar
foo();
//TODO barbar
}
private void foo(){
//TODO blabla
System.out.println("this = " + this);
//TODO blabla
}
}
* Inline foo()
ACTUAL: (comments are lost)
package com;
public class Main
{
private void bar()
{
System.out.println("this = " + this);
//TODO barbar
}
}
EXPECTED: (comments are retained)
package com;
public class Main
{
private void bar()
{
//TODO barbar
//TODO blabla
System.out.println("this = " + this);
//TODO blabla
//TODO barbar
}
}
When will this be fixed? It is very annoying to review the generated code after many of those simple refactorings.
Created attachment 146991 [details]
Proposed patch
Using the following patch
package com;
public class Main
{
private void bar()
{
//TODO barbar
foo();
//TODO barbar
}
private void foo(){
//TODO blabla
System.out.println("this = " + this);
//TODO blabla
}
}
can be transformed (at least) into
package com;
public class Main
{
private void bar()
{
//TODO blabla
System.out.println("this = " + this);
//TODO blabla
}
}
but I could not figure out how to preserve the original "barbar" comments.
BTW: In org.netbeans.modules.refactoring.java.plugins.InlineMethodTransformer there are also two other locations where the tree is rewritten.
@Ralph: Please review!
changeset : e0a6cabca94c author : Ralph Benjamin Ruijs <ralphbenjamin@netbeans.org> date : Tue May 20 16:00:05 CEST 2014 summary : #236447 - [Inline] Inline looses all formatting and comments The fix is a bit more complicated than the proposed patch. Comments are ignored if the tree is not new or changed. Integrated into 'main-silver', will be available in build *201405230001* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress) Changeset: http://hg.netbeans.org/main-silver/rev/e0a6cabca94c User: Ralph Benjamin Ruijs <ralphbenjamin@netbeans.org> Log: #236447 - [Inline] Inline looses all formatting and comments |