From bcf1c88cc249223b22a290b000988cb185fbb894 Mon Sep 17 00:00:00 2001 From: Gwilym Kuiper Date: Wed, 12 Feb 2020 09:34:04 +0000 Subject: [PATCH] If suppress marker is null, don't check for suppressions --- .../net/sourceforge/pmd/lang/apex/ast/ApexTreeBuilder.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ApexTreeBuilder.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ApexTreeBuilder.java index 230e8dfa9f..42ae4c6308 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ApexTreeBuilder.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ApexTreeBuilder.java @@ -357,13 +357,15 @@ public final class ApexTreeBuilder extends AstVisitor { Token token = lexer.nextToken(); int endIndex = lexer.getCharIndex(); + boolean checkForCommentSuppression = suppressMarker != null; + while (token.getType() != Token.EOF) { if (token.getType() == ApexLexer.BLOCK_COMMENT) { // Filter only block comments starting with "/**" if (token.getText().startsWith("/**")) { tokenLocations.add(new ApexDocTokenLocation(startIndex, token)); } - } else if (token.getType() == ApexLexer.EOL_COMMENT) { + } else if (checkForCommentSuppression && token.getType() == ApexLexer.EOL_COMMENT) { // check if it starts with the suppress marker String trimmedCommentText = token.getText().substring(2).trim();