diff --git a/pmd-dart/src/main/antlr4/net/sourceforge/pmd/lang/dart/antlr4/Dart2.g4 b/pmd-dart/src/main/antlr4/net/sourceforge/pmd/lang/dart/antlr4/Dart2.g4 index 01bef8c093..18ae87ca56 100644 --- a/pmd-dart/src/main/antlr4/net/sourceforge/pmd/lang/dart/antlr4/Dart2.g4 +++ b/pmd-dart/src/main/antlr4/net/sourceforge/pmd/lang/dart/antlr4/Dart2.g4 @@ -373,6 +373,7 @@ MultiLineString fragment StringContentTDQ : ~('\\' | '"' | '$') + | '\\' ~('\n' | '\r') | '"' ~'"' | '""' ~'"' | StringInterpolation ; @@ -380,6 +381,7 @@ StringContentTDQ fragment StringContentTSQ : ~('\\' | '\'' | '$') + | '\\' ~('\n' | '\r') | '\'' ~'\'' | '\'\'' ~'\'' | StringInterpolation ; diff --git a/pmd-dart/src/test/java/net/sourceforge/pmd/cpd/DartTokenizerTest.java b/pmd-dart/src/test/java/net/sourceforge/pmd/cpd/DartTokenizerTest.java index 72e0defad7..93231d4b26 100644 --- a/pmd-dart/src/test/java/net/sourceforge/pmd/cpd/DartTokenizerTest.java +++ b/pmd-dart/src/test/java/net/sourceforge/pmd/cpd/DartTokenizerTest.java @@ -59,6 +59,11 @@ public class DartTokenizerTest extends CpdTextComparisonTest { doTest("string_interpolation"); } + @Test + public void testEscapedDollar() { + doTest("escaped_dollar"); + } + @Test public void testRegex() { doTest("regex"); diff --git a/pmd-dart/src/test/resources/net/sourceforge/pmd/cpd/testdata/escaped_dollar.dart b/pmd-dart/src/test/resources/net/sourceforge/pmd/cpd/testdata/escaped_dollar.dart new file mode 100644 index 0000000000..770eb1d6a0 --- /dev/null +++ b/pmd-dart/src/test/resources/net/sourceforge/pmd/cpd/testdata/escaped_dollar.dart @@ -0,0 +1,3 @@ +var multiLineStringWithDollar = """ + \$ + """; diff --git a/pmd-dart/src/test/resources/net/sourceforge/pmd/cpd/testdata/escaped_dollar.txt b/pmd-dart/src/test/resources/net/sourceforge/pmd/cpd/testdata/escaped_dollar.txt new file mode 100644 index 0000000000..2b55dc0898 --- /dev/null +++ b/pmd-dart/src/test/resources/net/sourceforge/pmd/cpd/testdata/escaped_dollar.txt @@ -0,0 +1,7 @@ + [Image] or [Truncated image[ Bcol Ecol +L1 + [var] 1 3 + [multiLineStringWithDollar] 5 29 + [=] 31 31 + ["""\n \\$\n """] 33 9 +EOF