Merge branch 'pr-1802'

This commit is contained in:
Andreas Dangel
2019-05-03 12:28:50 +02:00
3 changed files with 17 additions and 1 deletions

View File

@ -22,12 +22,15 @@ This is a {{ site.pmd.release_type }} release.
* [#1738](https://github.com/pmd/pmd/issues/1738): \[java] MethodReturnsInternalArray does not work in inner classes
* java-codestyle
* [#1804](https://github.com/pmd/pmd/issues/1804): \[java] NPE in UnnecessaryLocalBeforeReturnRule
* python
* [#1810](https://github.com/pmd/pmd/issues/1810): \[python] \[cpd] Parse error when using Python 2 backticks
### API Changes
### External Contributions
* [#1799](https://github.com/pmd/pmd/pull/1799): \[java] MethodReturnsInternalArray does not work in inner classes - Fixed #1738 - [Srinivasan Venkatachalam](https://github.com/Srini1993)
* [#1802](https://github.com/pmd/pmd/pull/1802): \[python] \[cpd] Add support for Python 2 backticks - [Maikel Steneker](https://github.com/maikelsteneker)
* [#1803](https://github.com/pmd/pmd/pull/1803): \[dart] \[cpd] Dart escape sequences - [Maikel Steneker](https://github.com/maikelsteneker)
{% endtocmaker %}

View File

@ -52,6 +52,7 @@ TOKEN : /* SEPARATORS */
| < COMMA: "," >
| < DOT: "." >
| < COLON: ":" >
| < BACKTICK: "`" >
}
@ -280,4 +281,4 @@ MORE : /* Strings */
| <"\r"> { image.setCharAt(image.length()-1, '\n'); }
| <~["\n","\r"]>
| <"\\" ~["\n","\r"]>
}
}

View File

@ -53,4 +53,16 @@ public class PythonTokenizerTest extends AbstractTokenizerTest {
TokenEntry.getEOF();
assertEquals(3, tokens.size()); // 3 tokens: "import" + "logging" + EOF
}
@Test
public void testBackticks() throws IOException {
SourceCode sourceCode = new SourceCode(new SourceCode.StringCodeLoader("test = 'hello'" + PMD.EOL
+ "quoted = `test`" + PMD.EOL
+ "print quoted" + PMD.EOL
));
Tokens tokens = new Tokens();
tokenizer.tokenize(sourceCode, tokens); // should not result in parse error
TokenEntry.getEOF();
assertEquals(3, tokens.getTokens().get(tokens.getTokens().size() - 2).getBeginLine());
}
}