@@ -92,7 +92,7 @@ object Scanners {
92
92
|| token == IDENTIFIER && isOperatorPart(name(name.length - 1 ))
93
93
94
94
def isArrow =
95
- token == ARROW || token == CTXARROW
95
+ token == ARROW || token == CTXARROW || token == ARROWeol
96
96
}
97
97
98
98
abstract class ScannerCommon (source : SourceFile )(using Context ) extends CharArrayReader with TokenData {
@@ -612,7 +612,11 @@ object Scanners {
612
612
insert(if (pastBlankLine) NEWLINES else NEWLINE , lineOffset)
613
613
else if indentIsSignificant then
614
614
if nextWidth < lastWidth
615
- || nextWidth == lastWidth && (indentPrefix == MATCH || indentPrefix == CATCH ) && token != CASE then
615
+ || nextWidth == lastWidth
616
+ && indentPrefix.match
617
+ case MATCH | CATCH => token != CASE
618
+ case _ => false
619
+ then
616
620
if currentRegion.isOutermost then
617
621
if nextWidth < lastWidth then currentRegion = topLevelRegion(nextWidth)
618
622
else if ! isLeadingInfixOperator(nextWidth) && ! statCtdTokens.contains(lastToken) && lastToken != INDENT then
@@ -638,9 +642,13 @@ object Scanners {
638
642
insert(OUTDENT , offset)
639
643
else if r.isInstanceOf [InBraces ] && ! closingRegionTokens.contains(token) then
640
644
report.warning(" Line is indented too far to the left, or a `}` is missing" , sourcePos())
641
-
642
645
else if lastWidth < nextWidth
643
- || lastWidth == nextWidth && (lastToken == MATCH || lastToken == CATCH ) && token == CASE then
646
+ || lastWidth == nextWidth
647
+ && lastToken.match
648
+ case MATCH | CATCH => token == CASE
649
+ case ARROWeol => true
650
+ case _ => false
651
+ then
644
652
if canStartIndentTokens.contains(lastToken) then
645
653
currentRegion = Indented (nextWidth, lastToken, currentRegion)
646
654
insert(INDENT , offset)
@@ -658,7 +666,7 @@ object Scanners {
658
666
def spaceTabMismatchMsg (lastWidth : IndentWidth , nextWidth : IndentWidth ): Message =
659
667
em """ Incompatible combinations of tabs and spaces in indentation prefixes.
660
668
|Previous indent : $lastWidth
661
- |Latest indent : $nextWidth"""
669
+ |Latest indent : $nextWidth"""
662
670
663
671
def observeColonEOL (inTemplate : Boolean ): Unit =
664
672
val enabled =
@@ -672,6 +680,13 @@ object Scanners {
672
680
reset()
673
681
if atEOL then token = COLONeol
674
682
683
+ def observeArrowEOL (): Unit =
684
+ if indentSyntax && token == ARROW then
685
+ peekAhead()
686
+ val atEOL = isAfterLineEnd || token == EOF
687
+ reset()
688
+ if atEOL then token = ARROWeol
689
+
675
690
def observeIndented (): Unit =
676
691
if indentSyntax && isNewLine then
677
692
val nextWidth = indentWidth(next.offset)
@@ -680,7 +695,6 @@ object Scanners {
680
695
currentRegion = Indented (nextWidth, COLONeol , currentRegion)
681
696
offset = next.offset
682
697
token = INDENT
683
- end observeIndented
684
698
685
699
/** Insert an <outdent> token if next token closes an indentation region.
686
700
* Exception: continue if indentation region belongs to a `match` and next token is `case`.
@@ -1100,7 +1114,7 @@ object Scanners {
1100
1114
reset()
1101
1115
next
1102
1116
1103
- class LookaheadScanner (val allowIndent : Boolean = false ) extends Scanner (source, offset, allowIndent = allowIndent) {
1117
+ class LookaheadScanner (allowIndent : Boolean = false ) extends Scanner (source, offset, allowIndent = allowIndent) {
1104
1118
override protected def initialCharBufferSize = 8
1105
1119
override def languageImportContext = Scanner .this .languageImportContext
1106
1120
}
@@ -1652,7 +1666,7 @@ object Scanners {
1652
1666
case class InCase (outer : Region ) extends Region (OUTDENT )
1653
1667
1654
1668
/** A class describing an indentation region.
1655
- * @param width The principal indendation width
1669
+ * @param width The principal indentation width
1656
1670
* @param prefix The token before the initial <indent> of the region
1657
1671
*/
1658
1672
case class Indented (width : IndentWidth , prefix : Token , outer : Region | Null ) extends Region (OUTDENT ):
0 commit comments