From 92971b3fd3d51ab42512e4c411cd3e1e54419b3d Mon Sep 17 00:00:00 2001 From: Daniel Spiewak Date: Thu, 22 Dec 2016 22:12:28 -0700 Subject: [PATCH 1/2] [Scala] Fixed bug in all semicolon inference constructs --- Scala/Scala.sublime-syntax | 15 ++++++--------- Scala/syntax_test_scala.scala | 16 ++++++++++++++++ 2 files changed, 22 insertions(+), 9 deletions(-) diff --git a/Scala/Scala.sublime-syntax b/Scala/Scala.sublime-syntax index eac5e7586e..4a917ce2a9 100644 --- a/Scala/Scala.sublime-syntax +++ b/Scala/Scala.sublime-syntax @@ -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 @@ -473,7 +473,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' @@ -519,12 +519,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 @@ -552,9 +552,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 @@ -570,7 +567,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}}' diff --git a/Scala/syntax_test_scala.scala b/Scala/syntax_test_scala.scala index 32977a5d21..d7e00449e3 100644 --- a/Scala/syntax_test_scala.scala +++ b/Scala/syntax_test_scala.scala @@ -1413,3 +1413,19 @@ 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 From 360fdf227f5c2ed8f8ee96903fc22031ca59c40b Mon Sep 17 00:00:00 2001 From: Daniel Spiewak Date: Thu, 22 Dec 2016 22:16:08 -0700 Subject: [PATCH 2/2] [Scala] Improved bail-out behavior in function scoping --- Scala/Scala.sublime-syntax | 10 +++++++--- Scala/syntax_test_scala.scala | 12 ++++++++++++ 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/Scala/Scala.sublime-syntax b/Scala/Scala.sublime-syntax index 4a917ce2a9..88938929e7 100644 --- a/Scala/Scala.sublime-syntax +++ b/Scala/Scala.sublime-syntax @@ -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 @@ -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 @@ -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: diff --git a/Scala/syntax_test_scala.scala b/Scala/syntax_test_scala.scala index d7e00449e3..ab25cddf73 100644 --- a/Scala/syntax_test_scala.scala +++ b/Scala/syntax_test_scala.scala @@ -1429,3 +1429,15 @@ class Foo extends Bar 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