Merge branch 'pr-200' into pmd/5.5.x

This commit is contained in:
Juan Martín Sotuyo Dodero
2017-01-20 09:19:55 -03:00
2 changed files with 41 additions and 0 deletions

View File

@ -200,7 +200,16 @@ TOKEN :
| "'"
<SINGLE_STRING_LITERAL_BODY>
"'"
| "`"
<BACKTICK_STRING_LITERAL_BODY>
"`"
> : NOREGEXP
|
< #BACKTICK_STRING_LITERAL_BODY:(
("\\" ~[] )
| (~["`", "\\"])
)*
>
|
< #SINGLE_STRING_LITERAL_BODY:(
( "\\" ~[ "\r" , "\n" , "\u2028" , "\u2029"] )

View File

@ -118,4 +118,36 @@ public class EcmascriptTokenizerTest {
sb.append( "}" ).append(PMD.EOL);
return sb.toString();
}
@Test
public void testTemplateStrings() throws IOException {
Tokenizer t = new EcmascriptTokenizer();
SourceCode sourceCode = new SourceCode(new SourceCode.StringCodeLoader(
"export default class DrawLocation extends joint.shapes.basic.Generic {\n"
+ " constructor(location: ILocation) {\n"
+ " this.markup = `<g>\n"
+ " <path class=\"location\"/>\n"
+ " <text x=\"0\" y=\"0\" text-anchor=\"middle\" class=\"location-text\"></text>\n"
+ "\n"
+ " <path class=\"location\"/>\n"
+ " <circle class=\"location-circle\"/>\n"
+ " ${drawIndicators.Check.markup}\n"
+ "\n"
+ " </g>`;\n"
+ " }\n"
+ "\n"
+ "}"));
final Tokens tokens = new Tokens();
t.tokenize(sourceCode, tokens);
final String templateString = "`<g>\n"
+ " <path class=\"location\"/>\n"
+ " <text x=\"0\" y=\"0\" text-anchor=\"middle\" class=\"location-text\"></text>\n"
+ "\n"
+ " <path class=\"location\"/>\n"
+ " <circle class=\"location-circle\"/>\n"
+ " ${drawIndicators.Check.markup}\n"
+ "\n"
+ " </g>`";
assertEquals(templateString, tokens.getTokens().get(24).toString());
}
}