Skip to content

Commit

Permalink
Token: add a new Indentation branch (#3115)
Browse files Browse the repository at this point in the history
  • Loading branch information
kitbellew committed May 22, 2023
1 parent 1de6ce7 commit dd8c26a
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -617,8 +617,7 @@ final class ScannerTokens(val tokens: Tokens)(implicit dialect: Dialect) {
// !next.is[RightBrace] - braces can sometimes have -1 and we can start indent on }
prev match {
case _ if nextIndent < 0 || next.is[RightBrace] => None
case _ if prevToken.is[Indentation.Indent] => None
case _ if prevToken.is[Indentation.Outdent] => None
case _ if prevToken.is[Indentation] => None
// if does not work with indentation in pattern matches
case _: KwIf if sepRegions.headOption.contains(RegionArrow) => None
case _: KwCatch | _: KwMatch =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,9 +150,10 @@ object Token {
@freeform("xml end") class End extends Token
}

@branch trait Indentation extends Whitespace
object Indentation {
@freeform("indent") class Indent extends Token
@freeform("outdent") class Outdent extends Token
@freeform("indent") class Indent extends Indentation
@freeform("outdent") class Outdent extends Indentation
}

// Trivia
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,6 @@ class SurfaceSuite extends FunSuite {
|scala.meta.tokenizers.Tokenized.Success *
|scala.meta.tokens
|scala.meta.tokens.Token
|scala.meta.tokens.Token.Indentation *
|scala.meta.tokens.Token.Interpolation *
|scala.meta.tokens.Token.Xml *
|scala.meta.tokens.Tokens
Expand Down

0 comments on commit dd8c26a

Please sign in to comment.