我想要檢查並將轉換爲具有try-with-ressources形式的特定語句。但我有這種感覺,declarative hints format的語法不適合我。Netbeans聲明式提示語句,用於嘗試塊內的語句
我想:
<!description="Stmt into try-with-resources">
try {
$before$;
someMethod($arg1, $arg2, $arg3);
$after$;
} catch $catches$
=>
try (Resource res = acquire($arg1, $arg2, $arg3)) {
$before$;
res.use();
$after$;
} catch $catches$
但應用在我的代碼模式永遠不匹配。下面是一些示例代碼段,這是我預期相符:
public boolean step(String input) {
String id = getId(ID);
try {
SomethingBefore();
someMethod(10, "label", name);
return true;
} catch (Exception ex) {
log.error("problem", ex);
return true;
}
}
知道爲什麼這不匹配? ESP。因爲我覺得從文檔的例子匹配礦,除了finally
:
try {
$statements$;
} catch $catches$
finally {
$finally$;
}
更新:看來,Jackpot -Rules使用相同的語法,可能是因爲它使用相同的代碼庫。