Menu

#412 Suppress CheckstyleException due to antlr.Parser.match expecting EOF, found '<<'

Future
open
nobody
None
4
2017-12-20
2016-11-02
No

In general, it's useful of course that eclipse-cs surfaces unexpected internal CS errors by propagating its exceptions into Eclipse' Error Logs and sometimes pop up into your face.

There is one particular condition however which I've faced a number of times which IMHO in an ideal world would be nice to suppress - the one shown below. That one is, of course, caused by me being in the middle of a conflict resolution (with EGit, but whatever the cause). I know my .java is invalid; it's got JDT's red error markers all over it - I don't need CS to jump in. If there is a Lexer/Parser exception, perhaps even one specifically one related to ">>", then just shut up?

com.puppycrawl.tools.checkstyle.api.CheckstyleException: Exception was thrown while processing /home/vorburger/dev/ODL/git/netvirt/vpnservice/elanmanager/elanmanager-impl/src/main/java/org/opendaylight/netvirt/elan/utils/ElanUtils.java
    at com.puppycrawl.tools.checkstyle.Checker.processFiles(Checker.java:281)
    at com.puppycrawl.tools.checkstyle.Checker.process(Checker.java:196)
    at net.sf.eclipsecs.core.builder.Auditor.runAudit(Auditor.java:159)
    at net.sf.eclipsecs.core.jobs.AuditorJob.runInWorkspace(AuditorJob.java:82)
    at org.eclipse.core.internal.resources.InternalWorkspaceJob.run(InternalWorkspaceJob.java:39)
    at org.eclipse.core.internal.jobs.Worker.run(Worker.java:55)
Caused by: com.puppycrawl.tools.checkstyle.api.CheckstyleException: MismatchedTokenException occurred during the analysis of file /home/vorburger/dev/ODL/git/netvirt/vpnservice/elanmanager/elanmanager-impl/src/main/java/org/opendaylight/netvirt/elan/utils/ElanUtils.java.
    at com.puppycrawl.tools.checkstyle.TreeWalker.processFiltered(TreeWalker.java:193)
    at com.puppycrawl.tools.checkstyle.api.AbstractFileSetCheck.process(AbstractFileSetCheck.java:78)
    at com.puppycrawl.tools.checkstyle.Checker.processFile(Checker.java:301)
    at com.puppycrawl.tools.checkstyle.Checker.processFiles(Checker.java:271)
    ... 5 more
Caused by: /home/vorburger/dev/ODL/git/netvirt/vpnservice/elanmanager/elanmanager-impl/src/main/java/org/opendaylight/netvirt/elan/utils/ElanUtils.java:23:1: expecting EOF, found '<<'
    at antlr.Parser.match(Parser.java:211)
    at com.puppycrawl.tools.checkstyle.grammars.GeneratedJavaRecognizer.compilationUnit(GeneratedJavaRecognizer.java:211)
    at com.puppycrawl.tools.checkstyle.TreeWalker.parse(TreeWalker.java:440)
    at com.puppycrawl.tools.checkstyle.TreeWalker.processFiltered(TreeWalker.java:175)
    ... 8 more

Discussion

  • Lars Koedderitzsch

    If this would be done (it could, presumably), how would one discern those exceptions from honest bugs in Checkstyle core?

    Back in the day, eclipse-cs used to pop up an error dialog, which was truly disturbing.
    Nowadays it just logs an Checkstyle error, like "hey, something unexpected happened, please check the error log if you care" - which I think is pretty unobtrusive, while still retaining all the information needed for bug hunting.

    How would you propose to solve this?

     
    • Michael Vorburger

      You are probably right, as long as CS (Core) only throws you (eclipse-cs) a general CheckstyleException, it will be very difficult for you to distinguish a parsing error from "honest bugs in Checkstyle core" ... I guess the "right" way would be for CS Core to throw a CheckstyleSourceParseException kind of thing instead a CheckstyleException if the cause is a MismatchedTokenException, and others like that?

       

Log in to post a comment.