Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Block comments highlighting issue #3

Open
yegorpetrov opened this issue Feb 17, 2016 · 6 comments
Open

Block comments highlighting issue #3

yegorpetrov opened this issue Feb 17, 2016 · 6 comments
Labels

Comments

@yegorpetrov
Copy link
Contributor

Well, not just block comments, but it's reproducible with antlr/jetbrains-plugin-sample: http://recordit.co/ODFaSxunOl

Same issue in my project using this adapter: http://recordit.co/dsL5dlHS9t

@parrt
Copy link
Member

parrt commented Feb 17, 2016

thanks

@parrt parrt added the bug label Feb 17, 2016
@yegorpetrov
Copy link
Contributor Author

I've played with this a little. It looks like LexerEditorHighlighter doesn't expect lexers to recover and split incomplete input into more than two (three?) tokens, which ANTLR does when fed with /* aa * at the first pass. This can be dealt with by editing the grammar to accept unclosed comments or strings (e.g. ANTLRv4Lexer.g4). But it doesn't seem to be very easy to do for other complex lexing rules like the one in my second recording (http://pastebin.com/GEXk1HJr).

@parrt
Copy link
Member

parrt commented Feb 23, 2016

wow! Thanks very much for the help! I to get back to the plug-in related stuff soon.

@Kisioj
Copy link

Kisioj commented Feb 12, 2019

@parrt How's the progress on this?

@parrt
Copy link
Member

parrt commented Feb 12, 2019

Sorry. Pinging @bjansen to see if he has time to look.

@bjansen
Copy link
Collaborator

bjansen commented Feb 12, 2019

There's an interesting comment in the thread that @Kisioj opened on JetBrains' forums. From what I understand, because the lexer used by IntelliJ is incremental, there might be cases where the whole comment will not be re-lexed. For example, when a space is inserted in the closing */, then removed, the lexer will only re-lex from the beginning of the token that was located at that offset. I.e. it will only lex starting from * or / I guess.

Because IDEs will very likely have to parse incorrect or partial source files, the correct (and recommended) approach to this problem seems to make lexers recognize unclosed comments, strings etc.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants