From a51c9af36e8920c52305ca673a883f99548c163d Mon Sep 17 00:00:00 2001 From: Andy Scott Date: Mon, 25 Jan 2016 14:15:48 -0800 Subject: [PATCH] Add lexer support for string extractors with wildcards --- .../src/main/scala/scalariform/lexer/ScalaOnlyLexer.scala | 3 +++ .../src/test/scala/scalariform/lexer/ScalaLexerTest.scala | 2 ++ 2 files changed, 5 insertions(+) diff --git a/scalariform/src/main/scala/scalariform/lexer/ScalaOnlyLexer.scala b/scalariform/src/main/scala/scalariform/lexer/ScalaOnlyLexer.scala index aeb8ec77..8df36422 100644 --- a/scalariform/src/main/scala/scalariform/lexer/ScalaOnlyLexer.scala +++ b/scalariform/src/main/scala/scalariform/lexer/ScalaOnlyLexer.scala @@ -238,6 +238,9 @@ private[lexer] trait ScalaOnlyLexer { self: ScalaLexer ⇒ if (ch == '$') { nextChar() getStringPart(multiLine) + } else if (ch == '_') { + token(STRING_PART) + stringInterpolationMode.interpolationVariable = true } else if (ch == '{') { token(STRING_PART) switchToScalaMode() diff --git a/scalariform/src/test/scala/scalariform/lexer/ScalaLexerTest.scala b/scalariform/src/test/scala/scalariform/lexer/ScalaLexerTest.scala index 01663fdb..8843db08 100644 --- a/scalariform/src/test/scala/scalariform/lexer/ScalaLexerTest.scala +++ b/scalariform/src/test/scala/scalariform/lexer/ScalaLexerTest.scala @@ -129,6 +129,8 @@ class ScalaLexerTest extends FlatSpec with ShouldMatchers { """ s"$this" """ producesTokens (WS, INTERPOLATION_ID, STRING_PART, THIS, STRING_LITERAL, WS) + """ s"$_" """ producesTokens (WS, INTERPOLATION_ID, STRING_PART, USCORE, STRING_LITERAL, WS) + s"""""".text producesTokens (INTERPOLATION_ID, STRING_LITERAL) s""""""""".text producesTokens (INTERPOLATION_ID, STRING_LITERAL) s""" $foo """.text producesTokens (INTERPOLATION_ID, STRING_PART, VARID, STRING_LITERAL)