Merge branch 'pr-1821'

This commit is contained in:
Andreas Dangel 2019-05-12 16:16:05 +02:00
commit 7b871ddaf9
3 changed files with 21 additions and 2 deletions

View File

@ -14,6 +14,17 @@ This is a {{ site.pmd.release_type }} release.
### New and noteworthy
#### Enhanced Matlab support
Thanks to the contribution from [Maikel Steneker](https://github.com/maikelsteneker) CPD for Matlab can
now parse matlab programs which use the question mark operator to specify access to
class members:
```
lassdef Class1
properties (SetAccess = ?Class2)
```
### Fixed Issues
* dart
@ -36,6 +47,7 @@ This is a {{ site.pmd.release_type }} release.
* [#1803](https://github.com/pmd/pmd/pull/1803): \[dart] \[cpd] Dart escape sequences - [Maikel Steneker](https://github.com/maikelsteneker)
* [#1807](https://github.com/pmd/pmd/pull/1807): \[ci] Fix missing local branch issues when executing pmd-regression-tester - [BBG](https://github.com/djydewang)
* [#1813](https://github.com/pmd/pmd/pull/1813): \[matlab] \[cpd] Matlab comments - [Maikel Steneker](https://github.com/maikelsteneker)
* [#1821](https://github.com/pmd/pmd/pull/1821): \[matlab] \[cpd] Matlab question mark token - [Maikel Steneker](https://github.com/maikelsteneker)
{% endtocmaker %}

View File

@ -65,6 +65,7 @@ PARSER_END(MatlabParser)
| < AT: "@" > : DEFAULT
| < DOT: "." > : TRANSPOSE
| < COMMA: "," > : DEFAULT
| < QUESTIONMARK: "?" > : DEFAULT
}
<DEFAULT, TRANSPOSE> TOKEN : /* OPERATORS AND ASSIGNMENTS */

View File

@ -65,7 +65,6 @@ public class MatlabTokenizerTest extends AbstractTokenizerTest {
+ "end"));
Tokens tokens = new Tokens();
tokenizer.tokenize(sourceCode, tokens); // should not result in parse error
TokenEntry.getEOF();
assertEquals(28, tokens.size());
}
@ -83,7 +82,14 @@ public class MatlabTokenizerTest extends AbstractTokenizerTest {
+ "msgbox('Hello World!','Hello World!');"));
Tokens tokens = new Tokens();
tokenizer.tokenize(sourceCode, tokens); // should not result in parse error
TokenEntry.getEOF();
assertEquals(13, tokens.size());
}
public void testQuestionMark() throws IOException {
SourceCode sourceCode = new SourceCode(new SourceCode.StringCodeLoader("classdef Class1" + PMD.EOL
+ "properties (SetAccess = ?Class2)"));
Tokens tokens = new Tokens();
tokenizer.tokenize(sourceCode, tokens);
assertEquals(10, tokens.size());
}
}