Skip to content

Commit

Permalink
Merge pull request #756 from djspiewak/bug/next-line-with
Browse files Browse the repository at this point in the history
[Scala] Various stateful bailout bugs
  • Loading branch information
wbond authored Dec 23, 2016
2 parents 29e1264 + 360fdf2 commit 7449bbd
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 12 deletions.
25 changes: 13 additions & 12 deletions Scala/Scala.sublime-syntax
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ contexts:
# this is included when a single newline is found in a declaration
# you should never push/set this context, only include
decl-newline-double-check:
- match: '(?=[\{\}\)]|\b(class|def|val|var|trait|object|private|protected|for|while|if|)\b)'
- match: '(?=[\{\}\)]|\b(case|class|def|val|var|trait|object|private|protected|for|while|if)\b)'
pop: true
- match: '\n'
pop: true
Expand All @@ -399,10 +399,12 @@ contexts:
push: function-tparams-brackets
- match: ':'
set: function-return-type-definition
- match: '\n'
set: function-type-parameter-list-newline
- match: '(?=[\{\};]|{{nonopchar}}?={{nonopchar}})'
pop: true
- match: (?=\S)
pop: true
- match: '\n'
set: function-type-parameter-list-newline

function-type-parameter-list-newline:
- include: decl-newline-double-check
Expand All @@ -423,6 +425,8 @@ contexts:
- match: '(?=[\{\};]|{{nonopchar}}?={{nonopchar}})'
pop: true
- include: delimited-type-expression
- match: (?=\S)
pop: true

function-return-type-definition-newline:
- include: decl-newline-double-check
Expand Down Expand Up @@ -457,7 +461,7 @@ contexts:
set: function-return-type-definition
- match: '\n'
set: function-parameter-list-newline
- match: '(?=[\{=])'
- match: '(?=\S)'
pop: true

function-parameter-list-newline:
Expand All @@ -473,7 +477,7 @@ contexts:
- match: '\['
push: class-tparams-brackets
- match: '(?=\b(extends|with)\b)'
set: class-inheritance
set: class-inheritance-extends
- match: '(?=\{)'
set: class-pre-inheritance-early-initializer
- match: '\n'
Expand Down Expand Up @@ -519,12 +523,12 @@ contexts:
- match: '(?=[=])'
pop: true
- include: main
- match: '\n'
set: class-parameter-list-newline
- match: '(?=\b(extends|with)\b)'
set: class-inheritance
set: class-inheritance-extends
- match: '(?=\{)'
set: class-pre-inheritance-early-initializer
- match: '\n'
set: class-parameter-list-newline

class-parameter-list-newline:
- include: decl-newline-double-check
Expand Down Expand Up @@ -552,9 +556,6 @@ contexts:
- match: '(?=\S)'
set: class-pre-inheritance-early-initializer

class-inheritance:
- include: class-inheritance-extends

class-inheritance-extends:
- match: \bwith\b
scope: invalid.keyword.with-before-extends.scala
Expand All @@ -570,7 +571,7 @@ contexts:
class-inheritance-extends-newline:
- include: decl-newline-double-check
- match: '(?=\S)'
set: class-inheritance
set: class-inheritance-extends

class-inheritance-extends-token:
- match: '{{id}}'
Expand Down
28 changes: 28 additions & 0 deletions Scala/syntax_test_scala.scala
Original file line number Diff line number Diff line change
Expand Up @@ -1413,3 +1413,31 @@ class Foo extends (Int => String)
class Foo extends Bar[Int]
// ^ punctuation.section.brackets.begin.scala
// ^ punctuation.section.brackets.end.scala

class Foo
extends Bar
// ^^^^^^^ keyword.declaration.scala
// ^^^ entity.other.inherited-class.scala

class Foo extends Bar
with Baz
// ^^^^ keyword.declaration.scala
// ^^^ entity.other.inherited-class.scala

class Foo extends Bar
with Baz
with Bin
// ^^^^ keyword.declaration.scala
// ^^^ entity.other.inherited-class.scala

def foo
42
// ^^ constant.numeric.integer.scala

def foo()
42
// ^^ constant.numeric.integer.scala

def foo():
42
// ^^ constant.numeric.integer.scala

0 comments on commit 7449bbd

Please sign in to comment.