Bug 131445 - [templates] Provide templates that check for 'null'
Summary: [templates] Provide templates that check for 'null'
Status: RESOLVED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Text (show other bugs)
Version: 3.2   Edit
Hardware: All All
: P3 enhancement (vote)
Target Milestone: 4.6 M3   Edit
Assignee: Lars Vogel CLA
QA Contact:
URL:
Whiteboard:
Keywords: noteworthy
Depends on:
Blocks:
 
Reported: 2006-03-11 21:53 EST by Jared Burns CLA
Modified: 2015-10-09 06:36 EDT (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jared Burns CLA 2006-03-11 21:53:11 EST
I find the following template very useful and would suggest that it be included by default:
Name: ifnotnull
Description: if not null statement
Pattern:
if (${name} != null) {
	${cursor}
}
Comment 1 Dani Megert CLA 2006-03-13 05:48:28 EST
If we add this we should also add an 'ifnull' template.
Comment 2 Tom Hofmann CLA 2006-08-14 12:00:14 EDT
In 3.3, the template should look like this (so one gets proposals for local variables):

if (${v:var(java.lang.Object} != null) {
        ${cursor}
}

Comment 3 Dani Megert CLA 2006-08-14 12:49:56 EDT
I think it's best to add the one you like by your own. This allows you to decide whether you want the use the brackets or not.
Comment 4 Jared Burns CLA 2006-08-14 14:01:42 EDT
The question of brackets is not different than the current templates we provide like "if statement".

I think that programmers check "if not null" frequently enough that we should include the template by default. But of course, that's just my intuition.
Comment 5 Dani Megert CLA 2006-08-28 09:20:07 EDT
Jared,

I'm willing to do this if you provide the patch for the 'ifNull' and 'ifNotNull' templates.

See bug 153880 for pending problems with the new template variable support.
Comment 6 Lars Vogel CLA 2015-09-08 06:04:44 EDT
ifnotnull and ifnull templates sound useful. I plan to provide a patch for them.
Comment 7 Dani Megert CLA 2015-09-08 10:16:42 EDT
(In reply to Lars Vogel from comment #6)
> ifnotnull and ifnull templates sound useful. I plan to provide a patch for
> them.

If so, please use the spelling suggested in comment 5.
Comment 8 Eclipse Genie CLA 2015-10-05 18:57:39 EDT
New Gerrit change created: https://git.eclipse.org/r/57470
Comment 10 Noopur Gupta CLA 2015-10-09 06:23:15 EDT
Thanks for the patch, Lars. Released in master.
Comment 11 Lars Vogel CLA 2015-10-09 06:36:29 EDT
(In reply to Noopur Gupta from comment #10)
> Thanks for the patch, Lars. Released in master.

Thanks Noopur, great to get fast reviews from you! I feel motivated to do more.