@ -255,7 +255,16 @@ public class JavaTokenizer implements Tokenizer {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
// other tokens are not relevant to process
|
/*
|
||||||
|
* Did we find a "class" token not followed by an identifier? i.e:
|
||||||
|
* expectThrows(IllegalStateException.class, () -> {
|
||||||
|
* newSearcher(r).search(parentQuery.build(), c);
|
||||||
|
* });
|
||||||
|
*/
|
||||||
|
if (storeNextIdentifier) {
|
||||||
|
classMembersIndentations.pop();
|
||||||
|
storeNextIdentifier = false;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -202,4 +202,25 @@ public class JavaTokensTokenizerTest {
|
|||||||
// Enum constructor
|
// Enum constructor
|
||||||
assertEquals("Foo", tokenList.get(13).toString());
|
assertEquals("Foo", tokenList.get(13).toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testIgnoreIdentifiersWithClassKeyword() throws IOException {
|
||||||
|
JavaTokenizer t = new JavaTokenizer();
|
||||||
|
t.setIgnoreAnnotations(false);
|
||||||
|
t.setIgnoreIdentifiers(true);
|
||||||
|
|
||||||
|
SourceCode sourceCode = new SourceCode(new SourceCode.StringCodeLoader(
|
||||||
|
"package foo.bar.baz;" + PMD.EOL + "public class Foo {" + PMD.EOL + "Foo() {" + PMD.EOL
|
||||||
|
+ "}" + PMD.EOL + "public void bar() {" + PMD.EOL + "Bar.baz(Foo.class, () -> {});"
|
||||||
|
+ PMD.EOL + "}" + PMD.EOL + "}" + PMD.EOL
|
||||||
|
));
|
||||||
|
Tokens tokens = new Tokens();
|
||||||
|
t.tokenize(sourceCode, tokens);
|
||||||
|
TokenEntry.getEOF();
|
||||||
|
List<TokenEntry> tokenList = tokens.getTokens();
|
||||||
|
|
||||||
|
// Class constructor
|
||||||
|
assertEquals("Foo", tokenList.get(4).toString());
|
||||||
|
assertEquals(String.valueOf(JavaParserConstants.IDENTIFIER), tokenList.get(11).toString());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -235,6 +235,7 @@ to avoid XSS attacks.
|
|||||||
* apex-complexity
|
* apex-complexity
|
||||||
* [#183](https://github.com/pmd/pmd/issues/183): \[apex] NCSS Method length is incorrect when using method chaining
|
* [#183](https://github.com/pmd/pmd/issues/183): \[apex] NCSS Method length is incorrect when using method chaining
|
||||||
* Java
|
* Java
|
||||||
|
* [#185](https://github.com/pmd/pmd/issues/185): \[java] CPD runs into NPE when analyzing Lucene
|
||||||
* [#1545](https://sourceforge.net/p/pmd/bugs/1545/): \[java] Symbol Table fails to resolve inner classes
|
* [#1545](https://sourceforge.net/p/pmd/bugs/1545/): \[java] Symbol Table fails to resolve inner classes
|
||||||
* java-design
|
* java-design
|
||||||
* [#1512](https://sourceforge.net/p/pmd/bugs/1512/): \[java] Combine rules AvoidConstantsInInterface and ConstantsInInterface
|
* [#1512](https://sourceforge.net/p/pmd/bugs/1512/): \[java] Combine rules AvoidConstantsInInterface and ConstantsInInterface
|
||||||
|
Reference in New Issue
Block a user