Structural Replace bug? broken comments and extra ";"

In IDEA 4.5.4:

I was trying to add a method to all implementations of an interface, but could not get the correct output. Reducing the problem to a simple case of "add a method to this class" the replacement code is still broken.

Search:

replace:


Test class:



Output:


As you can see, the initial comment block is wrong, lines following the // coment have been moved into the comment, and there is no new "foo" method.

I tried adding a semicolon after the $body$ in the search and replace templates, but now end up with:


which still has a broken initial comment block, and now has extra semicolons for all non-method lines in the class body.

Any suggestions?

1 comment
Comment actions Permalink

This issue was fixed in Irida.

Daniel van Enckevort wrote:

In IDEA 4.5.4:

I was trying to add a method to all implementations of an interface, but could not get the correct output. Reducing the problem to a simple case of "add a method to this class" the replacement code is still broken.

Search:

     $body$
> }
> ]]>

replace:

     $body$
>     public String foo() {
>         return "foo";
>     }
> }]]>


Test class:

 
> /**
>  * @author Daniel van Enckevort
>  * @version $Revision: 1.1 $
>  */
> public class Test {
>     private int i; //some comment
>     private int j;
> 
>     public Test(int i) {
>         this.i = i;
>     }
> }]]>



Output:

 
> /**
>  * @author Daniel van Enckevort
>  * @author Daniel van Enckevort
>  * @version $Revision: 1.1 $
>  */
> /**
>  * @author Daniel van Enckevort
>  * @version $Revision: 1.1 $
>  */
>         public class Test {
>     private int i; //some comment private int j; public Test(int i) {
>     this.i = i;
> }]]>


As you can see, the initial comment block is wrong, lines following the // coment have been moved into the comment, and there is no new "foo" method.

I tried adding a semicolon after the $body$ in the search and replace templates, but now end up with:

 
> /**
>  * @author Daniel van Enckevort
>  * @author Daniel van Enckevort
>  * @version $Revision: 1.1 $
>  */
> /**
>  * @author Daniel van Enckevort
>  * @version $Revision: 1.1 $
>  */
>         public class Test {
>     private int i; //some comment;
>     private int j;;
> 
>     public Test(int i) {
>         this.i = i;
>     }
> 
>     public String foo() {
>         return "foo";
>     }
> }]]>


which still has a broken initial comment block, and now has extra semicolons for all non-method lines in the class body.

Any suggestions?



--
Best regards,
Maxim Mossienko
IntelliJ Labs / JetBrains Inc.
http://www.intellij.com
"Develop with pleasure!"

0

Please sign in to leave a comment.