How to interpret / *** / in java?

What am I doing?

Now I am creating a comment segregator as part of my simple IDE stimulator (which will detect all comments in Java code).

That my task is to write down all the starting and ending positions of comments and documentation of all forms ...

1. // 2. /*......*/ 3. /**.......*/ 

(I do this using deterministic finite state machines .)

And I will give separate colors for comments and documentation.

Where is my doubt?

Although this is unusual, When the code has the operator /***/ , how should I interpret this code? Should I treat it as a comment or documentation?

+4
source share
4 answers

Think of it as a comment, since there is obviously no documentation to be shared with anyone.

Edit

Eclipse, for example, will handle /***/ as documentation. Taking cue from on this site where the Java grammar is explained , /**"documentation"*/ also officially indicates that the documentation is between /** and */ , even if the length of its contents is zero.

In fact, I would say: consider it as comments. Formally consider it as documentation. Choose one.

+3
source

Color, however, you want. As a separate line, you cannot determine whether it should be interpreted as /** */ (documentation) or /* * */ (one commented star) or /* **/ (oddball comment). You can try and conclude if it is documentation or not, if you look at the previous and next lines. If any of them is documentation, then most likely this little /***/ also documentation.

+1
source

The javadoc comment style was not an extension of the language; It is not part of the Java syntax. So essentially every javadoc comment is a comment first, and the second one is javadoc. For this reason, I would use "normal comment" as the default.

+1
source

If you treat /** */ as documentation, then you should also treat /***/ as documentation - there is no practical difference between zero-length documentation and documentation with only spaces.

I think this is also easier to implement, otherwise you should consider /***/ as a special case (maybe this is due to some kind of look).

+1
source

All Articles