I often find myself writing code like this:
EmployeesRow empRow = (EmployeesRow)iter.next();
It's a pain that I need to type in the EmployeesRow part twice, and a pain that I need to invent a name for this local variable. So, I tried out our new Smart Code Templates feature today to make my life easier. Using JDeveloper 10.1.3 Early Access 1 release from OTN, here's what I did...
- Selected Tools | Preferences... menu and selected the Code Templates category under the Code Editor group.
- Clicked (Add) to add a new code template
- Typed a Shortcut name of "cast" in the table in the new row
- Click into the Code area and typed the following:
$type$ $name$ = ($type$)$end$
- Selected the Variables tab, and picked the
suggestNameFromType() function from the dropdown for the type of the name code template variable.
- I typed
$type$ inside the parenthesis to leave the type of the name variable looking like suggestNameFromType($type$)
- Then I clicked (Ok).
I then went back to my code editor, and now whenver I want to type this kind of cast statement, I can just type:
cast + [Ctrl][Enter]
And it will expand to let me fill in the smart variables by typing and tabbing between them. If I type EmpViewRow as the value for the first smart variable, and press [Tab] twice, my cursor will be placed where the $end$ token was in the code template, where I can finish the job, having saved some typing. The name of the variable gets automatically suggested from the type that I've entered for the first smart variable. Pretty powerful stuff.
2:44:29 PM
|
|