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

Commit

Permalink
highlight comments in module
Browse files Browse the repository at this point in the history
Signed-off-by: Yan Zhang <[email protected]>
  • Loading branch information
Eskibear committed Jan 20, 2021
1 parent 5f2f890 commit a3d1e9b
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
6 changes: 6 additions & 0 deletions grammars/java.cson
Original file line number Diff line number Diff line change
Expand Up @@ -1002,6 +1002,12 @@
'match': '\\b(requires|transitive|exports|opens|to|uses|provides|with)\\b'
'name': 'keyword.module.java'
}
{
'include': '#comments'
}
{
'include': '#comments-javadoc'
}
]
}
]
Expand Down
21 changes: 21 additions & 0 deletions spec/java-spec.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,27 @@ describe 'Java grammar', ->
expect(lines[2][3]).toEqual value: 'with', scopes: ['source.java', 'meta.module.java', 'meta.module.body.java', 'keyword.module.java']
expect(lines[3][0]).toEqual value: '}', scopes: ['source.java', 'meta.module.java', 'punctuation.section.module.end.bracket.curly.java']

# TODO: module names in module body not implemented.
it 'tokenizes module name and comments', ->
lines = grammar.tokenizeLines '''
module com.foo.bar {
// comments
/* comments */
/** javadoc */
requires java.base;
}
'''

expect(lines[0][0]).toEqual value: 'module', scopes: ['source.java', 'meta.module.java', 'storage.modifier.java']
# expect(lines[0][2]).toEqual value: 'com.foo.bar', scopes: ['source.java', 'meta.module.java', 'entity.name.type.module.java']
expect(lines[0][4]).toEqual value: '{', scopes: ['source.java', 'meta.module.java', 'punctuation.section.module.begin.bracket.curly.java']
expect(lines[1][2]).toEqual value: ' comments', scopes: ['source.java', 'meta.module.java', 'meta.module.body.java', 'comment.line.double-slash.java']
expect(lines[2][2]).toEqual value: ' comments ', scopes: ['source.java', 'meta.module.java', 'meta.module.body.java', 'comment.block.java']
expect(lines[3][2]).toEqual value: ' javadoc ', scopes: ['source.java', 'meta.module.java', 'meta.module.body.java', 'comment.block.javadoc.java']
expect(lines[4][1]).toEqual value: 'requires', scopes: ['source.java', 'meta.module.java', 'meta.module.body.java', 'keyword.module.java']
# expect(lines[4][2]).toEqual value: 'java.base', scopes: ['source.java', 'meta.module.java', 'meta.module.body.java', 'entity.name.type.module.java']
expect(lines[5][0]).toEqual value: '}', scopes: ['source.java', 'meta.module.java', 'punctuation.section.module.end.bracket.curly.java']

it 'tokenizes classes', ->
lines = grammar.tokenizeLines '''
class Thing {
Expand Down

0 comments on commit a3d1e9b

Please sign in to comment.