Skip to content
This repository was archived by the owner on Dec 15, 2022. It is now read-only.

Commit 29f977d

Browse files
authored
Highlight comments in module (#246)
Signed-off-by: Yan Zhang <[email protected]> ### Requirements * Filling out the template is required. Any pull request that does not include enough information to be reviewed in a timely manner may be closed at the maintainers' discretion. * All new code requires tests to ensure against regressions ### Description of the Change <!-- We must be able to understand the design of your change from this description. If we can't get a good idea of what the code will be doing from the description here, the pull request may be closed at the maintainers' discretion. Keep in mind that the maintainer reviewing this PR may not be familiar with or have worked with the code here recently, so please walk us through the concepts. --> To enable comments and javadocs in `module` ### Alternate Designs unknown <!-- Explain what other alternates were considered and why the proposed version was selected --> ### Benefits To fix part of #245 <!-- What benefits will be realized by the code change? --> ### Possible Drawbacks unknown <!-- What are the possible side-effects or negative impacts of the code change? --> ### Applicable Issues #245 <!-- Enter any applicable Issues here -->
1 parent 5f2f890 commit 29f977d

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

grammars/java.cson

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -998,6 +998,12 @@
998998
'contentName': 'meta.module.body.java'
999999
'patterns': [
10001000
# TODO: Write more rules for module grammar
1001+
{
1002+
'include': '#comments'
1003+
}
1004+
{
1005+
'include': '#comments-javadoc'
1006+
}
10011007
{
10021008
'match': '\\b(requires|transitive|exports|opens|to|uses|provides|with)\\b'
10031009
'name': 'keyword.module.java'

spec/java-spec.coffee

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,24 @@ describe 'Java grammar', ->
209209
expect(lines[2][3]).toEqual value: 'with', scopes: ['source.java', 'meta.module.java', 'meta.module.body.java', 'keyword.module.java']
210210
expect(lines[3][0]).toEqual value: '}', scopes: ['source.java', 'meta.module.java', 'punctuation.section.module.end.bracket.curly.java']
211211

212+
it 'tokenizes comments inside module', ->
213+
lines = grammar.tokenizeLines '''
214+
module com.foo.bar {
215+
// comments
216+
/* comments */
217+
/** javadoc */
218+
requires java.base;
219+
}
220+
'''
221+
222+
expect(lines[0][0]).toEqual value: 'module', scopes: ['source.java', 'meta.module.java', 'storage.modifier.java']
223+
expect(lines[0][4]).toEqual value: '{', scopes: ['source.java', 'meta.module.java', 'punctuation.section.module.begin.bracket.curly.java']
224+
expect(lines[1][2]).toEqual value: ' comments', scopes: ['source.java', 'meta.module.java', 'meta.module.body.java', 'comment.line.double-slash.java']
225+
expect(lines[2][2]).toEqual value: ' comments ', scopes: ['source.java', 'meta.module.java', 'meta.module.body.java', 'comment.block.java']
226+
expect(lines[3][2]).toEqual value: ' javadoc ', scopes: ['source.java', 'meta.module.java', 'meta.module.body.java', 'comment.block.javadoc.java']
227+
expect(lines[4][1]).toEqual value: 'requires', scopes: ['source.java', 'meta.module.java', 'meta.module.body.java', 'keyword.module.java']
228+
expect(lines[5][0]).toEqual value: '}', scopes: ['source.java', 'meta.module.java', 'punctuation.section.module.end.bracket.curly.java']
229+
212230
it 'tokenizes classes', ->
213231
lines = grammar.tokenizeLines '''
214232
class Thing {

0 commit comments

Comments
 (0)