Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Checkstyle eclipse plugin: error cannot initialize module TreeWalker Token "WILDCARD_TYPE"

I have a problem with eclipse checkstyle plugin, i just installed this one and when i execute checkstyle-configuration with sun_checkstyle(eclipse) on java file, i have this error:

cannot initialize module TreeWalker - Token "WILDCARD_TYPE" was not found in Acceptable tokens list in check com.puppycrawl.tools.checkstyle.checks.whitespace.WhitespaceAroundCheck@2261fbd cannot initialize module TreeWalker - Token "WILDCARD_TYPE" was not found in Acceptable tokens list in check com.puppycrawl.tools.checkstyle.checks.whitespace.WhitespaceAroundCheck@2261fbd

But when i use checkstyle configuration : Sun Checks or Google Checks, it's works. Do you have a solution ? Thanks, Neyoh

like image 202
Neyoh Avatar asked Mar 14 '15 15:03

Neyoh


3 Answers

The error is in the xml file sun_checks_eclipse.xml, found in your plugins folder for checkstyle (e.g. .\eclipse\plugins\net.sf.eclipsecs.core_xxxxxx):

<module name="WhitespaceAround">
        <property name="tokens" value="ASSIGN,BAND,BAND_ASSIGN,BOR,BOR_ASSIGN,BSR,BSR_ASSIGN,BXOR,BXOR_ASSIGN,COLON,DIV,DIV_ASSIGN,EQUAL,GE,GT,LAND,LCURLY,LE,LITERAL_ASSERT,LITERAL_CATCH,LITERAL_DO,LITERAL_ELSE,LITERAL_FINALLY,LITERAL_FOR,LITERAL_IF,LITERAL_RETURN,LITERAL_SYNCHRONIZED,LITERAL_TRY,LITERAL_WHILE,LOR,LT,MINUS,MINUS_ASSIGN,MOD,MOD_ASSIGN,NOT_EQUAL,PLUS,PLUS_ASSIGN,QUESTION,RCURLY,SL,SLIST,SL_ASSIGN,SR,SR_ASSIGN,STAR,STAR_ASSIGN,LITERAL_ASSERT,TYPE_EXTENSION_AND,WILDCARD_TYPE"/>
    </module>

Simply remove the last entry WILDCARD_TYPE

I suspect the people writing checkstyle assume something that isn't correct, e.g. a specific version of Eclipse.

Anyway, I had it 5 minutes ago, I changed the entry above and it works now.

like image 122
Neil Walker Avatar answered Oct 19 '22 04:10

Neil Walker


Actually, there is not any "WILDCARD_TYPE" token available for WhitespaceAroundCheck.

List of the tokens which you can use are as below:

ASSIGN, BAND, BAND_ASSIGN, BOR, BOR_ASSIGN, BSR, BSR_ASSIGN, BXOR, BXOR_ASSIGN, COLON, DIV, DIV_ASSIGN, DO_WHILE, EQUAL, GE, GT, LAND, LCURLY, LE, LITERAL_ASSERT, LITERAL_CATCH, LITERAL_DO, LITERAL_ELSE, LITERAL_FINALLY, LITERAL_FOR, LITERAL_IF, LITERAL_RETURN, LITERAL_SWITCH, LITERAL_SYNCHRONIZED, LITERAL_TRY, LITERAL_WHILE, LOR, LT, MINUS, MINUS_ASSIGN, MOD, MOD_ASSIGN, NOT_EQUAL, PLUS, PLUS_ASSIGN, QUESTION, RCURLY, SL, SLIST, SL_ASSIGN, SR, SR_ASSIGN, STAR, STAR_ASSIGN, TYPE_EXTENSION_AND

For more information, you can have a look on our website: http://checkstyle.sourceforge.net/config_whitespace.html

Here, go to link, find "whitespacearound", you will find description for how to configure check for it. There is also information about each token if you want. just click on it.

If you have any other problem regarding, please let me know.

Thanks,

Bhavik

like image 24
Bhavik Patel Avatar answered Oct 19 '22 03:10

Bhavik Patel


token was added accepted list, fix was released http://checkstyle.sourceforge.net/releasenotes.html#Release_6.5

like image 28
Roman Ivanov Avatar answered Oct 19 '22 03:10

Roman Ivanov