forked from phoedos/pmd
[apex] Report LexException when extracting comments
This commit is contained in:
parent
8c58a0b3f5
commit
991bc2c41d
@ -14,10 +14,14 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.RandomAccess;
|
||||
|
||||
import org.antlr.v4.runtime.BaseErrorListener;
|
||||
import org.antlr.v4.runtime.CharStreams;
|
||||
import org.antlr.v4.runtime.RecognitionException;
|
||||
import org.antlr.v4.runtime.Recognizer;
|
||||
import org.antlr.v4.runtime.Token;
|
||||
|
||||
import net.sourceforge.pmd.annotation.InternalApi;
|
||||
import net.sourceforge.pmd.lang.ast.LexException;
|
||||
import net.sourceforge.pmd.lang.document.TextDocument;
|
||||
import net.sourceforge.pmd.lang.document.TextRegion;
|
||||
|
||||
@ -106,6 +110,13 @@ final class ApexCommentBuilder {
|
||||
private static CommentInformation extractInformationFromComments(TextDocument sourceCode, String suppressMarker) {
|
||||
String source = sourceCode.getText().toString();
|
||||
ApexLexer lexer = new ApexLexer(new CaseInsensitiveInputStream(CharStreams.fromString(source)));
|
||||
lexer.removeErrorListeners();
|
||||
lexer.addErrorListener(new BaseErrorListener() {
|
||||
@Override
|
||||
public void syntaxError(Recognizer<?, ?> recognizer, Object offendingSymbol, int line, int charPositionInLine, String msg, RecognitionException e) {
|
||||
throw new LexException(line, charPositionInLine, sourceCode.getFileId(), msg, e);
|
||||
}
|
||||
});
|
||||
|
||||
List<Token> allCommentTokens = new ArrayList<>();
|
||||
Map<Integer, String> suppressMap = new HashMap<>();
|
||||
|
Loading…
x
Reference in New Issue
Block a user