Skip to content

Commit

Permalink
Merge pull request #3628 from tfesenko/java9-module-info-keywords
Browse files Browse the repository at this point in the history
Java: Add Java 9 module-related keywords
  • Loading branch information
nightwing authored Mar 31, 2018
2 parents 344a211 + 13aeade commit 77b932d
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 0 deletions.
33 changes: 33 additions & 0 deletions lib/ace/mode/_test/tokens_java.json
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,39 @@
["identifier","d"],
["rparen",")"],
["text",";"]
],[
"start",
["text"," "],
["keyword","int"],
["text"," "],
["identifier","exports"],
["text"," "],
["keyword.operator","="],
["text"," "],
["constant.numeric","10"],
["text",";"]
],[
"start",
["text"," "],
["keyword","int"],
["text"," "],
["identifier","requires"],
["text"," "],
["keyword.operator","="],
["text"," "],
["constant.numeric","20"],
["text",";"]
],[
"start",
["text"," "],
["keyword","int"],
["text"," "],
["identifier","open"],
["text"," "],
["keyword.operator","="],
["text"," "],
["constant.numeric","30"],
["text",";"]
],[
"start",
["text"," "],
Expand Down
33 changes: 33 additions & 0 deletions lib/ace/mode/java_highlight_rules.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,37 @@ var JavaHighlightRules = function() {
}, {
token : "constant.language.boolean",
regex : "(?:true|false)\\b"
}, {
regex: "(open(?:\\s+))?module(?=\\s*\\w)",
token: "keyword",
next: [{
regex: "{",
token: "paren.lparen",
next: [{
regex: "}",
token: "paren.rparen",
next: "start"
}, {
// From Section 3.9 of http://cr.openjdk.java.net/~mr/jigsaw/spec/java-se-9-jls-diffs.pdf
regex: "\\b(requires|transitive|exports|opens|to|uses|provides|with)\\b",
token: "keyword"
}]
}, {
token : "text",
regex : "\\s+"
}, {
token : "identifier",
regex : "\\w+"
}, {
token : "punctuation.operator",
regex : "."
}, {
token : "text",
regex : "\\s+"
}, {
regex: "", // exit if there is anything else
next: "start"
}]
}, {
token : keywordMapper,
// TODO: Unicode escape sequences
Expand Down Expand Up @@ -118,8 +149,10 @@ var JavaHighlightRules = function() {
]
};


this.embedRules(DocCommentHighlightRules, "doc-",
[ DocCommentHighlightRules.getEndRule("start") ]);
this.normalizeRules();
};

oop.inherits(JavaHighlightRules, TextHighlightRules);
Expand Down

0 comments on commit 77b932d

Please sign in to comment.