Community
Participate
Working Groups
I tried to format the following code: /* Object[] objects = new Object[3]; objects[0] = new String("Hallo Welt !!!"); objects[1] = new String("Test !!!"); objects[2] = new Integer("1980"); ObjectFile.write(pathname, objects); Object[] objs = ObjectFile.read(pathname); for(int i = 0; i < objs.length; i++) { System.out.println(objs[i].toString()); } */ and got the following code: /* * Object[] objects = new Object[3]; objects[0] = new String("Hallo Welt !!!"); * objects[1] = new String("Test !!!"); objects[2] = new Integer("1980"); * ObjectFile.write(pathname, objects); Object[] objs = ObjectFile.read(pathname); * for(int i = 0; i < objs.length; i++) { System.out.println(objs[i].toString()); } */ Im not sure that commented source code should be formated in a javadoc format.
Two problems: 1) the format Java code snippets is in the general section of the prefs but only applied to Javadoc 2) we should offer different settings for end of line, block and Javadoc comments. This is already reported in bug 49412. FYI: If you have code inside a comment you should mark it as <pre> </pre> and it will be formatted like code (if chosen in the formatter preferences).
Ownership changed.
(In reply to comment #1) > Two problems: > 1) the format Java code snippets is in the general section of the prefs but only applied to Javadoc We might want to put it in a section related to block and javadoc formatting. I don't think it should apply to line comments. I am working on getting bug 49412 fixed.
>I don't think it should apply to line comments. Agree.
With the fix for bug 49412, we put the formatting of the code snippet inside the javadoc section. Also you can now disable formatting for the block comment. So we can keep formatting of code snippets inside javadoc only using a <pre></pre> tag. Does this sound reasonable? Daniel, any thought?
This means that if formatting of block comments is disabled, the case in comment 0 would be left as is. The only possible change would be the indentation of the lines in the comment, but no more line wrapping.
Sounds good. The only thing what I always missed is - that I cannot use <code></code> - that the preference doesn't tell how to mark a Java code snippet (Benno fixes that one)
(In reply to comment #7) > Sounds good. The only thing what I always missed is > - that I cannot use <code></code> What do you mean? Using <code></code> to insert a code snippet? or using <code></code> to insert a code snippet inside block comment ?
use the code tag like the pre tag (inside Javadoc)
*** Bug 97202 has been marked as a duplicate of this bug. ***
In 3.3, you can disable the block comment formatting. This will preserve your existing comment layout. Closing as WONTFIX. No further action planned.