| Summary: | [templates] add finally (block) template | ||
|---|---|---|---|
| Product: | [Eclipse Project] JDT | Reporter: | Lars Vogel <Lars.Vogel> |
| Component: | Text | Assignee: | JDT-Text-Inbox <jdt-text-inbox> |
| Status: | CLOSED DUPLICATE | QA Contact: | |
| Severity: | enhancement | ||
| Priority: | P3 | CC: | daniel_megert, deepakazad, Lars.Vogel |
| Version: | 3.8 | Keywords: | helpwanted |
| Target Milestone: | --- | ||
| Hardware: | PC | ||
| OS: | Linux | ||
| Whiteboard: | |||
Can you confirm that JDT actually creates the block? In my installation, triggering _JDT's_ completion on } fin<^Space> only results in the keyword completion without curly braces too. Yet, I can't observe a different behavior. This was more a "be better then JDT" request which I believe is the mission of Code Recommenders. :-) Phew. I though this is a bug - not a feature request ;) I think it makes sense to have this in JDT. CC'ed Deepak. Deepak, is there a reason why JDT completion on keyword final does not add brackets as it does for statements like if, for etc.? final --> finally (In reply to comment #3) > CC'ed Deepak. Deepak, is there a reason why JDT completion on keyword final > does not add brackets as it does for statements like if, for etc.? Completion for keywords (including if, for etc) just adds the keywords, which is correct. You are likely confusing 'template' completion for if, for etc with 'keyword' completion. There is no template for 'finally' block, hence you do not get braces with completion. It can be argued that a template for 'finally' should be added to JDT, but the template will not do much other than add braces. So I would say it is not worth it, but others may think differently. Since finally is expected to be _always_ followed by block, I think this makes perfectly sense. It's for sure a minor usability improvement but to my understanding many of these little things sum up to an excellent user experience, and thus, should be added. Maybe just adding a "final template" would do it. Lars, you may just add such a template into your local Eclipse installation and work a while with it to see if this would fit your needs? (In reply to comment #6) JDT has a template for 'else' which also pretty much adds a block. Hence, I do not see any reason why a template for 'finally' should not be added. Lars you can open a bug against JDT (or maybe move this bug itself), and provide a patch, if possible :-) Move the bug as requested by Deepak. *** This bug has been marked as a duplicate of bug 184222 *** |
If I try to use code recommenders to create the finally block in a try/catch statement it does not add the brackts. Here is the result: public void onClick(View view) { URL url; try { url = new URL("http://www.vogella.de"); HttpURLConnection con = (HttpURLConnection) url.openConnection(); InputStream in = con.getInputStream(); BufferedReader reader = new BufferedReader( new InputStreamReader(in)); String s = ""; while ((s = reader) != null) { System.out.println(s); } } catch (Exception e) { e.printStackTrace(); } finally <- this was triggered with fin-> Ctrl+Space } I think the block should be closed.