Skip to content

Introduce new semantic highlight token for format specifier #4183

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

Merged
merged 1 commit into from
Apr 28, 2020

Conversation

ltentrup
Copy link
Contributor

Follow up from #4006: Instead of using the attribute highlight token, introduce a new semantic token for format specifier.

@@ -12,6 +12,7 @@ pub(crate) const TYPE_ALIAS: SemanticTokenType = SemanticTokenType::new("typeAli
pub(crate) const UNION: SemanticTokenType = SemanticTokenType::new("union");
pub(crate) const UNRESOLVED_REFERENCE: SemanticTokenType =
SemanticTokenType::new("unresolvedReference");
pub(crate) const FORMAT_SPECIFIER: SemanticTokenType = SemanticTokenType::new("formatSpecifier");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add it to SUPPORTED_MODIFIERS bellow as well? Also, do you have any ideas how to make "forgot to add to the list of tokens" error impossible?

I did this myself a coulpe of times, and that's a pretty bug to have, as the syntax highlgithing will die horribly in runtime.

At the moment, I'm leaning towards hacking the "one definition" with a macro, but perhaps there's a simpler solution?...

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bors d+

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/MODIFIERS/the other thing which is for types/

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One could add a test case that checks for every syntax range that the HighlightTag is contained in SUPPORTED_TYPES. That would be rather simple to implement and would spot those kind of mistakes (assuming that the HighlighTag is actually used in the syntax highlighting tests).

@bors
Copy link
Contributor

bors bot commented Apr 28, 2020

✌️ ltentrup can now approve this pull request. To approve and merge a pull request, simply reply with bors r+. More detailed instructions are available here.

@ltentrup ltentrup force-pushed the highlight-format-tag branch from caf4f89 to 052e9fa Compare April 28, 2020 09:14
@matklad
Copy link
Member

matklad commented Apr 28, 2020

bors r+

@bors
Copy link
Contributor

bors bot commented Apr 28, 2020

@bors bors bot merged commit 965e621 into rust-lang:master Apr 28, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants