Skip to content

Commit

Permalink
enh(c,cpp) highlight type modifiers as type (#3316)
Browse files Browse the repository at this point in the history
  • Loading branch information
joshgoebel committed Aug 30, 2021
1 parent e4226f5 commit 1fcf615
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 11 deletions.
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

0 comments on commit 1fcf615

Please sign in to comment.