Skip to content

Commit

Permalink
Get rid of false warnings about possible string interpolation
Browse files Browse the repository at this point in the history
  • Loading branch information
kiritsuku committed Dec 28, 2015
1 parent 5b29316 commit 376684d
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ class AstSelectorTest extends FlatSpec with ShouldMatchers {
{
implicit val scalaVersion = "2.10.0"

""" s"my name is ${person.name}." """ ~
""" s"my name is ?{person.name}." """.replace('?', '$') ~
""" $$$$$$ " """ ~
""" $$$$$$$$$$$ " """ ~
""" $$$$$$$$$$$$$$ " """ ~
Expand All @@ -304,7 +304,6 @@ class AstSelectorTest extends FlatSpec with ShouldMatchers {
""" $ """ ~
""" $$$$ """


}

private def findSelectionRange(s: String): Range = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ class StringInterpolationFormatterTest extends AbstractExpressionFormatterTest {
<t>s""</t>.text ==> <t>s""</t>.text
<t>s"my name is $name"</t>.text ==> <t>s"my name is $name"</t>.text
<t>s"my name is $this"</t>.text ==> <t>s"my name is $this"</t>.text
"""s"my name is ${bob}"""" ==> """s"my name is ${bob}""""
"""s"my name is ${ person.name }"""" ==> """s"my name is ${person.name}""""
"""s"my name is ?{bob}"""".replace('?', '$') ==> """s"my name is ?{bob}"""".replace('?', '$')
"""s"my name is ?{ person.name }"""".replace('?', '$') ==> """s"my name is ?{person.name}"""".replace('?', '$')

"""s"my name is ${
|bob}"""" ==>
Expand All @@ -29,7 +29,7 @@ class StringInterpolationFormatterTest extends AbstractExpressionFormatterTest {
<t>s"""foo"""</t>.text ==> <t>s"""foo"""</t>.text
<t>s""""""</t>.text ==> <t>s""""""</t>.text
<t>s"""my name is $name"""</t>.text ==> <t>s"""my name is $name"""</t>.text
"s\"\"\"my name is ${bob}\"\"\"" ==> "s\"\"\"my name is ${bob}\"\"\""
"s\"\"\"my name is ${ person.name }\"\"\"" ==> "s\"\"\"my name is ${person.name}\"\"\""
"s\"\"\"my name is ?{bob}\"\"\"".replace('?', '$') ==> "s\"\"\"my name is ?{bob}\"\"\"".replace('?', '$')
"s\"\"\"my name is ?{ person.name }\"\"\"".replace('?', '$') ==> "s\"\"\"my name is ?{person.name}\"\"\"".replace('?', '$')

}
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ class RedundantSemicolonDetectorTest extends FlatSpec with ShouldMatchers {
{
implicit val scalaVersion = "2.10.0";
"""
s"my name is ${person.name<;>}"
""".check
s"my name is ?{person.name<;>}"
""".replace('?', '$').check
}

private def checkSemis(encodedSource: String, scalaVersion: String) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,8 @@ class ScalaLexerTest extends FlatSpec with ShouldMatchers {
""" X s "$foo" """ producesTokens (WS, VARID, WS, VARID, WS, STRING_LITERAL, WS)
""" s"$foo" """ producesTokens (WS, INTERPOLATION_ID, STRING_PART, VARID, STRING_LITERAL, WS)
""" s"$$" """ producesTokens (WS, INTERPOLATION_ID, STRING_LITERAL, WS)
""" s"${foo}" """ producesTokens (WS, INTERPOLATION_ID, STRING_PART, LBRACE, VARID, RBRACE, STRING_LITERAL, WS)
""" s"${s"${x}"}" """ producesTokens (WS, INTERPOLATION_ID, STRING_PART, LBRACE, INTERPOLATION_ID, STRING_PART, LBRACE, VARID, RBRACE, STRING_LITERAL, RBRACE, STRING_LITERAL, WS)
""" s"?{foo}" """.replace('?', '$') producesTokens (WS, INTERPOLATION_ID, STRING_PART, LBRACE, VARID, RBRACE, STRING_LITERAL, WS)
""" s"?{s"?{x}"}" """.replace('?', '$') producesTokens (WS, INTERPOLATION_ID, STRING_PART, LBRACE, INTERPOLATION_ID, STRING_PART, LBRACE, VARID, RBRACE, STRING_LITERAL, RBRACE, STRING_LITERAL, WS)

""" s"$this" """ producesTokens (WS, INTERPOLATION_ID, STRING_PART, THIS, STRING_LITERAL, WS)

Expand Down

0 comments on commit 376684d

Please sign in to comment.