Skip to content

Commit

Permalink
Classify object names and enum names as class names
Browse files Browse the repository at this point in the history
  • Loading branch information
pmwmedia authored and alecthomas committed Nov 2, 2022
1 parent 6ca7db7 commit d6ea504
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 5 deletions.
3 changes: 3 additions & 0 deletions lexers/embedded/kotlin.xml
Expand Up @@ -180,6 +180,9 @@
<rule pattern="@(?:[_\p{L}][\p{L}\p{N}]*|`@?[_\p{L}][\p{L}\p{N}]+`)">
<token type="NameDecorator"/>
</rule>
<rule pattern="(?:\p{Lu}[_\p{L}]*)(?=\.)">
<token type="NameClass"/>
</rule>
<rule pattern="(?:[_\p{L}][\p{L}\p{N}]*|`@?[_\p{L}][\p{L}\p{N}]+`)">
<token type="Name"/>
</rule>
Expand Down
2 changes: 2 additions & 0 deletions lexers/testdata/kotlin.actual
Expand Up @@ -48,6 +48,8 @@ fun someOperators(a: Int, b: Int) {
println( a % b)
println(c in a..b)

Logger.info("Hello World")

a %= 2
a && b
a *= 2
Expand Down
17 changes: 12 additions & 5 deletions lexers/testdata/kotlin.expected
Expand Up @@ -309,6 +309,13 @@
{"type":"Name","value":"b"},
{"type":"Punctuation","value":")"},
{"type":"Text","value":"\n \n "},
{"type":"NameClass","value":"Logger"},
{"type":"Punctuation","value":"."},
{"type":"Name","value":"info"},
{"type":"Punctuation","value":"("},
{"type":"LiteralStringDouble","value":"\"Hello World\""},
{"type":"Punctuation","value":")"},
{"type":"Text","value":"\n \n "},
{"type":"Name","value":"a"},
{"type":"Text","value":" "},
{"type":"Operator","value":"%="},
Expand Down Expand Up @@ -488,29 +495,29 @@
{"type":"Text","value":"\n\n"},
{"type":"NameDecorator","value":"@Target"},
{"type":"Punctuation","value":"("},
{"type":"Name","value":"AnnotationTarget"},
{"type":"NameClass","value":"AnnotationTarget"},
{"type":"Punctuation","value":"."},
{"type":"Name","value":"CLASS"},
{"type":"Punctuation","value":","},
{"type":"Text","value":" "},
{"type":"Name","value":"AnnotationTarget"},
{"type":"NameClass","value":"AnnotationTarget"},
{"type":"Punctuation","value":"."},
{"type":"Name","value":"FUNCTION"},
{"type":"Punctuation","value":","},
{"type":"Text","value":"\n "},
{"type":"Name","value":"AnnotationTarget"},
{"type":"NameClass","value":"AnnotationTarget"},
{"type":"Punctuation","value":"."},
{"type":"Name","value":"VALUE_PARAMETER"},
{"type":"Punctuation","value":","},
{"type":"Text","value":" "},
{"type":"Name","value":"AnnotationTarget"},
{"type":"NameClass","value":"AnnotationTarget"},
{"type":"Punctuation","value":"."},
{"type":"Name","value":"EXPRESSION"},
{"type":"Punctuation","value":")"},
{"type":"Text","value":"\n"},
{"type":"NameDecorator","value":"@Retention"},
{"type":"Punctuation","value":"("},
{"type":"Name","value":"AnnotationRetention"},
{"type":"NameClass","value":"AnnotationRetention"},
{"type":"Punctuation","value":"."},
{"type":"Name","value":"SOURCE"},
{"type":"Punctuation","value":")"},
Expand Down

0 comments on commit d6ea504

Please sign in to comment.