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.

Bug 21093 - ConstructorElement.setBody()
Summary: ConstructorElement.setBody()
Status: CLOSED INVALID
Alias: None
Product: java
Classification: Unclassified
Component: Unsupported (show other bugs)
Version: 3.x
Hardware: PC Windows 3.1/NT
: P3 blocker (vote)
Assignee: Svata Dedic
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2002-03-01 19:21 UTC by Rao Bhethanabotla
Modified: 2007-09-26 09:14 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Rao Bhethanabotla 2002-03-01 19:21:19 UTC
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.
Comment 1 Svata Dedic 2002-03-01 22:23:09 UTC
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.
Comment 2 Quality Engineering 2003-07-01 15:57:34 UTC
Resolved for 3.4.x or earlier, no new info since then -> verified
Comment 3 Quality Engineering 2003-07-01 16:39:29 UTC
Resolved for 3.4.x or earlier, no new info since then -> closing.
Comment 4 Quality Engineering 2007-09-20 12:48:36 UTC
Reorganization of java component