Skip to content

Commit 7f4c828

Browse files
committed
Adapt doc page to new scheme
1 parent 25b1148 commit 7f4c828

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

docs/docs/reference/other-new-features/indentation.md

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -198,15 +198,21 @@ def largeMethod(...) =
198198
... // more code
199199
end largeMethod
200200
```
201-
An `end` marker consists of the identifier `end` which follows an `<outdent>` token, and is in turn followed on the same line by exactly one other token, which is either an identifier or one of the reserved words
201+
An `end` marker consists of the identifier `end` and a follow-on specifier token that together constitute all the tokes of a line. Possible specifier tokens are
202+
identifiers or one of the following keywords
202203
```scala
203-
if while for match try new given extension
204+
if while for match try new this val given
204205
```
205-
If `end` is followed by a reserved word, the compiler checks that the marker closes an indentation region belonging to a construct that starts with the reserved word. If it is followed by an identifier _id_, the compiler checks that the marker closes a definition
206-
that defines _id_ or a package clause that refers to _id_.
207-
208-
`end` itself is a soft keyword. It is only treated as an `end` marker if it
209-
occurs at the start of a line and is followed by an identifier or one of the reserved words above.
206+
End markers are allowed in statement sequences. The specifier token `s` of an end marker must correspond to the statement that precedes it. This means:
207+
208+
- If the statement defines a member `x` then `s` must be the same identifier `x`.
209+
- If the statement defines a constructor then `s` must be `this`.
210+
- If the statement defines an anonymous given, then `s` must be `given`.
211+
- If the statement defines an anonymous extension, then `s` must be `extension`.
212+
- If the statement defines an anonymous class, then `s` must be `new`.
213+
- If the statement is a `val` definition binding a pattern, then `s` must be `val`.
214+
- If the statement is a package clause that refers to package `p`, then `s` must be the same identifier `p`.
215+
- If the statement is an `if`, `while`, `for`, `try`, or `match` statement, then `s` must be that same token.
210216

211217
It is recommended that `end` markers are used for code where the extent of an indentation region is not immediately apparent "at a glance". Typically this is the case if an indentation region spans 20 lines or more.
212218

0 commit comments

Comments
 (0)