-
Notifications
You must be signed in to change notification settings - Fork 429
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
Support highlight for constructor call #2124
Comments
that's a question for @0dinD |
Thank you. |
I agree that this would be useful, and it was almost implemented in eclipse-jdtls/eclipse.jdt.ls#1514, but after some discussion with @Eskibear I decided not to add the feature for now to avoid the complexity of backwards-compatibility for old themes. The problem is that changing the token type of constructors might be a breaking change for themes that desire the same color for constructors and methods. One question is whether or not this really matters, as scope mapping could be added to fix TextMate themes, and explicit semantic token rules might not be as widely adopted. A second question is, given the answer to the first question, what is the optimal way to represent constructors using semantic tokens and modifiers to allow flexibility and/or backwards-compatibility for theme authors? Alternative 1Use the type of the constructor ( Pros:
Cons:
Alternative 2Introduce a new Pros:
Cons:
Alternative 3Introduce a new token type for each type of constructor ( Pros:
Cons:
Alternative 4Introduce new token modifiers for the types ( Pros:
Cons:
In conclusion: the feature itself is easily implemented, but we need to consider the semantics and backwards-compatibility. @OzelotVanilla @Eskibear What do you think? It's also totally possible I've missed something or there's a better alternative. |
I vote for Alternative 1, for it looks more like a systematic approach. |
@0dinD I also think Alternative 1 is good. By the way, is there a detailed tutorial for compose tmLanguage file? I have read the VS Code's docs, but I still have many question. Could you tell me how you learn writing tmLanguage file, if you want to tell me. |
I agree, just wanted to make sure we were on the same page about compatibility. I'll submit a PR as soon as I have time, hopefully we can get this into the next update.
Just so there's no misunderstanding, you mean writing a TextMate grammar for tokenizing a language, not theming right (difference explained here)? I don't have much experience writing TextMate grammars myself, but the main thing you'll need to learn if you haven't already are Regular Expressions. Also, I'd probably take a look at existing grammars to learn (once you know the basics), as there don't seem to be many guides available on the topic. I think this mostly has to do with TextMate being an old standard that most editors are moving away from for various reasons. One of the main limitations is that since TextMate grammars are only based on Regular Expressions, they cannot provide context from the project or other files, the tokenizer works with each file separately. That's why VS Code has added a new API called Semantic Highlighting where language extensions (like this one) can be used to provide tokenization based on their rich knowledge of the language and project files. This can be implemented in any way you prefer, as it's just a generic API: VS Code asks the Java extension to tokenize the file You can already see the difference in your screenshot: the TextMate grammar tokenized |
@0dinD Thank you very much that you want to tell me how to tokenize and the semantic highlighting. Actually I want to make highlight of a programming language (but now there is only me on this work). I really like the idea of Semantic Highlighting. I think I should learn the Semantic API. Thanks again. Hope the "constructor idea" can come true. By the way, RedHat formatting file need the abs path of the file, and |
No problem!
Well, the setting does say it takes a URL, and spaces are not valid characters in URLs (hence the |
The highlighter for Java cannot differ constructor from function call. Hope the syntax file can be edited so we can add colour to constructor call.
In this picture, the left
File
is highlighted asclass
, however the constructor call is highlighted as function.The text was updated successfully, but these errors were encountered: