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.
I have been trying to guard the signature of a method by adding "//GEN-LINE:" in the beginning of the body just after the beginning brace. I get the content of the method and prefix it with "//GEN-LINE:" and then set the body with setBody() of MethodElement. This works a fine when I create a new Method as shown below: String body = ... MethodElement method = new MethodElement(); method.setBody("//GEN-LINE:\n" + body); Then I see the method written as below: public void success() {//GEN-LINE: //body } But the issue is when I try to modify an existing method from a source file. MethodElement method = ... // get existing method String body = methd.getBody(); method.setBody("GEN-LINE:\n" + body); In this case an existing method: publid void failed() {} will be modified as: public void failed() { //GEN-LINE: } I am expecting this guarded comment to appear on the same line of the method signature as shown below so that I can guard the signature. public void failed() {//GEN-LINE: } I am not able to figure out where this new line is being added while modifying an existing method. Any help in this regard is greatly appreciated.
This is as designed; the body is indented according to the indentation engine settings - { is followed by a newline by default. Besides that, guarded blocks won't work when using this approach, or at least they are not designed to work this way (if they do, it's by accident). Please use public (although not API) methods for manipulating them in org.netbeans.modules.java.JavaEditor class. If you have further questions, please ask them on nbdev@ or dev@openide mailing lists/newsgroups.
Resolved for 3.4.x or earlier, no new info since then -> verified
Resolved for 3.4.x or earlier, no new info since then -> closing.
Reorganization of java component