-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Implement constructor tearoffs support in syntax highlighters #46235
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
Comments
Note that this issue currently does not have an owner. |
Good question. I think Ivan has previously updated the internal parser for Code Search. I've previously contributed to CodeMirror and highlight.js. I'm not sure who would do VSCode, GitHub, IntelliJ, ... |
@DanTup could probably take a look at https://github.com/dart-lang/dart-syntax-highlight/; it's likely it won't need changes. That powers both github and vs code. |
Neat, I'll take a look! LSP semantic tokens (and analysis server highlights) might also need tweaking - though I think |
I suspect that the underlying implementation is far enough along to support any work that needs to be done. The AST structure is defined and I believe it's fully resolved in the cases where it's being produced. However, unless we want to start highlighting tear-offs differently (and we haven't done that for other kinds of tear-offs, though it's an interesting idea), it isn't clear to me that there's any work to be done. We'll need to confirm that either way, of course. |
@emmanuel-p, for code search support |
@bwilkerson nevermind, I found I can add this to
|
Yep. |
For the textmate grammar, torn-off constructors are treated like fields, and then functions where they've invoked: I'm not sure if there's a way to improve this (since the colouring is basic and just uses the presence of the parens to colour the item). With LSP semantic tokens enabled, they become coloured like constructors, and also have the custom Although I'm not certain whether I'd expect |
Thanks all; I've updated the first comment on this issue to break out the anticipated work. I've also assigned speculative owners, so we know this is tracking forward; cc @DanTup @srawlins @domesticmouse. Note that some of the grammars are simple enough that the work here might not be implementation but just validation that things look reasonable. |
Note that out timeframe is to have constructor tear-offs feature complete by early October. |
I've opened https://dart-review.googlesource.com/c/sdk/+/213263/ to map the new Highlight Kinds in LSP so the colouring still works. We're not doing anything special for tear-offs so they'll just be coloured as standard functions/methods/constructors (we can easily add a custom modifier to colour them differently, but I don't know if that's a current goal?). I think that addresses the second item in the task list above (unless we do want to colour them differently?), and I don't think there's anything to do for the first since it doesn't use semantics for colouring (although I've verified things look by my expectations). |
Personally I think that looks fine. |
I don't have a definitive answer. The design principle I'd apply is that code should be highlighted differently if doing so aids the user's understanding of the code. In the case of tear-offs I think that means that they should be highlighted differently if
I don't know whether the syntactic difference and type errors are sufficient (I don't have any practical experience with it, nor have we done any user studies), but I suspect that they probably are. My recommendation is to leave them highlighted as is for now and we can change it if it proves to be necessary. |
@srawlins - I'm going to speculatively assume that we're good wrt highlight.js; I don't believe this is a real change to the grammar for what that highlighter is trying to do. |
This issue tracks support of the constructor tearoffs feature. See the enclosing meta-issue for details.
The text was updated successfully, but these errors were encountered: