Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Grammars:

- fix(python) Fix recognition of numeric literals followed by keywords without whitespace (#2985) [Richard Gibson][]
- enh(swift) add SE-0290 unavailability condition (#3382) [Bradley Mackey][]
- enh(java) add `sealed` and `non-sealed` keywords (#3386) [Bradley Mackey][]

[Richard Gibson]: https://github.com/gibson042
[Bradley Mackey]: https://github.com/bradleymackey
Expand Down
12 changes: 11 additions & 1 deletion src/languages/java.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@ export default function(hljs) {
'module',
'requires',
'exports',
'do'
'do',
'sealed'
];

const BUILT_INS = [
Expand Down Expand Up @@ -179,6 +180,15 @@ export default function(hljs) {
3: "title.class"
}
},
{
// Exceptions for hyphenated keywords
match: [
/non-sealed/
],
className: {
1: "keyword"
}
},
{
begin: [
JAVA_IDENT_RE,
Expand Down
8 changes: 8 additions & 0 deletions test/markup/java/titles.expect.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,11 @@
}
}
}

<span class="hljs-keyword">sealed</span> <span class="hljs-keyword">interface</span> <span class="hljs-title class_">Command</span> permits LoginCommand {
<span class="hljs-keyword">void</span> <span class="hljs-title function_">run</span><span class="hljs-params">()</span>;
}

<span class="hljs-keyword">non-sealed</span> <span class="hljs-keyword">abstract</span> <span class="hljs-keyword">class</span> <span class="hljs-title class_">UserPluginCommand</span> <span class="hljs-keyword">extends</span> <span class="hljs-title class_">Command</span> {
<span class="hljs-keyword">void</span> <span class="hljs-title function_">runAsUser</span><span class="hljs-params">()</span>;
}
8 changes: 8 additions & 0 deletions test/markup/java/titles.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,11 @@ public class Greet {
}
}
}

sealed interface Command permits LoginCommand {
void run();
}

non-sealed abstract class UserPluginCommand extends Command {
void runAsUser();
}