Skip to content

Commit 6036dc9

Browse files
committed
Fix support for multi val definitions
Fixes the following two cases ``` val a, b, c = ... var a, b, c = ... ```
1 parent 7d18e2a commit 6036dc9

9 files changed

+87
-66
lines changed

Diff for: src/typescript/Scala.tmLanguage.ts

+7-10
Original file line numberDiff line numberDiff line change
@@ -802,28 +802,25 @@ export const scalaTmLanguage: TmLanguage = {
802802
}
803803
}
804804
},
805-
{ // val x1, x2 = y
806-
match: `\\b(?:(val)|(var))\\b\\s*${notStartOfComment}${anyId}(?=\\s*,)`,
805+
{ // val x1[, x2, x3, ...] = y
806+
match: `\\b(val)\\b\\s*${notStartOfComment}(${anyId}(?:\\s*,\\s*${anyId})*)?`,
807807
captures: {
808808
'1': {
809809
name: 'keyword.declaration.stable.scala'
810810
},
811811
'2': {
812-
name: 'keyword.declaration.volatile.scala'
812+
name: 'variable.stable.declaration.scala'
813813
}
814814
}
815815
},
816-
{
817-
match: `\\b(?:(val)|(var))\\b\\s*${notStartOfComment}(${anyId})?`,
816+
{ // var x1[, x2, x3, ...] = y
817+
match: `\\b(var)\\b\\s*${notStartOfComment}(${anyId}(?:\\s*,\\s*${anyId})*)?`,
818818
captures: {
819819
'1': {
820-
name: 'keyword.declaration.stable.scala'
821-
},
822-
'2': {
823820
name: 'keyword.declaration.volatile.scala'
824821
},
825-
'3': {
826-
name: 'variable.other.declaration.scala'
822+
'2': {
823+
name: 'variable.volatile.declaration.scala'
827824
}
828825
}
829826
},

Diff for: syntaxes/Scala.tmLanguage.json

+1-1
Large diffs are not rendered by default.

Diff for: tests/unit/#157.test.scala

+5-5
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,22 @@
22

33
val Foo = ???
44
// ^^^ keyword.declaration.stable.scala
5-
// ^^^ variable.other.declaration.scala
5+
// ^^^ variable.stable.declaration.scala
66

77
val foo = ???
88
// ^^^ keyword.declaration.stable.scala
9-
// ^^^ variable.other.declaration.scala
9+
// ^^^ variable.stable.declaration.scala
1010

1111
var Foo = ???
1212
// ^^^ keyword.declaration.volatile.scala
13-
// ^^^ variable.other.declaration.scala
13+
// ^^^ variable.volatile.declaration.scala
1414

1515
var foo = ???
1616
// ^^^ keyword.declaration.volatile.scala
17-
// ^^^ variable.other.declaration.scala
17+
// ^^^ variable.volatile.declaration.scala
1818

1919
def Foo = ???
2020
// ^^^ entity.name.function.declaration
2121

22-
def foo
22+
def foo
2323
// ^^^ entity.name.function.declaration

Diff for: tests/unit/#234.test.scala

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// SYNTAX TEST "source.scala"
2+
3+
val foo = Value
4+
// ^^^ variable.stable.declaration.scala
5+
6+
val Mon = Value
7+
// ^^^ variable.stable.declaration.scala
8+
9+
val Mon, Tue = Value
10+
// ^^^ variable.stable.declaration.scala
11+
// ^^^ variable.stable.declaration.scala
12+
13+
val Mon, Tue, Wed = Value
14+
// ^^^ variable.stable.declaration.scala
15+
// ^^^ variable.stable.declaration.scala
16+
// ^^^ variable.stable.declaration.scala
17+
18+
var Mon = Value
19+
// ^^^ variable.volatile.declaration.scala
20+
21+
var Mon, Tue, Wed = Value
22+
// ^^^ variable.volatile.declaration.scala
23+
// ^^^ variable.volatile.declaration.scala
24+
// ^^^ variable.volatile.declaration.scala

Diff for: tests/unit/#72.test.scala

+2-2
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,14 @@
3030

3131
val a = 4; foo(a)
3232
// ^^^ keyword.declaration.stable.scala
33-
// ^ variable.other.declaration.scala
33+
// ^ variable.stable.declaration.scala
3434
// ^ keyword.operator.comparison.scala
3535
// ^ constant.numeric.scala
3636
s"$safeTagMarker${val a = 4; foo(a)}$safeTagMarker"
3737
// ^^^^^^^^^^^^^^^^^^^^ meta.template.expression.scala
3838
// ^^^^^^^^^^^^^^^^^ meta.embedded.line.scala
3939
// ^^^^^^^^^^^^^^^^^ - punctuation.definition.template-expression
4040
// ^^^ keyword.declaration.stable.scala
41-
// ^ variable.other.declaration.scala
41+
// ^ variable.stable.declaration.scala
4242
// ^ keyword.operator.comparison.scala
4343
// ^ constant.numeric.scala

Diff for: tests/unit/basic.test.scala

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class Stack[A] {
1212
private var elements: List[A] = Nil
1313
//^^^^^^^ storage.modifier.access
1414
// ^^^ keyword.declaration.volatile.scala
15-
// ^^^^^^^^ variable.other.declaration.scala
15+
// ^^^^^^^^ variable.volatile.declaration.scala
1616
// ^ keyword.operator.scala
1717
// ^^^^ entity.name.class
1818
// ^ meta.bracket.scala
@@ -39,7 +39,7 @@ class Stack[A] {
3939
def pop(): A = {
4040
val currentTop = peek
4141
// ^^^ keyword.declaration.stable.scala
42-
// ^^^^^^^^^^ variable.other.declaration.scala
42+
// ^^^^^^^^^^ variable.stable.declaration.scala
4343
// ^ keyword.operator.comparison.scala
4444
// ^^^^ source.scala
4545
elements = elements.tail

Diff for: tests/unit/enum.test.scala

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
// ^^^^ keyword.declaration.scala
1414
// ^^^^^^^ entity.name.class.declaration
1515
// ^^^ keyword.declaration.stable.scala
16-
// ^^^^^^^^^^^^^^ variable.other.declaration.scala
16+
// ^^^^^^^^^^^^^^ variable.stable.declaration.scala
1717
// ^^^ entity.name.class
1818
case Unicycle extends Vehicle(1)
1919
// ^^^^ source.scala keyword.control.flow.scala
@@ -23,7 +23,7 @@
2323
// ^ meta.bracket.scala
2424
// ^ constant.numeric.scala
2525
// ^ meta.bracket.scala
26-
26+
2727
case Bicycle extends Vehicle(2)
2828
// ^^^^ source.scala keyword.control.flow.scala
2929
// ^^^^^^^ entity.name.class

Diff for: tests/unit/lexical.test.scala

+36-36
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,33 @@
1-
// SYNTAX TEST "source.scala"
1+
// SYNTAX TEST "source.scala"
22

33
object ExampleIdentifiers {
44
val x = 3
5-
// ^ variable.other.declaration.scala
6-
val Object = 3
5+
// ^ variable.stable.declaration.scala
6+
val Object = 3
77
val maxIndex = 3
8-
// ^^^^^^^^ variable.other.declaration.scala
9-
val p2p = 3
10-
// ^^^ variable.other.declaration.scala
8+
// ^^^^^^^^ variable.stable.declaration.scala
9+
val p2p = 3
10+
// ^^^ variable.stable.declaration.scala
1111
val empty_? = 3
12-
// ^^^^^^^ variable.other.declaration.scala
13-
val + = 3
14-
// ^ variable.other.declaration.scala
15-
val `yield` = 3
16-
// ^^^^^^^ variable.other.declaration.scala
17-
val αρετη = 3
18-
val _y = 3
19-
// ^^ variable.other.declaration.scala
12+
// ^^^^^^^ variable.stable.declaration.scala
13+
val + = 3
14+
// ^ variable.stable.declaration.scala
15+
val `yield` = 3
16+
// ^^^^^^^ variable.stable.declaration.scala
17+
val αρετη = 3
18+
val _y = 3
19+
// ^^ variable.stable.declaration.scala
2020
val dot_product_* = 3
21-
// ^^^^^^^^^^^^^ variable.other.declaration.scala
22-
val __system = 3
23-
// ^^^^^^^^ variable.other.declaration.scala
21+
// ^^^^^^^^^^^^^ variable.stable.declaration.scala
22+
val __system = 3
23+
// ^^^^^^^^ variable.stable.declaration.scala
2424
val _MAX_LEN_ = 3
25-
// ^^^^^^^^^ variable.other.declaration.scala
25+
// ^^^^^^^^^ variable.stable.declaration.scala
2626
}
2727

2828
object IntegerLiterals {
2929
(0, 21, 0xFFFFFFFF, -42L)
30-
// ^ constant.numeric.scala
30+
// ^ constant.numeric.scala
3131
// ^^ constant.numeric.scala
3232
// ^^^^^^^^^^ constant.numeric.scala
3333
// ^ keyword.operator.arithmetic.scala
@@ -37,9 +37,9 @@ object IntegerLiterals {
3737
object FloatingPointLiterals {
3838
( 0.0, 1e30f, 3.14159f, 1.0e-100, .1 )
3939
// ^^^ constant.numeric.scala
40-
// ^^^^^^^^ constant.numeric.scala
41-
// ^^^^^^^^ constant.numeric.scala
42-
// ^^ constant.numeric.scala
40+
// ^^^^^^^^ constant.numeric.scala
41+
// ^^^^^^^^ constant.numeric.scala
42+
// ^^ constant.numeric.scala
4343
}
4444

4545
object Boolean {
@@ -54,9 +54,9 @@ object CharacterLiterals {
5454
// ^^^ constant.character.literal.scala
5555
// ^ punctuation.definition.character.end.scala
5656
// ^^^^^^^^ constant.character.literal.scala
57-
// ^^^^^^ constant.character.escape.scala
57+
// ^^^^^^ constant.character.escape.scala
5858
// ^^ constant.character.escape.scala
59-
// ^^ constant.character.escape.scala
59+
// ^^ constant.character.escape.scala
6060
}
6161

6262
object StringLiterals {
@@ -65,14 +65,14 @@ object StringLiterals {
6565
// ^^^^^^^^^^^^^^^^ string.quoted.double.scala
6666
// ^^ constant.character.escape.scala
6767
// ^ punctuation.definition.string.end.scala
68-
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ string.quoted.double.scala
68+
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ string.quoted.double.scala
6969
"""the present string
7070
// ^^^ punctuation.definition.string.begin.scala
7171
// ^^^^^^^^^^^^^^^^^^^^^ string.quoted.triple.scala
7272
spans three
7373
// ^^^^^^^^^^^ string.quoted.triple.scala
7474
lines."""
75-
// ^^^^^^^^^ string.quoted.triple.scala
75+
// ^^^^^^^^^ string.quoted.triple.scala
7676
// ^^^ punctuation.definition.string.end.scala
7777

7878
"""the present string
@@ -86,8 +86,8 @@ object StringLiterals {
8686

8787
s"$x plain ${val x = y}"
8888
//^ keyword.interpolation.scala
89-
// ^ punctuation.definition.string.begin.scala
90-
// ^ punctuation.definition.template-expression.begin.scala
89+
// ^ punctuation.definition.string.begin.scala
90+
// ^ punctuation.definition.template-expression.begin.scala
9191
// ^ - string.quoted.double.interpolated.scala string.quoted.double.scala
9292
// ^^^^^^^ string.quoted.double.interpolated.scala
9393
// ^^^^^^^^^^^^ meta.template.expression.scala
@@ -96,12 +96,12 @@ object StringLiterals {
9696
// ^^^ keyword.declaration.stable.scala
9797
// ^^^^^^^^^ - string.quoted.double.interpolated.scala string.quoted.double.scala
9898
// ^ punctuation.definition.template-expression.end.scala
99-
// ^ string.quoted.double.interpolated.scala punctuation.definition.string.end.scala
99+
// ^ string.quoted.double.interpolated.scala punctuation.definition.string.end.scala
100100

101101
custom"$x plain ${val x = y}"
102102
//^^^^^^ keyword.interpolation.scala
103-
// ^ punctuation.definition.string.begin.scala
104-
// ^ punctuation.definition.template-expression.begin.scala
103+
// ^ punctuation.definition.string.begin.scala
104+
// ^ punctuation.definition.template-expression.begin.scala
105105
// ^ - string.quoted.double.interpolated.scala string.quoted.double.scala
106106
// ^^^^^^^ string.quoted.double.interpolated.scala
107107
// ^^^^^^^^^^^^ meta.template.expression.scala
@@ -110,26 +110,26 @@ object StringLiterals {
110110
// ^^^ keyword.declaration.stable.scala
111111
// ^^^^^^^^^ - string.quoted.double.interpolated.scala string.quoted.double.scala
112112
// ^ punctuation.definition.template-expression.end.scala
113-
// ^ string.quoted.double.interpolated.scala punctuation.definition.string.end.scala
113+
// ^ string.quoted.double.interpolated.scala punctuation.definition.string.end.scala
114114

115115
object Symbols {
116116
('x, 'X, 'αρετη, '=, '+ )
117117
// ^^ constant.other.symbol.scala
118118
// ^^ constant.other.symbol.scala
119-
// ^^^^^^ constant.other.symbol.scala
119+
// ^^^^^^ constant.other.symbol.scala
120120
}
121121

122122
// single line comment
123-
// ^^ punctuation.definition.comment.scala
124-
// ^^^^^^^^^^^^^^^^^^^^^^ comment.line.double-slash.scala
123+
// ^^ punctuation.definition.comment.scala
124+
// ^^^^^^^^^^^^^^^^^^^^^^ comment.line.double-slash.scala
125125

126126
/*
127127
// ^^ punctuation.definition.comment.scala
128128
multiline comment*/
129129
// ^^^^^^^^^^^^^^^^^^^ comment.block.scala
130130
/**
131131
* Scaladoc comment
132-
* @scaladoc @param
132+
* @scaladoc @param
133133
*/
134134

135135
/* nested /* multi-line */ comment */

Diff for: tests/unit/unicode.identifiers.test.scala

+8-8
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// SYNTAX TEST "source.scala"
22

3-
class Φδφκξ(x : Int, δφξκξ: Int, val y: Int, val φξ: Int) {
3+
class Φδφκξ(x : Int, δφξκξ: Int, val y: Int, val φξ: Int) {
44
// <----- keyword.declaration.scala
55
// ^^^^^ entity.name.class.declaration
66
// ^ meta.bracket.scala
@@ -11,11 +11,11 @@ class Φδφκξ(x : Int, δφξκξ: Int, val y: Int, val φξ: Int) {
1111
// ^ meta.colon.scala
1212
// ^^^ entity.name.class
1313
// ^^^ keyword.declaration.stable.scala
14-
// ^ variable.other.declaration.scala
14+
// ^ variable.stable.declaration.scala
1515
// ^ keyword.operator.scala
1616
// ^^^ entity.name.class
1717
// ^^^ keyword.declaration.stable.scala
18-
// ^^ variable.other.declaration.scala
18+
// ^^ variable.stable.declaration.scala
1919
// ^ keyword.operator.scala
2020
// ^^^ entity.name.class
2121
// ^ meta.bracket.scala
@@ -27,11 +27,11 @@ class Φδφκξ(x : Int, δφξκξ: Int, val y: Int, val φξ: Int) {
2727
// ^ keyword.operator.comparison.scala
2828
val δφξ = 4
2929
//^^^ keyword.declaration.stable.scala
30-
// ^^^ variable.other.declaration.scala
30+
// ^^^ variable.stable.declaration.scala
3131
// ^ keyword.operator.comparison.scala
3232
var δφξ = 5
3333
//^^^ keyword.declaration.volatile.scala
34-
// ^^^ variable.other.declaration.scala
34+
// ^^^ variable.volatile.declaration.scala
3535
// ^ keyword.operator.comparison.scala
3636
def δφξ(δφξκξ: Int) = ()
3737
//^^^ keyword.declaration.scala
@@ -56,13 +56,13 @@ class Φδφκξ(x : Int, δφξκξ: Int, val y: Int, val φξ: Int) {
5656

5757
val Constant = 3
5858
//^^^ keyword.declaration.stable.scala
59-
// ^^^^^^^^ variable.other.declaration.scala
59+
// ^^^^^^^^ variable.stable.declaration.scala
6060
// ^ keyword.operator.comparison.scala
6161
val Константа = 4
6262
//^^^ keyword.declaration.stable.scala
63-
// ^^^^^^^^^ variable.other.declaration.scala
63+
// ^^^^^^^^^ variable.stable.declaration.scala
6464
// ^ keyword.operator.comparison.scala
65-
65+
6666
}
6767

6868

0 commit comments

Comments
 (0)