Commenter in custom language: comments but not uncomments

Good day!
I've implemented a commenter for my custom language and it comments my code very well, but not uncomment. Why could it be?

I press ctrl/ and my code string is commented and cursor moves down. I go up one line and press ctrl/ and cursor goes down without removing the leading '#'

6 comments
Comment actions Permalink

Uncomment works on selection
Jay wrote:

Good day!
I've implemented a commenter for my custom language and it comments my code very well, but not uncomment. Why could it be?

I press ctrl/ and my code string is commented and cursor moves down. I go up one line and press ctrl/ and cursor goes down without removing the leading '#'



--
Best regards,
Maxim Mossienko
IntelliJ Labs / JetBrains Inc.
http://www.intellij.com
"Develop with pleasure!"

0
Comment actions Permalink


Good day!

I still cannot get IDEA to uncomment my line comment. It worked once but when i
changed parsing of comments it stopped.
Can you tell me what are the requirements of psi parsing for uncomment to
actually uncomment.

Uncomment works on selection
Jay wrote:

>> Good day!
>> I've implemented a commenter for my custom language and it comments my
>> code very well, but not uncomment. Why could it be?
>>
>> I press ctrl+/ and my code string is commented and cursor moves down.
>> I go up one line and press ctrl+/ and cursor goes down without
>> removing the leading '#'


0
Comment actions Permalink

Hi,
your parser should produce PsiComment on comment, comment tokens should
be in parser definition (have you looked into Javascript plugin sources :)

__jay wrote:


Good day!

I still cannot get IDEA to uncomment my line comment. It worked once but
when i changed parsing of comments it stopped.
Can you tell me what are the requirements of psi parsing for uncomment
to actually uncomment.

>> Uncomment works on selection
>> Jay wrote:
>>
>>> Good day!
>>> I've implemented a commenter for my custom language and it comments
>>> my code very well, but not uncomment. Why could it be?
>>>
>>> I press ctrl+/ and my code string is commented and cursor moves down.
>>> I go up one line and press ctrl+/ and cursor goes down without
>>> removing the leading '#'
>>
>>
>>


--
Best regards,
Maxim Mossienko
IntelliJ Labs / JetBrains Inc.
http://www.intellij.com
"Develop with pleasure!"

0
Comment actions Permalink


Yes indeed!
I have my only comment as a psi comment in a tree, and it is returned in a
tokenset from parser definition.

My psi tree looks something like this
ParserFile:temp.p
ParserClass
PsiElement(CLASS_KEYWORD)('@CLASS')
PsiElement(NEW_LINE)('\n')
PsiElement(IDENTIFIER)('alpha')
PsiElement(NEW_LINE)('\n')
PsiWhiteSpace('\n')
ParserMethod
PsiElement(KEY_AT_SIGN)('@')
PsiElement(IDENTIFIER)('beta')
ParserParameterList
PsiElement(LBRACKET)('[')
PsiElement(RBRACKET)(']')
PsiElement(NEW_LINE)('\n')
PsiComment(SHARP_COMMENT)('###') <- here's the comment

Maybe my comment element needs an ast wrapper or some formatting (or something
else there is to implement)?

Hi,
your parser should produce PsiComment on comment, comment tokens should
be in parser definition (have you looked into Javascript plugin sources :)

__jay wrote:

>>
>> Good day!
>>
>> I still cannot get IDEA to uncomment my line comment. It worked once
>> but when i changed parsing of comments it stopped.
>> Can you tell me what are the requirements of psi parsing for uncomment
>> to actually uncomment.
>>
>>
>>> Uncomment works on selection
>>> Jay wrote:
>>>
>>>> Good day!
>>>> I've implemented a commenter for my custom language and it comments
>>>> my code very well, but not uncomment. Why could it be?
>>>>
>>>> I press ctrl+/ and my code string is commented and cursor moves
>>>> down. I go up one line and press ctrl+/ and cursor goes down without
>>>> removing the leading '#'
>>>
>>>
>>>


0
Comment actions Permalink

It looks like this is a bug in IDEA that causes the uncomment only to work if your language's commenter returns a non-null String from com.intellij.lang.Commenter#getBlockCommentSuffix. If the language only supports single-line comments, just return an empty String.

Sascha

0
Comment actions Permalink

Thanks Sascha

unfortunately i've abandoned that plugin and would not be able to test your solution. But since i now develop another language plugin - maybe i'll meet just the same bug (:

0

Please sign in to leave a comment.