|
Hi guys
I'm wondering if and how I can use SSLR CommentAnalyzer to handle multilines comment like the following
/* blah blah blih bloh blah blah */
As far as I understand CommentAnalyzer assumes that a comment is only one code line... right? or am I missing something (again) :) ?
Regards Patroklos
|
|
Hi Pappetrou, Here is the global picture: 1) The lexer: The lexer is in charge of consuming multi-line comments. So, in your case, you end up with a regular expression which looks similar to "(?s)/\\*.*?\\*/"
Note the (?s) DOT_ALL flag which enables the dot character '.' to consume any characters, including new lines.
2) The CommentAnalyzer Currently, the goal of the comment analyzer is two-fold: a) To extract the comment tags from the comment itself, to get the content. In your case, you simply have to remove the leading "/*" and trailing "*/" to handle your multi-line comment syntax, i.e. return comment.substring(2, comment.length() - 2)
b) Determine whether or not a single line of comment is blank or not. This function is later going to be used by the SSLR-Squid-Bridge CommentsVisitor, see part 3 3) SSLR-Squid-Bridge's CommentsVisitor
This class will enable you to collect basic metrics regarding your comments. It will start by removing the comments tags, using the CommentsAnaylzer, and then split your multi-line comment into separate lines.
Afterwards, on each line, it will call the isBlank() method with the line's content to determine which metric (blank, comments, etc..) to feed. See https://github.com/SonarSource/sslr-squid-bridge/blob/master/src/main/java/com/sonar/sslr/squid/metrics/CommentsVisitor.java for details
Et voila! Let me know if this helps -- Dinesh Bolkensteyn
On Fri, Jun 29, 2012 at 2:39 PM, Papapetrou P.Patroklos <[hidden email]> wrote: Hi guys |
|
Hi Dinesh
Thanks a lot for the information :) I'll study and let you know :)
Regards Patroklos 2012/6/29 Dinesh Bolkensteyn <[hidden email]>
|
| Powered by Nabble | Edit this page |
