I would like to test and convert a specific expression into a try-with-ressources form. But I feel that the syntax of the declarative hint format eludes me for this.
I tried:
<!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$
But the template applied to my code never matches. Here is a sample code that I expected would match:
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; } }
Any idea why this is not consistent? Especially because I think the example from the documentation matches mine, with the exception of finally :
try { $statements$; } catch $catches$ finally { $finally$; }
Update. Jackpot- Rules seems to use the same syntax, probably because it uses the same code base.
java refactoring netbeans
towi
source share