| Summary: | [1.7][extract method][extract constant][extract local] Extract local variable should not be available inside the resource specification of try-with-resources | ||||||
|---|---|---|---|---|---|---|---|
| Product: | [Eclipse Project] JDT | Reporter: | Ayushman Jain <amj87.iitr> | ||||
| Component: | UI | Assignee: | Deepak Azad <deepakazad> | ||||
| Status: | VERIFIED FIXED | QA Contact: | |||||
| Severity: | normal | ||||||
| Priority: | P2 | CC: | daniel_megert, deepakazad, markus.kell.r, raksha.vasisht | ||||
| Version: | 3.7 | Flags: | daniel_megert:
review+
|
||||
| Target Milestone: | 3.7.1 | ||||||
| Hardware: | All | ||||||
| OS: | All | ||||||
| Whiteboard: | |||||||
| Attachments: |
|
||||||
Also the same happens with the "Extract constant" refactoring on
class Test{
public static void main(String[] args) throws IOException {
try (FileInputStream fis = new FileInputStream("")) {
}
}
}
(select the whole of FileInputStream fis = new FileInputStream("") ).
IMHO, these 2 refactorings should be disabled.
Confirmed. Deepak, please take a look. Adding extract method to the list. Created attachment 200259 [details] proposed fix + tests The patch contains 3 new strings to explain why a refactoring is not enabled. Dani is it possible to add these now ? (The patch also has the fix for Bug 352445) (In reply to comment #4) > Created attachment 200259 [details] [diff] > proposed fix + tests > > The patch contains 3 new strings to explain why a refactoring is not enabled. > Dani is it possible to add these now ? Yes. > (The patch also has the fix for Bug > 352445) You probably meant "bug 352448". NOTE: You forgot to add the legal blurb to ConstantChecks.java ExtractMethodAnalyzer.java (In reply to comment #5) > > (The patch also has the fix for Bug > > 352445) > You probably meant "bug 352448". Yes :) (In reply to comment #4) > Created attachment 200259 [details] > proposed fix + tests Committed to BETA_JAVA7 (after addition of the missing legal blurbs). Verified for Juno M1 with 4.2 build I20110729-0200. . |
BETA_JAVA7 class Test{ public static void main(String[] args) throws IOException { try (FileInputStream fis = null) { } } } Select FileInputStream fis = null > refactor> extract local variable is proposed. Choosing it gives some garbage code.