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 186816 - [69cat] Provide a way to turn off automatic source formatting for code templates
Summary: [69cat] Provide a way to turn off automatic source formatting for code templates
Status: RESOLVED FIXED
Alias: None
Product: editor
Classification: Unclassified
Component: Completion & Templates (show other bugs)
Version: 6.x
Hardware: PC Windows XP
: P3 normal with 3 votes (vote)
Assignee: Dusan Balek
URL:
Keywords:
: 136074 138499 (view as bug list)
Depends on:
Blocks:
 
Reported: 2010-05-27 14:24 UTC by matthies
Modified: 2010-11-11 06:10 UTC (History)
5 users (show)

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 matthies 2010-05-27 14:24:33 UTC
Automatic source formatting breaks many of my use cases for code templates. For one, I want to use code templates for stuff that is not completely valid code (yet), but instead is only some fragment. The source formatting logic tends to mess up thing there.

Secondly, I rarely use the source formatting command anyway, as half of the time it doesn't do what I want or need. It's just not smart enough, and in certain cases can't be smart enough because the formatting choice depends on the respective purpose of the code, not just on its syntax. (For example 'if' statements may be one-liners for defensive precondition checks or guards, but otherwise not.)

In both cases, correcting the automatic source formatting creates more work than is saved by the respective code templates. It's counter-productive.

It would be much better if the automatic formatting could be turned off. (Source formatting can still selectively triggered by Alt+Shift+F when desired.)
Comment 1 laurin1 2010-05-27 14:29:58 UTC
I second that!
Comment 2 ulfzibis 2010-05-27 18:44:24 UTC
Same problem occurs on e.g. surrounding a block with try..catch using the auto-correct action on red error badge. The whole block becomes formatted, so the only workaround is to surround manually.
Comment 3 matthies 2010-05-27 19:04:06 UTC
@Ulf: Pretty much all refactoring/code-generating actions perform source formatting on what they generate. I think this is a separate issue, as code templates are really just textual macros, i.e. character-level, as opposed to refactoring/code-generating actions which operate at the level of language constructs, i.e. grammar-level. They shouldn't be lumped together in this issue.
Comment 4 ulfzibis 2010-05-27 20:14:36 UTC
(In reply to comment #3)
@Matties: I said that in assumption, that those source manipulating actions too internally use some kind of template. If so, it might be handled at same time. If not, you are right, that this is another case. Thanks for your feedback.
Comment 5 Dusan Balek 2010-10-27 15:26:16 UTC
Do you mind to have a per template option or global option for turning off the automatic template formatting?
Comment 6 matthies 2010-11-02 17:03:03 UTC
@dbalek: Not entirely sure what you're asking. I would like a global option to be available. A per-template option might be useful for some.
Comment 7 Dusan Balek 2010-11-05 15:51:45 UTC
*** Bug 138499 has been marked as a duplicate of this bug. ***
Comment 8 Dusan Balek 2010-11-10 08:52:09 UTC
Fixed in jet-main.

http://hg.netbeans.org/jet-main/rev/43dec7128a59

${no-format} and ${no-indent} parameters could be used as flags on each particular code template allowing you to disable its implicit formatting/indentation on expansion. Also, there is a global option (in Tools->Options->Editor->Code Templates) that overrides the per-template setting(s).
Comment 9 Dusan Balek 2010-11-10 08:54:44 UTC
*** Bug 136074 has been marked as a duplicate of this bug. ***
Comment 10 Quality Engineering 2010-11-11 06:10:15 UTC
Integrated into 'main-golden', will be available in build *201011110000* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main/rev/43dec7128a59
User: Dusan Balek <dbalek@netbeans.org>
Log: Issue #186816: Provide a way to turn off automatic source formatting for code templates - fixed.