better-cpp-syntax icon indicating copy to clipboard operation
better-cpp-syntax copied to clipboard

std::size_t highlighting

Open matter123 opened this issue 6 years ago • 9 comments

std::size_t size; has interesting highlighting. Screen Shot 2019-04-26 at 14 37 52

Plain size_t highlighted the same as a primitive type makes some sense. However std::size_t should probably have uniform highlighting.

size_t is not a keyword like bool or int are. It is explicitly a typedef that is only available when <cstddef> or <stddef.h> are included. However, it is unique in that sizeof operator is required to return a size_t weather <cstddef> was included or not ([expr.sizeof]/5).

matter123 avatar Apr 26 '19 21:04 matter123

I think its tagged correctly as entity.name.scope-resolution.cpp and storage.type.built-in.cpp. Why should it have uniform scopes when std::string and others do not?

jeff-hykin avatar Jun 24 '19 23:06 jeff-hykin

Because std::size_t is the canonical name, and size_t has keyword highlighting.

matter123 avatar Jun 24 '19 23:06 matter123

Wouldn't we need to do it for all of them then? like clock_t, ssize_t, time_t

jeff-hykin avatar Jun 25 '19 00:06 jeff-hykin

Are any of those tagged as a keywords?

matter123 avatar Jun 25 '19 00:06 matter123

All of them have the same attributes as size_t in the tokens.rb for cpp. Is size_t tagged as a keyword somewhere?

jeff-hykin avatar Jun 25 '19 00:06 jeff-hykin

The reason I feel that std::size_t (and std::ssize_t and similar) should be a single token is that size_t has the scope storage.type.built-in However, the canonical name for the size type is std::size_t and ::size_t is a type alias to std::size_t. If a type alias has storage.type.built-in then the canonical name should as well.

matter123 avatar Jun 25 '19 00:06 matter123

Even if its built in, its still a namespace std an operator :: and a type size_t right? Does a reference somewhere in the C++ spec refer to it as a single token? It seems weird to me to remove the scope-resolution tag from a namespace.

jeff-hykin avatar Jun 25 '19 01:06 jeff-hykin

I'm not opposed with keeping the std and :: as separate tokens, but they should in addition have the storage.type.built-in scope as well if the type would be tagged as built in

matter123 avatar Jun 25 '19 01:06 matter123

Okay yeah, I think we can do that for all of the built in types. 👍

jeff-hykin avatar Jun 25 '19 01:06 jeff-hykin