1
1
"use strict" ;
2
2
import { TmLanguage } from "./TMLanguageModel" ;
3
3
4
- const letter = "[_a-zA-Z\\$\\p{Lo}\\p{Lt}\\p{Nl}\\p{Ll}\\p{Lu}]"
4
+ const upperLetter = "[A-Z\\p{Lt}\\p{Lu}]"
5
+ const lowerLetter = "[_a-z\\$\\p{Lo}\\p{Nl}\\p{Ll}]"
6
+ const letter = `[${ upperLetter } ${ lowerLetter } ]`
5
7
const digit = "[0-9]"
6
8
const letterOrDigit = `${ letter } |${ digit } `
7
9
const alphaId = `${ letter } +`
8
10
const simpleInterpolatedVariable = `${ letter } (?:${ letterOrDigit } )*` // see SIP-11 https://docs.scala-lang.org/sips/string-interpolation.html
9
11
const opchar = `[!#%&*+\\-\\/:<>=?@^|~[\\p{Sm}\\p{So}]]`
10
- const idrest = `${ letter } (?:${ letterOrDigit } )*(?:((?<=_))${ opchar } +)?`
12
+ const idrest = `${ letter } (?:${ letterOrDigit } )*(?:(?<=_)${ opchar } +)?`
13
+ const idUpper = `${ upperLetter } (?:${ letterOrDigit } )*(?:(?<=_)${ opchar } +)?`
14
+ const idLower = `${ lowerLetter } (?:${ letterOrDigit } )*(?:(?<=_)${ opchar } +)?`
11
15
const plainid = `(?:${ idrest } |(?:${ opchar } )+)`
16
+ const backQuotedId = "`[^`]+`"
17
+
12
18
13
19
export const scalaTmLanguage : TmLanguage = {
14
20
fileTypes : [
@@ -41,7 +47,7 @@ export const scalaTmLanguage: TmLanguage = {
41
47
include : '#comments'
42
48
} ,
43
49
{
44
- match : '(`[^`]+`|[_$a-zA-Z][_$a-zA-Z0-9]*)' ,
50
+ match : `( ${ backQuotedId } | ${ plainid } )` ,
45
51
name : 'entity.name.import.scala'
46
52
} ,
47
53
{
@@ -58,7 +64,7 @@ export const scalaTmLanguage: TmLanguage = {
58
64
} ,
59
65
patterns : [
60
66
{
61
- match : ' (?x) \\s*\n\t\t\t\t (`[^`]+`|[_$a-zA-Z][_$a-zA-Z0-9]*) \\s*\n\t\t\t\t (=>) \\s*\n\t\t\t\t (`[^`]+`|[_$a-zA-Z][_$a-zA-Z0-9]*) \\s*\n\t\t\t ' ,
67
+ match : ` (?x)\\s*( ${ backQuotedId } | ${ plainid } ) \\s*(=>)\\s*( ${ backQuotedId } | ${ plainid } ) \\s*` ,
62
68
captures : {
63
69
'1' : {
64
70
name : 'entity.name.import.renamed-from.scala'
@@ -118,7 +124,7 @@ export const scalaTmLanguage: TmLanguage = {
118
124
include : '#block-comments'
119
125
} ,
120
126
{
121
- match : '(?x)\n\t\t\t (?! /\\*)\n\t\t\t (?! \\*/)\n\t\t '
127
+ match : '(?x)(?! /\\*)(?! \\*/)'
122
128
}
123
129
] ,
124
130
name : 'comment.block.scala'
@@ -201,7 +207,7 @@ export const scalaTmLanguage: TmLanguage = {
201
207
} ,
202
208
'special-identifier' : {
203
209
match : '\\b[_$a-zA-Z][_$a-zA-Z0-9]*(?:_[^\\t .,;()\\[\\]{}\'"`\\w])' ,
204
- comment : '\n\t\t Match special scala style identifiers that can end with and underscore and\n\t\t a a not letter such as blank_?. This way the symbol will not be colored\n\t\t differently.\n\t\t '
210
+ comment : 'Match special scala style identifiers that can end with and underscore and a a not letter such as blank_?. This way the symbol will not be colored differently.'
205
211
} ,
206
212
strings : {
207
213
patterns : [
@@ -449,7 +455,7 @@ export const scalaTmLanguage: TmLanguage = {
449
455
declarations : {
450
456
patterns : [
451
457
{
452
- match : ' (?x)\n\t\t\t\t\t\t\\ b(def)\\s+\n\t\t\t\t\t\t(`[^`]+`|[_$a-zA-Z][_$a-zA-Z0-9]*(?:_[^\\t .,;()\\[\\]{}\'"`\\w])(?=[(\\t ])|[_$a-zA-Z][_$a-zA-Z0-9]*|[-?~><^+*%:!#|/@\\\\]+)' ,
458
+ match : ` (?x)\\ b(def)\\s+( ${ backQuotedId } | ${ plainid } )` ,
453
459
captures : {
454
460
'1' : {
455
461
name : 'keyword.declaration.scala'
@@ -485,7 +491,7 @@ export const scalaTmLanguage: TmLanguage = {
485
491
}
486
492
} ,
487
493
{
488
- match : ' \\b(type)\\s+(`[^`]+`|[_$a-zA-Z][_$a-zA-Z0-9]*(?:_[^\\s])(?=[\\t ])|[_$a-zA-Z][_$a-zA-Z0-9]*|[-?~><^+*%:!#|/@\\\\]+)' ,
494
+ match : ` \\b(type)\\s+(${ backQuotedId } | ${ plainid } )` ,
489
495
captures : {
490
496
'1' : {
491
497
name : 'keyword.declaration.scala'
@@ -496,18 +502,19 @@ export const scalaTmLanguage: TmLanguage = {
496
502
}
497
503
} ,
498
504
{
499
- match : ' \\b(val)\\s+(?:([A-Z][_a-zA-Z0-9]*)) \\b' ,
505
+ match : ` \\b(val)\\s+(${ idUpper } ) \\b` ,
500
506
captures : {
501
507
'1' : {
502
508
name : 'keyword.declaration.stable.scala'
503
- } ,
509
+ }
510
+ ,
504
511
'2' : {
505
512
name : 'constant.other.declaration.scala'
506
513
}
507
514
}
508
515
} ,
509
516
{
510
- match : ' \\b(?:(val)|(var))\\s+(?:(`[^`]+`|[_$a-zA-Z][_$a-zA-Z0-9]*(?:_[^\\t .,;()\\[\\]{}\'"`\\w])(?=[\\t ])|[_$a-zA-Z][_$a-zA-Z0-9]*|[-?~><^+*%:!#|/@\\\\]+ )|(?=\\())' ,
517
+ match : ` \\b(?:(val)|(var))\\s+(?:(${ backQuotedId } | ${ plainid } )|(?=\\())` ,
511
518
captures : {
512
519
'1' : {
513
520
name : 'keyword.declaration.stable.scala'
@@ -547,7 +554,7 @@ export const scalaTmLanguage: TmLanguage = {
547
554
include : '#comments'
548
555
} ,
549
556
{
550
- match : '(`[^`]+`|[_$a-zA-Z][_$a-zA-Z0-9]*)' ,
557
+ match : `( ${ backQuotedId } | ${ plainid } )` ,
551
558
name : 'entity.name.package.scala'
552
559
} ,
553
560
{
@@ -812,16 +819,15 @@ export const scalaTmLanguage: TmLanguage = {
812
819
'parameter-list' : {
813
820
patterns : [
814
821
{
815
- match : ' (?<=[^\\._$a-zA-Z0-9])(`[^`]+`|[_$a-z][_$a-zA-Z0-9]*(?:_[^\\s])(?=[\\t ])|[_$a-z][_$a-zA-Z0-9]*|[-?~><^+*%:!#|/@\\\\]+ )\\s*(:)\\s+' ,
822
+ match : ` (?<=[^\\._$a-zA-Z0-9])(${ backQuotedId } | ${ idLower } )\\s*(:)\\s+` ,
816
823
captures : {
817
824
'1' : {
818
825
name : 'variable.parameter.scala'
819
826
} ,
820
827
'2' : {
821
828
name : 'meta.colon.scala'
822
829
}
823
- } ,
824
- comment : 'We do not match param names that start with a Capitol letter'
830
+ }
825
831
}
826
832
]
827
833
} ,
@@ -852,7 +858,7 @@ export const scalaTmLanguage: TmLanguage = {
852
858
include : '#xml-embedded-content'
853
859
}
854
860
] ,
855
- comment : 'We do not allow a tag name to start with a - since this would\n\t\t\t\t likely conflict with the <- operator. This is not very common\n\t\t\t\t for tag names anyway. Also code such as -- if (val <val2 || val> val3)\n\t\t\t\t will falsly be recognized as an xml tag. The solution is to put a\n\t\t\t\t space on either side of the comparison operator' ,
861
+ comment : 'We do not allow a tag name to start with a - since this would likely conflict with the <- operator. This is not very common for tag names anyway. Also code such as -- if (val <val2 || val> val3) will falsly be recognized as an xml tag. The solution is to put a space on either side of the comparison operator' ,
856
862
endCaptures : {
857
863
'1' : {
858
864
name : 'punctuation.definition.tag.xml'
0 commit comments