From f6b0ff292fde1c46455659d9caf30fbb5f00ec5d Mon Sep 17 00:00:00 2001 From: sgrimm-sg Date: Wed, 11 Apr 2018 07:59:22 -0700 Subject: [PATCH 1/2] Specify position of close parenthesis (#63) Mandate attaching closing parentheses to the preceding token, a la the Google Java style guide. --- style.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/style.md b/style.md index daaac7b..a29a10c 100644 --- a/style.md +++ b/style.md @@ -259,8 +259,9 @@ The prime directive of line-wrapping is: prefer to break at a **higher syntactic * the two colons of a member reference (`::`) 2. When a line is broken at an _assignment_ operator the break comes _after_ the symbol. 3. A method or constructor name stays attached to the open parenthesis (`(`) that follows it. - 4. A comma (`,`) stays attached to the token that precedes it. - 5. A lambda arrow (`->`) stays attached to the argument list that precedes it. + 4. A close parenthesis (`)`) stays attached to the token that precedes it, except in method or class signatures that span multiple lines. + 5. A comma (`,`) stays attached to the token that precedes it. + 6. A lambda arrow (`->`) stays attached to the argument list that precedes it. Note: The primary goal for line wrapping is to have clear code, _not necessarily_ code that fits in the smallest number of lines. From 4d2e3f24fda2fc7cd8b7d189609cb38304c27291 Mon Sep 17 00:00:00 2001 From: Steven Grimm Date: Mon, 23 Jul 2018 16:18:58 -0700 Subject: [PATCH 2/2] Update to match JetBrains style guide --- style.md | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/style.md b/style.md index a29a10c..422bfb8 100644 --- a/style.md +++ b/style.md @@ -258,14 +258,15 @@ The prime directive of line-wrapping is: prefer to break at a **higher syntactic * the dot separator (`.`) * the two colons of a member reference (`::`) 2. When a line is broken at an _assignment_ operator the break comes _after_ the symbol. - 3. A method or constructor name stays attached to the open parenthesis (`(`) that follows it. - 4. A close parenthesis (`)`) stays attached to the token that precedes it, except in method or class signatures that span multiple lines. - 5. A comma (`,`) stays attached to the token that precedes it. - 6. A lambda arrow (`->`) stays attached to the argument list that precedes it. + 3. A method or constructor name stays attached to the opening parenthesis (`(`) that follows it. + 4. A comma (`,`) stays attached to the token that precedes it. + 5. A lambda arrow (`->`) stays attached to the argument list that precedes it. + 6. A closing parenthesis (`)`) stays attached to the token that precedes it if the corresponding opening parenthesis (`(`) is on the same line. + 7. A closing parenthesis (`)`) on a different line than its corresponding opening parenthesis (`(`) is placed on a line by itself indented the same amount as the line with the opening parenthesis. + * Exception: If the closing parenthesis is immediately followed by an opening curly brace (`{`), the open brace is placed on the same line as the closing parenthesis separated by a space. Note: The primary goal for line wrapping is to have clear code, _not necessarily_ code that fits in the smallest number of lines. - ### Continuation indent When line-wrapping, each line after the first (each _continuation line_) is indented at least +8 from the original line. @@ -350,7 +351,7 @@ Multiple consecutive blank lines are permitted, but not encouraged or ever requi Beyond where required by the language or other style rules, and apart from literals, comments, and KDoc, a single ASCII space also appears in the following places only: - 1. Separating any reserved word, such as `if`, `for`, or `catch` from an open parenthesis (`(`) that follows it on that line. + 1. Separating any reserved word, such as `if`, `for`, or `catch` from an opening parenthesis (`(`) that follows it on that line. ```kotlin // WRONG!