{"action":"created","issue":{"url":"https://api.github.com/repos/sublimehq/Packages/issues/491","repository_url":"https://api.github.com/repos/sublimehq/Packages","labels_url":"https://api.github.com/repos/sublimehq/Packages/issues/491/labels{/name}","comments_url":"https://api.github.com/repos/sublimehq/Packages/issues/491/comments","events_url":"https://api.github.com/repos/sublimehq/Packages/issues/491/events","html_url":"https://github.com/sublimehq/Packages/pull/491","id":161485030,"number":491,"title":"[Scala] Pattern match highlighting for case, val and for","user":{"login":"djspiewak","id":752,"avatar_url":"https://avatars.githubusercontent.com/u/752?v=3","gravatar_id":"","url":"https://api.github.com/users/djspiewak","html_url":"https://github.com/djspiewak","followers_url":"https://api.github.com/users/djspiewak/followers","following_url":"https://api.github.com/users/djspiewak/following{/other_user}","gists_url":"https://api.github.com/users/djspiewak/gists{/gist_id}","starred_url":"https://api.github.com/users/djspiewak/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/djspiewak/subscriptions","organizations_url":"https://api.github.com/users/djspiewak/orgs","repos_url":"https://api.github.com/users/djspiewak/repos","events_url":"https://api.github.com/users/djspiewak/events{/privacy}","received_events_url":"https://api.github.com/users/djspiewak/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":54,"created_at":"2016-06-21T16:40:31Z","updated_at":"2016-07-21T16:18:00Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/sublimehq/Packages/pulls/491","html_url":"https://github.com/sublimehq/Packages/pull/491","diff_url":"https://github.com/sublimehq/Packages/pull/491.diff","patch_url":"https://github.com/sublimehq/Packages/pull/491.patch"},"body":"Scala's variable definition syntax is quite rich, and Sublime doesn't (currently) handle it very well.  Additionally, several special syntactic forms are available in both `val` declarations and `case` pattern matches (the syntax is actually identical) which are not highlighted at all by Sublime.  Finally, complex patterns in `val` declarations and *any* patterns in `case` pattern matches are not currently considered for \"go to definition\", which is annoying.\r\n\r\nThis PR fixes all that.\r\n\r\n- ![case example](http://i.imgur.com/qvOpC0d.png)\r\n- ![val examples](http://i.imgur.com/M0WkCuM.png)\r\n\r\nThe orange italic parameters in the above are both considered for symbol matching, which enables go to definition jumping into pattern match extractors, as well as provides more accurate auto-complete.\r\n\r\nThere is a slight cost here.  Specifically, when you type `case`, you open up a new scope which highlights the *rest of your file* differently.  This scope is closed by either `=>` or `⇒`, but it does make the process of actually *typing* Scala in a left-to-right fashion a bit different.  If you use the `case`<kbd>TAB</kbd> snippet, this problem is resolved.  The additional wrinkle is if you write a syntactically *invalid* pattern match, you may see some weird syntax highlighting.  For example:\r\n\r\n```scala\r\ncase f: Int => Boolean :: _ => f\r\n```\r\n\r\nThis is not valid Scala, but it's a relatively easy mistake to make.  What will happen here is the first `=>` will terminate the pattern match scope and the `_` character will not be correctly highlighted.  I don't feel too bad about this since Scala will actually not compile the above, and the fix for the syntax highlighting is identical to the fix for the Scala parser: wrap it in parentheses:\r\n\r\n```scala\r\ncase (f: Int => Boolean) :: _ => f\r\n```\r\n\r\n~~This PR does not currently address the problem of `for`-comprehensions, which are another instance of pattern matching syntax, but unfortunately one which is far more syntactically complex.  Specifically, I would need to do some sort of backtracking scope push on the `<-` and `←` characters, defining everything from the start of the line to that character to be in pattern match scope while within a `for` block, but any line which does *not* contain these characters gets parsed normally.  As far as I can tell, `.sublime-syntax` does not have a way of expressing this sort of thing.~~"},"comment":{"url":"https://api.github.com/repos/sublimehq/Packages/issues/comments/234305234","html_url":"https://github.com/sublimehq/Packages/pull/491#issuecomment-234305234","issue_url":"https://api.github.com/repos/sublimehq/Packages/issues/491","id":234305234,"user":{"login":"wbond","id":41734,"avatar_url":"https://avatars.githubusercontent.com/u/41734?v=3","gravatar_id":"","url":"https://api.github.com/users/wbond","html_url":"https://github.com/wbond","followers_url":"https://api.github.com/users/wbond/followers","following_url":"https://api.github.com/users/wbond/following{/other_user}","gists_url":"https://api.github.com/users/wbond/gists{/gist_id}","starred_url":"https://api.github.com/users/wbond/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wbond/subscriptions","organizations_url":"https://api.github.com/users/wbond/orgs","repos_url":"https://api.github.com/users/wbond/repos","events_url":"https://api.github.com/users/wbond/events{/privacy}","received_events_url":"https://api.github.com/users/wbond/received_events","type":"User","site_admin":false},"created_at":"2016-07-21T16:18:00Z","updated_at":"2016-07-21T16:18:00Z","body":"I'm glad some Scala users are showing up! Hopefully you can all stick around and help provide info and feedback as improvements are made."}}
{"actor":{"display_login":"wbond"}}