@@ -307,11 +307,6 @@ object Scanners {
307
307
*/
308
308
var currentRegion : Region = Outermost
309
309
310
- def currentIndentWidth : IndentWidth = currentRegion match {
311
- case r : Indented => r.width
312
- case _ => IndentWidth .Zero
313
- }
314
-
315
310
/** The end marker that was skipped last */
316
311
val endMarkers = new mutable.ListBuffer [EndMarker ]
317
312
@@ -416,7 +411,7 @@ object Scanners {
416
411
* value at the end of the endMarkers queue.
417
412
*/
418
413
private def handleEndMarkers (width : IndentWidth ): Unit = {
419
- if (next.token == IDENTIFIER && next.name == nme.end && width == currentIndentWidth ) {
414
+ if (next.token == IDENTIFIER && next.name == nme.end && width == currentRegion.indentWidth ) {
420
415
val lookahead = lookaheadScanner
421
416
lookahead.nextToken() // skip the `end`
422
417
@@ -589,15 +584,14 @@ object Scanners {
589
584
insert(if (pastBlankLine) NEWLINES else NEWLINE , lineOffset)
590
585
else if (indentIsSignificant) {
591
586
if (nextWidth < lastWidth
592
- || nextWidth == lastWidth && (indentPrefix == MATCH || indentPrefix == CATCH ) && token != CASE ) {
587
+ || nextWidth == lastWidth && (indentPrefix == MATCH || indentPrefix == CATCH ) && token != CASE )
593
588
currentRegion match {
594
589
case r : Indented if ! r.isOutermost && ! isLeadingInfixOperator() =>
595
590
currentRegion = r.enclosing
596
591
insert(OUTDENT , offset)
597
592
handleEndMarkers(nextWidth)
598
593
case _ =>
599
594
}
600
- }
601
595
else if (lastWidth < nextWidth ||
602
596
lastWidth == nextWidth && (lastToken == MATCH || lastToken == CATCH ) && token == CASE ) {
603
597
if (canStartIndentTokens.contains(lastToken)) {
@@ -1369,16 +1363,21 @@ object Scanners {
1369
1363
def outer : Region | Null
1370
1364
def isOutermost = outer == null
1371
1365
def enclosing : Region = outer.asInstanceOf [Region ]
1366
+ def indentWidth = IndentWidth .Zero
1372
1367
}
1373
- case class InParens (prefix : Token , outer : Region ) extends Region
1374
- case class InBraces (var width : IndentWidth | Null , outer : Region ) extends Region
1375
1368
case class InString (multiLine : Boolean , outer : Region ) extends Region
1369
+ case class InParens (prefix : Token , outer : Region ) extends Region
1370
+ case class InBraces (var width : IndentWidth | Null , outer : Region ) extends Region {
1371
+ override def indentWidth = width
1372
+ }
1376
1373
1377
1374
/** A class describing an indentation region.
1378
1375
* @param width The principal indendation width
1379
1376
* @param others Other indendation widths > width of lines in the same region
1380
1377
*/
1381
- case class Indented (width : IndentWidth , others : Set [IndentWidth ], prefix : Token , outer : Region | Null ) extends Region
1378
+ case class Indented (width : IndentWidth , others : Set [IndentWidth ], prefix : Token , outer : Region | Null ) extends Region {
1379
+ override def indentWidth = width
1380
+ }
1382
1381
1383
1382
val Outermost = Indented (IndentWidth .Zero , Set (), EMPTY , null )
1384
1383
0 commit comments