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 17839 - formatter :- allow for the insertion of blank lines around comments
Summary: formatter :- allow for the insertion of blank lines around comments
Status: RESOLVED WONTFIX
Alias: None
Product: editor
Classification: Unclassified
Component: Formatting & Indentation (show other bugs)
Version: 3.x
Hardware: All All
: P3 blocker with 1 vote (vote)
Assignee: Dusan Balek
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2001-11-19 16:14 UTC by mikeskells
Modified: 2016-07-07 07:28 UTC (History)
1 user (show)

See Also:
Issue Type: ENHANCEMENT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description mikeskells 2001-11-19 16:14:24 UTC
It would be useful to allow for the insertion of balnak lines around comments, 
so that the comments can be associated with the lines to which they pertain

I would suggest that the formatted should have the ability to insert and remove 
blank lines around comments so as to ensure that there are a specified number 
present. I have used formattrs athat allow for the specification of the number 
of lines before and after single line and multi line comments and also for /* 
*/ style and // style comments

I have sued this facility to ensure that comments are placed above the code 
that they relate to, and so that they can group with that code.


x=1;
//code note
y=x;

becomes

x=1;

//code note
y=x;

The setting for code block and different style of comments are to allow for 
different house styles
Comment 1 mikeskells 2001-11-19 16:38:45 UTC
related to the indendation engine/formatter which is targetted at 3.4. 
Comment 2 mikeskells 2001-11-19 16:39:18 UTC
related to the indendation engine/formatter which is targetted at 3.4. 
Comment 3 Marek Grummich 2002-07-22 12:15:15 UTC
Set target milestone to TBD
Comment 4 Marek Grummich 2002-07-22 12:20:14 UTC
Set target milestone to TBD
Comment 5 Roman Strobl 2004-12-06 13:42:51 UTC
Changing subcomponent to formatting.
Comment 6 klr8 2014-11-21 13:43:41 UTC
Also see #170166
Comment 7 klr8 2014-11-21 13:48:26 UTC
(Using NetBeans IDE 8.0.1 (Build 201408251540))

I often use comments to structure logically related parts of code. For instance:

public class Test {

	// f methods

	public void f1() {
	}

	public void f2() {
	}

	// g methods

	public void g1() {
	}

	public void g2() {
	}
}

Unfortunately, this gets formatted into:

public class Test {

	// f methods
	public void f1() {
	}

	public void f2() {
	}

	// g methods
	public void g1() {
	}

	public void g2() {
	}
}

Notice that the blank lines after the comments were removed. Consequently it now seems the "// f methods" comment is for the f1() method, which is of course not the intention.
Comment 8 Ralph Ruijs 2014-11-21 14:16:12 UTC
(In reply to klr8 from comment #7)
> 
> Notice that the blank lines after the comments were removed. Consequently it
> now seems the "// f methods" comment is for the f1() method, which is of
> course not the intention.

This is how the all the java parts in NetBeans look at it, "// f methods" is a comment for method f1(). Moving, renaming, organizing members on this method will all include the comment as part of method f1().
Comment 9 Martin Balin 2016-07-07 07:28:25 UTC
This old bug may not be relevant anymore. If you can still reproduce it in 8.2 development builds please reopen this issue.

Thanks for your cooperation,
NetBeans IDE 8.2 Release Boss