Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 184222 - [templates] 2 new code templates: finally & lock
Summary: [templates] 2 new code templates: finally & lock
Status: RESOLVED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Text (show other bugs)
Version: 3.3   Edit
Hardware: All All
: P3 enhancement (vote)
Target Milestone: 4.5 M7   Edit
Assignee: Robert Roth CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 37825 373471 (view as bug list)
Depends on:
Blocks: 466252
  Show dependency tree
 
Reported: 2007-04-26 09:11 EDT by Sebastian Davids CLA
Modified: 2015-05-04 02:45 EDT (History)
7 users (show)

See Also:


Attachments
fix (2.61 KB, patch)
2007-04-26 09:13 EDT, Sebastian Davids CLA
no flags Details | Diff
forgot the "lock"'s id (2.64 KB, patch)
2007-04-26 09:18 EDT, Sebastian Davids CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Sebastian Davids CLA 2007-04-26 09:11:35 EDT
Build ID: xx

Steps To Reproduce:
try {

} finally {

}

@@@@

lock.lock();
try {

} finally {
  lock.unlock();
}

@@@@

Both patterns are very common in concurrent programming.

More information:
Comment 1 Sebastian Davids CLA 2007-04-26 09:13:49 EDT
Created attachment 65025 [details]
fix

also removes two unneccessary spaces in properties file
Comment 2 Sebastian Davids CLA 2007-04-26 09:18:21 EDT
Created attachment 65028 [details]
forgot the "lock"'s id
Comment 3 Dani Megert CLA 2007-04-26 09:24:49 EDT
*** Bug 37825 has been marked as a duplicate of this bug. ***
Comment 4 Dani Megert CLA 2012-03-12 08:44:56 EDT
*** Bug 373471 has been marked as a duplicate of this bug. ***
Comment 5 Eclipse Genie CLA 2015-03-27 18:43:58 EDT
New Gerrit change created: https://git.eclipse.org/r/44787
Comment 6 Robert Roth CLA 2015-03-27 18:45:57 EDT
In context of hte #greatfix initiative I have pushed a branch for review with these two templates, based on the proposed templates, but for "java-statements" context instead of "java" context, as these do not make any sense outside the java-statements scope.

Please assign me and add the greatfix keyword.
Comment 7 Noopur Gupta CLA 2015-04-07 08:52:35 EDT
(In reply to Robert Roth from comment #6)
> In context of hte #greatfix initiative I have pushed a branch for review
> with these two templates, based on the proposed templates, but for
> "java-statements" context instead of "java" context, as these do not make
> any sense outside the java-statements scope.
> 
> Please assign me and add the greatfix keyword.

https://git.eclipse.org/r/44787 cannot be considered for greatfix as most of the implementation was already available as a patch in comment #2.

This can be committed as your contribution once the following issues are handled:
- Fix test failures and update the tests by adding new tests for the new templates.
- See duplicate bug 373471 which needs the new template 'finally block' to just add the keyword 'finally' with a block - similar to template for "else block".
- The other template (added in this patch) could be 'try finally' that adds try finally block - similar to template for "try catch block".
- Update copyright header in the files. See https://wiki.eclipse.org/JDT_UI/How_to_Contribute#Coding_Conventions.
- The template for lock looks fine.
Comment 8 Robert Roth CLA 2015-04-07 16:33:18 EDT
I didn't know that fixing patches and getting them accepted doesn't count as a greatfix, but it totally makes sense. Thanks for the comments on the proposal though, I knew about the failing tests since I saw the logs, but I'm having a hard time correctly setting up a testing environment, but the other comments are new and useful for me, next time I won't forget updating the headers.
I'll update the gerrit request once I manage to fix the failing tests and the rest of the issues.
Comment 9 Noopur Gupta CLA 2015-04-08 04:58:41 EDT
(In reply to Robert Roth from comment #8)
> I didn't know that fixing patches and getting them accepted doesn't count as
> a greatfix, but it totally makes sense. Thanks for the comments on the
> proposal though, I knew about the failing tests since I saw the logs, but
> I'm having a hard time correctly setting up a testing environment, but the
> other comments are new and useful for me, next time I won't forget updating
> the headers.
> I'll update the gerrit request once I manage to fix the failing tests and
> the rest of the issues.

Sure. See https://wiki.eclipse.org/JDT_UI/How_to_Contribute for setup and other details.
Comment 10 Robert Roth CLA 2015-04-21 13:51:06 EDT
Fixed all issues mentioned above (hopefully I didn't miss anything), and rebased to master. Please let me know if you see anything else to fix in the updated patchset.
Comment 12 Noopur Gupta CLA 2015-04-22 03:45:06 EDT
(In reply to Robert Roth from comment #10)
> Fixed all issues mentioned above (hopefully I didn't miss anything), and
> rebased to master. Please let me know if you see anything else to fix in the
> updated patchset.

Thanks, I made the following changes and released the patch:
- Copyright year should be incremented instead of adding the year again in all the modified files.
- Renamed the existing 'try' template to 'try_catch'.
- Renamed the new 'tryfinally' template to 'try_finally'.
- TODO is not required in 'finally' template. Similar to the 'else' template.
- In AdvancedQuickAssistTest, moved the tests for new templates at the end of each test method.

(In reply to Eclipse Genie from comment #11)
> Gerrit change https://git.eclipse.org/r/44787 was merged to [master].
> Commit:
> http://git.eclipse.org/c/jdt/eclipse.jdt.ui.git/commit/
> ?id=b7707ee96000dc96768ec554bc7ef41a2c90c7e8