Skip to content

Allow for catch and finally in try expression to be on a new line #16

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 12, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ name: Build/test
on:
push:
branches:
- "**"
- master
pull_request:
Comment on lines +5 to +6
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

jobs:
test:
runs-on: ${{ matrix.os }}
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@ target
test.scala
package-lock.json
Cargo.lock
.scalafmt.conf
*worksheet.sc
35 changes: 32 additions & 3 deletions corpus/expressions.txt
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,18 @@ Try expressions

def main() {
try a() finally depth -= 1
try b() catch { case e => println(e) }
try {
doThing()
} catch {
case e: SomeException => prinlnt(e.message)
} finally {
tryAnotherThing()
}
try b()
catch { case e => println(e) }
finally doFinalThing()
try a()
finally b()
}

---
Expand All @@ -153,8 +164,26 @@ def main() {
(call_expression (identifier) (arguments))
(finally_clause (infix_expression (identifier) (operator_identifier) (number))))
(try_expression
(call_expression (identifier) (arguments))
(catch_clause (case_block (case_clause (identifier) (call_expression (identifier) (arguments (identifier))))))))))
(block (call_expression (identifier) (arguments)))
(catch_clause (case_block (case_clause
(typed_pattern
(identifier)
(type_identifier))
(call_expression
(identifier)
(arguments (field_expression
(identifier)
(identifier)))))))
(finally_clause (block (call_expression (identifier) (arguments)))))
(try_expression (call_expression (identifier) (arguments))
(catch_clause (case_block (case_clause
(identifier)
(call_expression
(identifier)
(arguments (identifier))))))
(finally_clause (call_expression (identifier) (arguments))))
(try_expression (call_expression (identifier) (arguments))
(finally_clause (call_expression (identifier) (arguments)))))))

===============================
Match expressions
Expand Down
2 changes: 2 additions & 0 deletions grammar.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ module.exports = grammar({
$._multiline_string_middle,
$._multiline_string_end,
'else',
'catch',
'finally'
],

inline: $ => [
Expand Down
8 changes: 8 additions & 0 deletions src/grammar.json
Original file line number Diff line number Diff line change
Expand Up @@ -3553,6 +3553,14 @@
{
"type": "STRING",
"value": "else"
},
{
"type": "STRING",
"value": "catch"
},
{
"type": "STRING",
"value": "finally"
}
],
"inline": [
Expand Down
Loading