Skip to content

Commit

Permalink
(dart) add title.class scope to built-in classes
Browse files Browse the repository at this point in the history
  • Loading branch information
guuido committed Nov 18, 2024
1 parent 1f1a76a commit ea46b1f
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 11 deletions.
9 changes: 0 additions & 9 deletions src/languages/dart.js
Original file line number Diff line number Diff line change
Expand Up @@ -224,10 +224,6 @@ export default function(hljs) {
$pattern: /[A-Za-z][A-Za-z0-9_]*\??/
};

const CAPITALIZED_BUILT_IN_TYPES = BUILT_IN_TYPES.filter(type => /^[A-Z]/.test(type));

const BUILT_IN_TYPES_REGEX = `\\b(${CAPITALIZED_BUILT_IN_TYPES.join('|')})\\b`;

const CLASS_NAME_RE = regex.either(
/\b([A-Z]+[a-z0-9]+)+/,
// ends in caps
Expand All @@ -237,11 +233,6 @@ export default function(hljs) {
const CLASS_REFERENCE = {
relevance: 0,
variants: [
{
// prevent built-in types with capital letter from being selected as title.class
match: BUILT_IN_TYPES_REGEX,
skip: true
},
{
match: CLASS_NAME_RE,
scope: "title.class"
Expand Down
2 changes: 1 addition & 1 deletion test/markup/dart/class.expect.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">Person</span> </span>{
<span class="hljs-built_in">String</span> name;
<span class="hljs-title class_">String</span> name;
<span class="hljs-built_in">int</span> age;

<span class="hljs-title class_">Person</span>(<span class="hljs-keyword">this</span>.name, <span class="hljs-keyword">this</span>.age);
Expand Down
2 changes: 1 addition & 1 deletion test/markup/dart/function.expect.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<span class="hljs-keyword">void</span> <span class="hljs-title function_">greet</span>(<span class="hljs-built_in">String</span> name) {
<span class="hljs-keyword">void</span> <span class="hljs-title function_">greet</span>(<span class="hljs-title class_">String</span> name) {
<span class="hljs-title function_">print</span>(<span class="hljs-string">&#x27;Hello, <span class="hljs-subst">$name</span>!&#x27;</span>);
}

Expand Down

0 comments on commit ea46b1f

Please sign in to comment.