??????????Χ
???????????????????????????????????????????????????????????????????????ú????????????????????????????????????????????????????????????????????????????Σ?????????????????????Σ???????????????????????Ρ??????????????????????????????????????????????????????????????????????????????????????????д??????????????????????????????????????????????????????????????
??????????????
??????????ε?????????????У??????????????????????????淶??????????????????????????????ɡ??????????????????????????????????????????????????????????Ч??????ж?????????????д?????????.???????????С????????????????????鲿?????????У?????????????????ο??????á?????????????????????????????????沿?????????????????????????д?????飬????е??????γ?????????????????????????????????????????????????????????????????????????????????????
?????????????????????????????????????????У??????????????????????飬?????????????????????????÷???壬???????????????塣???繫????????????????????????????????壬???????????С?
????????????????????????????????????????????????.??Щ???????????????????????????????????????????????????.????????????????????????????????.??Щ??????????????????????????????.????????????????????Runtime??????????????????????д?????????????????????????????????????
??????????黹???????????????????????????????????????????顣????????????????????????????????????????????Ч????????????????????????????????????????Ч?????????????????????????????????????????????????????????????????????????????????????if-else??????????ж??????????????????????????????????????????羭???????????????ü??????????Щ??????????????????????????????÷???????????????????
???????????
????????????????????????????????????????????????????????????????????????????????г?????Щ?????????У????? jindent??checkstyle??pmd??Jtest??jfindbugs????jinent??checkstyle?????????????д?????????pmd????????????Щ????????????jtest??findbugs??????????????????????????????д???????bug????Щ????????Щ???????????????????????а?????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????
?????????????Щ??????????????????????????????????---JRULER?????????????????????JRULER???????????????????д???????????????????????????????????.??????????????????????????????????????????????????????????????????????????????????????????????????????????????????д????????????????????????????????飬???????????????????????80%????????????????????????????????????????????棬???????????????????????????????????????Ч???????????????????????????????п????????????????????????
???????JRULER????????
????1????д???????????????????????????д???????????????С???????
????2??????????????????????????????????????????????????????
????4??????????????????????????????????????????????????????????檔
????5??????????????????????????????棬?????????????????????????????????????????????????????
????3???????????????????????????????????????????????????????????Ч??????????????????????飬?????????????????????????????????????????????
????????????www.jruler.com
????????????www.jruler.com/downloads/plugins_v2.0.zip
????????????www.jruler.com/downloads/plugins_v2.0.feature
???????????
????1????μ??????????????
/**
*??μ??????????????
*/
#include "java.h"
string getClassName(token tk);
string checkClassNaming() hooks tk : @"CLS" {
if(tk == null) return null;
string cls_name=getClassName(tk);
if(cls_name == null) {
return null;
}
boolean b=regMatch(cls_name?? "[A-Z][a-zA-Z]+");
if(!b) {
return "class name is not suitable.";
}
}
string getClassName(token tk){
token [] tkList = tk.childs;
var i=0;
while(i<tkList.length) {
token ttk=tkList[i];
string s = toString(ttk.values);
if(s=="class") {
break;
}
i=i+1;
}
if(i<tkList.length) {
token tkCName = tkList[i+1];
return toString(tkCName.values);
}
return null;
}