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.
Code like: ClassElement ce... ce.getJavaDoc().getRawText(); returns text with different format. Comment like: "/** Class comment */" is parsed: " Class comment \n". There were not the first space and the new line at the end of the comment text.
Caused by integration of #48568 - Fixed JavaDoc when there aren't stars on every line. See issue details. Are the new lines at the end of javadoc always duplicated, i.e. /** line 1 * line 2 */ contains two new lines at the end? The space before comment is left now intentionally. What to do if the comment is written without space, i.e. "/**Class comment */"?
Comment: /** * comment */ is returned as "\s\n\scomment\n\s\n" or comment /** * line1 * line2 */ is returned like "\s\nline1\n\sline2\n\s\s\s\s\s\n". I think the lines should be trimed. JavaDoc is transformed into HTML and many spaces are redundant there - are transformed into one space or a new line. The first empty line is redundant too. There is not any information. The last new line and spaces before it are incorrect.
I missed, the second string is formated: "\s\n\sline1\n\sline2\n\s\s\s\s\s\n".
Assigning to Pavel.
We can remove leading and trailing new lines and spaces, but not for all lines. We can do that only at the beginning and end of javadoc. Do you think that it is enough?
I think there is an inconsistance. Try to run Auto Comment tool to some class. Select a method and add a multiline comment: line1 line2 in appropriate "JavaDoc Comment Text" textarea. Go back to the source file, there is new comment: /** * line1 * line2 */ Correct. But if you run Auto Comment Tool next time and check content of the textarea for the method. There is text: line1 line2 - new spaces before each line. If you make a change of this comment another spaces will be add to the begins of all lines etc.
Fixed extra new line at the end. Other things mentioned in this issue are not changed intentionaly. Get JavaDoc text does not guarantee any formatting functionality, it is only rough text. Please, see issue #48568, where spaces at the begining of line are important (when there are HTML tags inside.) Checking in src/org/netbeans/modules/javacore/parser/ASTProvider.java; /cvs/java/javacore/src/org/netbeans/modules/javacore/parser/ASTProvider.java,v <-- ASTProvider.java new revision: 1.22; previous revision: 1.21 done
Eliminate redundant spaces after asterisk in javadoc. Now it works exactly as in 3.6. If you want to change behaviour of autocomment tool, please, file a separate issue against it. (It has to be solved at level of tool. Model impl cannot solve formatting issues as it is not only autocomment tool service.) Checking in src/org/netbeans/modules/javacore/parser/JavaDocParser.java; /cvs/java/javacore/src/org/netbeans/modules/javacore/parser/JavaDocParser.java,v <-- JavaDocParser.java new revision: 1.10; previous revision: 1.9 done
It doesn't work now again. /** * Comment * Comment2 */ is returned like: "\s\sComment\sComment2" - two spaces at the begin and no new lines.
Finally fixed. Added test for trim to javacore/test/unit. Please verify. Thanks. Checking in src/org/netbeans/modules/javacore/parser/ASTProvider.java; /cvs/java/javacore/src/org/netbeans/modules/javacore/parser/ASTProvider.java,v <-- ASTProvider.java new revision: 1.25; previous revision: 1.24 done Processing log script arguments... More commits to come... Checking in test/cfg-unit.xml; /cvs/java/javacore/test/cfg-unit.xml,v <-- cfg-unit.xml new revision: 1.18; previous revision: 1.17 done Processing log script arguments... More commits to come... RCS file: /cvs/java/javacore/test/unit/data/projects/default/src/org/netbeans/test/getters/JavaDocText.java,v done Checking in test/unit/data/projects/default/src/org/netbeans/test/getters/JavaDocText.java; /cvs/java/javacore/test/unit/data/projects/default/src/org/netbeans/test/getters/JavaDocText.java,v <-- JavaDocText.java initial revision: 1.1 done Processing log script arguments... More commits to come... RCS file: /cvs/java/javacore/test/unit/src/org/netbeans/jmi/javamodel/getters/JavaDocTextTest.java,v done Checking in test/unit/src/org/netbeans/jmi/javamodel/getters/JavaDocTextTest.java; /cvs/java/javacore/test/unit/src/org/netbeans/jmi/javamodel/getters/JavaDocTextTest.java,v <-- JavaDocTextTest.java initial revision: 1.1 done Processing log script arguments...
It would be better to let the first line as others - javadoc begins after the last '*' of the comment sign or from the begin of line if the '*' is not there.
My last attempt to fix this issue ;-). I tried now to leave the text as raw as possible (remove only javadoc begin and end and leading asterisks on every line, if it is there.) Added test too. Emane, can you give me info how I can run your tests? -- Bear in mind, that getRawText() provides (as in its name) raw text. It is up to client to format the provided text, if he need it formatted. Feel free to open bugs against the different clients. The most important client is now 'javadoc completion window' in editor, which shows html. Because of intesive use of it, we need to leave this call as fast and simple as possible. If you need more structured information, used parsed javadoc instead of text representation. Checking in src/org/netbeans/modules/javacore/parser/ASTProvider.java; /cvs/java/javacore/src/org/netbeans/modules/javacore/parser/ASTProvider.java,v <-- ASTProvider.java new revision: 1.28; previous revision: 1.27 done Processing log script arguments... More commits to come... Checking in test/unit/data/projects/default/src/org/netbeans/test/getters/JavaDocText.java; /cvs/java/javacore/test/unit/data/projects/default/src/org/netbeans/test/getters/JavaDocText.java,v <-- JavaDocText.java new revision: 1.2; previous revision: 1.1 done Processing log script arguments... More commits to come... Checking in test/unit/src/org/netbeans/jmi/javamodel/getters/JavaDocTextTest.java; /cvs/java/javacore/test/unit/src/org/netbeans/jmi/javamodel/getters/JavaDocTextTest.java,v <-- JavaDocTextTest.java new revision: 1.2; previous revision: 1.1 done Processing log script arguments...
verified
Reorganization of java component