Multi line comment not closed if string with closing comment is found
In the following example the comment is not automatically closed:
The */ inside of the string is interpreted as regular comment closing.
/**^
val str = "*/"
The */ inside of the string is interpreted as regular comment closing.
Leave a comment
on 2013-02-13 10:53 *
By Simon Schäfer
This one is extremely difficult, even JDT and IntelliJ IDEA can not solve it. IntelliJ IDEA has a mixed solution. When there are " immediately before the */ in strings, the multi line comment is closed otherwise not. I will implement it the same way because it helps a little bit and I don't have any idea on what to do otherwise.
on 2013-02-13 16:24 *
By Mirco Dotta
Sounds reasonable.
By the way, I was wondering why not having a "automatic close strategy" for multiline comments, i.e., whenever you type /**, the comment is closed right away. The Java Editor doesn't do it, so I was wondering why (there must be some issue I guess, no?).
By the way, I was wondering why not having a "automatic close strategy" for multiline comments, i.e., whenever you type /**, the comment is closed right away. The Java Editor doesn't do it, so I was wondering why (there must be some issue I guess, no?).
on 2013-02-13 16:41 *
By Simon Schäfer
Do you mean why there is no way to deactivate the behavior? The answer for this is that I didn't thought about it. ;) This probably results from the fact that I can't imagine why one doesn't want to have them closed automatically. I will add an option to the preferences.
on 2013-02-13 16:51 *
By Mirco Dotta
What I meant is closing the comment as soon as you type /*, not after inserting the newline, i.e, /*^ ==> /*^*/
on 2013-02-13 17:10 *
By Simon Schäfer
I think this behavior wouldn't be useful, because you need to manually adjust the */ in a new line, which is difficult because each time one inserts a newline a new * is placed at the beginning of the line. Next, the cursor position wouldn't be set correctly. Furthermore it would close an already closed comment again. The problem with the latter one is that it is difficult to detect if a comment is already closed, thus as for this, I wouldn't work for all cases.
on 2013-02-13 17:17 *
By Mirco Dotta
Ok :)
on 2013-02-13 17:45 *
By Simon Schäfer
Damn, after thinking in more detail about this, it doesn't look that bad anymore. Most of the current behavior wouldn't be that difficult to implement, even finding the end doesn't look as difficult as for the current implementation. I will look at this one again when I have more time.
on 2013-02-14 08:50 *
By Mirco Dotta
Feel free to open a ticket. Though, if neither the Eclipse Java Editor nor the IntelijIDEA one do it, there my be a good reason ;-)
(In scala-ide:f655cccdf5d3febf1a42a8348e599343c76311e3) Correct behavior of multi line comments before string literals
This is not a full fix for the problem that multi line comments are not
automatically closed when they are followed by a string containing the
/ sign. It is difficult to completely solve this problem because
whenever one opens a multi line comment with / the rest of the document
does no longer contain any partitions because the comment spans the
complete content. Thus, it is not possible anymore to detect if the
closing sign */ is located inside of strings or not.
The behavior introduced solves the problem as good as possible. What it
does is it looks if the line containing a */ sign contains a quotation
mark. If this is the case it is assumed that the ending is located
inside of a string literal, thus the multi line comment is closed.
This fix doesn't work if the */ sign is located inside of multi line
string literals or if the string literals aren't even closed but it
helps at least partially.
Fixes #1001515
Branch: master
This is not a full fix for the problem that multi line comments are not
automatically closed when they are followed by a string containing the
/ sign. It is difficult to completely solve this problem because
whenever one opens a multi line comment with / the rest of the document
does no longer contain any partitions because the comment spans the
complete content. Thus, it is not possible anymore to detect if the
closing sign */ is located inside of strings or not.
The behavior introduced solves the problem as good as possible. What it
does is it looks if the line containing a */ sign contains a quotation
mark. If this is the case it is assumed that the ending is located
inside of a string literal, thus the multi line comment is closed.
This fix doesn't work if the */ sign is located inside of multi line
string literals or if the string literals aren't even closed but it
helps at least partially.
Fixes #1001515
Branch: master
on 2013-03-08 20:45 *
By Simon Schäfer
Follow up in #1001566
on 2013-06-05 08:54 *
By Simon Schäfer
(In scala-ide:f655cccdf5d3febf1a42a8348e599343c76311e3) Correct behavior of multi line comments before string literals
This is not a full fix for the problem that multi line comments are not
automatically closed when they are followed by a string containing the
/ sign. It is difficult to completely solve this problem because
whenever one opens a multi line comment with / the rest of the document
does no longer contain any partitions because the comment spans the
complete content. Thus, it is not possible anymore to detect if the
closing sign */ is located inside of strings or not.
The behavior introduced solves the problem as good as possible. What it
does is it looks if the line containing a */ sign contains a quotation
mark. If this is the case it is assumed that the ending is located
inside of a string literal, thus the multi line comment is closed.
This fix doesn't work if the */ sign is located inside of multi line
string literals or if the string literals aren't even closed but it
helps at least partially.
Fixes #1001515
Branch: platform/juno
This is not a full fix for the problem that multi line comments are not
automatically closed when they are followed by a string containing the
/ sign. It is difficult to completely solve this problem because
whenever one opens a multi line comment with / the rest of the document
does no longer contain any partitions because the comment spans the
complete content. Thus, it is not possible anymore to detect if the
closing sign */ is located inside of strings or not.
The behavior introduced solves the problem as good as possible. What it
does is it looks if the line containing a */ sign contains a quotation
mark. If this is the case it is assumed that the ending is located
inside of a string literal, thus the multi line comment is closed.
This fix doesn't work if the */ sign is located inside of multi line
string literals or if the string literals aren't even closed but it
helps at least partially.
Fixes #1001515
Branch: platform/juno