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

enh(c,cpp) highlight type modifiers as type #3316

Merged
merged 4 commits into from Aug 30, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGES.md
Expand Up @@ -4,6 +4,7 @@
- enh(css/less/stylus/scss) detect block comments more fully (#3301) [Josh Goebel][]
- fix(cpp) switch is a keyword (#3312) [Josh Goebel][]
- fix(cpp) fix `xor_eq` keyword highlighting. [Denis Kovalchuk][]
- enh(c,cpp) highlight type modifiers as type (#3316) [Josh Goebel][]
- enh(css/less/stylus/scss) add support for CSS Grid properties [monochromer][]

[Josh Goebel]: https://github.com/joshgoebel
Expand Down
5 changes: 3 additions & 2 deletions src/languages/c.js
Expand Up @@ -116,7 +116,6 @@ export default function(hljs) {
"auto",
"break",
"case",
"const",
"continue",
"default",
"do",
Expand All @@ -132,7 +131,6 @@ export default function(hljs) {
"restrict",
"return",
"sizeof",
"static",
"struct",
"switch",
"typedef",
Expand Down Expand Up @@ -172,6 +170,9 @@ export default function(hljs) {
"_Decimal32",
"_Decimal64",
"_Decimal128",
// modifiers
"const",
"static",
// aliases
"complex",
"bool",
Expand Down
10 changes: 5 additions & 5 deletions src/languages/cpp.js
Expand Up @@ -128,7 +128,6 @@ export default function(hljs) {
'co_yield',
'compl',
'concept',
'const',
'const_cast|10',
'consteval',
'constexpr',
Expand Down Expand Up @@ -172,9 +171,7 @@ export default function(hljs) {
'reinterpret_cast|10',
'requires',
'return',
'signed',
'sizeof',
'static',
'static_assert',
'static_cast|10',
'struct',
Expand All @@ -192,7 +189,6 @@ export default function(hljs) {
'typeid',
'typename',
'union',
'unsigned',
'using',
'virtual',
'volatile',
Expand All @@ -214,7 +210,11 @@ export default function(hljs) {
'long',
'short',
'void',
'wchar_t'
'wchar_t',
'unsigned',
'signed',
'const',
'static'
];

const TYPE_HINTS = [
Expand Down
4 changes: 2 additions & 2 deletions test/markup/cpp/bitwise-keywords.expect.txt
@@ -1,5 +1,5 @@
<span class="hljs-keyword">unsigned</span> <span class="hljs-type">char</span> a = <span class="hljs-number">0xFA</span>;
<span class="hljs-keyword">unsigned</span> <span class="hljs-type">char</span> b = <span class="hljs-number">0x4C</span>;
<span class="hljs-type">unsigned</span> <span class="hljs-type">char</span> a = <span class="hljs-number">0xFA</span>;
<span class="hljs-type">unsigned</span> <span class="hljs-type">char</span> b = <span class="hljs-number">0x4C</span>;

a = <span class="hljs-keyword">compl</span> b;
a = <span class="hljs-keyword">not</span> b;
Expand Down
4 changes: 2 additions & 2 deletions test/markup/cpp/template-complexity.expect.txt
Expand Up @@ -7,8 +7,8 @@
}

<span class="hljs-comment">// Disable overload for already valid operands.</span>
<span class="hljs-keyword">template</span>&lt;<span class="hljs-keyword">class</span> <span class="hljs-title class_">T</span>, <span class="hljs-keyword">class</span> = std::<span class="hljs-type">enable_if_t</span>&lt;!impl::is_streamable_v&lt;<span class="hljs-keyword">const</span> T &amp;&gt; &amp;&amp; std::is_convertible_v&lt;<span class="hljs-keyword">const</span> T &amp;, std::wstring_view&gt;&gt;&gt;
std::wostream &amp;<span class="hljs-keyword">operator</span> &lt;&lt;(std::wostream &amp;stream, <span class="hljs-keyword">const</span> T &amp;thing)
<span class="hljs-keyword">template</span>&lt;<span class="hljs-keyword">class</span> <span class="hljs-title class_">T</span>, <span class="hljs-keyword">class</span> = std::<span class="hljs-type">enable_if_t</span>&lt;!impl::is_streamable_v&lt;<span class="hljs-type">const</span> T &amp;&gt; &amp;&amp; std::is_convertible_v&lt;<span class="hljs-type">const</span> T &amp;, std::wstring_view&gt;&gt;&gt;
std::wostream &amp;<span class="hljs-keyword">operator</span> &lt;&lt;(std::wostream &amp;stream, <span class="hljs-type">const</span> T &amp;thing)
{
<span class="hljs-keyword">return</span> stream &lt;&lt; <span class="hljs-built_in">static_cast</span>&lt;std::wstring_view&gt;(thing);
}
Expand Down